Imports
/- Copyright (c) 2024 Joseph Tooby-Smith. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Joseph Tooby-Smith -/ module public import Mathlib.Algebra.Module.LinearMap.Defs public import Mathlib.Data.Fintype.BigOperators public import Physlib.Meta.TODO.Basic public import Mathlib.Algebra.Ring.Rat

Linear maps

Some definitions and properties of linear, bilinear, and trilinear maps, along with homogeneous quadratic and cubic equations.

@[expose] public sectionTODO "Replace the definitions of bi-linear maps in `./Mathematics/LinaerMaps` with definitions from Mathlib."

The structure defining a homogeneous quadratic equation.

@[simp] def HomogeneousQuadratic (V : Type) [AddCommMonoid V] [Module ℚ V] : Type := V →ₑ[((fun a => a ^ 2) : ℚ → ℚ)] ℚ

A homogeneous quadratic equation can be treated as a function from V to ℚ.

instance instFun : FunLike (HomogeneousQuadratic V) V ℚ where coe f := f.toFun coe_injective f g h := V:Typeinst✝¹:AddCommMonoid Vinst✝:Module ℚ Vf:HomogeneousQuadratic Vg:HomogeneousQuadratic Vh:(fun f => f.toFun) f = (fun f => f.toFun) g⊢ f = g V:Typeinst✝¹:AddCommMonoid Vinst✝:Module ℚ Vg:HomogeneousQuadratic VtoFun✝:V → ℚmap_smul'✝:∀ (m : ℚ) (x : V), toFun✝ (m • x) = m ^ 2 • toFun✝ xh:(fun f => f.toFun) { toFun := toFun✝, map_smul' := map_smul'✝ } = (fun f => f.toFun) g⊢ { toFun := toFun✝, map_smul' := map_smul'✝ } = g V:Typeinst✝¹:AddCommMonoid Vinst✝:Module ℚ VtoFun✝¹:V → ℚmap_smul'✝¹:∀ (m : ℚ) (x : V), toFun✝ (m • x) = m ^ 2 • toFun✝ xtoFun✝:V → ℚmap_smul'✝:∀ (m : ℚ) (x : V), toFun✝ (m • x) = m ^ 2 • toFun✝ xh:(fun f => f.toFun) { toFun := toFun✝¹, map_smul' := map_smul'✝¹ } = (fun f => f.toFun) { toFun := toFun✝, map_smul' := map_smul'✝ }⊢ { toFun := toFun✝¹, map_smul' := map_smul'✝¹ } = { toFun := toFun✝, map_smul' := map_smul'✝ } All goals completed! 🐙
lemma map_smul (f : HomogeneousQuadratic V) (a : ℚ) (S : V) : f (a • S) = a ^ 2 * f S := f.map_smul' a S

The structure of a symmetric bilinear function.

structure BiLinearSymm (V : Type) [AddCommMonoid V] [Module ℚ V] extends V →ₗ[ℚ] V →ₗ[ℚ] ℚ where swap' : ∀ S T, toFun S T = toFun T S

A symmetric bilinear function.

class IsSymmetric {V : Type} [AddCommMonoid V] [Module ℚ V] (f : V →ₗ[ℚ] V →ₗ[ℚ] ℚ) : Prop where swap : ∀ S T, f S T = f T S

A symmetric bilinear form can be treated as a function from V to V →ₗ[ℚ] ℚ.

instance instFun (V : Type) [AddCommMonoid V] [Module ℚ V] : FunLike (BiLinearSymm V) V (V →ₗ[ℚ] ℚ) where coe f := f.toFun coe_injective f g h := V✝:Typeinst✝³:AddCommMonoid V✝inst✝²:Module ℚ V✝V:Typeinst✝¹:AddCommMonoid Vinst✝:Module ℚ Vf:BiLinearSymm Vg:BiLinearSymm Vh:(fun f => f.toFun) f = (fun f => f.toFun) g⊢ f = g V✝:Typeinst✝³:AddCommMonoid V✝inst✝²:Module ℚ V✝V:Typeinst✝¹:AddCommMonoid Vinst✝:Module ℚ Vg:BiLinearSymm VtoLinearMap✝:V →ₗ[ℚ] V →ₗ[ℚ] ℚswap'✝:∀ (S T : V), (toLinearMap✝.toFun S) T = (toLinearMap✝.toFun T) Sh:(fun f => f.toFun) { toLinearMap := toLinearMap✝, swap' := swap'✝ } = (fun f => f.toFun) g⊢ { toLinearMap := toLinearMap✝, swap' := swap'✝ } = g V✝:Typeinst✝³:AddCommMonoid V✝inst✝²:Module ℚ V✝V:Typeinst✝¹:AddCommMonoid Vinst✝:Module ℚ VtoLinearMap✝¹:V →ₗ[ℚ] V →ₗ[ℚ] ℚswap'✝¹:∀ (S T : V), (toLinearMap✝.toFun S) T = (toLinearMap✝.toFun T) StoLinearMap✝:V →ₗ[ℚ] V →ₗ[ℚ] ℚswap'✝:∀ (S T : V), (toLinearMap✝.toFun S) T = (toLinearMap✝.toFun T) Sh:(fun f => f.toFun) { toLinearMap := toLinearMap✝¹, swap' := swap'✝¹ } = (fun f => f.toFun) { toLinearMap := toLinearMap✝, swap' := swap'✝ }⊢ { toLinearMap := toLinearMap✝¹, swap' := swap'✝¹ } = { toLinearMap := toLinearMap✝, swap' := swap'✝ } All goals completed! 🐙

The construction of a symmetric bilinear map from smul and map_add in the first factor, and swap.

V:Typeinst✝¹:AddCommMonoid Vinst✝:Module ℚ Vf:V × V → ℚmap_smul:∀ (a : ℚ) (S T : V), f (a • S, T) = a * f (S, T)map_add:∀ (S1 S2 T : V), f (S1 + S2, T) = f (S1, T) + f (S2, T)swap:∀ (S T : V), f (S, T) = f (T, S)S:Va:ℚT:V⊢ a * f (T, S) = a * f (S, T) All goals completed! 🐙 } map_smul' := fun a S => LinearMap.ext fun T => map_smul a S T map_add' := fun S1 S2 => LinearMap.ext fun T => map_add S1 S2 T swap' := swap
V:Typeinst✝¹:AddCommMonoid Vinst✝:Module ℚ Vf:BiLinearSymm Va:ℚS:VT:Vh:f (a • S) = a • f S⊢ (f (a • S)) T = a * (f S) T All goals completed! 🐙lemma swap (f : BiLinearSymm V) (S T : V) : f S T = f T S := f.swap' S TAll goals completed! 🐙V:Typeinst✝¹:AddCommMonoid Vinst✝:Module ℚ Vf:BiLinearSymm VS1:VS2:VT:Vh:f (S1 + S2) = f S1 + f S2⊢ (f (S1 + S2)) T = (f S1) T + (f S2) T All goals completed! 🐙All goals completed! 🐙

Fixing the second input vectors, the resulting linear map.

def toLinear₁ (f : BiLinearSymm V) (T : V) : V →ₗ[ℚ] ℚ where toFun S := f S T map_add' S1 S2 := map_add₁ f S1 S2 T map_smul' a S := V:Typeinst✝¹:AddCommMonoid Vinst✝:Module ℚ Vf:BiLinearSymm VT:Va:ℚS:V⊢ (f (a • S)) T = (RingHom.id ℚ) a • (f S) T All goals completed! 🐙
lemma toLinear₁_apply (f : BiLinearSymm V) (S T : V) : f S T = f.toLinear₁ T S := rfllemma map_sum₁ {n : ℕ} (f : BiLinearSymm V) (S : Fin n → V) (T : V) : f (∑ i, S i) T = ∑ i, f (S i) T := V:Typeinst✝¹:AddCommMonoid Vinst✝:Module ℚ Vn:ℕf:BiLinearSymm VS:Fin n → VT:V⊢ (f (∑ i, S i)) T = ∑ i, (f (S i)) T All goals completed! 🐙lemma map_sum₂ {n : ℕ} (f : BiLinearSymm V) (S : Fin n → V) (T : V) : f T (∑ i, S i) = ∑ i, f T (S i) := map_sum (f T) S Finset.univ

The homogeneous quadratic equation obtainable from a bilinear function.

@[simps!] def toHomogeneousQuad {V : Type} [AddCommMonoid V] [Module ℚ V] (τ : BiLinearSymm V) : HomogeneousQuadratic V where toFun S := τ S S map_smul' a S := V✝:Typeinst✝³:AddCommMonoid V✝inst✝²:Module ℚ V✝V:Typeinst✝¹:AddCommMonoid Vinst✝:Module ℚ Vτ:BiLinearSymm Va:ℚS:V⊢ (τ (a • S)) (a • S) = a ^ 2 • (τ S) S V✝:Typeinst✝³:AddCommMonoid V✝inst✝²:Module ℚ V✝V:Typeinst✝¹:AddCommMonoid Vinst✝:Module ℚ Vτ:BiLinearSymm Va:ℚS:V⊢ a * (a * (τ S) S) = a ^ 2 * (τ S) S All goals completed! 🐙
set_option backward.isDefEq.respectTransparency false in lemma toHomogeneousQuad_add {V : Type} [AddCommMonoid V] [Module ℚ V] (τ : BiLinearSymm V) (S T : V) : τ.toHomogeneousQuad (S + T) = τ.toHomogeneousQuad S + τ.toHomogeneousQuad T + 2 * τ S T := V:Typeinst✝¹:AddCommMonoid Vinst✝:Module ℚ Vτ:BiLinearSymm VS:VT:V⊢ τ.toHomogeneousQuad (S + T) = τ.toHomogeneousQuad S + τ.toHomogeneousQuad T + 2 * (τ S) T V:Typeinst✝¹:AddCommMonoid Vinst✝:Module ℚ Vτ:BiLinearSymm VS:VT:V⊢ (τ S) S + (τ S) T + ((τ S) T + (τ T) T) = (τ S) S + (τ T) T + 2 * (τ S) T All goals completed! 🐙

The structure of a homogeneous cubic equation.

@[simp] def HomogeneousCubic (V : Type) [AddCommMonoid V] [Module ℚ V] : Type := V →ₑ[((fun a => a ^ 3) : ℚ → ℚ)] ℚ

A homogeneous cubic equation can be treated as a function from V to ℚ.

instance instFun : FunLike (HomogeneousCubic V) V ℚ where coe f := f.toFun coe_injective f g h := V:Typeinst✝¹:AddCommMonoid Vinst✝:Module ℚ Vf:HomogeneousCubic Vg:HomogeneousCubic Vh:(fun f => f.toFun) f = (fun f => f.toFun) g⊢ f = g V:Typeinst✝¹:AddCommMonoid Vinst✝:Module ℚ Vg:HomogeneousCubic VtoFun✝:V → ℚmap_smul'✝:∀ (m : ℚ) (x : V), toFun✝ (m • x) = m ^ 3 • toFun✝ xh:(fun f => f.toFun) { toFun := toFun✝, map_smul' := map_smul'✝ } = (fun f => f.toFun) g⊢ { toFun := toFun✝, map_smul' := map_smul'✝ } = g V:Typeinst✝¹:AddCommMonoid Vinst✝:Module ℚ VtoFun✝¹:V → ℚmap_smul'✝¹:∀ (m : ℚ) (x : V), toFun✝ (m • x) = m ^ 3 • toFun✝ xtoFun✝:V → ℚmap_smul'✝:∀ (m : ℚ) (x : V), toFun✝ (m • x) = m ^ 3 • toFun✝ xh:(fun f => f.toFun) { toFun := toFun✝¹, map_smul' := map_smul'✝¹ } = (fun f => f.toFun) { toFun := toFun✝, map_smul' := map_smul'✝ }⊢ { toFun := toFun✝¹, map_smul' := map_smul'✝¹ } = { toFun := toFun✝, map_smul' := map_smul'✝ } All goals completed! 🐙
lemma map_smul (f : HomogeneousCubic V) (a : ℚ) (S : V) : f (a • S) = a ^ 3 * f S := f.map_smul' a S

The structure of a symmetric trilinear function.

structure TriLinearSymm (V : Type) [AddCommMonoid V] [Module ℚ V] extends V →ₗ[ℚ] V →ₗ[ℚ] V →ₗ[ℚ] ℚ where swap₁' : ∀ S T L, toFun S T L = toFun T S L swap₂' : ∀ S T L, toFun S T L = toFun S L T

A symmetric trilinear form can be treated as a function from V to V →ₗ[ℚ] V →ₗ[ℚ] ℚ.

instance instFun : FunLike (TriLinearSymm V) V (V →ₗ[ℚ] V →ₗ[ℚ] ℚ) where coe f := f.toFun coe_injective f g h := V:Typeinst✝¹:AddCommMonoid Vinst✝:Module ℚ Vf:TriLinearSymm Vg:TriLinearSymm Vh:(fun f => f.toFun) f = (fun f => f.toFun) g⊢ f = g V:Typeinst✝¹:AddCommMonoid Vinst✝:Module ℚ Vg:TriLinearSymm VtoLinearMap✝:V →ₗ[ℚ] V →ₗ[ℚ] V →ₗ[ℚ] ℚswap₁'✝:∀ (S T L : V), ((toLinearMap✝.toFun S) T) L = ((toLinearMap✝.toFun T) S) Lswap₂'✝:∀ (S T L : V), ((toLinearMap✝.toFun S) T) L = ((toLinearMap✝.toFun S) L) Th:(fun f => f.toFun) { toLinearMap := toLinearMap✝, swap₁' := swap₁'✝, swap₂' := swap₂'✝ } = (fun f => f.toFun) g⊢ { toLinearMap := toLinearMap✝, swap₁' := swap₁'✝, swap₂' := swap₂'✝ } = g V:Typeinst✝¹:AddCommMonoid Vinst✝:Module ℚ VtoLinearMap✝¹:V →ₗ[ℚ] V →ₗ[ℚ] V →ₗ[ℚ] ℚswap₁'✝¹:∀ (S T L : V), ((toLinearMap✝.toFun S) T) L = ((toLinearMap✝.toFun T) S) Lswap₂'✝¹:∀ (S T L : V), ((toLinearMap✝.toFun S) T) L = ((toLinearMap✝.toFun S) L) TtoLinearMap✝:V →ₗ[ℚ] V →ₗ[ℚ] V →ₗ[ℚ] ℚswap₁'✝:∀ (S T L : V), ((toLinearMap✝.toFun S) T) L = ((toLinearMap✝.toFun T) S) Lswap₂'✝:∀ (S T L : V), ((toLinearMap✝.toFun S) T) L = ((toLinearMap✝.toFun S) L) Th:(fun f => f.toFun) { toLinearMap := toLinearMap✝¹, swap₁' := swap₁'✝¹, swap₂' := swap₂'✝¹ } = (fun f => f.toFun) { toLinearMap := toLinearMap✝, swap₁' := swap₁'✝, swap₂' := swap₂'✝ }⊢ { toLinearMap := toLinearMap✝¹, swap₁' := swap₁'✝¹, swap₂' := swap₂'✝¹ } = { toLinearMap := toLinearMap✝, swap₁' := swap₁'✝, swap₂' := swap₂'✝ } All goals completed! 🐙

The construction of a symmetric trilinear map from smul and map_add in the first factor, and two swap.

All goals completed! 🐙) (V:Typeinst✝¹:AddCommMonoid Vinst✝:Module ℚ Vf:V × V × V → ℚmap_smul:∀ (a : ℚ) (S T L : V), f (a • S, T, L) = a * f (S, T, L)map_add:∀ (S1 S2 T L : V), f (S1 + S2, T, L) = f (S1, T, L) + f (S2, T, L)swap₁:∀ (S T L : V), f (S, T, L) = f (T, S, L)swap₂:∀ (S T L : V), f (S, T, L) = f (S, L, T)S:V⊢ ∀ (S_1 T : V), f (S, S_1, T) = f (S, T, S_1) All goals completed! 🐙)).toLinearMap map_add' S1 S2 := LinearMap.ext fun T ↦ LinearMap.ext fun L => map_add S1 S2 T L map_smul' a S := LinearMap.ext fun T => LinearMap.ext fun L => map_smul a S T L swap₁' := swap₁ swap₂' := swap₂
lemma swap₁ (f : TriLinearSymm V) (S T L : V) : f S T L = f T S L := f.swap₁' S T Llemma swap₂ (f : TriLinearSymm V) (S T L : V) : f S T L = f S L T := f.swap₂' S T LAll goals completed! 🐙V:Typeinst✝¹:AddCommMonoid Vinst✝:Module ℚ Vf:TriLinearSymm Va:ℚS:VT:VL:Vh:f (a • S) = a • f S⊢ ((f (a • S)) T) L = a * ((f S) T) L All goals completed! 🐙All goals completed! 🐙All goals completed! 🐙V:Typeinst✝¹:AddCommMonoid Vinst✝:Module ℚ Vf:TriLinearSymm VS1:VS2:VT:VL:Vh:f (S1 + S2) = f S1 + f S2⊢ ((f (S1 + S2)) T) L = ((f S1) T) L + ((f S2) T) L All goals completed! 🐙All goals completed! 🐙All goals completed! 🐙

Fixing the second and third input vectors, the resulting linear map.

def toLinear₁ (f : TriLinearSymm V) (T L : V) : V →ₗ[ℚ] ℚ where toFun S := f S T L map_add' S1 S2 := map_add₁ f S1 S2 T L map_smul' a S := V:Typeinst✝¹:AddCommMonoid Vinst✝:Module ℚ Vf:TriLinearSymm VT:VL:Va:ℚS:V⊢ ((f (a • S)) T) L = (RingHom.id ℚ) a • ((f S) T) L V:Typeinst✝¹:AddCommMonoid Vinst✝:Module ℚ Vf:TriLinearSymm VT:VL:Va:ℚS:V⊢ a * ((f S) T) L = (RingHom.id ℚ) a • ((f S) T) L All goals completed! 🐙
lemma toLinear₁_apply (f : TriLinearSymm V) (S T L : V) : f S T L = f.toLinear₁ T L S := rflV:Typeinst✝¹:AddCommMonoid Vinst✝:Module ℚ Vn:ℕf:TriLinearSymm VS:Fin n → VT:VL:V⊢ ∑ x, (f.toLinear₁ T L) (S x) = ∑ i, ((f (S i)) T) L All goals completed! 🐙V:Typeinst✝¹:AddCommMonoid Vinst✝:Module ℚ Vn:ℕf:TriLinearSymm VS:Fin n → VT:VL:V⊢ ∑ i, ((f (S i)) T) L = ∑ i, ((f T) (S i)) L All goals completed! 🐙lemma map_sum₃ {n : ℕ} (f : TriLinearSymm V) (S : Fin n → V) (T : V) (L : V) : f T L (∑ i, S i) = ∑ i, f T L (S i) := map_sum ((f T) L) S Finset.univV:Typeinst✝¹:AddCommMonoid Vinst✝:Module ℚ Vn1:ℕn2:ℕn3:ℕf:TriLinearSymm VS:Fin n1 → VT:Fin n2 → VL:Fin n3 → Vx✝:Fin n1⊢ ∑ i, ((f (S x✝)) (T i)) (∑ i, L i) = ∑ k, ∑ l, ((f (S x✝)) (T k)) (L l) All goals completed! 🐙

The homogeneous cubic equation obtainable from a symmetric trilinear function.

V:Typeinst✝³:AddCommMonoid Vinst✝²:Module ℚ Vcharges:Typeinst✝¹:AddCommMonoid chargesinst✝:Module ℚ chargesτ:TriLinearSymm chargesa:ℚS:charges⊢ a * (a * (a * ((τ S) S) S)) = a ^ 3 * ((τ S) S) S All goals completed! 🐙
charges:Typeinst✝¹:AddCommMonoid chargesinst✝:Module ℚ chargesτ:TriLinearSymm chargesS:chargesT:charges⊢ ((τ S) S) S + ((τ S) S) T + (((τ S) S) T + ((τ T) T) S) + (((τ S) S) T + ((τ T) T) S + (((τ T) T) S + ((τ T) T) T)) = ((τ S) S) S + ((τ T) T) T + 3 * ((τ S) S) T + 3 * ((τ T) T) S All goals completed! 🐙