l3lab/ntp-mathlib huggingface dataset:
/-- Compose a quadratic form with a linear function on the left. -/
@[simps (config := { simpRhs := true })]
def _root_.LinearMap.compQuadraticForm [CommSemiring S] [Algebra S R] [Module S M]
    [IsScalarTower S R M] (f : R →ₗ[S] S) (Q : QuadraticForm R M) : QuadraticForm S M where
  toFun x := f (Q x)
  toFun_smul b x := by 

Proof state:
S : Type u_1
T : Type u_2
R : Type u_3
M : Type u_4
inst✝⁸ : CommSemiring R
inst✝⁷ : AddCommMonoid M
inst✝⁶ : Module R M
N : Type v
inst✝⁵ : AddCommMonoid N
inst✝⁴ : Module R N
inst✝³ : CommSemiring S
inst✝² : Algebra S R
inst✝¹ : Module S M
inst✝ : IsScalarTower S R M
f : R →ₗ[S] S
Q : QuadraticForm R M
b : S
x : M
⊢ (fun x => f (Q x)) (b • x) = b * b * (fun x => f (Q x)) x

Next tactic:
simp only [Q.map_smul_of_tower b x, f.map_smul, smul_eq_mul]
/-- Compose a quadratic form with a linear function on the left. -/
@[simps (config := { simpRhs := true })]
def _root_.LinearMap.compQuadraticForm [CommSemiring S] [Algebra S R] [Module S M]
    [IsScalarTower S R M] (f : R →ₗ[S] S) (Q : QuadraticForm R M) : QuadraticForm S M where
  toFun x := f (Q x)
  toFun_smul b x := by simp only [Q.map_smul_of_tower b x, f.map_smul, smul_eq_mul]
  exists_companion' :=
    let ⟨B, h⟩ := Q.exists_companion
    ⟨f.compBilinForm B, fun x y => by 

Proof state:
S : Type u_1
T : Type u_2
R : Type u_3
M : Type u_4
inst✝⁸ : CommSemiring R
inst✝⁷ : AddCommMonoid M
inst✝⁶ : Module R M
N : Type v
inst✝⁵ : AddCommMonoid N
inst✝⁴ : Module R N
inst✝³ : CommSemiring S
inst✝² : Algebra S R
inst✝¹ : Module S M
inst✝ : IsScalarTower S R M
f : R →ₗ[S] S
Q : QuadraticForm R M
B : BilinForm R M
h : ∀ (x y : M), Q (x + y) = Q x + Q y + BilinForm.bilin B x y
x y : M
⊢ (fun x => f (Q x)) (x + y) =
    (fun x => f (Q x)) x + (fun x => f (Q x)) y + BilinForm.bilin (LinearMap.compBilinForm f B) x y

Next tactic:
simp_rw [h, f.map_add, LinearMap.compBilinForm_apply]
/-- The product of linear forms is a quadratic form. -/
def linMulLin (f g : M →ₗ[R] R) : QuadraticForm R M where
  toFun := f * g
  toFun_smul a x := by
    

Proof state:
S : Type u_1
T : Type u_2
R : Type u_3
M : Type u_4
inst✝² : CommSemiring R
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
f g : M →ₗ[R] R
a : R
x : M
⊢ (⇑f * ⇑g) (a • x) = a * a * (⇑f * ⇑g) x

Next tactic:
simp only [smul_eq_mul, RingHom.id_apply, Pi.mul_apply, LinearMap.map_smulₛₗ]
/-- The product of linear forms is a quadratic form. -/
def linMulLin (f g : M →ₗ[R] R) : QuadraticForm R M where
  toFun := f * g
  toFun_smul a x := by
    simp only [smul_eq_mul, RingHom.id_apply, Pi.mul_apply, LinearMap.map_smulₛₗ]
    

Proof state:
S : Type u_1
T : Type u_2
R : Type u_3
M : Type u_4
inst✝² : CommSemiring R
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
f g : M →ₗ[R] R
a : R
x : M
⊢ a * f x * (a * g x) = a * a * (f x * g x)

Next tactic:
ring
/-- The product of linear forms is a quadratic form. -/
def linMulLin (f g : M →ₗ[R] R) : QuadraticForm R M where
  toFun := f * g
  toFun_smul a x := by
    simp only [smul_eq_mul, RingHom.id_apply, Pi.mul_apply, LinearMap.map_smulₛₗ]
    ring
  exists_companion' :=
    ⟨BilinForm.linMulLin f g + BilinForm.linMulLin g f, fun x y => by
      

Proof state:
S : Type u_1
T : Type u_2
R : Type u_3
M : Type u_4
inst✝² : CommSemiring R
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
f g : M →ₗ[R] R
x y : M
⊢ (⇑f * ⇑g) (x + y) =
    (⇑f * ⇑g) x + (⇑f * ⇑g) y + BilinForm.bilin (BilinForm.linMulLin f g + BilinForm.linMulLin g f) x y

Next tactic:
simp only [Pi.mul_apply, map_add, BilinForm.add_apply, BilinForm.linMulLin_apply]
/-- The product of linear forms is a quadratic form. -/
def linMulLin (f g : M →ₗ[R] R) : QuadraticForm R M where
  toFun := f * g
  toFun_smul a x := by
    simp only [smul_eq_mul, RingHom.id_apply, Pi.mul_apply, LinearMap.map_smulₛₗ]
    ring
  exists_companion' :=
    ⟨BilinForm.linMulLin f g + BilinForm.linMulLin g f, fun x y => by
      simp only [Pi.mul_apply, map_add, BilinForm.add_apply, BilinForm.linMulLin_apply]
      

Proof state:
S : Type u_1
T : Type u_2
R : Type u_3
M : Type u_4
inst✝² : CommSemiring R
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
f g : M →ₗ[R] R
x y : M
⊢ (f x + f y) * (g x + g y) = f x * g x + f y * g y + (f x * g y + g x * f y)

Next tactic:
ring
/-- A bilinear form gives a quadratic form by applying the argument twice. -/
def toQuadraticForm (B : BilinForm R M) : QuadraticForm R M where
  toFun x := B x x
  toFun_smul a x := by 

Proof state:
S : Type u_1
T : Type u_2
R : Type u_3
M : Type u_4
inst✝² : CommSemiring R
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
B✝ B : BilinForm R M
a : R
x : M
⊢ (fun x => bilin B x x) (a • x) = a * a * (fun x => bilin B x x) x

Next tactic:
simp only [mul_assoc, smul_right, smul_left]
/-- A bilinear form gives a quadratic form by applying the argument twice. -/
def toQuadraticForm (B : BilinForm R M) : QuadraticForm R M where
  toFun x := B x x
  toFun_smul a x := by simp only [mul_assoc, smul_right, smul_left]
  exists_companion' := ⟨B + BilinForm.flipHom ℕ B, fun x y => by 

Proof state:
S : Type u_1
T : Type u_2
R : Type u_3
M : Type u_4
inst✝² : CommSemiring R
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
B✝ B : BilinForm R M
x y : M
⊢ (fun x => bilin B x x) (x + y) = (fun x => bilin B x x) x + (fun x => bilin B x x) y + bilin (B + (flipHom ℕ) B) x y

Next tactic:
simp [add_add_add_comm, add_comm]
theorem polar_toQuadraticForm (x y : M) : polar (toQuadraticForm B) x y = B x y + B y x := by
  

Proof state:
S : Type u_1
T : Type u_2
R : Type u_3
M : Type u_4
inst✝² : CommRing R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
B : BilinForm R M
x y : M
⊢ polar (⇑(toQuadraticForm B)) x y = bilin B x y + bilin B y x

Next tactic:
simp only [toQuadraticForm_apply, add_assoc, add_sub_cancel', add_right, polar, add_left_inj,
    add_neg_cancel_left, add_left, sub_eq_add_neg _ (B y y), add_comm (B y x) _]
@[simp] theorem _root_.QuadraticForm.toQuadraticForm_polarBilin (Q : QuadraticForm R M) :
    toQuadraticForm (polarBilin Q) = 2 • Q :=
  QuadraticForm.ext <| fun x => (polar_self _ x).trans <| by 

Proof state:
S : Type u_1
T : Type u_2
R : Type u_3
M : Type u_4
inst✝² : CommRing R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
B : BilinForm R M
Q : QuadraticForm R M
x : M
⊢ 2 * Q x = (2 • Q) x

Next tactic:
simp
theorem  _root_.QuadraticForm.polarBilin_injective (h : IsUnit (2 : R)) :
    Function.Injective (polarBilin : QuadraticForm R M → _) :=
  fun Q₁ Q₂ h₁₂ => QuadraticForm.ext fun x => h.mul_left_cancel <| by
    

Proof state:
S : Type u_1
T : Type u_2
R : Type u_3
M : Type u_4
inst✝² : CommRing R
inst✝¹ : AddCommGroup M
inst✝ : Module R M
B : BilinForm R M
h : IsUnit 2
Q₁ Q₂ : QuadraticForm R M
h₁₂ : polarBilin Q₁ = polarBilin Q₂
x : M
⊢ 2 * Q₁ x = 2 * Q₂ x

Next tactic:
simpa using FunLike.congr_fun (congr_arg toQuadraticForm h₁₂) x
theorem _root_.QuadraticForm.polarBilin_comp (Q : QuadraticForm R N) (f : M →ₗ[R] N) :
    polarBilin (Q.comp f) = BilinForm.comp (polarBilin Q) f f :=
  BilinForm.ext <| fun x y => by 

Proof state:
S : Type u_1
T : Type u_2
R : Type u_3
M : Type u_4
inst✝⁸ : CommRing R
inst✝⁷ : AddCommGroup M
inst✝⁶ : Module R M
B : BilinForm R M
N : Type v
inst✝⁵ : CommRing S
inst✝⁴ : Algebra S R
inst✝³ : Module S M
inst✝² : IsScalarTower S R M
inst✝¹ : AddCommGroup N
inst✝ : Module R N
Q : QuadraticForm R N
f : M →ₗ[R] N
x y : M
⊢ bilin (polarBilin (QuadraticForm.comp Q f)) x y = bilin (comp (polarBilin Q) f f) x y

Next tactic:
simp [polar]
theorem _root_.LinearMap.compQuadraticForm_polar (f : R →ₗ[S] S) (Q : QuadraticForm R M) (x y : M) :
    polar (f.compQuadraticForm Q) x y = f (polar Q x y) := by
  

Proof state:
S : Type u_1
T : Type u_2
R : Type u_3
M : Type u_4
inst✝⁸ : CommRing R
inst✝⁷ : AddCommGroup M
inst✝⁶ : Module R M
B : BilinForm R M
N : Type v
inst✝⁵ : CommRing S
inst✝⁴ : Algebra S R
inst✝³ : Module S M
inst✝² : IsScalarTower S R M
inst✝¹ : AddCommGroup N
inst✝ : Module R N
f : R →ₗ[S] S
Q : QuadraticForm R M
x y : M
⊢ polar (⇑(LinearMap.compQuadraticForm f Q)) x y = f (polar (⇑Q) x y)

Next tactic:
simp [polar]
@[simp] theorem two_nsmul_associated : 2 • associatedHom S Q = Q.polarBilin := by
  

Proof state:
S : Type u_1
T : Type u_2
R : Type u_3
M : Type u_4
inst✝⁵ : CommRing R
inst✝⁴ : AddCommGroup M
inst✝³ : Module R M
inst✝² : CommSemiring S
inst✝¹ : Algebra S R
inst✝ : Invertible 2
B₁ : BilinForm R M
Q : QuadraticForm R M
⊢ 2 • (associatedHom S) Q = polarBilin Q

Next tactic:
ext
@[simp] theorem two_nsmul_associated : 2 • associatedHom S Q = Q.polarBilin := by
  ext
  

Proof state:
case H
S : Type u_1
T : Type u_2
R : Type u_3
M : Type u_4
inst✝⁵ : CommRing R
inst✝⁴ : AddCommGroup M
inst✝³ : Module R M
inst✝² : CommSemiring S
inst✝¹ : Algebra S R
inst✝ : Invertible 2
B₁ : BilinForm R M
Q : QuadraticForm R M
x✝ y✝ : M
⊢ bilin (2 • (associatedHom S) Q) x✝ y✝ = bilin (polarBilin Q) x✝ y✝

Next tactic:
dsimp
@[simp] theorem two_nsmul_associated : 2 • associatedHom S Q = Q.polarBilin := by
  ext
  dsimp
  

Proof state:
case H
S : Type u_1
T : Type u_2
R : Type u_3
M : Type u_4
inst✝⁵ : CommRing R
inst✝⁴ : AddCommGroup M
inst✝³ : Module R M
inst✝² : CommSemiring S
inst✝¹ : Algebra S R
inst✝ : Invertible 2
B₁ : BilinForm R M
Q : QuadraticForm R M
x✝ y✝ : M
⊢ 2 • (⅟2 * (Q (x✝ + y✝) - Q x✝ - Q y✝)) = polar (⇑Q) x✝ y✝

Next tactic:
rw [← smul_mul_assoc, two_nsmul, invOf_two_add_invOf_two, one_mul, polar]
theorem associated_isSymm : (associatedHom S Q).IsSymm := fun x y => by
  

Proof state:
S : Type u_1
T : Type u_2
R : Type u_3
M : Type u_4
inst✝⁵ : CommRing R
inst✝⁴ : AddCommGroup M
inst✝³ : Module R M
inst✝² : CommSemiring S
inst✝¹ : Algebra S R
inst✝ : Invertible 2
B₁ : BilinForm R M
Q : QuadraticForm R M
x y : M
⊢ bilin ((associatedHom S) Q) x y = bilin ((associatedHom S) Q) y x

Next tactic:
simp only [associated_apply, add_comm, add_left_comm, sub_eq_add_neg, add_assoc]
@[simp]
theorem associated_comp {N : Type v} [AddCommGroup N] [Module R N] (f : N →ₗ[R] M) :
    associatedHom S (Q.comp f) = (associatedHom S Q).comp f f := by
  

Proof state:
S : Type u_1
T : Type u_2
R : Type u_3
M : Type u_4
inst✝⁷ : CommRing R
inst✝⁶ : AddCommGroup M
inst✝⁵ : Module R M
inst✝⁴ : CommSemiring S
inst✝³ : Algebra S R
inst✝² : Invertible 2
B₁ : BilinForm R M
Q : QuadraticForm R M
N : Type v
inst✝¹ : AddCommGroup N
inst✝ : Module R N
f : N →ₗ[R] M
⊢ (associatedHom S) (comp Q f) = BilinForm.comp ((associatedHom S) Q) f f

Next tactic:
ext
@[simp]
theorem associated_comp {N : Type v} [AddCommGroup N] [Module R N] (f : N →ₗ[R] M) :
    associatedHom S (Q.comp f) = (associatedHom S Q).comp f f := by
  ext
  

Proof state:
case H
S : Type u_1
T : Type u_2
R : Type u_3
M : Type u_4
inst✝⁷ : CommRing R
inst✝⁶ : AddCommGroup M
inst✝⁵ : Module R M
inst✝⁴ : CommSemiring S
inst✝³ : Algebra S R
inst✝² : Invertible 2
B₁ : BilinForm R M
Q : QuadraticForm R M
N : Type v
inst✝¹ : AddCommGroup N
inst✝ : Module R N
f : N →ₗ[R] M
x✝ y✝ : N
⊢ bilin ((associatedHom S) (comp Q f)) x✝ y✝ = bilin (BilinForm.comp ((associatedHom S) Q) f f) x✝ y✝

Next tactic:
simp only [QuadraticForm.comp_apply, BilinForm.comp_apply, associated_apply, LinearMap.map_add]
theorem associated_toQuadraticForm (B : BilinForm R M) (x y : M) :
    associatedHom S B.toQuadraticForm x y = ⅟ 2 * (B x y + B y x) := by
  

Proof state:
S : Type u_1
T : Type u_2
R : Type u_3
M : Type u_4
inst✝⁵ : CommRing R
inst✝⁴ : AddCommGroup M
inst✝³ : Module R M
inst✝² : CommSemiring S
inst✝¹ : Algebra S R
inst✝ : Invertible 2
B₁ : BilinForm R M
Q : QuadraticForm R M
B : BilinForm R M
x y : M
⊢ bilin ((associatedHom S) (toQuadraticForm B)) x y = ⅟2 * (bilin B x y + bilin B y x)

Next tactic:
simp only [associated_apply, ← polar_toQuadraticForm, polar]
theorem associated_left_inverse (h : B₁.IsSymm) : associatedHom S B₁.toQuadraticForm = B₁ :=
  BilinForm.ext fun x y => by
    

Proof state:
S : Type u_1
T : Type u_2
R : Type u_3
M : Type u_4
inst✝⁵ : CommRing R
inst✝⁴ : AddCommGroup M
inst✝³ : Module R M
inst✝² : CommSemiring S
inst✝¹ : Algebra S R
inst✝ : Invertible 2
B₁ : BilinForm R M
Q : QuadraticForm R M
h : BilinForm.IsSymm B₁
x y : M
⊢ bilin ((associatedHom S) (toQuadraticForm B₁)) x y = bilin B₁ x y

Next tactic:
rw [associated_toQuadraticForm, h.eq x y, ← two_mul, ← mul_assoc, invOf_mul_self,
      one_mul]
theorem associated_eq_self_apply (x : M) : associatedHom S Q x x = Q x := by
  

Proof state:
S : Type u_1
T : Type u_2
R : Type u_3
M : Type u_4
inst✝⁵ : CommRing R
inst✝⁴ : AddCommGroup M
inst✝³ : Module R M
inst✝² : CommSemiring S
inst✝¹ : Algebra S R
inst✝ : Invertible 2
B₁ : BilinForm R M
Q : QuadraticForm R M
x : M
⊢ bilin ((associatedHom S) Q) x x = Q x

Next tactic:
rw [associated_apply, map_add_self, ← three_add_one_eq_four, ← two_add_one_eq_three,
    add_mul, add_mul, one_mul, add_sub_cancel, add_sub_cancel, invOf_mul_self_assoc]
/-- There exists a non-null vector with respect to any quadratic form `Q` whose associated
bilinear form is non-zero, i.e. there exists `x` such that `Q x ≠ 0`. -/
theorem exists_quadraticForm_ne_zero {Q : QuadraticForm R M}
    -- Porting note: added implicit argument
    (hB₁ : associated' (R := R) Q ≠ 0) :
    ∃ x, Q x ≠ 0 := by
  

Proof state:
S : Type u_1
T : Type u_2
R : Type u_3
M : Type u_4
inst✝⁵ : CommRing R
inst✝⁴ : AddCommGroup M
inst✝³ : Module R M
inst✝² : CommSemiring S
inst✝¹ : Algebra S R
inst✝ : Invertible 2
B₁ : BilinForm R M
Q✝ Q : QuadraticForm R M
hB₁ : associated' Q ≠ 0
⊢ ∃ x, Q x ≠ 0

Next tactic:
rw [← not_forall]
/-- There exists a non-null vector with respect to any quadratic form `Q` whose associated
bilinear form is non-zero, i.e. there exists `x` such that `Q x ≠ 0`. -/
theorem exists_quadraticForm_ne_zero {Q : QuadraticForm R M}
    -- Porting note: added implicit argument
    (hB₁ : associated' (R := R) Q ≠ 0) :
    ∃ x, Q x ≠ 0 := by
  rw [← not_forall]
  

Proof state:
S : Type u_1
T : Type u_2
R : Type u_3
M : Type u_4
inst✝⁵ : CommRing R
inst✝⁴ : AddCommGroup M
inst✝³ : Module R M
inst✝² : CommSemiring S
inst✝¹ : Algebra S R
inst✝ : Invertible 2
B₁ : BilinForm R M
Q✝ Q : QuadraticForm R M
hB₁ : associated' Q ≠ 0
⊢ ¬∀ (x : M), Q x = 0

Next tactic:
intro h
/-- There exists a non-null vector with respect to any quadratic form `Q` whose associated
bilinear form is non-zero, i.e. there exists `x` such that `Q x ≠ 0`. -/
theorem exists_quadraticForm_ne_zero {Q : QuadraticForm R M}
    -- Porting note: added implicit argument
    (hB₁ : associated' (R := R) Q ≠ 0) :
    ∃ x, Q x ≠ 0 := by
  rw [← not_forall]
  intro h
  

Proof state:
S : Type u_1
T : Type u_2
R : Type u_3
M : Type u_4
inst✝⁵ : CommRing R
inst✝⁴ : AddCommGroup M
inst✝³ : Module R M
inst✝² : CommSemiring S
inst✝¹ : Algebra S R
inst✝ : Invertible 2
B₁ : BilinForm R M
Q✝ Q : QuadraticForm R M
hB₁ : associated' Q ≠ 0
h : ∀ (x : M), Q x = 0
⊢ False

Next tactic:
apply hB₁
/-- There exists a non-null vector with respect to any quadratic form `Q` whose associated
bilinear form is non-zero, i.e. there exists `x` such that `Q x ≠ 0`. -/
theorem exists_quadraticForm_ne_zero {Q : QuadraticForm R M}
    -- Porting note: added implicit argument
    (hB₁ : associated' (R := R) Q ≠ 0) :
    ∃ x, Q x ≠ 0 := by
  rw [← not_forall]
  intro h
  apply hB₁
  

Proof state:
S : Type u_1
T : Type u_2
R : Type u_3
M : Type u_4
inst✝⁵ : CommRing R
inst✝⁴ : AddCommGroup M
inst✝³ : Module R M
inst✝² : CommSemiring S
inst✝¹ : Algebra S R
inst✝ : Invertible 2
B₁ : BilinForm R M
Q✝ Q : QuadraticForm R M
hB₁ : associated' Q ≠ 0
h : ∀ (x : M), Q x = 0
⊢ associated' Q = 0

Next tactic:
rw [(QuadraticForm.ext h : Q = 0), LinearMap.map_zero]
@[simp]
theorem associated_linMulLin (f g : M →ₗ[R] R) :
    associated (R := R) (linMulLin f g) =
      ⅟ (2 : R) • (BilinForm.linMulLin f g + BilinForm.linMulLin g f) := by
  

Proof state:
S : Type u_1
T : Type u_2
R : Type u_3
M : Type u_4
inst✝⁵ : CommSemiring S
inst✝⁴ : CommRing R
inst✝³ : AddCommGroup M
inst✝² : Algebra S R
inst✝¹ : Module R M
inst✝ : Invertible 2
f g : M →ₗ[R] R
⊢ associated (linMulLin f g) = ⅟2 • (BilinForm.linMulLin f g + BilinForm.linMulLin g f)

Next tactic:
ext
@[simp]
theorem associated_linMulLin (f g : M →ₗ[R] R) :
    associated (R := R) (linMulLin f g) =
      ⅟ (2 : R) • (BilinForm.linMulLin f g + BilinForm.linMulLin g f) := by
  ext
  

Proof state:
case H
S : Type u_1
T : Type u_2
R : Type u_3
M : Type u_4
inst✝⁵ : CommSemiring S
inst✝⁴ : CommRing R
inst✝³ : AddCommGroup M
inst✝² : Algebra S R
inst✝¹ : Module R M
inst✝ : Invertible 2
f g : M →ₗ[R] R
x✝ y✝ : M
⊢ bilin (associated (linMulLin f g)) x✝ y✝ = bilin (⅟2 • (BilinForm.linMulLin f g + BilinForm.linMulLin g f)) x✝ y✝

Next tactic:
simp only [smul_add, Algebra.id.smul_eq_mul, BilinForm.linMulLin_apply,
    QuadraticForm.linMulLin_apply, BilinForm.smul_apply, associated_apply, BilinForm.add_apply,
    LinearMap.map_add]
@[simp]
theorem associated_linMulLin (f g : M →ₗ[R] R) :
    associated (R := R) (linMulLin f g) =
      ⅟ (2 : R) • (BilinForm.linMulLin f g + BilinForm.linMulLin g f) := by
  ext
  simp only [smul_add, Algebra.id.smul_eq_mul, BilinForm.linMulLin_apply,
    QuadraticForm.linMulLin_apply, BilinForm.smul_apply, associated_apply, BilinForm.add_apply,
    LinearMap.map_add]
  

Proof state:
case H
S : Type u_1
T : Type u_2
R : Type u_3
M : Type u_4
inst✝⁵ : CommSemiring S
inst✝⁴ : CommRing R
inst✝³ : AddCommGroup M
inst✝² : Algebra S R
inst✝¹ : Module R M
inst✝ : Invertible 2
f g : M →ₗ[R] R
x✝ y✝ : M
⊢ ⅟2 * ((f x✝ + f y✝) * (g x✝ + g y✝) - f x✝ * g x✝ - f y✝ * g y✝) = ⅟2 * (f x✝ * g y✝) + ⅟2 * (g x✝ * f y✝)

Next tactic:
ring
@[simp]
lemma associated_sq : associated (R := R) sq = LinearMap.toBilin (LinearMap.mul R R) :=
  (associated_linMulLin (LinearMap.id) (LinearMap.id)).trans <|
    by 

Proof state:
S : Type u_1
T : Type u_2
R : Type u_3
M : Type u_4
inst✝⁵ : CommSemiring S
inst✝⁴ : CommRing R
inst✝³ : AddCommGroup M
inst✝² : Algebra S R
inst✝¹ : Module R M
inst✝ : Invertible 2
⊢ ⅟2 • (BilinForm.linMulLin LinearMap.id LinearMap.id + BilinForm.linMulLin LinearMap.id LinearMap.id) =
    LinearMap.toBilin (LinearMap.mul R R)

Next tactic:
simp only [smul_add, invOf_two_smul_add_invOf_two_smul]
@[simp]
lemma associated_sq : associated (R := R) sq = LinearMap.toBilin (LinearMap.mul R R) :=
  (associated_linMulLin (LinearMap.id) (LinearMap.id)).trans <|
    by simp only [smul_add, invOf_two_smul_add_invOf_two_smul]; 

Proof state:
S : Type u_1
T : Type u_2
R : Type u_3
M : Type u_4
inst✝⁵ : CommSemiring S
inst✝⁴ : CommRing R
inst✝³ : AddCommGroup M
inst✝² : Algebra S R
inst✝¹ : Module R M
inst✝ : Invertible 2
⊢ BilinForm.linMulLin LinearMap.id LinearMap.id = LinearMap.toBilin (LinearMap.mul R R)

Next tactic:
rfl
theorem not_anisotropic_iff_exists (Q : QuadraticForm R M) :
    ¬Anisotropic Q ↔ ∃ x, x ≠ 0 ∧ Q x = 0 := by
  

Proof state:
S : Type u_1
T : Type u_2
R : Type u_3
M : Type u_4
inst✝² : CommSemiring R
inst✝¹ : AddCommMonoid M
inst✝ : Module R M
Q : QuadraticForm R M
⊢ ¬Anisotropic Q ↔ ∃ x, x ≠ 0 ∧ Q x = 0

Next tactic:
simp only [Anisotropic, not_forall, exists_prop, and_comm]
/-- The associated bilinear form of an anisotropic quadratic form is nondegenerate. -/
theorem nondegenerate_of_anisotropic [Invertible (2 : R)] (Q : QuadraticForm R M)
    (hB : Q.Anisotropic) :
    -- Porting note: added implicit argument
    (QuadraticForm.associated' (R := R) Q).Nondegenerate := fun x hx ↦ hB _ <| by
  

Proof state:
S : Type u_1
T : Type u_2
R : Type u_3
M : Type u_4
inst✝³ : CommRing R
inst✝² : AddCommGroup M
inst✝¹ : Module R M
inst✝ : Invertible 2
Q : QuadraticForm R M
hB : Anisotropic Q
x : M
hx : ∀ (n : M), bilin (associated' Q) x n = 0
⊢ Q x = 0

Next tactic:
rw [← hx x]
/-- The associated bilinear form of an anisotropic quadratic form is nondegenerate. -/
theorem nondegenerate_of_anisotropic [Invertible (2 : R)] (Q : QuadraticForm R M)
    (hB : Q.Anisotropic) :
    -- Porting note: added implicit argument
    (QuadraticForm.associated' (R := R) Q).Nondegenerate := fun x hx ↦ hB _ <| by
  rw [← hx x]
  

Proof state:
S : Type u_1
T : Type u_2
R : Type u_3
M : Type u_4
inst✝³ : CommRing R
inst✝² : AddCommGroup M
inst✝¹ : Module R M
inst✝ : Invertible 2
Q : QuadraticForm R M
hB : Anisotropic Q
x : M
hx : ∀ (n : M), bilin (associated' Q) x n = 0
⊢ Q x = bilin (associated' Q) x x

Next tactic:
exact (associated_eq_self_apply _ _ x).symm
theorem PosDef.anisotropic {Q : QuadraticForm R₂ M} (hQ : Q.PosDef) : Q.Anisotropic := fun x hQx =>
  by_contradiction fun hx =>
    lt_irrefl (0 : R₂) <| by
      

Proof state:
S : Type u_1
T : Type u_2
R : Type u_3
M : Type u_4
R₂ : Type u
inst✝² : OrderedCommRing R₂
inst✝¹ : AddCommMonoid M
inst✝ : Module R₂ M
Q₂ : QuadraticForm R₂ M
n : Type u_5
Q : QuadraticForm R₂ M
hQ : PosDef Q
x : M
hQx : Q x = 0
hx : ¬x = 0
⊢ 0 < 0

Next tactic:
have := hQ _ hx
theorem PosDef.anisotropic {Q : QuadraticForm R₂ M} (hQ : Q.PosDef) : Q.Anisotropic := fun x hQx =>
  by_contradiction fun hx =>
    lt_irrefl (0 : R₂) <| by
      have := hQ _ hx
      

Proof state:
S : Type u_1
T : Type u_2
R : Type u_3
M : Type u_4
R₂ : Type u
inst✝² : OrderedCommRing R₂
inst✝¹ : AddCommMonoid M
inst✝ : Module R₂ M
Q₂ : QuadraticForm R₂ M
n : Type u_5
Q : QuadraticForm R₂ M
hQ : PosDef Q
x : M
hQx : Q x = 0
hx : ¬x = 0
this : 0 < Q x
⊢ 0 < 0

Next tactic:
rw [hQx] at this
theorem PosDef.anisotropic {Q : QuadraticForm R₂ M} (hQ : Q.PosDef) : Q.Anisotropic := fun x hQx =>
  by_contradiction fun hx =>
    lt_irrefl (0 : R₂) <| by
      have := hQ _ hx
      rw [hQx] at this
      

Proof state:
S : Type u_1
T : Type u_2
R : Type u_3
M : Type u_4
R₂ : Type u
inst✝² : OrderedCommRing R₂
inst✝¹ : AddCommMonoid M
inst✝ : Module R₂ M
Q₂ : QuadraticForm R₂ M
n : Type u_5
Q : QuadraticForm R₂ M
hQ : PosDef Q
x : M
hQx : Q x = 0
hx : ¬x = 0
this : 0 < 0
⊢ 0 < 0

Next tactic:
exact this
theorem QuadraticForm.toMatrix'_smul (a : R) (Q : QuadraticForm R (n → R)) :
    (a • Q).toMatrix' = a • Q.toMatrix' := by
  

Proof state:
S : Type u_1
T : Type u_2
R : Type u_3
M : Type u_4
n : Type w
inst✝⁵ : Fintype n
inst✝⁴ : DecidableEq n
inst✝³ : CommRing R
inst✝² : AddCommMonoid M
inst✝¹ : Module R M
inst✝ : Invertible 2
a : R
Q : QuadraticForm R (n → R)
⊢ toMatrix' (a • Q) = a • toMatrix' Q

Next tactic:
simp only [toMatrix', LinearEquiv.map_smul, LinearMap.map_smul]
theorem QuadraticForm.isSymm_toMatrix' (Q : QuadraticForm R (n → R)) : Q.toMatrix'.IsSymm := by
  

Proof state:
S : Type u_1
T : Type u_2
R : Type u_3
M : Type u_4
n : Type w
inst✝⁵ : Fintype n
inst✝⁴ : DecidableEq n
inst✝³ : CommRing R
inst✝² : AddCommMonoid M
inst✝¹ : Module R M
inst✝ : Invertible 2
Q : QuadraticForm R (n → R)
⊢ Matrix.IsSymm (toMatrix' Q)

Next tactic:
ext i j
theorem QuadraticForm.isSymm_toMatrix' (Q : QuadraticForm R (n → R)) : Q.toMatrix'.IsSymm := by
  ext i j
  

Proof state:
case a.h
S : Type u_1
T : Type u_2
R : Type u_3
M : Type u_4
n : Type w
inst✝⁵ : Fintype n
inst✝⁴ : DecidableEq n
inst✝³ : CommRing R
inst✝² : AddCommMonoid M
inst✝¹ : Module R M
inst✝ : Invertible 2
Q : QuadraticForm R (n → R)
i j : n
⊢ Matrix.transpose (toMatrix' Q) i j = toMatrix' Q i j

Next tactic:
rw [toMatrix', Matrix.transpose_apply, BilinForm.toMatrix'_apply, BilinForm.toMatrix'_apply,
    associated_isSymm]
@[simp]
theorem toMatrix'_comp (Q : QuadraticForm R (m → R)) (f : (n → R) →ₗ[R] m → R) :
    (Q.comp f).toMatrix' = (LinearMap.toMatrix' f)ᵀ * Q.toMatrix' * (LinearMap.toMatrix' f) := by
  

Proof state:
S : Type u_1
T : Type u_2
R : Type u_3
M : Type u_4
n : Type w
inst✝⁵ : Fintype n
inst✝⁴ : CommRing R
inst✝³ : DecidableEq n
inst✝² : Invertible 2
m : Type w
inst✝¹ : DecidableEq m
inst✝ : Fintype m
Q : QuadraticForm R (m → R)
f : (n → R) →ₗ[R] m → R
⊢ toMatrix' (comp Q f) = (LinearMap.toMatrix' f)ᵀ * toMatrix' Q * LinearMap.toMatrix' f

Next tactic:
ext
@[simp]
theorem toMatrix'_comp (Q : QuadraticForm R (m → R)) (f : (n → R) →ₗ[R] m → R) :
    (Q.comp f).toMatrix' = (LinearMap.toMatrix' f)ᵀ * Q.toMatrix' * (LinearMap.toMatrix' f) := by
  ext
  

Proof state:
case a.h
S : Type u_1
T : Type u_2
R : Type u_3
M : Type u_4
n : Type w
inst✝⁵ : Fintype n
inst✝⁴ : CommRing R
inst✝³ : DecidableEq n
inst✝² : Invertible 2
m : Type w
inst✝¹ : DecidableEq m
inst✝ : Fintype m
Q : QuadraticForm R (m → R)
f : (n → R) →ₗ[R] m → R
i✝ x✝ : n
⊢ toMatrix' (comp Q f) i✝ x✝ = ((LinearMap.toMatrix' f)ᵀ * toMatrix' Q * LinearMap.toMatrix' f) i✝ x✝

Next tactic:
simp only [QuadraticForm.associated_comp, BilinForm.toMatrix'_comp, toMatrix']