Mathlib algebraic structure on Hex.Matrix, transported along matrixEquiv.
matrixEquiv carries the executable dense-matrix operations to Mathlib's
function-based Matrix, so we equip Hex.Matrix with the Mathlib algebraic
tower (AddCommMonoid, AddCommGroup, Module, Semiring, Ring, Algebra)
whose operations are the executable ones, and upgrade matrixEquiv to the
corresponding additive, linear, ring, and algebra equivalences.
Base operations on the opaque structure #
The abbreviation representation inherited these pointwise operations from
Vector; the opaque structure delegates them to the row data, so the
Mathlib tower transported along matrixEquiv has executable operations.
Equations
- HexMatrixMathlib.instAdd = { add := fun (A B : Hex.Matrix R n m) => { data := A.data + B.data } }
Equations
- HexMatrixMathlib.instNeg = { neg := fun (A : Hex.Matrix R n m) => { data := -A.data } }
Equations
- HexMatrixMathlib.instSub = { sub := fun (A B : Hex.Matrix R n m) => { data := A.data - B.data } }
Preservation of the additive operations #
1 on a square matrix is the identity matrix. The instance is here rather than
in HexMatrix because the Semiring/Ring structures transported below need it,
while HexMatrix states its own lemmas with Matrix.identity.
Equations
- HexMatrixMathlib.instOne = { one := Hex.Matrix.identity n }
Additive instances and the additive equivalence #
Equations
matrixEquiv as an additive equivalence.
Equations
- HexMatrixMathlib.matrixAddEquiv = { toEquiv := HexMatrixMathlib.matrixEquiv, map_add' := ⋯ }
Instances For
Module structure and the linear equivalence #
matrixEquiv as an R-linear equivalence.
Equations
- HexMatrixMathlib.matrixLinearEquiv = { toFun := HexMatrixMathlib.matrixEquiv.toFun, map_add' := ⋯, map_smul' := ⋯, invFun := HexMatrixMathlib.matrixEquiv.invFun, left_inv := ⋯, right_inv := ⋯ }
Instances For
Multiplicative preservation #
Auxiliary operations, pulled back through matrixEquiv #
These NatCast, IntCast, and Pow instances exist only to populate the
corresponding fields of the Semiring/Ring structures. They are proof-facing:
defined by transport through matrixEquiv, not in executable form. Executable
code never goes through them — it uses the HexMatrix operations directly (the
square-matrix *, the ofFn identity). Their transport lemmas below reduce them
to the Mathlib side for simp/grind.
Equations
- HexMatrixMathlib.instNatCast = { natCast := fun (k : ℕ) => HexMatrixMathlib.matrixEquiv.symm ↑k }
Equations
- HexMatrixMathlib.instIntCast = { intCast := fun (k : ℤ) => HexMatrixMathlib.matrixEquiv.symm ↑k }
Equations
- HexMatrixMathlib.instPow = { pow := fun (M : Hex.Matrix R n n) (k : ℕ) => HexMatrixMathlib.matrixEquiv.symm (HexMatrixMathlib.matrixEquiv M ^ k) }
Ring structure and the ring equivalence #
Equations
Equations
- HexMatrixMathlib.instRing = Function.Injective.ring ⇑HexMatrixMathlib.matrixEquiv ⋯ ⋯ ⋯ ⋯ ⋯ ⋯ ⋯ ⋯ ⋯ ⋯ ⋯ ⋯
matrixEquiv as a ring equivalence on square matrices.
Equations
- HexMatrixMathlib.matrixRingEquiv = { toEquiv := HexMatrixMathlib.matrixEquiv, map_mul' := ⋯, map_add' := ⋯ }
Instances For
Algebra structure and the algebra equivalence #
Equations
matrixEquiv as an R-algebra equivalence on square matrices.
Equations
- HexMatrixMathlib.matrixAlgEquiv = { toEquiv := HexMatrixMathlib.matrixRingEquiv.toEquiv, map_mul' := ⋯, map_add' := ⋯, commutes' := ⋯ }