Skip to content

Commit 64ea9c7

Browse files
committed
grind pred
1 parent f1767b2 commit 64ea9c7

File tree

2 files changed

+8
-36
lines changed

2 files changed

+8
-36
lines changed

src/Std/Tactic/BVDecide/Bitblast/BVExpr/Circuit/Impl/Expr.lean

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,12 +296,14 @@ end
296296

297297
end bitblast
298298

299+
@[grind =]
299300
theorem bitblast_decl_eq (aig : AIG BVBit) (input : WithCache (BVExpr w) aig) :
300301
∀ (idx : Nat) (h1) (h2), (bitblast aig input).result.val.aig.decls[idx]'h2 = aig.decls[idx]'h1 := by
301302
intros
302303
unfold bitblast
303304
apply bitblast.goCache_decl_eq
304305

306+
@[grind! .]
305307
theorem bitblast_le_size (aig : AIG BVBit) (input : WithCache (BVExpr w) aig) :
306308
aig.decls.size ≤ (bitblast aig input).result.val.aig.decls.size := by
307309
exact (bitblast aig input).result.property

src/Std/Tactic/BVDecide/Bitblast/BVExpr/Circuit/Impl/Pred.lean

Lines changed: 6 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ module
88
prelude
99
public import Std.Tactic.BVDecide.Bitblast.BVExpr.Circuit.Impl.Operations.GetLsbD
1010
public import Std.Tactic.BVDecide.Bitblast.BVExpr.Circuit.Impl.Expr
11+
import Init.Grind
1112

1213
@[expose] public section
1314

@@ -37,20 +38,12 @@ def bitblast (aig : AIG BVBit) (input : BVExpr.WithCache BVPred aig) : Return ai
3738
| .eq =>
3839
let res := mkEq aig ⟨lhsRefs, rhsRefs⟩
3940
let cache := cache.cast (AIG.LawfulOperator.le_size (f := mkEq) ..)
40-
have := by
41-
apply AIG.LawfulOperator.le_size_of_le_aig_size (f := mkEq)
42-
dsimp only at hlhs hrhs
43-
omega
44-
⟨⟨res, this⟩, cache⟩
41+
⟨⟨res, by grind⟩, cache⟩
4542
| .ult =>
4643
let res := mkUlt aig ⟨lhsRefs, rhsRefs⟩
4744
have := AIG.LawfulOperator.le_size (f := mkUlt) ..
4845
let cache := cache.cast this
49-
have := by
50-
apply AIG.LawfulOperator.le_size_of_le_aig_size (f := mkUlt)
51-
dsimp only at hlhs hrhs
52-
omega
53-
⟨⟨res, this⟩, cache⟩
46+
⟨⟨res, by grind⟩, cache⟩
5447
| .getLsbD expr idx =>
5548
/-
5649
Note: This blasts the entire expression up to `w` despite only needing it up to `idx`.
@@ -61,38 +54,15 @@ def bitblast (aig : AIG BVBit) (input : BVExpr.WithCache BVPred aig) : Return ai
6154
let res := blastGetLsbD aig ⟨refs, idx⟩
6255
⟨⟨⟨aig, res⟩, hrefs⟩, cache⟩
6356

57+
@[grind =]
6458
theorem bitblast_decl_eq (aig : AIG BVBit) (input : BVExpr.WithCache BVPred aig) :
6559
∀ (idx : Nat) (h1) (h2), (bitblast aig input).result.val.aig.decls[idx]'h2 = aig.decls[idx]'h1 := by
6660
intro idx h1 h2
6761
rcases input with ⟨pred, cache⟩
6862
unfold BVPred.bitblast
69-
cases pred with
70-
| bin lhs op rhs =>
71-
cases op with
72-
| eq =>
73-
dsimp only
74-
rw [AIG.LawfulOperator.decl_eq (f := mkEq)]
75-
rw [BVExpr.bitblast_decl_eq]
76-
rw [BVExpr.bitblast_decl_eq]
77-
· apply BVExpr.bitblast_lt_size_of_lt_aig_size
78-
assumption
79-
· apply BVExpr.bitblast_lt_size_of_lt_aig_size
80-
apply BVExpr.bitblast_lt_size_of_lt_aig_size
81-
assumption
82-
| ult =>
83-
simp only
84-
rw [AIG.LawfulOperator.decl_eq (f := mkUlt)]
85-
rw [BVExpr.bitblast_decl_eq]
86-
rw [BVExpr.bitblast_decl_eq]
87-
· apply BVExpr.bitblast_lt_size_of_lt_aig_size
88-
assumption
89-
· apply BVExpr.bitblast_lt_size_of_lt_aig_size
90-
apply BVExpr.bitblast_lt_size_of_lt_aig_size
91-
assumption
92-
| getLsbD expr idx =>
93-
simp only
94-
rw [BVExpr.bitblast_decl_eq]
63+
grind
9564

65+
@[grind! .]
9666
theorem bitblast_le_size (aig : AIG BVBit) (input : BVExpr.WithCache BVPred aig) :
9767
aig.decls.size ≤ (bitblast aig input).result.val.aig.decls.size := by
9868
exact (bitblast aig input).result.property

0 commit comments

Comments
 (0)