Lemmas for concrete matrices Matrix (Fin m) (Fin n) α
#
This file contains alternative definitions of common operators on matrices that expand
definitionally to the expected expression when evaluated on !![]
notation.
This allows "proof by reflection", where we prove A = !![A 0 0, A 0 1; A 1 0, A 1 1]
by defining
Matrix.etaExpand A
to be equal to the RHS definitionally, and then prove that
A = eta_expand A
.
The definitions in this file should normally not be used directly; the intent is for the
corresponding *_eq
lemmas to be used in a place where they are definitionally unfolded.
Main definitions #
∀
with better defeq for ∀ x : Matrix (Fin m) (Fin n) α, P x
.
Equations
- Matrix.Forall x = x (Matrix.of ![])
- Matrix.Forall x = FinVec.Forall fun (r : Fin x✝ → α) => Matrix.Forall fun (A : Matrix (Fin n) (Fin x✝) α) => x (Matrix.of (Matrix.vecCons r A))
Instances For
∃
with better defeq for ∃ x : Matrix (Fin m) (Fin n) α, P x
.
Equations
- Matrix.Exists x = x (Matrix.of ![])
- Matrix.Exists x = FinVec.Exists fun (r : Fin x✝ → α) => Matrix.Exists fun (A : Matrix (Fin n) (Fin x✝) α) => x (Matrix.of (Matrix.vecCons r A))
Instances For
Matrix.transpose
with better defeq for Fin
Equations
- x_4.transposeᵣ = Matrix.of ![]
- A.transposeᵣ = Matrix.of (Matrix.vecCons (FinVec.map (fun (v : Fin (n + 1) → α) => v 0) A) (A.submatrix id Fin.succ).transposeᵣ)
Instances For
Matrix.dotProduct
with better defeq for Fin
Equations
- Matrix.dotProductᵣ a b = FinVec.sum (FinVec.seq (FinVec.map (fun (x x_1 : α) => x * x_1) a) b)
Instances For
This can be used to prove
example (a b c d : α) [Mul α] [AddCommMonoid α] :
dot_product ![a, b] ![c, d] = a * c + b * d :=
(dot_productᵣ_eq _ _).symm
Matrix.mul
with better defeq for Fin
Equations
- A.mulᵣ B = Matrix.of (FinVec.map (fun (v₁ : Fin m → α) => FinVec.map (fun (v₂ : Fin m → α) => Matrix.dotProductᵣ v₁ v₂) B.transpose) A)
Instances For
This can be used to prove
example [AddCommMonoid α] [Mul α] (a₁₁ a₁₂ a₂₁ a₂₂ b₁₁ b₁₂ b₂₁ b₂₂ : α) :
!![a₁₁, a₁₂;
a₂₁, a₂₂] * !![b₁₁, b₁₂;
b₂₁, b₂₂] =
!![a₁₁*b₁₁ + a₁₂*b₂₁, a₁₁*b₁₂ + a₁₂*b₂₂;
a₂₁*b₁₁ + a₂₂*b₂₁, a₂₁*b₁₂ + a₂₂*b₂₂] :=
(mulᵣ_eq _ _).symm
Matrix.mulVec
with better defeq for Fin
Equations
- A.mulVecᵣ v = FinVec.map (fun (a : Fin m → α) => Matrix.dotProductᵣ a v) A
Instances For
This can be used to prove
example [NonUnitalNonAssocSemiring α] (a₁₁ a₁₂ a₂₁ a₂₂ b₁ b₂ : α) :
!![a₁₁, a₁₂;
a₂₁, a₂₂] *ᵥ ![b₁, b₂] = ![a₁₁*b₁ + a₁₂*b₂, a₂₁*b₁ + a₂₂*b₂] :=
(mulVecᵣ_eq _ _).symm
Matrix.vecMul
with better defeq for Fin
Equations
- Matrix.vecMulᵣ v A = FinVec.map (fun (a : Fin l → α) => Matrix.dotProductᵣ v a) A.transpose
Instances For
This can be used to prove
example [NonUnitalNonAssocSemiring α] (a₁₁ a₁₂ a₂₁ a₂₂ b₁ b₂ : α) :
![b₁, b₂] ᵥ* !![a₁₁, a₁₂;
a₂₁, a₂₂] = ![b₁*a₁₁ + b₂*a₂₁, b₁*a₁₂ + b₂*a₂₂] :=
(vecMulᵣ_eq _ _).symm