Skip to content

Commit b790269

Browse files
committed
chore: fix build
1 parent cac12f2 commit b790269

File tree

5 files changed

+51
-21
lines changed

5 files changed

+51
-21
lines changed

src/Init/Data/BitVec/Bitblast.lean

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1980,7 +1980,7 @@ theorem clz_eq_clzAuxRec_of_false (x : BitVec w) (h : ∀ i, n < i → x.getLsbD
19801980
rw [Nat.mod_eq_of_lt (by omega), Nat.mod_eq_of_lt (by omega)]
19811981
simp only [show ¬∀ i, i < w + 1 → x.getLsbD i = false by simp; exists 0; simp [hx0],
19821982
iff_false] at heq
1983-
rw [clzAux_eq_iff_forall_of_clzAuz_lt (by omega) (by omega)]
1983+
rw [clzAux_eq_iff_forall_of_clzAux_lt (by omega)]
19841984
simp only [Nat.sub_self, zero_lt_succ, getLsbD_eq_getElem, hx0, _root_.and_true]
19851985
intro i hi
19861986
apply h
@@ -2003,7 +2003,7 @@ theorem clz_eq_clzAuxRec_of_false (x : BitVec w) (h : ∀ i, n < i → x.getLsbD
20032003
simp only [iff_false, show ¬∀ i, i < w + 1 → x.getLsbD i = false by simp; exists n + 1] at heq
20042004
simp only [hxn, ↓reduceIte, toNat_eq, toNat_ofNat]
20052005
rw [Nat.mod_eq_of_lt (by omega), Nat.mod_eq_of_lt (by omega),
2006-
clzAux_eq_iff_forall_of_clzAuz_lt (by omega) (by omega)]
2006+
clzAux_eq_iff_forall_of_clzAux_lt (by omega)]
20072007
simp only [show w - (w - (n + 1)) = n + 1 by omega, hxn, _root_.and_true]
20082008
intro i hi
20092009
apply h
@@ -2021,4 +2021,12 @@ theorem clz_eq_clzAuxRec_of_eq (x : BitVec w) (h : w - 1 ≤ n) :
20212021
intro i hi
20222022
simp [show w ≤ i by omega]
20232023

2024+
theorem clzAuxRec_eq_of_le (x : BitVec w) (hn : w ≤ n) :
2025+
x.clzAuxRec n = x.clzAuxRec (w - 1) := by
2026+
rcases w with _|w
2027+
· simp [of_length_zero]
2028+
· rw [← clz_eq_clzAuxRec_of_eq]
2029+
· rw [clz_eq_clzAuxRec_of_eq]; omega
2030+
· omega
2031+
20242032
end BitVec

src/Init/Data/BitVec/Lemmas.lean

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5635,6 +5635,39 @@ theorem clzAux_eq_zero_iff {x : BitVec w} {n : Nat}:
56355635
unfold clzAux
56365636
cases n <;> simp
56375637

5638+
theorem clzAux_eq_iff {x : BitVec w} {n : Nat} :
5639+
clzAux x n = (n + 1) ↔ (∀ i, i < n + 1 → x.getLsbD i = false) := by
5640+
induction n
5641+
· case zero => simp [clzAux]
5642+
· case succ n ihn =>
5643+
by_cases hn1 : x.getLsbD (n + 1)
5644+
· simp only [clzAux, hn1, ↓reduceIte, Nat.right_eq_add, Nat.add_eq_zero, reduceCtorEq, and_false,
5645+
false_iff, Classical.not_forall, not_imp, Bool.not_eq_false]
5646+
exists n + 1, by omega
5647+
· have h3 : 1 + x.clzAux n = n + 1 + 1 ↔ x.clzAux n = n + 1 := by omega
5648+
simp only [clzAux, hn1, Bool.false_eq_true, ↓reduceIte, h3, ihn]
5649+
constructor
5650+
· intro h i hin
5651+
by_cases hi : i ≤ n
5652+
· apply h
5653+
omega
5654+
· simp only [Bool.not_eq_true] at hn1
5655+
simp [show i = n + 1 by omega, hn1]
5656+
· intro h i hin
5657+
apply h
5658+
omega
5659+
5660+
theorem clzAux_le {x : BitVec w} {n : Nat} :
5661+
clzAux x n ≤ n + 1 := by
5662+
induction n
5663+
· case zero =>
5664+
by_cases hx0 : x.getLsbD 0
5665+
<;> simp [clzAux, hx0]
5666+
· case succ n ihn =>
5667+
by_cases hxn : x.getLsbD (n + 1)
5668+
· simp [clzAux, hxn]
5669+
· simp [clzAux, hxn]; omega
5670+
56385671
@[simp]
56395672
theorem clzAux_zero {x : BitVec w} : clzAux x 0 = if x.getLsbD 0 then 0 else 1 := by simp [clzAux]
56405673

@@ -5665,8 +5698,8 @@ theorem clzAux_eq_iff_forall_of_clzAux_lt {x : BitVec w} (hlt : (clzAux x n < n
56655698
intro hi
56665699
specialize hi 0 (by omega)
56675700
simp [hxn] at hi
5668-
· simp [hxn, Bool.false_eq_true, ↓reduceIte] at hlt
5669-
simp [show x.clzAux n < n + 1 by omega, forall_const] at ihn
5701+
· simp only [hxn, Bool.false_eq_true, ↓reduceIte] at hlt
5702+
simp only [show x.clzAux n < n + 1 by omega, forall_const] at ihn
56705703
simp only [hxn, Bool.false_eq_true, ↓reduceIte,
56715704
show 1 + x.clzAux n = k + 1 ↔ x.clzAux n = k by omega, Nat.reduceSubDiff, ihn,
56725705
and_congr_left_iff]

src/Std/Tactic/BVDecide/Bitblast/BVExpr/Basic.lean

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@ theorem eval_arithShiftRightConst : eval (arithShiftRightConst n) = (BitVec.sshi
186186

187187
@[simp] theorem eval_clz : eval .clz = (BitVec.clz : BitVec w → BitVec w) := by rfl
188188

189-
190189
end BVUnOp
191190

192191
/--

src/Std/Tactic/BVDecide/Bitblast/BVExpr/Circuit/Impl/Operations/Clz.lean

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,10 @@
11
/-
22
Copyright (c) 2025 Lean FRO, LLC. All rights reserved.
33
Released under Apache 2.0 license as described in the file LICENSE.
4-
Authors: Luisa Cicolini, Siddharth Bhat
4+
Authors: Luisa Cicolini, Siddharth Bhat, Henrik Böving
55
-/
66
prelude
7-
import Std.Tactic.BVDecide.Bitblast.BVExpr.Basic
8-
import Std.Tactic.BVDecide.Bitblast.BVExpr.Circuit.Impl.Operations.GetLsbD
9-
import Std.Tactic.BVDecide.Bitblast.BVExpr.Circuit.Impl.Operations.Eq
10-
import Std.Sat.AIG
11-
import Std.Tactic.BVDecide.Bitblast.BVExpr.Basic
12-
import Std.Tactic.BVDecide.Bitblast.BVExpr.Circuit.Impl.Operations.Sub
13-
import Std.Tactic.BVDecide.Bitblast.BVExpr.Circuit.Impl.Operations.Eq
14-
import Std.Tactic.BVDecide.Bitblast.BVExpr.Circuit.Impl.Operations.Ult
15-
import Std.Tactic.BVDecide.Bitblast.BVExpr.Circuit.Impl.Operations.ZeroExtend
7+
import Std.Tactic.BVDecide.Bitblast.BVExpr.Circuit.Impl.Const
168
import Std.Sat.AIG.If
179

1810
/-!
@@ -35,7 +27,6 @@ def blastClz (aig : AIG α) (x : AIG.RefVec aig w) :
3527
where
3628
go (aig : AIG α) (x : AIG.RefVec aig w) (curr : Nat) (acc : AIG.RefVec aig w) :=
3729
if hc : curr < w then
38-
-- w - curr - 1
3930
let lhs := blastConst aig (w := w) (w - 1 - curr)
4031
let res := AIG.RefVec.ite aig ⟨x.get curr hc, lhs, acc⟩
4132
let aig := res.aig
@@ -72,8 +63,7 @@ theorem blastClz.go_decl_eq (aig : AIG α) (curr : Nat) (acc : AIG.RefVec aig w)
7263
split at hgo
7364
· rw [← hgo]
7465
intros
75-
rw [blastClz.go_decl_eq]
76-
rw [AIG.LawfulVecOperator.decl_eq (f := AIG.RefVec.ite)]
66+
rw [blastClz.go_decl_eq, AIG.LawfulVecOperator.decl_eq (f := AIG.RefVec.ite)]
7767
apply AIG.LawfulVecOperator.lt_size_of_lt_aig_size (f := AIG.RefVec.ite)
7868
assumption
7969
· simp [← hgo]
@@ -84,12 +74,12 @@ instance : AIG.LawfulVecOperator α AIG.RefVec blastClz where
8474
intros
8575
unfold blastClz
8676
dsimp only
87-
(expose_names; exact blastClz.go_le_size aig 0 (blastConst aig ↑len) input)
77+
apply blastClz.go_le_size
8878
decl_eq := by
8979
intros
9080
unfold blastClz
9181
dsimp only
92-
(expose_names; exact blastClz.go_decl_eq aig 0 (blastConst aig ↑len) input idx h2 h1)
82+
apply blastClz.go_decl_eq
9383

9484
end bitblast
9585
end BVExpr

src/Std/Tactic/BVDecide/Bitblast/BVExpr/Circuit/Lemmas/Operations/Clz.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/-
22
Copyright (c) 2025 Lean FRO, LLC. All rights reserved.
33
Released under Apache 2.0 license as described in the file LICENSE.
4-
Authors: Luisa Cicolini, Siddharth Bhat
4+
Authors: Luisa Cicolini, Siddharth Bhat, Henrik Böving
55
-/
66
prelude
77
import Std.Tactic.BVDecide.Bitblast.BVExpr.Circuit.Lemmas.Basic

0 commit comments

Comments
 (0)