Skip to content

Commit bbde3ce

Browse files
j-loreauxReemMelamed
authored andcommitted
feat: clean up PositiveLinearMap and add API (leanprover-community#40492)
Among other things, this removes the coercion from the morphism class into the morphism type, and renames the underlying convenience constructor to `PositiveLinearMap.ofClass`.
1 parent f2ea2f2 commit bbde3ce

2 files changed

Lines changed: 36 additions & 12 deletions

File tree

Mathlib/Algebra/Order/Module/PositiveLinearMap.lean

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,23 @@ add_decl_doc PositiveLinearMap.toOrderHom
3838
/-- Notation for a `PositiveLinearMap`. -/
3939
notation:25 E " →ₚ[" R:25 "] " F:0 => PositiveLinearMap R E F
4040

41-
namespace PositiveLinearMapClass
41+
section PositiveLinearMapClass
4242

4343
variable {F R E₁ E₂ : Type*} [Semiring R]
4444
[AddCommMonoid E₁] [PartialOrder E₁] [AddCommMonoid E₂] [PartialOrder E₂]
4545
[Module R E₁] [Module R E₂] [FunLike F E₁ E₂] [LinearMapClass F R E₁ E₂]
4646
[OrderHomClass F E₁ E₂]
4747

4848
/-- Reinterpret an element of a type of positive linear maps as a positive linear map. -/
49-
def toPositiveLinearMap (f : F) : E₁ →ₚ[R] E₂ :=
49+
def PositiveLinearMap.ofClass (f : F) : E₁ →ₚ[R] E₂ :=
5050
{ (f : E₁ →ₗ[R] E₂), (f : E₁ →o E₂) with }
5151

52-
/-- Reinterpret an element of a type of positive linear maps as a positive linear map. -/
53-
instance instCoeToLinearMap : CoeHead F (E₁ →ₚ[R] E₂) where
54-
coe f := toPositiveLinearMap f
52+
@[deprecated (since := "2026-06-10")]
53+
alias PositiveLinearMapClass.toPositiveLinearMap := PositiveLinearMap.ofClass
5554

56-
/-- An additive group homomorphism that maps nonnegative elements to nonnegative elements
57-
is an order homomorphism. -/
58-
lemma _root_.OrderHomClass.of_addMonoidHom {F' E₁' E₂' : Type*} [FunLike F' E₁' E₂'] [AddGroup E₁']
55+
/-- A type of additive group homomorphisms that map nonnegative elements to nonnegative elements
56+
is also a type of order homomorphisms. -/
57+
lemma OrderHomClass.of_addMonoidHom {F' E₁' E₂' : Type*} [FunLike F' E₁' E₂'] [AddGroup E₁']
5958
[LE E₁'] [AddRightMono E₁'] [AddGroup E₂'] [LE E₂'] [AddRightMono E₂']
6059
[AddMonoidHomClass F' E₁' E₂']
6160
(h : ∀ f : F', ∀ x, 0 ≤ x → 0 ≤ f x) : OrderHomClass F' E₁' E₂' where
@@ -67,9 +66,11 @@ namespace PositiveLinearMap
6766

6867
section general
6968

70-
variable {R E₁ E₂ : Type*} [Semiring R]
71-
[AddCommMonoid E₁] [PartialOrder E₁] [AddCommMonoid E₂] [PartialOrder E₂]
72-
[Module R E₁] [Module R E₂]
69+
variable {R E₁ E₂ E₃ : Type*} [Semiring R]
70+
[AddCommMonoid E₁] [PartialOrder E₁]
71+
[AddCommMonoid E₂] [PartialOrder E₂]
72+
[AddCommMonoid E₃] [PartialOrder E₃]
73+
[Module R E₁] [Module R E₂] [Module R E₃]
7374

7475
instance : FunLike (E₁ →ₚ[R] E₂) E₁ E₂ where
7576
coe f := f.toFun
@@ -80,10 +81,33 @@ instance : FunLike (E₁ →ₚ[R] E₂) E₁ E₂ where
8081
apply DFunLike.coe_injective
8182
exact h
8283

84+
initialize_simps_projections PositiveLinearMap (toFun → apply, as_prefix toLinearMap)
85+
8386
@[ext]
8487
lemma ext {f g : E₁ →ₚ[R] E₂} (h : ∀ x, f x = g x) : f = g :=
8588
DFunLike.ext f g h
8689

90+
variable (R E₁) in
91+
/-- The identity as a positive linear map. -/
92+
@[simps! apply toLinearMap] protected def id : E₁ →ₚ[R] E₁ where
93+
__ := LinearMap.id
94+
__ := OrderHom.id
95+
96+
@[simp] lemma toOrderHom_id : (PositiveLinearMap.id R E₁).toOrderHom = .id := rfl
97+
98+
/-- The composition of positive linear maps is again a positive linear map. -/
99+
@[simps! apply toLinearMap]
100+
def comp (g : E₂ →ₚ[R] E₃) (f : E₁ →ₚ[R] E₂) : E₁ →ₚ[R] E₃ where
101+
toLinearMap := g.toLinearMap.comp f.toLinearMap
102+
monotone' := g.monotone'.comp f.monotone'
103+
104+
@[simp] lemma toOrderHom_comp (g : E₂ →ₚ[R] E₃) (f : E₁ →ₚ[R] E₂) :
105+
(g.comp f).toOrderHom = g.toOrderHom.comp f.toOrderHom :=
106+
rfl
107+
108+
@[simp] lemma comp_id (f : E₁ →ₚ[R] E₂) : f.comp (.id R E₁) = f := rfl
109+
@[simp] lemma id_comp (f : E₁ →ₚ[R] E₂) : (PositiveLinearMap.id R E₂).comp f = f := rfl
110+
87111
instance : LinearMapClass (E₁ →ₚ[R] E₂) R E₁ E₂ where
88112
map_add f := map_add f.toLinearMap
89113
map_smulₛₗ f := f.toLinearMap.map_smul'

Mathlib/Analysis/CStarAlgebra/PositiveLinearMap.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ instance {F : Type*} [FunLike F A₁ A₂] [LinearMapClass F ℂ A₁ A₂] [Ord
130130
ContinuousLinearMapClass F ℂ A₁ A₂ where
131131
map_continuous f := by
132132
have hbound : ∃ C : ℝ, ∀ a, ‖f a‖ ≤ C * ‖a‖ := by
133-
obtain ⟨C, h⟩ := exists_norm_apply_le (f : A₁ →ₚ[ℂ] A₂)
133+
obtain ⟨C, h⟩ := exists_norm_apply_le (.ofClass f)
134134
exact ⟨C, h⟩
135135
exact (LinearMap.mkContinuousOfExistsBound (f : A₁ →ₗ[ℂ] A₂) hbound).continuous
136136

0 commit comments

Comments
 (0)