Skip to content

Commit 9c47f39

Browse files
authored
refactor: change iff lowering rule in bv_decide (#7287)
This PR uses a better lowering rule for iff in bv_decide's preprocessing.
1 parent 3f98b48 commit 9c47f39

File tree

3 files changed

+7
-11
lines changed

3 files changed

+7
-11
lines changed

src/Std/Tactic/BVDecide/Normalize/Bool.lean

-3
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,6 @@ theorem if_eq_cond {b : Bool} {x y : α} : (if b = true then x else y) = (bif b
5252
@[bv_normalize]
5353
theorem Bool.not_xor : ∀ (a b : Bool), !(a ^^ b) = (a == b) := by decide
5454

55-
@[bv_normalize]
56-
theorem Bool.or_elim : ∀ (a b : Bool), (a || b) = !(!a && !b) := by decide
57-
5855
@[bv_normalize]
5956
theorem Bool.not_beq_one : ∀ (a : BitVec 1), (!(a == 1#1)) = (a == 0#1) := by
6057
decide

src/Std/Tactic/BVDecide/Normalize/Canonicalize.lean

+6-8
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,8 @@ theorem Bool.and_to_and (a b : Bool) : ((a = true) ∧ (b = true)) = ((a && b) =
5454
simp
5555

5656
@[bv_normalize]
57-
theorem Bool.iff_to_or (a b : Bool)
58-
: ((a = true) ↔ (b = true)) = (((!a || b) && (!b || a)) = true) := by
59-
revert a b
57+
theorem Bool.iff_to_beq :
58+
∀ (a b : Bool), ((a = true) ↔ (b = true)) = ((a == b) = true) := by
6059
decide
6160

6261
@[bv_normalize]
@@ -67,10 +66,6 @@ theorem Bool.eq_false (a : Bool) : ((a = true) = False) = ((!a) = true) := by
6766
theorem Bool.decide_eq_true (a : Bool) : (decide (a = true)) = a := by
6867
simp
6968

70-
@[bv_normalize]
71-
theorem Bool.eq_true_eq_true_eq (x y : Bool) : ((x = true) = (y = true)) ↔ ((x == y) = true) := by
72-
simp
73-
7469
attribute [bv_normalize] BitVec.getLsbD_cast
7570
attribute [bv_normalize] BitVec.testBit_toNat
7671

@@ -80,10 +75,13 @@ theorem BitVec.lt_ult (x y : BitVec w) : (x < y) = (BitVec.ult x y = true) := by
8075
simp only [(· < ·)]
8176
simp
8277

78+
@[bv_normalize]
79+
theorem Bool.or_elim : ∀ (a b : Bool), (a || b) = !(!a && !b) := by decide
80+
8381
@[bv_normalize]
8482
theorem BitVec.or_elim (x y : BitVec w) : x ||| y = ~~~(~~~x &&& ~~~y) := by
8583
ext
86-
simp_all
84+
simp
8785

8886
attribute [bv_normalize] BitVec.natCast_eq_ofNat
8987
attribute [bv_normalize] BitVec.append_eq

tests/lean/run/bv_decide_rewriter.lean

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ theorem mem_subset_refl : mem_subset a1 a2 a1 a2 := by
2626
unfold mem_subset
2727
bv_normalize
2828

29+
example (a b : Bool) : ((a = true) ↔ (b = true)) ↔ (a == b) := by bv_normalize
2930
example {x : BitVec 16} : 0#16 + x = x := by bv_normalize
3031
example {x : BitVec 16} : x + 0#16 = x := by bv_normalize
3132
example {x : BitVec 16} : x.setWidth 16 = x := by bv_normalize

0 commit comments

Comments
 (0)