Skip to content

Commit

Permalink
refactor: remove isDefEq check
Browse files Browse the repository at this point in the history
  • Loading branch information
alexkeizer committed Feb 14, 2025
1 parent fc284d1 commit 20988c9
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/Lean/Elab/Tactic/BVDecide/Frontend/Normalize/AC.lean
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,17 @@ def toExpr : Op → Expr
def neutralElement : Op → Expr
| .mul w => mkBitVecLit w 1

/-- Parse `op'` using `ofExpr?` and return true if the resulting operation is
of the same kind as `op` (i.e., both are multiplications).
Returns false if `op'` fails to parse.
Note that the width of the operation is *not* compared.
-/
def isSameKind (op : Op) (op' : Expr) : Bool := Id.run do
let some op' := ofExpr? op' | false
match op, op' with
| .mul _, .mul _ => true

instance : ToMessageData Op where
toMessageData op := m!"{toExpr op}"

Expand Down Expand Up @@ -167,7 +178,7 @@ where
return coeff.alter idx (fun c => some <| (c.getD 0) + 1)
go (coeff : CoefficientsMap) : Expr → VarStateM CoefficientsMap
| e@(AC.bin op' x y) => do
if ← isDefEq op' op.toExpr then
if op.isSameKind op' then
let coeff ← go coeff x
let coeff ← go coeff y
return coeff
Expand Down

0 comments on commit 20988c9

Please sign in to comment.