Skip to content

Commit

Permalink
refactor: remove PiLp.equiv (#6501)
Browse files Browse the repository at this point in the history
This removes the `(PiLp.equiv 2 fun i => α i)` abbreviation, replacing it with its implementation `(WithLp.equiv 2 (∀ i, α i))`. The same thing is done for `PiLp.linearEquiv`.
  • Loading branch information
eric-wieser committed Aug 30, 2023
1 parent 0a341a6 commit bfb6bb7
Show file tree
Hide file tree
Showing 9 changed files with 107 additions and 103 deletions.
38 changes: 19 additions & 19 deletions Mathlib/Analysis/InnerProductSpace/PiL2.lean
Expand Up @@ -166,12 +166,12 @@ theorem finrank_euclideanSpace_fin {n : ℕ} :
#align finrank_euclidean_space_fin finrank_euclideanSpace_fin

theorem EuclideanSpace.inner_eq_star_dotProduct (x y : EuclideanSpace 𝕜 ι) :
⟪x, y⟫ = Matrix.dotProduct (star <| PiLp.equiv _ _ x) (PiLp.equiv _ _ y) :=
⟪x, y⟫ = Matrix.dotProduct (star <| WithLp.equiv _ _ x) (WithLp.equiv _ _ y) :=
rfl
#align euclidean_space.inner_eq_star_dot_product EuclideanSpace.inner_eq_star_dotProduct

theorem EuclideanSpace.inner_piLp_equiv_symm (x y : ι → 𝕜) :
⟪(PiLp.equiv 2 _).symm x, (PiLp.equiv 2 _).symm y⟫ = Matrix.dotProduct (star x) y :=
⟪(WithLp.equiv 2 _).symm x, (WithLp.equiv 2 _).symm y⟫ = Matrix.dotProduct (star x) y :=
rfl
#align euclidean_space.inner_pi_Lp_equiv_symm EuclideanSpace.inner_piLp_equiv_symm

Expand Down Expand Up @@ -227,7 +227,7 @@ variable {ι 𝕜}
/-- The projection on the `i`-th coordinate of `EuclideanSpace 𝕜 ι`, as a linear map. -/
@[simps!]
def EuclideanSpace.projₗ (i : ι) : EuclideanSpace 𝕜 ι →ₗ[𝕜] 𝕜 :=
(LinearMap.proj i).comp (PiLp.linearEquiv 2 𝕜 fun _ : ι => 𝕜 : EuclideanSpace 𝕜 ι →ₗ[𝕜] ι → 𝕜)
(LinearMap.proj i).comp (WithLp.linearEquiv 2 𝕜 (ι → 𝕜) : EuclideanSpace 𝕜 ι →ₗ[𝕜] ι → 𝕜)
#align euclidean_space.projₗ EuclideanSpace.projₗ
#align euclidean_space.projₗ_apply EuclideanSpace.projₗ_apply

Expand All @@ -245,25 +245,25 @@ def EuclideanSpace.proj (i : ι) : EuclideanSpace 𝕜 ι →L[𝕜] 𝕜 :=
/-- The vector given in euclidean space by being `1 : 𝕜` at coordinate `i : ι` and `0 : 𝕜` at
all other coordinates. -/
def EuclideanSpace.single [DecidableEq ι] (i : ι) (a : 𝕜) : EuclideanSpace 𝕜 ι :=
(PiLp.equiv _ _).symm (Pi.single i a)
(WithLp.equiv _ _).symm (Pi.single i a)
#align euclidean_space.single EuclideanSpace.single

@[simp]
theorem PiLp.equiv_single [DecidableEq ι] (i : ι) (a : 𝕜) :
PiLp.equiv _ _ (EuclideanSpace.single i a) = Pi.single i a :=
theorem WithLp.equiv_single [DecidableEq ι] (i : ι) (a : 𝕜) :
WithLp.equiv _ _ (EuclideanSpace.single i a) = Pi.single i a :=
rfl
#align pi_Lp.equiv_single PiLp.equiv_single
#align pi_Lp.equiv_single WithLp.equiv_single

@[simp]
theorem PiLp.equiv_symm_single [DecidableEq ι] (i : ι) (a : 𝕜) :
(PiLp.equiv _ _).symm (Pi.single i a) = EuclideanSpace.single i a :=
theorem WithLp.equiv_symm_single [DecidableEq ι] (i : ι) (a : 𝕜) :
(WithLp.equiv _ _).symm (Pi.single i a) = EuclideanSpace.single i a :=
rfl
#align pi_Lp.equiv_symm_single PiLp.equiv_symm_single
#align pi_Lp.equiv_symm_single WithLp.equiv_symm_single

@[simp]
theorem EuclideanSpace.single_apply [DecidableEq ι] (i : ι) (a : 𝕜) (j : ι) :
(EuclideanSpace.single i a) j = ite (j = i) a 0 := by
rw [EuclideanSpace.single, PiLp.equiv_symm_apply, ← Pi.single_apply i a j]
rw [EuclideanSpace.single, WithLp.equiv_symm_pi_apply, ← Pi.single_apply i a j]
#align euclidean_space.single_apply EuclideanSpace.single_apply

theorem EuclideanSpace.inner_single_left [DecidableEq ι] (i : ι) (a : 𝕜) (v : EuclideanSpace 𝕜 ι) :
Expand Down Expand Up @@ -351,14 +351,14 @@ instance instFunLike : FunLike (OrthonormalBasis ι 𝕜 E) ι fun _ => E where
coe_injective' b b' h := repr_injective <| LinearIsometryEquiv.toLinearEquiv_injective <|
LinearEquiv.symm_bijective.injective <| LinearEquiv.toLinearMap_injective <| by
classical
rw [← LinearMap.cancel_right (PiLp.linearEquiv 2 𝕜 (fun _ => 𝕜)).symm.surjective]
rw [← LinearMap.cancel_right (WithLp.linearEquiv 2 𝕜 (_ → 𝕜)).symm.surjective]
simp only [LinearIsometryEquiv.toLinearEquiv_symm]
refine LinearMap.pi_ext fun i k => ?_
have : k = k • (1 : 𝕜) := by rw [smul_eq_mul, mul_one]
rw [this, Pi.single_smul]
replace h := congr_fun h i
simp only [LinearEquiv.comp_coe, SMulHomClass.map_smul, LinearEquiv.coe_coe,
LinearEquiv.trans_apply, WithLp.linearEquiv_symm_apply, PiLp.equiv_symm_single,
LinearEquiv.trans_apply, WithLp.linearEquiv_symm_apply, WithLp.equiv_symm_single,
LinearIsometryEquiv.coe_toLinearEquiv] at h ⊢
rw [h]

Expand Down Expand Up @@ -972,20 +972,20 @@ variable [Fintype m] [Fintype n] [DecidableEq n]
/-- `Matrix.toLin'` adapted for `EuclideanSpace 𝕜 _`. -/
def toEuclideanLin : Matrix m n 𝕜 ≃ₗ[𝕜] EuclideanSpace 𝕜 n →ₗ[𝕜] EuclideanSpace 𝕜 m :=
Matrix.toLin' ≪≫ₗ
LinearEquiv.arrowCongr (PiLp.linearEquiv _ 𝕜 fun _ : n => 𝕜).symm
(PiLp.linearEquiv _ 𝕜 fun _ : m => 𝕜).symm
LinearEquiv.arrowCongr (WithLp.linearEquiv _ 𝕜 (n → 𝕜)).symm
(WithLp.linearEquiv _ 𝕜 (m → 𝕜)).symm
#align matrix.to_euclidean_lin Matrix.toEuclideanLin

@[simp]
theorem toEuclideanLin_piLp_equiv_symm (A : Matrix m n 𝕜) (x : n → 𝕜) :
Matrix.toEuclideanLin A ((PiLp.equiv _ _).symm x) =
(PiLp.equiv _ _).symm (Matrix.toLin' A x) :=
Matrix.toEuclideanLin A ((WithLp.equiv _ _).symm x) =
(WithLp.equiv _ _).symm (Matrix.toLin' A x) :=
rfl
#align matrix.to_euclidean_lin_pi_Lp_equiv_symm Matrix.toEuclideanLin_piLp_equiv_symm

@[simp]
theorem piLp_equiv_toEuclideanLin (A : Matrix m n 𝕜) (x : EuclideanSpace 𝕜 n) :
PiLp.equiv _ _ (Matrix.toEuclideanLin A x) = Matrix.toLin' A (PiLp.equiv _ _ x) :=
WithLp.equiv _ _ (Matrix.toEuclideanLin A x) = Matrix.toLin' A (WithLp.equiv _ _ x) :=
rfl
#align matrix.pi_Lp_equiv_to_euclidean_lin Matrix.piLp_equiv_toEuclideanLin

Expand All @@ -999,7 +999,7 @@ theorem toEuclideanLin_eq_toLin :
end Matrix

local notation "⟪" x ", " y "⟫ₑ" =>
@inner 𝕜 _ _ (Equiv.symm (PiLp.equiv 2 _) x) (Equiv.symm (PiLp.equiv 2 _) y)
@inner 𝕜 _ _ (Equiv.symm (WithLp.equiv 2 _) x) (Equiv.symm (WithLp.equiv 2 _) y)

/-- The inner product of a row of `A` and a row of `B` is an entry of `B * Aᴴ`. -/
theorem inner_matrix_row_row [Fintype n] (A B : Matrix m n 𝕜) (i j : m) :
Expand Down
30 changes: 15 additions & 15 deletions Mathlib/Analysis/Matrix.lean
Expand Up @@ -253,7 +253,7 @@ variable [SeminormedAddCommGroup α]
theorem linfty_op_norm_def (A : Matrix m n α) :
‖A‖ = ((Finset.univ : Finset m).sup fun i : m => ∑ j : n, ‖A i j‖₊ : ℝ≥0) := by
-- porting note: added
change ‖fun i => (PiLp.equiv 1 _).symm (A i)‖ = _
change ‖fun i => (WithLp.equiv 1 _).symm (A i)‖ = _
simp [Pi.norm_def, PiLp.nnnorm_eq_sum ENNReal.one_ne_top]
#align matrix.linfty_op_norm_def Matrix.linfty_op_norm_def

Expand Down Expand Up @@ -434,10 +434,10 @@ variable [SeminormedAddCommGroup α] [SeminormedAddCommGroup β]

theorem frobenius_nnnorm_def (A : Matrix m n α) :
‖A‖₊ = (∑ i, ∑ j, ‖A i j‖₊ ^ (2 : ℝ)) ^ (1 / 2 : ℝ) := by
-- porting note: added, along with `PiLp.equiv_symm_apply` below
change ‖(PiLp.equiv 2 _).symm <| fun i => (PiLp.equiv 2 _).symm <| fun j => A i j‖₊ = _
-- porting note: added, along with `WithLp.equiv_symm_pi_apply` below
change ‖(WithLp.equiv 2 _).symm <| fun i => (WithLp.equiv 2 _).symm <| fun j => A i j‖₊ = _
simp_rw [PiLp.nnnorm_eq_of_L2, NNReal.sq_sqrt, NNReal.sqrt_eq_rpow, NNReal.rpow_two,
PiLp.equiv_symm_apply]
WithLp.equiv_symm_pi_apply]
#align matrix.frobenius_nnnorm_def Matrix.frobenius_nnnorm_def

theorem frobenius_norm_def (A : Matrix m n α) :
Expand Down Expand Up @@ -485,30 +485,30 @@ instance frobenius_normedStarGroup [StarAddMonoid α] [NormedStarGroup α] :
#align matrix.frobenius_normed_star_group Matrix.frobenius_normedStarGroup

@[simp]
theorem frobenius_norm_row (v : m → α) : ‖row v‖ = ‖(PiLp.equiv 2 _).symm v‖ := by
theorem frobenius_norm_row (v : m → α) : ‖row v‖ = ‖(WithLp.equiv 2 _).symm v‖ := by
rw [frobenius_norm_def, Fintype.sum_unique, PiLp.norm_eq_of_L2, Real.sqrt_eq_rpow]
simp only [row_apply, Real.rpow_two, PiLp.equiv_symm_apply]
simp only [row_apply, Real.rpow_two, WithLp.equiv_symm_pi_apply]
#align matrix.frobenius_norm_row Matrix.frobenius_norm_row

@[simp]
theorem frobenius_nnnorm_row (v : m → α) : ‖row v‖₊ = ‖(PiLp.equiv 2 _).symm v‖₊ :=
theorem frobenius_nnnorm_row (v : m → α) : ‖row v‖₊ = ‖(WithLp.equiv 2 _).symm v‖₊ :=
Subtype.ext <| frobenius_norm_row v
#align matrix.frobenius_nnnorm_row Matrix.frobenius_nnnorm_row

@[simp]
theorem frobenius_norm_col (v : n → α) : ‖col v‖ = ‖(PiLp.equiv 2 _).symm v‖ := by
theorem frobenius_norm_col (v : n → α) : ‖col v‖ = ‖(WithLp.equiv 2 _).symm v‖ := by
simp_rw [frobenius_norm_def, Fintype.sum_unique, PiLp.norm_eq_of_L2, Real.sqrt_eq_rpow]
simp only [col_apply, Real.rpow_two, PiLp.equiv_symm_apply]
simp only [col_apply, Real.rpow_two, WithLp.equiv_symm_pi_apply]
#align matrix.frobenius_norm_col Matrix.frobenius_norm_col

@[simp]
theorem frobenius_nnnorm_col (v : n → α) : ‖col v‖₊ = ‖(PiLp.equiv 2 _).symm v‖₊ :=
theorem frobenius_nnnorm_col (v : n → α) : ‖col v‖₊ = ‖(WithLp.equiv 2 _).symm v‖₊ :=
Subtype.ext <| frobenius_norm_col v
#align matrix.frobenius_nnnorm_col Matrix.frobenius_nnnorm_col

@[simp]
theorem frobenius_nnnorm_diagonal [DecidableEq n] (v : n → α) :
‖diagonal v‖₊ = ‖(PiLp.equiv 2 _).symm v‖₊ := by
‖diagonal v‖₊ = ‖(WithLp.equiv 2 _).symm v‖₊ := by
simp_rw [frobenius_nnnorm_def, ← Finset.sum_product', Finset.univ_product_univ,
PiLp.nnnorm_eq_of_L2]
let s := (Finset.univ : Finset n).map ⟨fun i : n => (i, i), fun i j h => congr_arg Prod.fst h⟩
Expand All @@ -523,7 +523,7 @@ theorem frobenius_nnnorm_diagonal [DecidableEq n] (v : n → α) :

@[simp]
theorem frobenius_norm_diagonal [DecidableEq n] (v : n → α) :
‖diagonal v‖ = ‖(PiLp.equiv 2 _).symm v‖ :=
‖diagonal v‖ = ‖(WithLp.equiv 2 _).symm v‖ :=
(congr_arg ((↑) : ℝ≥0 → ℝ) <| frobenius_nnnorm_diagonal v : _).trans rfl
#align matrix.frobenius_norm_diagonal Matrix.frobenius_norm_diagonal

Expand Down Expand Up @@ -552,9 +552,9 @@ theorem frobenius_nnnorm_mul (A : Matrix l m α) (B : Matrix m n α) : ‖A * B
mul_div_cancel' (1 : ℝ) two_ne_zero, NNReal.rpow_one, NNReal.mul_rpow]
dsimp only
have :=
@nnnorm_inner_le_nnnorm α _ _ _ _ ((PiLp.equiv 2 fun _ => α).symm fun j => star (A i j))
((PiLp.equiv 2 fun _ => α).symm fun k => B k j)
simpa only [PiLp.equiv_symm_apply, PiLp.inner_apply, IsROrC.inner_apply, starRingEnd_apply,
@nnnorm_inner_le_nnnorm α _ _ _ _ ((WithLp.equiv 2 <| _ α).symm fun j => star (A i j))
((WithLp.equiv 2 <| _ α).symm fun k => B k j)
simpa only [WithLp.equiv_symm_pi_apply, PiLp.inner_apply, IsROrC.inner_apply, starRingEnd_apply,
Pi.nnnorm_def, PiLp.nnnorm_eq_of_L2, star_star, nnnorm_star, NNReal.sqrt_eq_rpow,
NNReal.rpow_two] using this
#align matrix.frobenius_nnnorm_mul Matrix.frobenius_nnnorm_mul
Expand Down

0 comments on commit bfb6bb7

Please sign in to comment.