Skip to content

Commit

Permalink
Support lifting reverse implication: <==
Browse files Browse the repository at this point in the history
  • Loading branch information
parno committed Dec 19, 2024
1 parent 9fd46e3 commit 97b8d77
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 3 deletions.
4 changes: 4 additions & 0 deletions crates/hir-ty/src/mir/lower.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1034,6 +1034,9 @@ impl<'ctx> MirLowerCtx<'ctx> {
syntax::ast::LogicOp::Imply => {
todo!()
}
syntax::ast::LogicOp::RevImply => {
todo!()
}
syntax::ast::LogicOp::Iff => {
todo!()
}
Expand Down Expand Up @@ -1075,6 +1078,7 @@ impl<'ctx> MirLowerCtx<'ctx> {
hir_def::hir::LogicOp::And => BinOp::BitAnd, // FIXME: make these short circuit
hir_def::hir::LogicOp::Or => BinOp::BitOr,
hir_def::hir::LogicOp::Imply => todo!(),
hir_def::hir::LogicOp::RevImply => todo!(),
hir_def::hir::LogicOp::Iff => todo!(),
},
hir_def::hir::BinaryOp::ArithOp(op) => BinOp::from(op),
Expand Down
2 changes: 2 additions & 0 deletions crates/syntax/src/ast/expr_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,12 @@ impl ast::BinExpr {
let bin_op = match c.kind() {
T![||] => BinaryOp::LogicOp(LogicOp::Or),
T![&&] => BinaryOp::LogicOp(LogicOp::And),
// verus
T![|||] => BinaryOp::LogicOp(LogicOp::Or),
T![&&&] => BinaryOp::LogicOp(LogicOp::And),
T![==>]=> BinaryOp::LogicOp(LogicOp::Imply),
T![<==>] => BinaryOp::LogicOp(LogicOp::Iff),
T![<==]=> BinaryOp::LogicOp(LogicOp::RevImply),

T![==] => BinaryOp::CmpOp(CmpOp::Eq { negated: false }),
T![!=] => BinaryOp::CmpOp(CmpOp::Eq { negated: true }),
Expand Down
2 changes: 2 additions & 0 deletions crates/syntax/src/ast/operators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ pub enum LogicOp {
Or,
// verus
Imply,
RevImply,
Iff,
}

Expand Down Expand Up @@ -71,6 +72,7 @@ impl fmt::Display for LogicOp {
LogicOp::And => "&&",
LogicOp::Or => "||",
LogicOp::Imply => "==>",
LogicOp::RevImply => "<==",
LogicOp::Iff => "<==>",
};
f.write_str(res)
Expand Down
1 change: 1 addition & 0 deletions crates/syntax/src/ast/prec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ impl Expr {
And => (9, 10),
// verus
Imply => (0, 0),
RevImply => (0, 0),
Iff => (0, 0),
},
CmpOp(_) => (11, 11),
Expand Down
6 changes: 4 additions & 2 deletions crates/va-test/examples/misc-parsing/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
verus! {

spec fn mul_auto(x:bool, y:bool) -> bool {
x &&& y
spec fn lemma_div_basics(a:bool, b:bool)
{
a <== b
}


} // verus!

fn main() { }
2 changes: 1 addition & 1 deletion crates/va-test/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ fn main() {
println!("Failed to lift function {:?}: got error: {:?}", foo.name(&db), fn_vst_result);
continue;
}
let fn_vst: vst::Fn = fn_vst_result.expect("shouldn't have been an Error at this point"); //fn_cst.value.try_into().expect("vst lifting failure");
let _fn_vst: vst::Fn = fn_vst_result.expect("shouldn't have been an Error at this point"); //fn_cst.value.try_into().expect("vst lifting failure");
//dbg!(&fn_vst.name);

// TODO: use the source-level proof rewrite
Expand Down

0 comments on commit 97b8d77

Please sign in to comment.