88prelude
99public import Std.Tactic.BVDecide.Bitblast.BVExpr.Circuit.Impl.Operations.GetLsbD
1010public 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 =]
6458theorem 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! .]
9666theorem 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