@@ -23,25 +23,12 @@ use crate::fixpoint_encoding::{
2323 } ,
2424} ;
2525
26- #[ derive( Debug , Clone , Copy ) ]
27- pub enum BoolMode {
28- Bool ,
29- Prop ,
30- }
31-
3226pub struct LeanCtxt < ' a , ' genv , ' tcx > {
3327 pub genv : GlobalEnv < ' genv , ' tcx > ,
3428 pub pretty_var_map : & ' a PrettyMap < LocalVar > ,
3529 pub adt_map : & ' a FxIndexSet < DefId > ,
3630 pub opaque_adt_map : & ' a [ ( FluxDefId , SortDecl ) ] ,
3731 pub kvar_solutions : & ' a KVarSolutions ,
38- pub bool_mode : BoolMode ,
39- }
40-
41- impl < ' a , ' genv , ' tcx > LeanCtxt < ' a , ' genv , ' tcx > {
42- pub ( crate ) fn with_bool_mode ( & self , bool_mode : BoolMode ) -> Self {
43- LeanCtxt { bool_mode, ..* self }
44- }
4532}
4633
4734pub struct WithLeanCtxt < ' a , ' b , ' genv , ' tcx , T > {
@@ -320,12 +307,7 @@ impl LeanFmt for Sort {
320307 fn lean_fmt ( & self , f : & mut std:: fmt:: Formatter , cx : & LeanCtxt ) -> std:: fmt:: Result {
321308 match self {
322309 Sort :: Int => write ! ( f, "Int" ) ,
323- Sort :: Bool => {
324- match cx. bool_mode {
325- BoolMode :: Bool => write ! ( f, "Bool" ) ,
326- BoolMode :: Prop => write ! ( f, "Prop" ) ,
327- }
328- }
310+ Sort :: Bool => write ! ( f, "Prop" ) ,
329311 Sort :: Real => write ! ( f, "Real" ) ,
330312 Sort :: Str => write ! ( f, "String" ) ,
331313 Sort :: Func ( f_sort) => {
@@ -394,12 +376,7 @@ impl LeanFmt for Expr {
394376 Expr :: Constant ( c) => {
395377 match c {
396378 Constant :: Numeral ( n) => write ! ( f, "{n}" , ) ,
397- Constant :: Boolean ( b) => {
398- match cx. bool_mode {
399- BoolMode :: Bool => write ! ( f, "{}" , if * b { "true" } else { "false" } ) ,
400- BoolMode :: Prop => write ! ( f, "{}" , if * b { "True" } else { "False" } ) ,
401- }
402- }
379+ Constant :: Boolean ( b) => write ! ( f, "{}" , if * b { "True" } else { "False" } ) ,
403380 Constant :: String ( s) => write ! ( f, "{}" , s. display( ) ) ,
404381 Constant :: Real ( n) => write ! ( f, "{n}.0" ) ,
405382 Constant :: BitVec ( bv, size) => write ! ( f, "{}#{}" , bv, size) ,
@@ -452,8 +429,7 @@ impl LeanFmt for Expr {
452429 write ! ( f, ")" ) ?;
453430 if let Some ( out_sort) = out_sort {
454431 write ! ( f, " : (" ) ?;
455- let sort_cx = cx. with_bool_mode ( BoolMode :: Bool ) ;
456- out_sort. lean_fmt ( f, & sort_cx) ?;
432+ out_sort. lean_fmt ( f, & cx) ?;
457433 write ! ( f, "))" ) ?;
458434 }
459435 Ok ( ( ) )
@@ -462,10 +438,7 @@ impl LeanFmt for Expr {
462438 write ! ( f, "(" ) ?;
463439 for ( i, expr) in exprs. iter ( ) . enumerate ( ) {
464440 if i > 0 {
465- match cx. bool_mode {
466- BoolMode :: Bool => write ! ( f, " && " ) ?,
467- BoolMode :: Prop => write ! ( f, " ∧ " ) ?,
468- } ;
441+ write ! ( f, " ∧ " ) ?;
469442 }
470443 expr. lean_fmt ( f, cx) ?;
471444 }
@@ -475,10 +448,7 @@ impl LeanFmt for Expr {
475448 write ! ( f, "(" ) ?;
476449 for ( i, expr) in exprs. iter ( ) . enumerate ( ) {
477450 if i > 0 {
478- match cx. bool_mode {
479- BoolMode :: Bool => write ! ( f, " || " ) ?,
480- BoolMode :: Prop => write ! ( f, " ∨ " ) ?,
481- } ;
451+ write ! ( f, " ∨ " ) ?;
482452 }
483453 expr. lean_fmt ( f, cx) ?;
484454 }
@@ -501,10 +471,7 @@ impl LeanFmt for Expr {
501471 }
502472 Expr :: Not ( inner) => {
503473 write ! ( f, "(" ) ?;
504- match cx. bool_mode {
505- BoolMode :: Bool => write ! ( f, "!" ) ?,
506- BoolMode :: Prop => write ! ( f, "¬" ) ?,
507- } ;
474+ write ! ( f, "¬" ) ?;
508475 inner. as_ref ( ) . lean_fmt ( f, cx) ?;
509476 write ! ( f, ")" )
510477 }
@@ -559,7 +526,7 @@ impl LeanFmt for Expr {
559526impl LeanFmt for FunDef {
560527 fn lean_fmt ( & self , f : & mut fmt:: Formatter , cx : & LeanCtxt ) -> fmt:: Result {
561528 let FunDef { name, sort, comment : _, body } = self ;
562- write ! ( f, "def " ) ?;
529+ write ! ( f, "noncomputable def " ) ?;
563530 name. lean_fmt ( f, cx) ?;
564531 if let Some ( body) = body {
565532 for ( arg, arg_sort) in iter:: zip ( & body. args , & sort. inputs ) {
@@ -675,8 +642,6 @@ impl<'a> LeanFmt for LeanKConstraint<'a> {
675642 if !cx. kvar_solutions . is_empty ( ) {
676643 writeln ! ( f, "namespace {namespace}\n " ) ?;
677644
678- let cx = cx. with_bool_mode ( BoolMode :: Prop ) ;
679-
680645 if !cx. kvar_solutions . cut_solutions . is_empty ( ) {
681646 writeln ! ( f, "-- cyclic (cut) kvars" ) ?;
682647 for kvar_solution in & cx. kvar_solutions . cut_solutions {
0 commit comments