l3lab/ntp-mathlib huggingface dataset:
/-- The isometry between a weighted sum of squares with weights `u` on the
(non-zero) real numbers and the weighted sum of squares with weights `sign ∘ u`. -/
noncomputable def isometryEquivSignWeightedSumSquares [DecidableEq ι] (w : ι → ℝ) :
    IsometryEquiv (weightedSumSquares ℝ w) (weightedSumSquares ℝ (Real.sign ∘ w)) := by
  let u i := if h : w i = 0 then (1 : ℝˣ) else Units.mk0 (w i) h
  have hu' : ∀ i : ι, (Real.sign (u i) * u i) ^ (-(1 / 2 : ℝ)) ≠ 0 := by
    intro i
    refine' (ne_of_lt (Real.rpow_pos_of_pos (sign_mul_pos_of_ne_zero _ <| Units.ne_zero _) _)).symm
  convert
    (weightedSumSquares ℝ w).isometryEquivBasisRepr
      ((Pi.basisFun ℝ ι).unitsSMul fun i => (isUnit_iff_ne_zero.2 <| hu' i).unit)
  ext1 v
  rw [basisRepr_apply, weightedSumSquares_apply, weightedSumSquares_apply]
  refine' sum_congr rfl fun j hj => _
  have hsum :
    (∑ i : ι, v i • ((isUnit_iff_ne_zero.2 <| hu' i).unit : ℝ) • (Pi.basisFun ℝ ι) i) j =
      v j • (Real.sign (u j) * u j) ^ (-(1 / 2 : ℝ)) := by
    rw [Finset.sum_apply, sum_eq_single j, Pi.basisFun_apply, IsUnit.unit_spec,
      LinearMap.stdBasis_apply, Pi.smul_apply, Pi.smul_apply, Function.update_same, smul_eq_mul,
      smul_eq_mul, smul_eq_mul, mul_one]
    intro i _ hij
    rw [Pi.basisFun_apply, LinearMap.stdBasis_apply, Pi.smul_apply, Pi.smul_apply,
      Function.update_noteq hij.symm, Pi.zero_apply, smul_eq_mul, smul_eq_mul,
      mul_zero, mul_zero]
    intro hj'; exact False.elim (hj' hj)
  simp_rw [Basis.unitsSMul_apply]
  erw [hsum]
  simp only [Function.comp, smul_eq_mul]
  split_ifs with h
  · simp only [h, zero_smul, zero_mul, Real.sign_zero]
  

Proof state:
case neg
ι : Type u_1
inst✝¹ : Fintype ι
inst✝ : DecidableEq ι
w : ι → ℝ
u : ι → ℝˣ := fun i => if h : w i = 0 then 1 else Units.mk0 (w i) h
hu' : ∀ (i : ι), (sign ↑(u i) * ↑(u i)) ^ (-(1 / 2)) ≠ 0
v : ι → ℝ
j : ι
hj : j ∈ univ
hsum :
  Finset.sum univ
      (fun i => v i • ↑(IsUnit.unit (_ : IsUnit ((sign ↑(u i) * ↑(u i)) ^ (-(1 / 2))))) • (Pi.basisFun ℝ ι) i) j =
    v j • (sign ↑(u j) * ↑(u j)) ^ (-(1 / 2))
h : ¬w j = 0
⊢ sign (w j) * (v j * v j) =
    w j *
      (v j * (sign ↑(Units.mk0 (w j) h) * ↑(Units.mk0 (w j) h)) ^ (-(1 / 2)) *
        (v j * (sign ↑(Units.mk0 (w j) h) * ↑(Units.mk0 (w j) h)) ^ (-(1 / 2))))

Next tactic:
have hwu : w j = u j := by simp only [dif_neg h, Units.val_mk0]
/-- The isometry between a weighted sum of squares with weights `u` on the
(non-zero) real numbers and the weighted sum of squares with weights `sign ∘ u`. -/
noncomputable def isometryEquivSignWeightedSumSquares [DecidableEq ι] (w : ι → ℝ) :
    IsometryEquiv (weightedSumSquares ℝ w) (weightedSumSquares ℝ (Real.sign ∘ w)) := by
  let u i := if h : w i = 0 then (1 : ℝˣ) else Units.mk0 (w i) h
  have hu' : ∀ i : ι, (Real.sign (u i) * u i) ^ (-(1 / 2 : ℝ)) ≠ 0 := by
    intro i
    refine' (ne_of_lt (Real.rpow_pos_of_pos (sign_mul_pos_of_ne_zero _ <| Units.ne_zero _) _)).symm
  convert
    (weightedSumSquares ℝ w).isometryEquivBasisRepr
      ((Pi.basisFun ℝ ι).unitsSMul fun i => (isUnit_iff_ne_zero.2 <| hu' i).unit)
  ext1 v
  rw [basisRepr_apply, weightedSumSquares_apply, weightedSumSquares_apply]
  refine' sum_congr rfl fun j hj => _
  have hsum :
    (∑ i : ι, v i • ((isUnit_iff_ne_zero.2 <| hu' i).unit : ℝ) • (Pi.basisFun ℝ ι) i) j =
      v j • (Real.sign (u j) * u j) ^ (-(1 / 2 : ℝ)) := by
    rw [Finset.sum_apply, sum_eq_single j, Pi.basisFun_apply, IsUnit.unit_spec,
      LinearMap.stdBasis_apply, Pi.smul_apply, Pi.smul_apply, Function.update_same, smul_eq_mul,
      smul_eq_mul, smul_eq_mul, mul_one]
    intro i _ hij
    rw [Pi.basisFun_apply, LinearMap.stdBasis_apply, Pi.smul_apply, Pi.smul_apply,
      Function.update_noteq hij.symm, Pi.zero_apply, smul_eq_mul, smul_eq_mul,
      mul_zero, mul_zero]
    intro hj'; exact False.elim (hj' hj)
  simp_rw [Basis.unitsSMul_apply]
  erw [hsum]
  simp only [Function.comp, smul_eq_mul]
  split_ifs with h
  · simp only [h, zero_smul, zero_mul, Real.sign_zero]
  have hwu : w j = u j := by 

Proof state:
ι : Type u_1
inst✝¹ : Fintype ι
inst✝ : DecidableEq ι
w : ι → ℝ
u : ι → ℝˣ := fun i => if h : w i = 0 then 1 else Units.mk0 (w i) h
hu' : ∀ (i : ι), (sign ↑(u i) * ↑(u i)) ^ (-(1 / 2)) ≠ 0
v : ι → ℝ
j : ι
hj : j ∈ univ
hsum :
  Finset.sum univ
      (fun i => v i • ↑(IsUnit.unit (_ : IsUnit ((sign ↑(u i) * ↑(u i)) ^ (-(1 / 2))))) • (Pi.basisFun ℝ ι) i) j =
    v j • (sign ↑(u j) * ↑(u j)) ^ (-(1 / 2))
h : ¬w j = 0
⊢ w j = ↑(u j)

Next tactic:
simp only [dif_neg h, Units.val_mk0]
/-- The isometry between a weighted sum of squares with weights `u` on the
(non-zero) real numbers and the weighted sum of squares with weights `sign ∘ u`. -/
noncomputable def isometryEquivSignWeightedSumSquares [DecidableEq ι] (w : ι → ℝ) :
    IsometryEquiv (weightedSumSquares ℝ w) (weightedSumSquares ℝ (Real.sign ∘ w)) := by
  let u i := if h : w i = 0 then (1 : ℝˣ) else Units.mk0 (w i) h
  have hu' : ∀ i : ι, (Real.sign (u i) * u i) ^ (-(1 / 2 : ℝ)) ≠ 0 := by
    intro i
    refine' (ne_of_lt (Real.rpow_pos_of_pos (sign_mul_pos_of_ne_zero _ <| Units.ne_zero _) _)).symm
  convert
    (weightedSumSquares ℝ w).isometryEquivBasisRepr
      ((Pi.basisFun ℝ ι).unitsSMul fun i => (isUnit_iff_ne_zero.2 <| hu' i).unit)
  ext1 v
  rw [basisRepr_apply, weightedSumSquares_apply, weightedSumSquares_apply]
  refine' sum_congr rfl fun j hj => _
  have hsum :
    (∑ i : ι, v i • ((isUnit_iff_ne_zero.2 <| hu' i).unit : ℝ) • (Pi.basisFun ℝ ι) i) j =
      v j • (Real.sign (u j) * u j) ^ (-(1 / 2 : ℝ)) := by
    rw [Finset.sum_apply, sum_eq_single j, Pi.basisFun_apply, IsUnit.unit_spec,
      LinearMap.stdBasis_apply, Pi.smul_apply, Pi.smul_apply, Function.update_same, smul_eq_mul,
      smul_eq_mul, smul_eq_mul, mul_one]
    intro i _ hij
    rw [Pi.basisFun_apply, LinearMap.stdBasis_apply, Pi.smul_apply, Pi.smul_apply,
      Function.update_noteq hij.symm, Pi.zero_apply, smul_eq_mul, smul_eq_mul,
      mul_zero, mul_zero]
    intro hj'; exact False.elim (hj' hj)
  simp_rw [Basis.unitsSMul_apply]
  erw [hsum]
  simp only [Function.comp, smul_eq_mul]
  split_ifs with h
  · simp only [h, zero_smul, zero_mul, Real.sign_zero]
  have hwu : w j = u j := by simp only [dif_neg h, Units.val_mk0]
  

Proof state:
case neg
ι : Type u_1
inst✝¹ : Fintype ι
inst✝ : DecidableEq ι
w : ι → ℝ
u : ι → ℝˣ := fun i => if h : w i = 0 then 1 else Units.mk0 (w i) h
hu' : ∀ (i : ι), (sign ↑(u i) * ↑(u i)) ^ (-(1 / 2)) ≠ 0
v : ι → ℝ
j : ι
hj : j ∈ univ
hsum :
  Finset.sum univ
      (fun i => v i • ↑(IsUnit.unit (_ : IsUnit ((sign ↑(u i) * ↑(u i)) ^ (-(1 / 2))))) • (Pi.basisFun ℝ ι) i) j =
    v j • (sign ↑(u j) * ↑(u j)) ^ (-(1 / 2))
h : ¬w j = 0
hwu : w j = ↑(u j)
⊢ sign (w j) * (v j * v j) =
    w j *
      (v j * (sign ↑(Units.mk0 (w j) h) * ↑(Units.mk0 (w j) h)) ^ (-(1 / 2)) *
        (v j * (sign ↑(Units.mk0 (w j) h) * ↑(Units.mk0 (w j) h)) ^ (-(1 / 2))))

Next tactic:
simp only [Units.val_mk0]
/-- The isometry between a weighted sum of squares with weights `u` on the
(non-zero) real numbers and the weighted sum of squares with weights `sign ∘ u`. -/
noncomputable def isometryEquivSignWeightedSumSquares [DecidableEq ι] (w : ι → ℝ) :
    IsometryEquiv (weightedSumSquares ℝ w) (weightedSumSquares ℝ (Real.sign ∘ w)) := by
  let u i := if h : w i = 0 then (1 : ℝˣ) else Units.mk0 (w i) h
  have hu' : ∀ i : ι, (Real.sign (u i) * u i) ^ (-(1 / 2 : ℝ)) ≠ 0 := by
    intro i
    refine' (ne_of_lt (Real.rpow_pos_of_pos (sign_mul_pos_of_ne_zero _ <| Units.ne_zero _) _)).symm
  convert
    (weightedSumSquares ℝ w).isometryEquivBasisRepr
      ((Pi.basisFun ℝ ι).unitsSMul fun i => (isUnit_iff_ne_zero.2 <| hu' i).unit)
  ext1 v
  rw [basisRepr_apply, weightedSumSquares_apply, weightedSumSquares_apply]
  refine' sum_congr rfl fun j hj => _
  have hsum :
    (∑ i : ι, v i • ((isUnit_iff_ne_zero.2 <| hu' i).unit : ℝ) • (Pi.basisFun ℝ ι) i) j =
      v j • (Real.sign (u j) * u j) ^ (-(1 / 2 : ℝ)) := by
    rw [Finset.sum_apply, sum_eq_single j, Pi.basisFun_apply, IsUnit.unit_spec,
      LinearMap.stdBasis_apply, Pi.smul_apply, Pi.smul_apply, Function.update_same, smul_eq_mul,
      smul_eq_mul, smul_eq_mul, mul_one]
    intro i _ hij
    rw [Pi.basisFun_apply, LinearMap.stdBasis_apply, Pi.smul_apply, Pi.smul_apply,
      Function.update_noteq hij.symm, Pi.zero_apply, smul_eq_mul, smul_eq_mul,
      mul_zero, mul_zero]
    intro hj'; exact False.elim (hj' hj)
  simp_rw [Basis.unitsSMul_apply]
  erw [hsum]
  simp only [Function.comp, smul_eq_mul]
  split_ifs with h
  · simp only [h, zero_smul, zero_mul, Real.sign_zero]
  have hwu : w j = u j := by simp only [dif_neg h, Units.val_mk0]
  simp only [Units.val_mk0]
  

Proof state:
case neg
ι : Type u_1
inst✝¹ : Fintype ι
inst✝ : DecidableEq ι
w : ι → ℝ
u : ι → ℝˣ := fun i => if h : w i = 0 then 1 else Units.mk0 (w i) h
hu' : ∀ (i : ι), (sign ↑(u i) * ↑(u i)) ^ (-(1 / 2)) ≠ 0
v : ι → ℝ
j : ι
hj : j ∈ univ
hsum :
  Finset.sum univ
      (fun i => v i • ↑(IsUnit.unit (_ : IsUnit ((sign ↑(u i) * ↑(u i)) ^ (-(1 / 2))))) • (Pi.basisFun ℝ ι) i) j =
    v j • (sign ↑(u j) * ↑(u j)) ^ (-(1 / 2))
h : ¬w j = 0
hwu : w j = ↑(u j)
⊢ sign (w j) * (v j * v j) = w j * (v j * (sign (w j) * w j) ^ (-(1 / 2)) * (v j * (sign (w j) * w j) ^ (-(1 / 2))))

Next tactic:
rw [hwu]
/-- The isometry between a weighted sum of squares with weights `u` on the
(non-zero) real numbers and the weighted sum of squares with weights `sign ∘ u`. -/
noncomputable def isometryEquivSignWeightedSumSquares [DecidableEq ι] (w : ι → ℝ) :
    IsometryEquiv (weightedSumSquares ℝ w) (weightedSumSquares ℝ (Real.sign ∘ w)) := by
  let u i := if h : w i = 0 then (1 : ℝˣ) else Units.mk0 (w i) h
  have hu' : ∀ i : ι, (Real.sign (u i) * u i) ^ (-(1 / 2 : ℝ)) ≠ 0 := by
    intro i
    refine' (ne_of_lt (Real.rpow_pos_of_pos (sign_mul_pos_of_ne_zero _ <| Units.ne_zero _) _)).symm
  convert
    (weightedSumSquares ℝ w).isometryEquivBasisRepr
      ((Pi.basisFun ℝ ι).unitsSMul fun i => (isUnit_iff_ne_zero.2 <| hu' i).unit)
  ext1 v
  rw [basisRepr_apply, weightedSumSquares_apply, weightedSumSquares_apply]
  refine' sum_congr rfl fun j hj => _
  have hsum :
    (∑ i : ι, v i • ((isUnit_iff_ne_zero.2 <| hu' i).unit : ℝ) • (Pi.basisFun ℝ ι) i) j =
      v j • (Real.sign (u j) * u j) ^ (-(1 / 2 : ℝ)) := by
    rw [Finset.sum_apply, sum_eq_single j, Pi.basisFun_apply, IsUnit.unit_spec,
      LinearMap.stdBasis_apply, Pi.smul_apply, Pi.smul_apply, Function.update_same, smul_eq_mul,
      smul_eq_mul, smul_eq_mul, mul_one]
    intro i _ hij
    rw [Pi.basisFun_apply, LinearMap.stdBasis_apply, Pi.smul_apply, Pi.smul_apply,
      Function.update_noteq hij.symm, Pi.zero_apply, smul_eq_mul, smul_eq_mul,
      mul_zero, mul_zero]
    intro hj'; exact False.elim (hj' hj)
  simp_rw [Basis.unitsSMul_apply]
  erw [hsum]
  simp only [Function.comp, smul_eq_mul]
  split_ifs with h
  · simp only [h, zero_smul, zero_mul, Real.sign_zero]
  have hwu : w j = u j := by simp only [dif_neg h, Units.val_mk0]
  simp only [Units.val_mk0]
  rw [hwu]
  

Proof state:
case neg
ι : Type u_1
inst✝¹ : Fintype ι
inst✝ : DecidableEq ι
w : ι → ℝ
u : ι → ℝˣ := fun i => if h : w i = 0 then 1 else Units.mk0 (w i) h
hu' : ∀ (i : ι), (sign ↑(u i) * ↑(u i)) ^ (-(1 / 2)) ≠ 0
v : ι → ℝ
j : ι
hj : j ∈ univ
hsum :
  Finset.sum univ
      (fun i => v i • ↑(IsUnit.unit (_ : IsUnit ((sign ↑(u i) * ↑(u i)) ^ (-(1 / 2))))) • (Pi.basisFun ℝ ι) i) j =
    v j • (sign ↑(u j) * ↑(u j)) ^ (-(1 / 2))
h : ¬w j = 0
hwu : w j = ↑(u j)
⊢ sign ↑(u j) * (v j * v j) =
    ↑(u j) * (v j * (sign ↑(u j) * ↑(u j)) ^ (-(1 / 2)) * (v j * (sign ↑(u j) * ↑(u j)) ^ (-(1 / 2))))

Next tactic:
suffices
    (u j : ℝ).sign * v j * v j =
      (Real.sign (u j) * u j) ^ (-(1 / 2 : ℝ)) * (Real.sign (u j) * u j) ^ (-(1 / 2 : ℝ)) *
            u j *
          v j *
        v j
    by erw [← mul_assoc, this]; ring
/-- The isometry between a weighted sum of squares with weights `u` on the
(non-zero) real numbers and the weighted sum of squares with weights `sign ∘ u`. -/
noncomputable def isometryEquivSignWeightedSumSquares [DecidableEq ι] (w : ι → ℝ) :
    IsometryEquiv (weightedSumSquares ℝ w) (weightedSumSquares ℝ (Real.sign ∘ w)) := by
  let u i := if h : w i = 0 then (1 : ℝˣ) else Units.mk0 (w i) h
  have hu' : ∀ i : ι, (Real.sign (u i) * u i) ^ (-(1 / 2 : ℝ)) ≠ 0 := by
    intro i
    refine' (ne_of_lt (Real.rpow_pos_of_pos (sign_mul_pos_of_ne_zero _ <| Units.ne_zero _) _)).symm
  convert
    (weightedSumSquares ℝ w).isometryEquivBasisRepr
      ((Pi.basisFun ℝ ι).unitsSMul fun i => (isUnit_iff_ne_zero.2 <| hu' i).unit)
  ext1 v
  rw [basisRepr_apply, weightedSumSquares_apply, weightedSumSquares_apply]
  refine' sum_congr rfl fun j hj => _
  have hsum :
    (∑ i : ι, v i • ((isUnit_iff_ne_zero.2 <| hu' i).unit : ℝ) • (Pi.basisFun ℝ ι) i) j =
      v j • (Real.sign (u j) * u j) ^ (-(1 / 2 : ℝ)) := by
    rw [Finset.sum_apply, sum_eq_single j, Pi.basisFun_apply, IsUnit.unit_spec,
      LinearMap.stdBasis_apply, Pi.smul_apply, Pi.smul_apply, Function.update_same, smul_eq_mul,
      smul_eq_mul, smul_eq_mul, mul_one]
    intro i _ hij
    rw [Pi.basisFun_apply, LinearMap.stdBasis_apply, Pi.smul_apply, Pi.smul_apply,
      Function.update_noteq hij.symm, Pi.zero_apply, smul_eq_mul, smul_eq_mul,
      mul_zero, mul_zero]
    intro hj'; exact False.elim (hj' hj)
  simp_rw [Basis.unitsSMul_apply]
  erw [hsum]
  simp only [Function.comp, smul_eq_mul]
  split_ifs with h
  · simp only [h, zero_smul, zero_mul, Real.sign_zero]
  have hwu : w j = u j := by simp only [dif_neg h, Units.val_mk0]
  simp only [Units.val_mk0]
  rw [hwu]
  suffices
    (u j : ℝ).sign * v j * v j =
      (Real.sign (u j) * u j) ^ (-(1 / 2 : ℝ)) * (Real.sign (u j) * u j) ^ (-(1 / 2 : ℝ)) *
            u j *
          v j *
        v j
    by 

Proof state:
ι : Type u_1
inst✝¹ : Fintype ι
inst✝ : DecidableEq ι
w : ι → ℝ
u : ι → ℝˣ := fun i => if h : w i = 0 then 1 else Units.mk0 (w i) h
hu' : ∀ (i : ι), (sign ↑(u i) * ↑(u i)) ^ (-(1 / 2)) ≠ 0
v : ι → ℝ
j : ι
hj : j ∈ univ
hsum :
  Finset.sum univ
      (fun i => v i • ↑(IsUnit.unit (_ : IsUnit ((sign ↑(u i) * ↑(u i)) ^ (-(1 / 2))))) • (Pi.basisFun ℝ ι) i) j =
    v j • (sign ↑(u j) * ↑(u j)) ^ (-(1 / 2))
h : ¬w j = 0
hwu : w j = ↑(u j)
this :
  sign ↑(u j) * v j * v j =
    (sign ↑(u j) * ↑(u j)) ^ (-(1 / 2)) * (sign ↑(u j) * ↑(u j)) ^ (-(1 / 2)) * ↑(u j) * v j * v j
⊢ sign ↑(u j) * (v j * v j) =
    ↑(u j) * (v j * (sign ↑(u j) * ↑(u j)) ^ (-(1 / 2)) * (v j * (sign ↑(u j) * ↑(u j)) ^ (-(1 / 2))))

Next tactic:
erw [← mul_assoc, this]
/-- The isometry between a weighted sum of squares with weights `u` on the
(non-zero) real numbers and the weighted sum of squares with weights `sign ∘ u`. -/
noncomputable def isometryEquivSignWeightedSumSquares [DecidableEq ι] (w : ι → ℝ) :
    IsometryEquiv (weightedSumSquares ℝ w) (weightedSumSquares ℝ (Real.sign ∘ w)) := by
  let u i := if h : w i = 0 then (1 : ℝˣ) else Units.mk0 (w i) h
  have hu' : ∀ i : ι, (Real.sign (u i) * u i) ^ (-(1 / 2 : ℝ)) ≠ 0 := by
    intro i
    refine' (ne_of_lt (Real.rpow_pos_of_pos (sign_mul_pos_of_ne_zero _ <| Units.ne_zero _) _)).symm
  convert
    (weightedSumSquares ℝ w).isometryEquivBasisRepr
      ((Pi.basisFun ℝ ι).unitsSMul fun i => (isUnit_iff_ne_zero.2 <| hu' i).unit)
  ext1 v
  rw [basisRepr_apply, weightedSumSquares_apply, weightedSumSquares_apply]
  refine' sum_congr rfl fun j hj => _
  have hsum :
    (∑ i : ι, v i • ((isUnit_iff_ne_zero.2 <| hu' i).unit : ℝ) • (Pi.basisFun ℝ ι) i) j =
      v j • (Real.sign (u j) * u j) ^ (-(1 / 2 : ℝ)) := by
    rw [Finset.sum_apply, sum_eq_single j, Pi.basisFun_apply, IsUnit.unit_spec,
      LinearMap.stdBasis_apply, Pi.smul_apply, Pi.smul_apply, Function.update_same, smul_eq_mul,
      smul_eq_mul, smul_eq_mul, mul_one]
    intro i _ hij
    rw [Pi.basisFun_apply, LinearMap.stdBasis_apply, Pi.smul_apply, Pi.smul_apply,
      Function.update_noteq hij.symm, Pi.zero_apply, smul_eq_mul, smul_eq_mul,
      mul_zero, mul_zero]
    intro hj'; exact False.elim (hj' hj)
  simp_rw [Basis.unitsSMul_apply]
  erw [hsum]
  simp only [Function.comp, smul_eq_mul]
  split_ifs with h
  · simp only [h, zero_smul, zero_mul, Real.sign_zero]
  have hwu : w j = u j := by simp only [dif_neg h, Units.val_mk0]
  simp only [Units.val_mk0]
  rw [hwu]
  suffices
    (u j : ℝ).sign * v j * v j =
      (Real.sign (u j) * u j) ^ (-(1 / 2 : ℝ)) * (Real.sign (u j) * u j) ^ (-(1 / 2 : ℝ)) *
            u j *
          v j *
        v j
    by erw [← mul_assoc, this]; 

Proof state:
ι : Type u_1
inst✝¹ : Fintype ι
inst✝ : DecidableEq ι
w : ι → ℝ
u : ι → ℝˣ := fun i => if h : w i = 0 then 1 else Units.mk0 (w i) h
hu' : ∀ (i : ι), (sign ↑(u i) * ↑(u i)) ^ (-(1 / 2)) ≠ 0
v : ι → ℝ
j : ι
hj : j ∈ univ
hsum :
  Finset.sum univ
      (fun i => v i • ↑(IsUnit.unit (_ : IsUnit ((sign ↑(u i) * ↑(u i)) ^ (-(1 / 2))))) • (Pi.basisFun ℝ ι) i) j =
    v j • (sign ↑(u j) * ↑(u j)) ^ (-(1 / 2))
h : ¬w j = 0
hwu : w j = ↑(u j)
this :
  sign ↑(u j) * v j * v j =
    (sign ↑(u j) * ↑(u j)) ^ (-(1 / 2)) * (sign ↑(u j) * ↑(u j)) ^ (-(1 / 2)) * ↑(u j) * v j * v j
⊢ (sign ↑(u j) * ↑(u j)) ^ (-(1 / 2)) * (sign ↑(u j) * ↑(u j)) ^ (-(1 / 2)) * ↑(u j) * v j * v j =
    ↑(u j) * (v j * (sign ↑(u j) * ↑(u j)) ^ (-(1 / 2)) * (v j * (sign ↑(u j) * ↑(u j)) ^ (-(1 / 2))))

Next tactic:
ring
/-- The isometry between a weighted sum of squares with weights `u` on the
(non-zero) real numbers and the weighted sum of squares with weights `sign ∘ u`. -/
noncomputable def isometryEquivSignWeightedSumSquares [DecidableEq ι] (w : ι → ℝ) :
    IsometryEquiv (weightedSumSquares ℝ w) (weightedSumSquares ℝ (Real.sign ∘ w)) := by
  let u i := if h : w i = 0 then (1 : ℝˣ) else Units.mk0 (w i) h
  have hu' : ∀ i : ι, (Real.sign (u i) * u i) ^ (-(1 / 2 : ℝ)) ≠ 0 := by
    intro i
    refine' (ne_of_lt (Real.rpow_pos_of_pos (sign_mul_pos_of_ne_zero _ <| Units.ne_zero _) _)).symm
  convert
    (weightedSumSquares ℝ w).isometryEquivBasisRepr
      ((Pi.basisFun ℝ ι).unitsSMul fun i => (isUnit_iff_ne_zero.2 <| hu' i).unit)
  ext1 v
  rw [basisRepr_apply, weightedSumSquares_apply, weightedSumSquares_apply]
  refine' sum_congr rfl fun j hj => _
  have hsum :
    (∑ i : ι, v i • ((isUnit_iff_ne_zero.2 <| hu' i).unit : ℝ) • (Pi.basisFun ℝ ι) i) j =
      v j • (Real.sign (u j) * u j) ^ (-(1 / 2 : ℝ)) := by
    rw [Finset.sum_apply, sum_eq_single j, Pi.basisFun_apply, IsUnit.unit_spec,
      LinearMap.stdBasis_apply, Pi.smul_apply, Pi.smul_apply, Function.update_same, smul_eq_mul,
      smul_eq_mul, smul_eq_mul, mul_one]
    intro i _ hij
    rw [Pi.basisFun_apply, LinearMap.stdBasis_apply, Pi.smul_apply, Pi.smul_apply,
      Function.update_noteq hij.symm, Pi.zero_apply, smul_eq_mul, smul_eq_mul,
      mul_zero, mul_zero]
    intro hj'; exact False.elim (hj' hj)
  simp_rw [Basis.unitsSMul_apply]
  erw [hsum]
  simp only [Function.comp, smul_eq_mul]
  split_ifs with h
  · simp only [h, zero_smul, zero_mul, Real.sign_zero]
  have hwu : w j = u j := by simp only [dif_neg h, Units.val_mk0]
  simp only [Units.val_mk0]
  rw [hwu]
  suffices
    (u j : ℝ).sign * v j * v j =
      (Real.sign (u j) * u j) ^ (-(1 / 2 : ℝ)) * (Real.sign (u j) * u j) ^ (-(1 / 2 : ℝ)) *
            u j *
          v j *
        v j
    by erw [← mul_assoc, this]; ring
  

Proof state:
case neg
ι : Type u_1
inst✝¹ : Fintype ι
inst✝ : DecidableEq ι
w : ι → ℝ
u : ι → ℝˣ := fun i => if h : w i = 0 then 1 else Units.mk0 (w i) h
hu' : ∀ (i : ι), (sign ↑(u i) * ↑(u i)) ^ (-(1 / 2)) ≠ 0
v : ι → ℝ
j : ι
hj : j ∈ univ
hsum :
  Finset.sum univ
      (fun i => v i • ↑(IsUnit.unit (_ : IsUnit ((sign ↑(u i) * ↑(u i)) ^ (-(1 / 2))))) • (Pi.basisFun ℝ ι) i) j =
    v j • (sign ↑(u j) * ↑(u j)) ^ (-(1 / 2))
h : ¬w j = 0
hwu : w j = ↑(u j)
⊢ sign ↑(u j) * v j * v j =
    (sign ↑(u j) * ↑(u j)) ^ (-(1 / 2)) * (sign ↑(u j) * ↑(u j)) ^ (-(1 / 2)) * ↑(u j) * v j * v j

Next tactic:
rw [← Real.rpow_add (sign_mul_pos_of_ne_zero _ <| Units.ne_zero _),
    show -(1 / 2 : ℝ) + -(1 / 2) = -1 by ring, Real.rpow_neg_one, mul_inv, inv_sign,
    mul_assoc (Real.sign (u j)) (u j)⁻¹, inv_mul_cancel (Units.ne_zero _), mul_one]
/-- The isometry between a weighted sum of squares with weights `u` on the
(non-zero) real numbers and the weighted sum of squares with weights `sign ∘ u`. -/
noncomputable def isometryEquivSignWeightedSumSquares [DecidableEq ι] (w : ι → ℝ) :
    IsometryEquiv (weightedSumSquares ℝ w) (weightedSumSquares ℝ (Real.sign ∘ w)) := by
  let u i := if h : w i = 0 then (1 : ℝˣ) else Units.mk0 (w i) h
  have hu' : ∀ i : ι, (Real.sign (u i) * u i) ^ (-(1 / 2 : ℝ)) ≠ 0 := by
    intro i
    refine' (ne_of_lt (Real.rpow_pos_of_pos (sign_mul_pos_of_ne_zero _ <| Units.ne_zero _) _)).symm
  convert
    (weightedSumSquares ℝ w).isometryEquivBasisRepr
      ((Pi.basisFun ℝ ι).unitsSMul fun i => (isUnit_iff_ne_zero.2 <| hu' i).unit)
  ext1 v
  rw [basisRepr_apply, weightedSumSquares_apply, weightedSumSquares_apply]
  refine' sum_congr rfl fun j hj => _
  have hsum :
    (∑ i : ι, v i • ((isUnit_iff_ne_zero.2 <| hu' i).unit : ℝ) • (Pi.basisFun ℝ ι) i) j =
      v j • (Real.sign (u j) * u j) ^ (-(1 / 2 : ℝ)) := by
    rw [Finset.sum_apply, sum_eq_single j, Pi.basisFun_apply, IsUnit.unit_spec,
      LinearMap.stdBasis_apply, Pi.smul_apply, Pi.smul_apply, Function.update_same, smul_eq_mul,
      smul_eq_mul, smul_eq_mul, mul_one]
    intro i _ hij
    rw [Pi.basisFun_apply, LinearMap.stdBasis_apply, Pi.smul_apply, Pi.smul_apply,
      Function.update_noteq hij.symm, Pi.zero_apply, smul_eq_mul, smul_eq_mul,
      mul_zero, mul_zero]
    intro hj'; exact False.elim (hj' hj)
  simp_rw [Basis.unitsSMul_apply]
  erw [hsum]
  simp only [Function.comp, smul_eq_mul]
  split_ifs with h
  · simp only [h, zero_smul, zero_mul, Real.sign_zero]
  have hwu : w j = u j := by simp only [dif_neg h, Units.val_mk0]
  simp only [Units.val_mk0]
  rw [hwu]
  suffices
    (u j : ℝ).sign * v j * v j =
      (Real.sign (u j) * u j) ^ (-(1 / 2 : ℝ)) * (Real.sign (u j) * u j) ^ (-(1 / 2 : ℝ)) *
            u j *
          v j *
        v j
    by erw [← mul_assoc, this]; ring
  rw [← Real.rpow_add (sign_mul_pos_of_ne_zero _ <| Units.ne_zero _),
    show -(1 / 2 : ℝ) + -(1 / 2) = -1 by 

Proof state:
ι : Type u_1
inst✝¹ : Fintype ι
inst✝ : DecidableEq ι
w : ι → ℝ
u : ι → ℝˣ := fun i => if h : w i = 0 then 1 else Units.mk0 (w i) h
hu' : ∀ (i : ι), (sign ↑(u i) * ↑(u i)) ^ (-(1 / 2)) ≠ 0
v : ι → ℝ
j : ι
hj : j ∈ univ
hsum :
  Finset.sum univ
      (fun i => v i • ↑(IsUnit.unit (_ : IsUnit ((sign ↑(u i) * ↑(u i)) ^ (-(1 / 2))))) • (Pi.basisFun ℝ ι) i) j =
    v j • (sign ↑(u j) * ↑(u j)) ^ (-(1 / 2))
h : ¬w j = 0
hwu : w j = ↑(u j)
⊢ -(1 / 2) + -(1 / 2) = -1

Next tactic:
ring
lemma zero_le_two [Preorder α] [ZeroLEOneClass α] [CovariantClass α α (·+·) (·≤·)] :
    (0 : α) ≤ 2 := by
  

Proof state:
α : Type u_1
inst✝³ : AddMonoidWithOne α
inst✝² : Preorder α
inst✝¹ : ZeroLEOneClass α
inst✝ : CovariantClass α α (fun x x_1 => x + x_1) fun x x_1 => x ≤ x_1
⊢ 0 ≤ 2

Next tactic:
rw [← one_add_one_eq_two]
lemma zero_le_two [Preorder α] [ZeroLEOneClass α] [CovariantClass α α (·+·) (·≤·)] :
    (0 : α) ≤ 2 := by
  rw [← one_add_one_eq_two]
  

Proof state:
α : Type u_1
inst✝³ : AddMonoidWithOne α
inst✝² : Preorder α
inst✝¹ : ZeroLEOneClass α
inst✝ : CovariantClass α α (fun x x_1 => x + x_1) fun x x_1 => x ≤ x_1
⊢ 0 ≤ 1 + 1

Next tactic:
exact add_nonneg zero_le_one zero_le_one
lemma zero_le_three [Preorder α] [ZeroLEOneClass α] [CovariantClass α α (·+·) (·≤·)] :
    (0 : α) ≤ 3 := by
  

Proof state:
α : Type u_1
inst✝³ : AddMonoidWithOne α
inst✝² : Preorder α
inst✝¹ : ZeroLEOneClass α
inst✝ : CovariantClass α α (fun x x_1 => x + x_1) fun x x_1 => x ≤ x_1
⊢ 0 ≤ 3

Next tactic:
rw [← two_add_one_eq_three]
lemma zero_le_three [Preorder α] [ZeroLEOneClass α] [CovariantClass α α (·+·) (·≤·)] :
    (0 : α) ≤ 3 := by
  rw [← two_add_one_eq_three]
  

Proof state:
α : Type u_1
inst✝³ : AddMonoidWithOne α
inst✝² : Preorder α
inst✝¹ : ZeroLEOneClass α
inst✝ : CovariantClass α α (fun x x_1 => x + x_1) fun x x_1 => x ≤ x_1
⊢ 0 ≤ 2 + 1

Next tactic:
exact add_nonneg zero_le_two zero_le_one
lemma zero_le_four [Preorder α] [ZeroLEOneClass α] [CovariantClass α α (·+·) (·≤·)] :
    (0 : α) ≤ 4 := by
  

Proof state:
α : Type u_1
inst✝³ : AddMonoidWithOne α
inst✝² : Preorder α
inst✝¹ : ZeroLEOneClass α
inst✝ : CovariantClass α α (fun x x_1 => x + x_1) fun x x_1 => x ≤ x_1
⊢ 0 ≤ 4

Next tactic:
rw [← three_add_one_eq_four]