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) gf = 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) gf = 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:Va * 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:Va * (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) gf = 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) gf = 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:Va * ((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:chargesa * (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! 🐙