Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - refactor(LinearAlgebra/QuadraticForm/Basic) : Generalise QuadraticForm to QuadraticMap #7569

Closed
wants to merge 141 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
141 commits
Select commit Hold shift + click to select a range
22eff29
WIP on Quadratic Maps
mans0954 Oct 5, 2023
08e698a
More
mans0954 Oct 5, 2023
9c113e8
More
mans0954 Oct 5, 2023
f6a70e1
Weaken hypothesis
mans0954 Oct 5, 2023
e069e48
Don't need extra import
mans0954 Oct 6, 2023
5e4ad04
Don't need SMulCommClass condition on R₂
mans0954 Oct 6, 2023
c3d358e
Merge branch 'master' into mans0954/Bilinear-SMulCommClass
mans0954 Oct 6, 2023
635619b
Merge branch 'mans0954/Bilinear-SMulCommClass' into mans0954/quadrati…
mans0954 Oct 6, 2023
81cb2b3
Add more SMulCommClass
mans0954 Oct 8, 2023
8d4ca5d
Remove changes to BilinearMap
mans0954 Oct 8, 2023
ad25eb1
Remove some noise
mans0954 Oct 8, 2023
3effb8e
Lint
mans0954 Oct 8, 2023
60be27f
Resync to master
mans0954 Oct 9, 2023
e59f746
Merge branch 'master' into mans0954/quadratic-maps
mans0954 Oct 9, 2023
e404bdc
Get us back to where we were
mans0954 Oct 9, 2023
2c611ce
WiP
mans0954 Oct 9, 2023
51d2ef1
Merge branch 'master' into mans0954/quadratic-maps
mans0954 Oct 26, 2023
bc1b52e
WIP
mans0954 Oct 26, 2023
ab540ab
Missed this earlier
mans0954 Oct 26, 2023
ef3c9cb
Progress
mans0954 Oct 26, 2023
d9e5e81
Lint
mans0954 Oct 26, 2023
b592bf3
QuadraticForm.polarBilin_injective
mans0954 Oct 26, 2023
a7e111e
Progress
mans0954 Oct 26, 2023
0d8a49c
Lint
mans0954 Oct 26, 2023
313469d
WIP
mans0954 Oct 27, 2023
0809e18
WiP
mans0954 Oct 27, 2023
d5da8b1
WiP
mans0954 Oct 27, 2023
adf9969
PosDef
mans0954 Oct 29, 2023
bd36143
Notes on matrices
mans0954 Oct 30, 2023
51e37b4
Merge branch 'master' into mans0954/quadratic-maps
mans0954 Oct 30, 2023
6323478
Merge branch 'master' into mans0954/quadratic-maps
mans0954 Nov 19, 2023
3f12e8e
Merge branch 'master' into mans0954/quadratic-maps
mans0954 Dec 4, 2023
93c24f1
Merge branch 'master' into mans0954/quadratic-maps
mans0954 Dec 4, 2023
653079d
Merge branch 'master' into mans0954/quadratic-maps
mans0954 Dec 23, 2023
dabc47b
Merge branch 'master' into mans0954/quadratic-maps
mans0954 Jan 5, 2024
d986a30
Merge branch 'master' into mans0954/quadratic-maps
mans0954 Jan 23, 2024
3839265
Fix
mans0954 Jan 23, 2024
ef09743
IsOrtho/CommSemiring
mans0954 Jan 23, 2024
b3ecfd6
AssociatedHom
mans0954 Jan 23, 2024
66d29d1
Associated
mans0954 Jan 24, 2024
b9faabb
Merge branch 'master' into mans0954/quadratic-maps
mans0954 Jan 27, 2024
e9b7360
Remove duplicate invOf_smul_eq_iff
mans0954 Jan 27, 2024
26f97ea
Merge branch 'master' into mans0954/quadratic-maps
mans0954 Mar 29, 2024
ace1123
Replace add_sub_cancel'
mans0954 Apr 4, 2024
969a79e
Tidy
mans0954 Apr 4, 2024
172e9c6
Make more use of BilinMap
mans0954 Apr 4, 2024
12059c0
Tidy
mans0954 Apr 4, 2024
76d42ba
Fix
mans0954 Apr 4, 2024
1c93859
Merge branch 'master' into mans0954/quadratic-maps
mans0954 Apr 4, 2024
a640495
BilinMap and BilinForm
mans0954 Apr 4, 2024
54ce9b4
Rename QuadraticForm to QuadraticMap
mans0954 Apr 4, 2024
37f4d06
Fix up the rest of Mathlib
mans0954 Apr 4, 2024
d0b7e63
Fix counter example
mans0954 Apr 4, 2024
80626e0
Fix counter example
mans0954 Apr 4, 2024
2560494
Add docstring
mans0954 Apr 4, 2024
1faf61f
No Doc
mans0954 Apr 4, 2024
9e417dd
remove unused arg
mans0954 Apr 4, 2024
571492d
Merge branch 'master' into mans0954/quadratic-maps
mans0954 Apr 4, 2024
63145ac
Remove check
mans0954 Apr 5, 2024
446ff4d
Merge branch 'master' into mans0954/quadratic-maps
mans0954 Apr 5, 2024
b4d324d
Update yaml
mans0954 Apr 5, 2024
e6c4b2a
Update docstrings
mans0954 Apr 5, 2024
64b088e
Tidy
mans0954 Apr 5, 2024
05c60f2
Update Mathlib/LinearAlgebra/QuadraticForm/Basic.lean
mans0954 Apr 9, 2024
d42d592
Update Mathlib/LinearAlgebra/QuadraticForm/Basic.lean
mans0954 Apr 9, 2024
2c356d3
Update Mathlib/LinearAlgebra/QuadraticForm/Basic.lean
mans0954 Apr 9, 2024
5b613f5
Update Mathlib/LinearAlgebra/QuadraticForm/Basic.lean
mans0954 Apr 9, 2024
5228893
Update Mathlib/LinearAlgebra/QuadraticForm/Basic.lean
mans0954 Apr 9, 2024
0526c72
Update Mathlib/LinearAlgebra/QuadraticForm/Basic.lean
mans0954 Apr 9, 2024
ff74bfc
Update Mathlib/LinearAlgebra/QuadraticForm/Basic.lean
mans0954 Apr 9, 2024
bdc3564
Update Mathlib/LinearAlgebra/QuadraticForm/Basic.lean
mans0954 Apr 9, 2024
af7f32b
Update Mathlib/LinearAlgebra/QuadraticForm/Basic.lean
mans0954 Apr 9, 2024
e525e23
Update Mathlib/LinearAlgebra/QuadraticForm/Basic.lean
mans0954 Apr 9, 2024
29b71bb
Fix
mans0954 Apr 9, 2024
0144093
map_add_self
mans0954 Apr 9, 2024
17bc77c
Merge branch 'master' into mans0954/quadratic-maps
mans0954 Apr 9, 2024
f48dcc2
Merge branch 'master' into mans0954/quadratic-maps
mans0954 Apr 14, 2024
e9b0cc1
Update Mathlib/LinearAlgebra/BilinearMap.lean
mans0954 Apr 14, 2024
aad903b
PosDef for Quadratic Maps
mans0954 Apr 19, 2024
55a472e
Convert linMulLin to Quadratic Maps
mans0954 Apr 19, 2024
3f1e782
Make linMulLinSelfPosDef work for maps
mans0954 Apr 19, 2024
6df6e28
Ready for non-assoc
mans0954 Apr 20, 2024
5f7efa3
Lint
mans0954 Apr 26, 2024
d2799ae
Merge branch 'master' into mans0954/quadratic-maps
mans0954 Apr 26, 2024
9805ded
fix after merge
mans0954 Apr 28, 2024
2beed79
Add toNonUnitalNonAssocCommSemiring instance
mans0954 Apr 28, 2024
475f67b
Revert "Add toNonUnitalNonAssocCommSemiring instance"
mans0954 Apr 28, 2024
92406c6
Add CommSemiring.toNonUnitalNonAssocCommSemiring to the wrong place
mans0954 Apr 28, 2024
63b3270
Rename N' to M'
mans0954 Apr 28, 2024
0e37c06
Split compQuadraticMap into a composition
mans0954 Apr 28, 2024
cff4d4e
Remove variable
mans0954 Apr 28, 2024
352cdd8
Merge branch 'master' into mans0954/quadratic-maps
mans0954 May 2, 2024
ddae0dd
Use A in NonUnitalNonAssocCommSemiring
mans0954 May 3, 2024
f45042a
Fix
mans0954 May 3, 2024
6234f0c
Use A in linMulLinSelfPosDef as well
mans0954 May 3, 2024
2181220
Merge branch 'master' into mans0954/quadratic-maps
mans0954 May 4, 2024
7f5e47e
Merge branch 'master' into mans0954/quadratic-maps
mans0954 May 7, 2024
ae01d41
Fix
mans0954 May 7, 2024
35cd288
Merge branch 'master' into mans0954/quadratic-maps
mans0954 May 19, 2024
b230323
Fix
mans0954 May 19, 2024
fba9c62
Merge branch 'master' into mans0954/quadratic-maps
mans0954 May 22, 2024
16c96a6
Merge branch 'master' into mans0954/quadratic-maps
mans0954 May 25, 2024
b82e978
Merge branch 'master' into mans0954/quadratic-maps
mans0954 Jun 1, 2024
63cce90
Merge branch 'master' into mans0954/quadratic-maps
mans0954 Jun 6, 2024
6bb68b8
Remove dup
mans0954 Jun 6, 2024
a4ba875
Merge branch 'master' into mans0954/quadratic-maps
mans0954 Jun 7, 2024
18f1e3e
Fix
mans0954 Jun 7, 2024
6955ed5
Fix
mans0954 Jun 7, 2024
e10cf6d
Merge branch 'master' into mans0954/quadratic-maps
mans0954 Jul 2, 2024
411786f
Merge branch 'master' into mans0954/quadratic-maps
eric-wieser Jul 10, 2024
69296c6
chore: protect `QuadraticForm.map_zero`
eric-wieser Jul 10, 2024
4aa7ee0
Merge branch 'eric-wieser/quadraticform-map_zero' into mans0954/quadr…
eric-wieser Jul 11, 2024
5605771
remove _root_
eric-wieser Jul 11, 2024
3e88792
prune typeclasses
eric-wieser Jul 11, 2024
3c60a70
unused arguments
eric-wieser Jul 11, 2024
6027e18
Merge remote-tracking branch 'origin/master' into mans0954/quadratic-…
eric-wieser Jul 11, 2024
9b9ccc1
Get it building
mans0954 Jul 11, 2024
d45b144
Rename compQuadraticMap to compQuadraticMap'
mans0954 Jul 11, 2024
6a8e48f
rename compQuadraticMapAux to compQuadraticMap
mans0954 Jul 11, 2024
d025c1c
Restrict linMulLin to unital assoc case for now
mans0954 Jul 11, 2024
255b66f
Merge branch 'master' into mans0954/quadratic-maps
mans0954 Jul 12, 2024
18f9235
reduce diff
eric-wieser Jul 12, 2024
8aa26b3
tidy variables
eric-wieser Jul 13, 2024
6830b5f
commutativity not needed
eric-wieser Jul 13, 2024
6e3c99b
drop commutativity one more time
eric-wieser Jul 13, 2024
102aa6b
heartbeat limit not needed
eric-wieser Jul 13, 2024
d6e19c6
Optimistically remove `set_option synthInstance.maxHeartbeats 7000 in`
eric-wieser Jul 13, 2024
2410793
Merge remote-tracking branch 'origin/master' into mans0954/quadratic-…
eric-wieser Jul 13, 2024
3113a24
Update Mathlib/LinearAlgebra/BilinearMap.lean
mans0954 Jul 13, 2024
0d8e1bc
Update Mathlib/LinearAlgebra/QuadraticForm/Basic.lean
mans0954 Jul 13, 2024
4df84ce
Update Mathlib/LinearAlgebra/QuadraticForm/Basic.lean
mans0954 Jul 13, 2024
ffc3c1d
Update Mathlib/LinearAlgebra/QuadraticForm/Basic.lean
mans0954 Jul 13, 2024
2afbdd0
Update Mathlib/LinearAlgebra/QuadraticForm/Basic.lean
mans0954 Jul 13, 2024
6835243
Update Mathlib/LinearAlgebra/QuadraticForm/Basic.lean
mans0954 Jul 13, 2024
4b97ea0
Update Mathlib/LinearAlgebra/QuadraticForm/Basic.lean
mans0954 Jul 13, 2024
7857382
Update Mathlib/LinearAlgebra/QuadraticForm/Basic.lean
mans0954 Jul 13, 2024
3c714d3
Update Mathlib/LinearAlgebra/QuadraticForm/Basic.lean
mans0954 Jul 13, 2024
3774529
Update Mathlib/LinearAlgebra/QuadraticForm/Basic.lean
mans0954 Jul 13, 2024
7e879da
Update Mathlib/LinearAlgebra/QuadraticForm/Basic.lean
mans0954 Jul 13, 2024
9b5284b
Explain what N is
mans0954 Jul 13, 2024
2532a7b
Merge branch 'master' into mans0954/quadratic-maps
mans0954 Jul 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions Counterexamples/CliffordAlgebraNotInjective.lean
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ are quadratic forms that cannot be expressed via even non-symmetric bilinear for
noncomputable section

open LinearMap (BilinForm)
open LinearMap (BilinMap)

namespace Q60596

Expand Down Expand Up @@ -149,7 +150,7 @@ abbrev L : Type _ := _ ⧸ LinearMap.ker lFunc

/-- The quadratic form corresponding to squaring a single coefficient. -/
def sq {ι R : Type*} [CommRing R] (i : ι) : QuadraticForm R (ι → R) :=
QuadraticForm.sq.comp <| LinearMap.proj i
QuadraticMap.sq.comp <| LinearMap.proj i

theorem sq_map_add_char_two {ι R : Type*} [CommRing R] [CharP R 2] (i : ι) (a b : ι → R) :
sq i (a + b) = sq i a + sq i b :=
Expand All @@ -165,10 +166,10 @@ def Q' : QuadraticForm K (Fin 3 → K) :=
∑ i, sq i

theorem Q'_add (x y : Fin 3 → K) : Q' (x + y) = Q' x + Q' y := by
simp only [Q', QuadraticForm.sum_apply, sq_map_add_char_two, Finset.sum_add_distrib]
simp only [Q', QuadraticMap.sum_apply, sq_map_add_char_two, Finset.sum_add_distrib]

theorem Q'_sub (x y : Fin 3 → K) : Q' (x - y) = Q' x - Q' y := by
simp only [Q', QuadraticForm.sum_apply, sq_map_sub_char_two, Finset.sum_sub_distrib]
simp only [Q', QuadraticMap.sum_apply, sq_map_sub_char_two, Finset.sum_sub_distrib]

theorem Q'_apply (a : Fin 3 → K) : Q' a = a 0 * a 0 + a 1 * a 1 + a 2 * a 2 :=
calc
Expand Down Expand Up @@ -204,7 +205,7 @@ theorem Q'_zero_under_ideal (v : Fin 3 → K) (hv : v ∈ LinearMap.ker lFunc) :
/-- `Q'`, lifted to operate on the quotient space `L`. -/
@[simps!]
def Q : QuadraticForm K L :=
QuadraticForm.ofPolar
QuadraticMap.ofPolar
(fun x =>
Quotient.liftOn' x Q' fun a b h => by
rw [Submodule.quotientRel_r_def] at h
Expand Down Expand Up @@ -263,7 +264,7 @@ theorem algebraMap_not_injective : ¬Function.Injective (algebraMap K <| Cliffor
fun h => αβγ_ne_zero <| h <| by rw [algebraMap_αβγ_eq_zero, RingHom.map_zero]

/-- Bonus counterexample: `Q` is a quadratic form that has no bilinear form. -/
theorem Q_not_in_range_toQuadraticForm : Q ∉ Set.range BilinForm.toQuadraticForm := by
theorem Q_not_in_range_toQuadraticForm : Q ∉ Set.range BilinMap.toQuadraticMap := by
rintro ⟨B, hB⟩
rw [← sub_zero Q] at hB
apply algebraMap_not_injective
Expand Down Expand Up @@ -294,10 +295,10 @@ open Q60596 in
theorem QuadraticForm.not_forall_mem_range_toQuadraticForm.{v} :
-- TODO: make `R` universe polymorphic
¬∀ (R : Type) (M : Type v) [CommRing R] [AddCommGroup M] [Module R M] (Q : QuadraticForm R M),
Q ∈ Set.range BilinForm.toQuadraticForm :=
Q ∈ Set.range BilinMap.toQuadraticMap :=
fun h => Q_not_in_range_toQuadraticForm <| by
let uU := ULift.moduleEquiv (R := K) (M := L)
obtain ⟨x, hx⟩ := h K (ULift L) (Q.comp uU)
refine ⟨x.compl₁₂ uU.symm uU.symm, ?_⟩
ext
simp [BilinForm.toQuadraticForm_comp_same, hx]
simp [BilinMap.toQuadraticMap_comp_same, hx]
5 changes: 3 additions & 2 deletions Counterexamples/QuadraticForm.lean
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ variable (F : Type*) [Nontrivial F] [CommRing F] [CharP F 2]
open LinearMap
open LinearMap.BilinForm
open LinearMap (BilinForm)
open LinearMap.BilinMap

namespace Counterexample

Expand Down Expand Up @@ -53,12 +54,12 @@ This disproves a weaker version of `QuadraticForm.associated_left_inverse`.
-/
theorem LinearMap.BilinForm.not_injOn_toQuadraticForm_isSymm.{u} :
¬∀ {R M : Type u} [CommSemiring R] [AddCommMonoid M], ∀ [Module R M],
Set.InjOn (toQuadraticForm : BilinForm R M → QuadraticForm R M) {B | B.IsSymm} := by
Set.InjOn (toQuadraticMap : BilinForm R M → QuadraticForm R M) {B | B.IsSymm} := by
intro h
let F := ULift.{u} (ZMod 2)
apply B_ne_zero F
apply h (isSymm_B F) isSymm_zero
rw [toQuadraticForm_zero, toQuadraticForm_eq_zero]
rw [toQuadraticMap_zero, toQuadraticMap_eq_zero]
exact isAlt_B F
#align counterexample.bilin_form.not_inj_on_to_quadratic_form_is_symm Counterexample.LinearMap.BilinForm.not_injOn_toQuadraticForm_isSymm

Expand Down
29 changes: 15 additions & 14 deletions Mathlib/LinearAlgebra/BilinearForm/TensorProduct.lean
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import Mathlib.LinearAlgebra.TensorProduct.Tower
## Main definitions
* `LinearMap.BilinForm.tensorDistrib (B₁ ⊗ₜ B₂)`: the bilinear form on `M₁ ⊗ M₂` constructed by
* `LinearMap.BilinMap.tensorDistrib (B₁ ⊗ₜ B₂)`: the bilinear form on `M₁ ⊗ M₂` constructed by
applying `B₁` on `M₁` and `B₂` on `M₂`.
* `LinearMap.BilinForm.tensorDistribEquiv`: `BilinForm.tensorDistrib` as an equivalence on finite
* `LinearMap.BilinMap.tensorDistribEquiv`: `BilinForm.tensorDistrib` as an equivalence on finite
free modules.
-/
Expand All @@ -30,8 +30,9 @@ open TensorProduct

namespace LinearMap

namespace BilinForm
namespace BilinMap

open LinearMap (BilinMap)
open LinearMap (BilinForm)

section CommSemiring
Expand All @@ -53,7 +54,7 @@ def tensorDistrib : BilinForm A M₁ ⊗[R] BilinForm R M₂ →ₗ[A] BilinForm
∘ₗ (TensorProduct.AlgebraTensorModule.congr
(TensorProduct.lift.equiv A M₁ M₁ A)
(TensorProduct.lift.equiv R _ _ _)).toLinearMap
#align bilin_form.tensor_distrib LinearMap.BilinForm.tensorDistrib
#align bilin_form.tensor_distrib LinearMap.BilinMap.tensorDistrib

-- TODO: make the RHS `MulOpposite.op (B₂ m₂ m₂') • B₁ m₁ m₁'` so that this has a nicer defeq for
-- `R = A` of `B₁ m₁ m₁' * B₂ m₂ m₂'`, as it did before the generalization in #6306.
Expand All @@ -63,28 +64,28 @@ theorem tensorDistrib_tmul (B₁ : BilinForm A M₁) (B₂ : BilinForm R M₂) (
tensorDistrib R A (B₁ ⊗ₜ B₂) (m₁ ⊗ₜ m₂) (m₁' ⊗ₜ m₂')
= B₂ m₂ m₂' • B₁ m₁ m₁' :=
rfl
#align bilin_form.tensor_distrib_tmul LinearMap.BilinForm.tensorDistrib_tmulₓ
#align bilin_form.tensor_distrib_tmul LinearMap.BilinMap.tensorDistrib_tmulₓ

/-- The tensor product of two bilinear forms, a shorthand for dot notation. -/
protected abbrev tmul (B₁ : BilinForm A M₁) (B₂ : BilinForm R M₂) : BilinForm A (M₁ ⊗[R] M₂) :=
protected abbrev tmul (B₁ : BilinMap A M₁ A) (B₂ : BilinMap R M₂ R) : BilinMap A (M₁ ⊗[R] M₂) A :=
tensorDistrib R A (B₁ ⊗ₜ[R] B₂)
#align bilin_form.tmul LinearMap.BilinForm.tmul
#align bilin_form.tmul LinearMap.BilinMap.tmul

attribute [local ext] TensorProduct.ext in
/-- A tensor product of symmetric bilinear forms is symmetric. -/
lemma _root_.LinearMap.IsSymm.tmul {B₁ : BilinForm A M₁} {B₂ : BilinForm R M₂}
lemma _root_.LinearMap.IsSymm.tmul {B₁ : BilinMap A M₁ A} {B₂ : BilinMap R M₂ R}
(hB₁ : B₁.IsSymm) (hB₂ : B₂.IsSymm) : (B₁.tmul B₂).IsSymm := by
rw [LinearMap.isSymm_iff_eq_flip]
ext x₁ x₂ y₁ y₂
exact congr_arg₂ (HSMul.hSMul) (hB₂ x₂ y₂) (hB₁ x₁ y₁)

variable (A) in
/-- The base change of a bilinear form. -/
protected def baseChange (B : BilinForm R M₂) : BilinForm A (A ⊗[R] M₂) :=
BilinForm.tmul (R := R) (A := A) (M₁ := A) (M₂ := M₂) (LinearMap.mul A A) B
protected def baseChange (B : BilinMap R M₂ R) : BilinForm A (A ⊗[R] M₂) :=
BilinMap.tmul (R := R) (A := A) (M₁ := A) (M₂ := M₂) (LinearMap.mul A A) B

@[simp]
theorem baseChange_tmul (B₂ : BilinForm R M₂) (a : A) (m₂ : M₂)
theorem baseChange_tmul (B₂ : BilinMap R M₂ R) (a : A) (m₂ : M₂)
(a' : A) (m₂' : M₂) :
B₂.baseChange A (a ⊗ₜ m₂) (a' ⊗ₜ m₂') = (B₂ m₂ m₂') • (a * a') :=
rfl
Expand Down Expand Up @@ -115,7 +116,7 @@ noncomputable def tensorDistribEquiv :
TensorProduct.dualDistribEquiv R (M₁ ⊗ M₁) (M₂ ⊗ M₂) ≪≫ₗ
(TensorProduct.tensorTensorTensorComm R _ _ _ _).dualMap ≪≫ₗ
(TensorProduct.lift.equiv R _ _ _).symm
#align bilin_form.tensor_distrib_equiv LinearMap.BilinForm.tensorDistribEquiv
#align bilin_form.tensor_distrib_equiv LinearMap.BilinMap.tensorDistribEquiv

@[simp]
theorem tensorDistribEquiv_tmul (B₁ : BilinForm R M₁) (B₂ : BilinForm R M₂) (m₁ : M₁) (m₂ : M₂)
Expand All @@ -137,10 +138,10 @@ theorem tensorDistribEquiv_toLinearMap :
theorem tensorDistribEquiv_apply (B : BilinForm R M₁ ⊗ BilinForm R M₂) :
tensorDistribEquiv R (M₁ := M₁) (M₂ := M₂) B = tensorDistrib R R B :=
DFunLike.congr_fun (tensorDistribEquiv_toLinearMap R M₁ M₂) B
#align bilin_form.tensor_distrib_equiv_apply LinearMap.BilinForm.tensorDistribEquiv_apply
#align bilin_form.tensor_distrib_equiv_apply LinearMap.BilinMap.tensorDistribEquiv_apply

end CommRing

end BilinForm
end BilinMap

end LinearMap
11 changes: 8 additions & 3 deletions Mathlib/LinearAlgebra/BilinearMap.lean
Original file line number Diff line number Diff line change
Expand Up @@ -393,9 +393,6 @@ theorem compr₂_apply (f : M →ₗ[R] Nₗ →ₗ[R] Pₗ) (g : Pₗ →ₗ[R]

variable (R M)

/-- For convenience, a shorthand for the type of bilinear forms from `M` to `R`. -/
protected abbrev BilinForm : Type _ := M →ₗ[R] M →ₗ[R] R

/-- Scalar multiplication as a bilinear map `R → M → M`. -/
def lsmul : R →ₗ[R] M →ₗ[R] M :=
mk₂ R (· • ·) add_smul (fun _ _ _ => mul_smul _ _ _) smul_add fun r s m => by
Expand All @@ -413,6 +410,14 @@ variable {M}
theorem lsmul_apply (r : R) (m : M) : lsmul R M r m = r • m := rfl
#align linear_map.lsmul_apply LinearMap.lsmul_apply

variable (R M Nₗ) in
/-- A shorthand for the type of `R`-bilinear `Nₗ`-valued maps on `M`. -/
protected abbrev BilinMap : Type _ := M →ₗ[R] M →ₗ[R] Nₗ

variable (R M) in
/-- For convenience, a shorthand for the type of bilinear forms from `M` to `R`. -/
protected abbrev BilinForm : Type _ := LinearMap.BilinMap R M R

end CommSemiring

section CommRing
Expand Down
6 changes: 3 additions & 3 deletions Mathlib/LinearAlgebra/CliffordAlgebra/BaseChange.lean
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ noncomputable def toBaseChange (Q : QuadraticForm R V) :
letI : Invertible (2 : A ⊗[R] CliffordAlgebra Q) :=
(Invertible.map (algebraMap R _) 2).copy 2 (map_ofNat _ _).symm
suffices hpure_tensor : ∀ v w, (1 * 1) ⊗ₜ[R] (ι Q v * ι Q w) + (1 * 1) ⊗ₜ[R] (ι Q w * ι Q v) =
QuadraticForm.polarBilin (Q.baseChange A) (1 ⊗ₜ[R] v) (1 ⊗ₜ[R] w) ⊗ₜ[R] 1 by
QuadraticMap.polarBilin (Q.baseChange A) (1 ⊗ₜ[R] v) (1 ⊗ₜ[R] w) ⊗ₜ[R] 1 by
-- the crux is that by converting to a statement about linear maps instead of quadratic forms,
-- we then have access to all the partially-applied `ext` lemmas.
rw [CliffordAlgebra.forall_mul_self_eq_iff (isUnit_of_invertible _)]
Expand All @@ -95,8 +95,8 @@ noncomputable def toBaseChange (Q : QuadraticForm R V) :
exact hpure_tensor v w
intros v w
rw [← TensorProduct.tmul_add, CliffordAlgebra.ι_mul_ι_add_swap,
QuadraticForm.polarBilin_baseChange, LinearMap.BilinForm.baseChange_tmul, one_mul,
TensorProduct.smul_tmul, Algebra.algebraMap_eq_smul_one, QuadraticForm.polarBilin_apply_apply]
QuadraticForm.polarBilin_baseChange, LinearMap.BilinMap.baseChange_tmul, one_mul,
TensorProduct.smul_tmul, Algebra.algebraMap_eq_smul_one, QuadraticMap.polarBilin_apply_apply]

@[simp] theorem toBaseChange_ι (Q : QuadraticForm R V) (z : A) (v : V) :
toBaseChange A Q (ι (Q.baseChange A) (z ⊗ₜ v)) = z ⊗ₜ ι Q v :=
Expand Down
14 changes: 7 additions & 7 deletions Mathlib/LinearAlgebra/CliffordAlgebra/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -235,14 +235,14 @@ theorem induction {C : CliffordAlgebra Q → Prop}

theorem mul_add_swap_eq_polar_of_forall_mul_self_eq {A : Type*} [Ring A] [Algebra R A]
(f : M →ₗ[R] A) (hf : ∀ x, f x * f x = algebraMap _ _ (Q x)) (a b : M) :
f a * f b + f b * f a = algebraMap R _ (QuadraticForm.polar Q a b) :=
f a * f b + f b * f a = algebraMap R _ (QuadraticMap.polar Q a b) :=
calc
f a * f b + f b * f a = f (a + b) * f (a + b) - f a * f a - f b * f b := by
rw [f.map_add, mul_add, add_mul, add_mul]; abel
_ = algebraMap R _ (Q (a + b)) - algebraMap R _ (Q a) - algebraMap R _ (Q b) := by
rw [hf, hf, hf]
_ = algebraMap R _ (Q (a + b) - Q a - Q b) := by rw [← RingHom.map_sub, ← RingHom.map_sub]
_ = algebraMap R _ (QuadraticForm.polar Q a b) := rfl
_ = algebraMap R _ (QuadraticMap.polar Q a b) := rfl

/-- An alternative way to provide the argument to `CliffordAlgebra.lift` when `2` is invertible.
Expand All @@ -255,18 +255,18 @@ theorem forall_mul_self_eq_iff {A : Type*} [Ring A] [Algebra R A] (h2 : IsUnit (
Q.polarBilin.compr₂ (Algebra.linearMap R A) := by
simp_rw [DFunLike.ext_iff]
refine ⟨mul_add_swap_eq_polar_of_forall_mul_self_eq _, fun h x => ?_⟩
change ∀ x y : M, f x * f y + f y * f x = algebraMap R A (QuadraticForm.polar Q x y) at h
change ∀ x y : M, f x * f y + f y * f x = algebraMap R A (QuadraticMap.polar Q x y) at h
apply h2.mul_left_cancel
rw [two_mul, two_mul, h x x, QuadraticForm.polar_self, two_mul, map_add]
rw [two_mul, two_mul, h x x, QuadraticMap.polar_self, two_smul, map_add]

/-- The symmetric product of vectors is a scalar -/
theorem ι_mul_ι_add_swap (a b : M) :
ι Q a * ι Q b + ι Q b * ι Q a = algebraMap R _ (QuadraticForm.polar Q a b) :=
ι Q a * ι Q b + ι Q b * ι Q a = algebraMap R _ (QuadraticMap.polar Q a b) :=
mul_add_swap_eq_polar_of_forall_mul_self_eq _ (ι_sq_scalar _) _ _
#align clifford_algebra.ι_mul_ι_add_swap CliffordAlgebra.ι_mul_ι_add_swap

theorem ι_mul_ι_comm (a b : M) :
ι Q a * ι Q b = algebraMap R _ (QuadraticForm.polar Q a b) - ι Q b * ι Q a :=
ι Q a * ι Q b = algebraMap R _ (QuadraticMap.polar Q a b) - ι Q b * ι Q a :=
eq_sub_of_add_eq (ι_mul_ι_add_swap a b)
#align clifford_algebra.ι_mul_comm CliffordAlgebra.ι_mul_ι_comm

Expand All @@ -293,7 +293,7 @@ end isOrtho

/-- $aba$ is a vector. -/
theorem ι_mul_ι_mul_ι (a b : M) :
ι Q a * ι Q b * ι Q a = ι Q (QuadraticForm.polar Q a b • a - Q a • b) := by
ι Q a * ι Q b * ι Q a = ι Q (QuadraticMap.polar Q a b • a - Q a • b) := by
rw [ι_mul_ι_comm, sub_mul, mul_assoc, ι_sq_scalar, ← Algebra.smul_def, ← Algebra.commutes, ←
Algebra.smul_def, ← map_smul, ← map_smul, ← map_sub]
#align clifford_algebra.ι_mul_ι_mul_ι CliffordAlgebra.ι_mul_ι_mul_ι
Expand Down
19 changes: 10 additions & 9 deletions Mathlib/LinearAlgebra/CliffordAlgebra/Contraction.lean
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Within this file, we use the local notation
-/

open LinearMap (BilinMap)
open LinearMap (BilinForm)

universe u1 u2 u3
Expand Down Expand Up @@ -255,39 +256,39 @@ theorem changeFormAux_changeFormAux (B : BilinForm R M) (v : M) (x : CliffordAlg

variable {Q}
variable {Q' Q'' : QuadraticForm R M} {B B' : BilinForm R M}
variable (h : B.toQuadraticForm = Q' - Q) (h' : B'.toQuadraticForm = Q'' - Q')
variable (h : B.toQuadraticMap = Q' - Q) (h' : B'.toQuadraticMap = Q'' - Q')

/-- Convert between two algebras of different quadratic form, sending vector to vectors, scalars to
scalars, and adjusting products by a contraction term.
This is $\lambda_B$ from [bourbaki2007][] $9 Lemma 2. -/
def changeForm (h : B.toQuadraticForm = Q' - Q) : CliffordAlgebra Q →ₗ[R] CliffordAlgebra Q' :=
def changeForm (h : B.toQuadraticMap = Q' - Q) : CliffordAlgebra Q →ₗ[R] CliffordAlgebra Q' :=
foldr Q (changeFormAux Q' B)
(fun m x =>
(changeFormAux_changeFormAux Q' B m x).trans <| by
dsimp only [← BilinForm.toQuadraticForm_apply]
rw [h, QuadraticForm.sub_apply, sub_sub_cancel])
dsimp only [← BilinMap.toQuadraticMap_apply]
rw [h, QuadraticMap.sub_apply, sub_sub_cancel])
1
#align clifford_algebra.change_form CliffordAlgebra.changeForm

/-- Auxiliary lemma used as an argument to `CliffordAlgebra.changeForm` -/
theorem changeForm.zero_proof : (0 : BilinForm R M).toQuadraticForm = Q - Q :=
theorem changeForm.zero_proof : (0 : BilinForm R M).toQuadraticMap = Q - Q :=
(sub_self _).symm
#align clifford_algebra.change_form.zero_proof CliffordAlgebra.changeForm.zero_proof

/-- Auxiliary lemma used as an argument to `CliffordAlgebra.changeForm` -/
theorem changeForm.add_proof : (B + B').toQuadraticForm = Q'' - Q :=
theorem changeForm.add_proof : (B + B').toQuadraticMap = Q'' - Q :=
(congr_arg₂ (· + ·) h h').trans <| sub_add_sub_cancel' _ _ _
#align clifford_algebra.change_form.add_proof CliffordAlgebra.changeForm.add_proof

/-- Auxiliary lemma used as an argument to `CliffordAlgebra.changeForm` -/
theorem changeForm.neg_proof : (-B).toQuadraticForm = Q - Q' :=
theorem changeForm.neg_proof : (-B).toQuadraticMap = Q - Q' :=
(congr_arg Neg.neg h).trans <| neg_sub _ _
#align clifford_algebra.change_form.neg_proof CliffordAlgebra.changeForm.neg_proof

theorem changeForm.associated_neg_proof [Invertible (2 : R)] :
(QuadraticForm.associated (R := R) (M := M) (-Q)).toQuadraticForm = 0 - Q := by
simp [QuadraticForm.toQuadraticForm_associated]
(QuadraticMap.associated (R := R) (M := M) (-Q)).toQuadraticMap = 0 - Q := by
simp [QuadraticMap.toQuadraticMap_associated]
#align clifford_algebra.change_form.associated_neg_proof CliffordAlgebra.changeForm.associated_neg_proof

@[simp]
Expand Down
13 changes: 7 additions & 6 deletions Mathlib/LinearAlgebra/CliffordAlgebra/Equivs.lean
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ open scoped ComplexConjugate

/-- The quadratic form sending elements to the negation of their square. -/
def Q : QuadraticForm ℝ ℝ :=
-QuadraticForm.sq (R := ℝ) -- Porting note: Added `(R := ℝ)`
-QuadraticMap.sq (R := ℝ) -- Porting note: Added `(R := ℝ)`
set_option linter.uppercaseLean3 false in
#align clifford_algebra_complex.Q CliffordAlgebraComplex.Q

Expand Down Expand Up @@ -259,7 +259,8 @@ variable {R : Type*} [CommRing R] (c₁ c₂ : R)
/-- `Q c₁ c₂` is a quadratic form over `R × R` such that `CliffordAlgebra (Q c₁ c₂)` is isomorphic
as an `R`-algebra to `ℍ[R,c₁,c₂]`. -/
def Q : QuadraticForm R (R × R) :=
(c₁ • QuadraticForm.sq (R := R)).prod (c₂ • QuadraticForm.sq) -- Porting note: Added `(R := R)`
-- Porting note: Added `(R := R)`
QuadraticForm.prod (c₁ • QuadraticMap.sq (R := R)) (c₂ • QuadraticMap.sq)
set_option linter.uppercaseLean3 false in
#align clifford_algebra_quaternion.Q CliffordAlgebraQuaternion.Q

Expand All @@ -283,7 +284,7 @@ def quaternionBasis : QuaternionAlgebra.Basis (CliffordAlgebra (Q c₁ c₂)) c
simp
i_mul_j := rfl
j_mul_i := by
rw [eq_neg_iff_add_eq_zero, ι_mul_ι_add_swap, QuadraticForm.polar]
rw [eq_neg_iff_add_eq_zero, ι_mul_ι_add_swap, QuadraticMap.polar]
simp
#align clifford_algebra_quaternion.quaternion_basis CliffordAlgebraQuaternion.quaternionBasis

Expand Down Expand Up @@ -399,7 +400,7 @@ variable {R M : Type*} [CommRing R] [AddCommGroup M] [Module R M]

theorem ι_mul_ι (r₁ r₂) : ι (0 : QuadraticForm R R) r₁ * ι (0 : QuadraticForm R R) r₂ = 0 := by
rw [← mul_one r₁, ← mul_one r₂, ← smul_eq_mul R, ← smul_eq_mul R, LinearMap.map_smul,
LinearMap.map_smul, smul_mul_smul, ι_sq_scalar, QuadraticForm.zero_apply, RingHom.map_zero,
LinearMap.map_smul, smul_mul_smul, ι_sq_scalar, QuadraticMap.zero_apply, RingHom.map_zero,
smul_zero]
#align clifford_algebra_dual_number.ι_mul_ι CliffordAlgebraDualNumber.ι_mul_ι

Expand All @@ -415,14 +416,14 @@ protected def equiv : CliffordAlgebra (0 : QuadraticForm R R) ≃ₐ[R] R[ε] :=
(by
ext : 1
-- This used to be a single `simp` before leanprover/lean4#2644
simp only [QuadraticForm.zero_apply, AlgHom.coe_comp, Function.comp_apply, lift_apply_eps,
simp only [QuadraticMap.zero_apply, AlgHom.coe_comp, Function.comp_apply, lift_apply_eps,
AlgHom.coe_id, id_eq]
erw [lift_ι_apply]
simp)
-- This used to be a single `simp` before leanprover/lean4#2644
(by
ext : 2
simp only [QuadraticForm.zero_apply, AlgHom.comp_toLinearMap, LinearMap.coe_comp,
simp only [QuadraticMap.zero_apply, AlgHom.comp_toLinearMap, LinearMap.coe_comp,
Function.comp_apply, AlgHom.toLinearMap_apply, AlgHom.toLinearMap_id, LinearMap.id_comp]
erw [lift_ι_apply]
simp)
Expand Down
Loading
Loading