The areas / V07. Linear algebra
Mathlib.Data.Matrix.Reflection
20 declarations. Mathlib docs · Source
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
Matrix.transposeᵣdotProductᵣMatrix.mulᵣMatrix.mulVecᵣMatrix.vecMulᵣMatrix.etaExpand
theorem Matrix.Forall.match_1.congr_eq_1 E1 #
∀ {α : Type u_1} (motive : (x x_1 : ℕ) → (Matrix (Fin x) (Fin x_1) α → Prop) → Sort u_2) (x x_1 : ℕ)
(x_2 : Matrix (Fin x) (Fin x_1) α → Prop) (h_1 : (x : ℕ) → (P : Matrix (Fin 0) (Fin x) α → Prop) → motive 0 x P)
(h_2 : (n x : ℕ) → (P : Matrix (Fin (n + 1)) (Fin x) α → Prop) → motive n.succ x P) (x_3 : ℕ)
(P : Matrix (Fin 0) (Fin x_3) α → Prop),
x = 0 →
x_1 = x_3 →
x_2 ≍ P →
(match x, x_1, x_2 with
| 0, x, P => h_1 x P
| n.succ, x, P => h_2 n x P) ≍
h_1 x_3 P
theorem Matrix.Forall.match_1.congr_eq_2 E1 #
∀ {α : Type u_1} (motive : (x x_1 : ℕ) → (Matrix (Fin x) (Fin x_1) α → Prop) → Sort u_2) (x x_1 : ℕ)
(x_2 : Matrix (Fin x) (Fin x_1) α → Prop) (h_1 : (x : ℕ) → (P : Matrix (Fin 0) (Fin x) α → Prop) → motive 0 x P)
(h_2 : (n x : ℕ) → (P : Matrix (Fin (n + 1)) (Fin x) α → Prop) → motive n.succ x P) (n x_3 : ℕ)
(P : Matrix (Fin (n + 1)) (Fin x_3) α → Prop),
x = n.succ →
x_1 = x_3 →
x_2 ≍ P →
(match x, x_1, x_2 with
| 0, x, P => h_1 x P
| n.succ, x, P => h_2 n x P) ≍
h_2 n x_3 P
theorem Matrix.transposeᵣ.match_1.congr_eq_2 E1 #
∀ {α : Type u_1} (motive : (x x_1 : ℕ) → Matrix (Fin x) (Fin x_1) α → Sort u_2) (x x_1 : ℕ)
(x_2 : Matrix (Fin x) (Fin x_1) α) (h_1 : (x : ℕ) → (x_3 : Matrix (Fin x) (Fin 0) α) → motive x 0 x_3)
(h_2 : (x n : ℕ) → (A : Matrix (Fin x) (Fin (n + 1)) α) → motive x n.succ A) (x_3 n : ℕ)
(A : Matrix (Fin x_3) (Fin (n + 1)) α),
x = x_3 →
x_1 = n.succ →
x_2 ≍ A →
(match x, x_1, x_2 with
| x, 0, x_4 => h_1 x x_4
| x, n.succ, A => h_2 x n A) ≍
h_2 x_3 n A
theorem Matrix.transposeᵣ.match_1.congr_eq_1 E1 #
∀ {α : Type u_1} (motive : (x x_1 : ℕ) → Matrix (Fin x) (Fin x_1) α → Sort u_2) (x x_1 : ℕ)
(x_2 : Matrix (Fin x) (Fin x_1) α) (h_1 : (x : ℕ) → (x_3 : Matrix (Fin x) (Fin 0) α) → motive x 0 x_3)
(h_2 : (x n : ℕ) → (A : Matrix (Fin x) (Fin (n + 1)) α) → motive x n.succ A) (x_3 : ℕ)
(x_4 : Matrix (Fin x_3) (Fin 0) α),
x = x_3 →
x_1 = 0 →
x_2 ≍ x_4 →
(match x, x_1, x_2 with
| x, 0, x_5 => h_1 x x_5
| x, n.succ, A => h_2 x n A) ≍
h_1 x_3 x_4
def Matrix.Forall E1 #
{α : Type u_1} → {m n : ℕ} → (Matrix (Fin m) (Fin n) α → Prop) → Prop
∀ with better defeq for ∀ x : Matrix (Fin m) (Fin n) α, P x.
theorem Matrix.forall_iff E0 #
∀ {α : Type u_1} {m n : ℕ} (P : Matrix (Fin m) (Fin n) α → Prop),
Matrix.Forall P ↔ ∀ (x : Matrix (Fin m) (Fin n) α), P x
This can be used to prove
example (P : Matrix (Fin 2) (Fin 3) α → Prop) :
(∀ x, P x) ↔ ∀ a b c d e f, P !![a, b, c; d, e, f] :=
(forall_iff _).symm
def Matrix.Exists E1 #
{α : Type u_1} → {m n : ℕ} → (Matrix (Fin m) (Fin n) α → Prop) → Prop
∃ with better defeq for ∃ x : Matrix (Fin m) (Fin n) α, P x.
theorem Matrix.exists_iff E0 #
∀ {α : Type u_1} {m n : ℕ} (P : Matrix (Fin m) (Fin n) α → Prop), Matrix.Exists P ↔ ∃ x, P x
This can be used to prove
example (P : Matrix (Fin 2) (Fin 3) α → Prop) :
(∃ x, P x) ↔ ∃ a b c d e f, P !![a, b, c; d, e, f] :=
(exists_iff _).symm
def Matrix.transposeᵣ E3 #
{α : Type u_1} → {m n : ℕ} → Matrix (Fin m) (Fin n) α → Matrix (Fin n) (Fin m) α
Matrix.transpose with better defeq for Fin
theorem Matrix.transposeᵣ_eq E0 #
∀ {α : Type u_1} {m n : ℕ} (A : Matrix (Fin m) (Fin n) α), A.transposeᵣ = A.transpose
This can be used to prove
example (a b c d : α) : transpose !![a, b; c, d] = !![a, c; b, d] := (transposeᵣ_eq _).symm
def Matrix.dotProductᵣ E3 #
{α : Type u_1} → [Mul α] → [Add α] → [Zero α] → {m : ℕ} → (Fin m → α) → (Fin m → α) → α
dotProduct with better defeq for Fin
theorem Matrix.dotProductᵣ_eq E0 #
∀ {α : Type u_1} [inst : Mul α] [inst_1 : AddCommMonoid α] {m : ℕ} (a b : Fin m → α), Matrix.dotProductᵣ a b = a ⬝ᵥ b
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
def Matrix.mulᵣ E3 #
{l m n : ℕ} →
{α : Type u_1} →
[Mul α] → [Add α] → [Zero α] → Matrix (Fin l) (Fin m) α → Matrix (Fin m) (Fin n) α → Matrix (Fin l) (Fin n) α
Matrix.mul with better defeq for Fin
theorem Matrix.mulᵣ_eq E0 #
∀ {l m n : ℕ} {α : Type u_1} [inst : Mul α] [inst_1 : AddCommMonoid α] (A : Matrix (Fin l) (Fin m) α)
(B : Matrix (Fin m) (Fin n) α), A.mulᵣ B = A * B
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
def Matrix.mulVecᵣ E3 #
{l m : ℕ} → {α : Type u_1} → [Mul α] → [Add α] → [Zero α] → Matrix (Fin l) (Fin m) α → (Fin m → α) → Fin l → α
Matrix.mulVec with better defeq for Fin
theorem Matrix.mulVecᵣ_eq E0 #
∀ {l m : ℕ} {α : Type u_1} [inst : NonUnitalNonAssocSemiring α] (A : Matrix (Fin l) (Fin m) α) (v : Fin m → α),
A.mulVecᵣ v = A.mulVec v
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
def Matrix.vecMulᵣ E3 #
{l m : ℕ} → {α : Type u_1} → [Mul α] → [Add α] → [Zero α] → (Fin l → α) → Matrix (Fin l) (Fin m) α → Fin m → α
Matrix.vecMul with better defeq for Fin
theorem Matrix.vecMulᵣ_eq E0 #
∀ {l m : ℕ} {α : Type u_1} [inst : NonUnitalNonAssocSemiring α] (v : Fin l → α) (A : Matrix (Fin l) (Fin m) α),
Matrix.vecMulᵣ v A = Matrix.vecMul v A
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
def Matrix.etaExpand E3 #
{α : Type u_1} → {m n : ℕ} → Matrix (Fin m) (Fin n) α → Matrix (Fin m) (Fin n) α
Expand A to !![A 0 0, ...; ..., A m n]
theorem Matrix.etaExpand_eq E0 #
∀ {α : Type u_1} {m n : ℕ} (A : Matrix (Fin m) (Fin n) α), A.etaExpand = A
This can be used to prove
example (A : Matrix (Fin 2) (Fin 2) α) :
A = !![A 0 0, A 0 1;
A 1 0, A 1 1] :=
(etaExpand_eq _).symm