Algebraic structure classification #
Detects the strongest algebraic structure available for a type and caches
the classification in Arith.State.typeClassify. The state is a SymExtension,
so a type is classified once per SymM run and the result is shared by every
grind goal and every tactic of a sym block. The detection order is:
Grind.CommRing(includesFieldcheck)Grind.Ring(non-commutative)Grind.CommSemiring(viaOfSemiring.Qenvelope)Grind.Semiring(non-commutative)
Results (including failures) are cached in a single PHashMap ExprPtr ClassifyResult
to avoid repeated synthesis attempts.
Returns some α if the operand types α, β and the result type γ of a binary operator
are the same type. Heterogeneous applications, such as c * xs with c : Nat and
xs : Vector Nat n, are not terms of α, and arithmetic modules must treat them as atoms.
The types are compared with isSameExpr, which relies on the terms being maximally shared.
Equations
- Lean.Meta.Sym.Arith.homoType? α β γ = if (Lean.Meta.Sym.isSameExpr α β && Lean.Meta.Sym.isSameExpr α γ) = true then some α else none
Instances For
Classify the algebraic structure of type, trying the strongest first:
CommRing > Ring > CommSemiring > Semiring.
Results are cached in Arith.State.typeClassify.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Classify type as an order structure (at least IsPreorder), returning its id in
State.orders. Results, including failures, are cached in State.typeOrderClassify.
Equations
- One or more equations did not get rendered due to their size.