Expr helpers #
Equations
Equations
- Lean.Elab.Tactic.BVDecide.Frontend.Normalize.BitVec.mkInstMul w = Lean.mkApp (Lean.Expr.const `BitVec.instMul []) w
Equations
- One or more equations did not get rendered due to their size.
Construct a literal of type BitVec w
, with value n
.
Equations
- Lean.Elab.Tactic.BVDecide.Frontend.Normalize.mkBitVecLit w n = Lean.mkApp2 (Lean.mkConst `BitVec.ofNat) w (Lean.mkNatLit n)
Types #
Bitvector operations that we perform AC canonicalization on.
Given an application of a recognized binary operation (to two arguments),
return the decoded Op
.
Return none
if the expression is not an application of a recognized operation.
Equations
- One or more equations did not get rendered due to their size.
The identity / neutral element of given operation
Equations
- One or more equations did not get rendered due to their size.
- op : Op
The associative and commutative operator we are currently canonicalizing with respect to.
- exprToVarIndex : Std.HashMap Expr VarIndex
Map from atomic expressions to an index.
Inverse of
exprToVarIndex
, which maps aVarIndex
to the expression it represents.
We don't verify the state manipulations, but if we would, these are the invariants:
structure LegalVarState extends VarState where
/-- `varToExpr` and `exprToVarIndex` have the same number of elements. -/
h_size : varToExpr.size = exprToVarIndex.size
/-- `exprToVarIndex` is the inverse of `varToExpr`. -/
h_elems : ∀ h_lt : i < varToExpr.size, exprToVarIndex[varToExpr[i]]? = some i
A representation of an expression as a map from variable index to the number of occurences of the expression represented by that variable.
See CoefficientsMap.toExpr
for the explicit conversion.
VarState monadic boilerplate #
Equations
- x.run' s = StateT.run' x s
Implementation #
Return the unique variable index for an expression, or none
if the expression
is a neutral element (see isNeutral
).
Modifies the monadic state to add a new mapping, if needed.
Equations
- One or more equations did not get rendered due to their size.
Return the expression that is represented by a specific variable index.
Equations
- One or more equations did not get rendered due to their size.
Given a binary, associative and commutative operation op
,
decompose expression e
into its variable coefficients.
For example a ⊕ b ⊕ (a ⊕ c)
will give the coefficients:
a => 2
b => 1
c => 1
Any compound expression which is not an application of the given op
will be
abstracted away and treated as a variable (see VarStateM.exprToVar
).
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
- Lean.Elab.Tactic.BVDecide.Frontend.Normalize.VarStateM.computeCoefficients.go op coeff x✝ = Lean.Elab.Tactic.BVDecide.Frontend.Normalize.VarStateM.computeCoefficients.incrVar coeff x✝
Compute the canonical expression for a given set of coefficients.
Returns none
if all coefficients are zero.
Equations
- One or more equations did not get rendered due to their size.
Given an expression P lhs rhs
, where lhs, rhs : ty
and P : $ty → $ty → _
,
canonicalize top-level applications of a recognized associative and commutative
operation on both the lhs
and the rhs
such that the final expression is:
P ($common ⊕ $lhs') ($common ⊕ $rhs')
That is, in a way that exposes terms that are shared between the lhs and rhs.
For example, x₁ * (y₁ * z) == x₂ * (y₂ * z)
is normalized to
z * (x₁ * y₁) == z * (x₂ * y₂)
, pulling the shared variable z
to the front on
both sides.
See Op.fromExpr?
to see which operations are recognized.
Other operations are ignored, even if they are associative and commutative.
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Tactic Boilerplate #
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.