refactor(Vorspiel): rename clashing Matrix.map/forall_iff/exists_iff to vec* (Mathlib co-import)#835
Conversation
…ib clash Foundation.Vorspiel.Matrix defined its own Matrix.map, a vector map (Fin k → α) → (Fin k → β), shadowing Mathlib's Matrix.map. Both auto-generate Matrix.map.eq_1, so importing Foundation alongside any Mathlib module that materializes Mathlib's Matrix.map.eq_1 (e.g. Bochner integration, matrix-heavy analysis) fails with an 'environment already contains Matrix.map.eq_1' clash. Because Vorspiel.Matrix sits in Foundation's prelude, this blocks co-importing Foundation with large parts of Mathlib. Rename the def to vecMap. The postfix notation ⨟ and all lemmas are unchanged in behavior; no qualified Matrix.map (vector) references exist elsewhere in the tree.
… Mathlib clash Same clash as Matrix.map -> vecMap in this PR: Vorspiel.Matrix's forall_iff and exists_iff collide by name with Mathlib.Data.Matrix.Reflection's Matrix.forall_iff / Matrix.exists_iff, blocking co-import of Foundation with that module (pulled in transitively via EuclideanSpace / InnerProductSpace.PiL2). Rename to vecForall_iff / vecExists_iff and update the 12 call sites in BinderNotation and Semantics.
|
Thanks for the PR! |
SnO2WMaN
left a comment
There was a problem hiding this comment.
For the lemmas involving Matrix.vecMap, I think renaming them to vecMap_* would be fine. The same goes for the other definitions.
…ency Co-Authored-By: Claude <noreply@anthropic.com>
|
Verified: a scratch module importing |
|
@A-M-Berns P.S.: I took a look at https://github.com/A-M-Berns/Formalized-Agent-Foundations and it looks like you're using something around the fixed-point theorem for modal logic GL. |
This PR was prepared with the help of Claude Fable 5 to fix a naming clash between Mathlib and FFL that I encountered when working on my Formalized Agent Foundations project that uses both as a dependency. This rename would be useful for any project that requires both Mathlib and FFL to reduce naming conflicts.
--
What
Renames the three
Foundation.Vorspiel.Matrixdeclarations that shadow existing MathlibMatrix.*names, so Foundation can be imported alongside Mathlib's matrix/analysis theory:Matrix.map(a vector map(Fin k → α) → (Fin k → β))Matrix.map(…Matrix.InvariantBasisNumbermaterializesMatrix.map.eq_1)Matrix.vecMapMatrix.forall_iffMatrix.forall_iff(Mathlib.Data.Matrix.Reflection)Matrix.vecForall_iffMatrix.exists_iffMatrix.exists_iff(Mathlib.Data.Matrix.Reflection)Matrix.vecExists_iffThe
⨟notation and all lemmas keep their behavior; the 12 call sites offorall_iff/exists_iffinBinderNotation.leanandSemantics.leanare updated.Why
Each of these lives in the
Matrixnamespace and shares a name with a distinct MathlibMatrixdeclaration. Importing Foundation together with the relevant Mathlib module fails at import time, e.g.:Because
Vorspiel.Matrixsits in Foundation's prelude, every Foundation module inherits the clash. It surfaces when co-importing Foundation with matrix-heavy Mathlib analysis —Mathlib.MeasureTheory.Integral.Bochner, and anything pullingEuclideanSpace/InnerProductSpace.PiL2(which transitively importsMatrix.Reflection).Scope / safety
Matrix-namespace name collisions: I intersected everyMatrix.*decl inVorspiel/Matrix.leanagainst Mathlib and confirmed the rest (vecConsLast,toList,foldr,foldl,appendr, …) have no MathlibMatrixcounterpart.EuclideanSpace ℝ (Fin d)) now builds green with these renames; before them the roll-up module hit exactly the two clashes above in sequence.lake build Foundationagainst master's current toolchain locally; these are pure renames of leaf decls with all call sites updated, so they should be toolchain-agnostic — happy to let CI confirm.Note on lemma names
I kept the
map_*lemma family (map_cons,map_app,map_map_comp', …) and thesection mapunchanged, to keep the diff to what's needed to clear the clash. Glad to rename those tovecMap_*for consistency with thefoldr_*/foldl_*convention if you'd prefer.