Commit 2026-10-28 04:22 05a213b6
View on Github →perf(Tactic/Echelon): allow any type for computations (#45233)
This PR refactors the ring computations in the bareiss decomposition algorithm to allow using any type for the computations. Previously, it could only be Expr or Int.
A natural way to allow this is to make the carrier type V a field of the Model structure. Unfortunately, this puts it in Type 1, which means it cannot be passed through IO/MetaM. Instead, we use an approach based on unsafeCast. The same approach is used in different places in Lean core, such as to handle environment extensions (which need to store arbitrary types), https://github.com/leanprover/lean4/blob/v4.36.0-rc1/src/Lean/Meta/Tactic/Grind/Types.lean#L118-L121 and https://github.com/leanprover/lean4/blob/v4.36.0-rc1/src/Lean/Meta/Sym/SymM.lean#L31-L34 ..