Skip to content

Commit

Permalink
final
Browse files Browse the repository at this point in the history
  • Loading branch information
hargoniX committed Feb 3, 2025
1 parent 4517a83 commit 8d1069b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
6 changes: 2 additions & 4 deletions src/Lean/Elab/Tactic/BVDecide/Frontend/Normalize/Simproc.lean
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,7 @@ builtin_simproc [bv_normalize] bv_equal_const_not (~~~(_ : BitVec _) == (_ : Bit
let_expr BEq.beq α inst outerLhs rhs := e | return .continue
let some ⟨w, rhsVal⟩ ← getBitVecValue? rhs | return .continue
let_expr Complement.complement _ _ lhs := outerLhs | return .continue
let newRhs := ~~~rhsVal
let expr := mkApp4 (mkConst ``BEq.beq [0]) α inst lhs (toExpr newRhs)
let expr := mkApp4 (mkConst ``BEq.beq [0]) α inst lhs (toExpr (~~~rhsVal))
let proof :=
mkApp3 (mkConst ``Std.Tactic.BVDecide.Frontend.Normalize.BitVec.not_eq_comm)
(toExpr w)
Expand All @@ -179,8 +178,7 @@ builtin_simproc [bv_normalize] bv_equal_const_not' ((_ : BitVec _) == ~~~(_ : Bi
let_expr BEq.beq α inst lhs outerRhs := e | return .continue
let some ⟨w, lhsVal⟩ ← getBitVecValue? lhs | return .continue
let_expr Complement.complement _ _ rhs := outerRhs | return .continue
let newLhs := ~~~lhsVal
let expr := mkApp4 (mkConst ``BEq.beq [0]) α inst (toExpr newLhs) rhs
let expr := mkApp4 (mkConst ``BEq.beq [0]) α inst rhs (toExpr (~~~lhsVal))
let proof :=
mkApp3 (mkConst ``Std.Tactic.BVDecide.Frontend.Normalize.BitVec.not_eq_comm')
(toExpr w)
Expand Down
5 changes: 3 additions & 2 deletions src/Std/Tactic/BVDecide/Normalize/Equal.lean
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,10 @@ theorem BitVec.not_eq_comm (a b : BitVec w) : (~~~a == b) = (a == ~~~b) := by
simp [_root_.BitVec.not_eq_comm]

-- used for bv_equal_const_not simproc
theorem BitVec.not_eq_comm' (a b : BitVec w) : (a == ~~~b) = (~~~a == b) := by
rw [Bool.eq_iff_iff]
theorem BitVec.not_eq_comm' (a b : BitVec w) : (a == ~~~b) = (b == ~~~a) := by
rw [Bool.eq_iff_iff, beq_iff_eq, Eq.comm]
simp [_root_.BitVec.not_eq_comm]


end Frontend.Normalize
end Std.Tactic.BVDecide
2 changes: 1 addition & 1 deletion tests/lean/run/bv_decide_rewriter.lean
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ example (d : Bool) (a b c : BitVec w) :
example (a : BitVec 32) : (~~~a = 0#32) ↔ (a = -1) := by
bv_normalize

example (a : BitVec 32) : (0#32 = ~~~a) ↔ (-1 = a) := by
example (a : BitVec 32) : (0#32 = ~~~a) ↔ (a = -1) := by
bv_normalize

-- reducing or to and while still applying or specific rewrites
Expand Down

0 comments on commit 8d1069b

Please sign in to comment.