From d60541cce8bd861d389c48df5bd40d0035bf9faf Mon Sep 17 00:00:00 2001 From: mcdoll Date: Sun, 16 Jan 2022 13:03:59 +0000 Subject: [PATCH] feat(analysis/seminorm): Add `has_add` and `has_scalar nnreal` (#11414) Add instances of `has_add` and `has_scalar nnreal` type classes for `seminorm`. Co-authored-by: Eric Wieser Co-authored-by: Eric Wieser --- src/analysis/seminorm.lean | 69 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 67 insertions(+), 2 deletions(-) diff --git a/src/analysis/seminorm.lean b/src/analysis/seminorm.lean index b149fb5ca0da9..a3dffa57ee266 100644 --- a/src/analysis/seminorm.lean +++ b/src/analysis/seminorm.lean @@ -66,9 +66,9 @@ Absorbent and balanced sets in a vector space over a normed field. -/ open normed_field set -open_locale pointwise topological_space +open_locale pointwise topological_space nnreal -variables {𝕜 E ι : Type*} +variables {R 𝕜 E ι : Type*} section semi_normed_ring variables [semi_normed_ring 𝕜] @@ -278,6 +278,71 @@ variables (p : seminorm 𝕜 E) (c : 𝕜) (x y : E) (r : ℝ) protected lemma smul : p (c • x) = ∥c∥ * p x := p.smul' _ _ protected lemma triangle : p (x + y) ≤ p x + p y := p.triangle' _ _ +/-- Any action on `ℝ` which factors through `ℝ≥0` applies to a seminorm. -/ +instance [has_scalar R ℝ] [has_scalar R ℝ≥0] [is_scalar_tower R ℝ≥0 ℝ] : + has_scalar R (seminorm 𝕜 E) := +{ smul := λ r p, + { to_fun := λ x, r • p x, + smul' := λ _ _, begin + simp only [←smul_one_smul ℝ≥0 r (_ : ℝ), nnreal.smul_def, smul_eq_mul], + rw [p.smul, mul_left_comm], + end, + triangle' := λ _ _, begin + simp only [←smul_one_smul ℝ≥0 r (_ : ℝ), nnreal.smul_def, smul_eq_mul], + exact (mul_le_mul_of_nonneg_left (p.triangle _ _) (nnreal.coe_nonneg _)).trans_eq + (mul_add _ _ _), + end } } + +lemma coe_smul [has_scalar R ℝ] [has_scalar R ℝ≥0] [is_scalar_tower R ℝ≥0 ℝ] + (r : R) (p : seminorm 𝕜 E) : ⇑(r • p) = r • p := rfl + +@[simp] lemma smul_apply [has_scalar R ℝ] [has_scalar R ℝ≥0] [is_scalar_tower R ℝ≥0 ℝ] + (r : R) (p : seminorm 𝕜 E) (x : E) : (r • p) x = r • p x := rfl + +instance : has_add (seminorm 𝕜 E) := +{ add := λ p q, + { to_fun := λ x, p x + q x, + smul' := λ a x, by rw [p.smul, q.smul, mul_add], + triangle' := λ _ _, has_le.le.trans_eq (add_le_add (p.triangle _ _) (q.triangle _ _)) + (add_add_add_comm _ _ _ _) } } + +lemma coe_add (p q : seminorm 𝕜 E) : ⇑(p + q) = p + q := rfl + +@[simp] lemma add_apply (p q : seminorm 𝕜 E) (x : E) : (p + q) x = p x + q x := rfl + +instance : add_monoid (seminorm 𝕜 E) := +fun_like.coe_injective.add_monoid_smul _ rfl coe_add (λ p n, coe_smul n p) + +instance : ordered_cancel_add_comm_monoid (seminorm 𝕜 E) := +{ nsmul := (•), -- to avoid introducing a diamond + ..seminorm.add_monoid, + ..(fun_like.coe_injective.ordered_cancel_add_comm_monoid _ rfl coe_add + : ordered_cancel_add_comm_monoid (seminorm 𝕜 E)) } + +instance [monoid R] [mul_action R ℝ] [has_scalar R ℝ≥0] [is_scalar_tower R ℝ≥0 ℝ] : + mul_action R (seminorm 𝕜 E) := +fun_like.coe_injective.mul_action _ coe_smul + +variables (𝕜 E) + +/-- `coe_fn` as an `add_monoid_hom`. Helper definition for showing that `seminorm 𝕜 E` is +a module. -/ +@[simps] +def coe_fn_add_monoid_hom : add_monoid_hom (seminorm 𝕜 E) (E → ℝ) := ⟨coe_fn, coe_zero, coe_add⟩ + +lemma coe_fn_add_monoid_hom_injective : function.injective (coe_fn_add_monoid_hom 𝕜 E) := +show @function.injective (seminorm 𝕜 E) (E → ℝ) coe_fn, from fun_like.coe_injective + +variables {𝕜 E} + +instance [monoid R] [distrib_mul_action R ℝ] [has_scalar R ℝ≥0] [is_scalar_tower R ℝ≥0 ℝ] : + distrib_mul_action R (seminorm 𝕜 E) := +(coe_fn_add_monoid_hom_injective 𝕜 E).distrib_mul_action _ coe_smul + +instance [semiring R] [module R ℝ] [has_scalar R ℝ≥0] [is_scalar_tower R ℝ≥0 ℝ] : + module R (seminorm 𝕜 E) := +(coe_fn_add_monoid_hom_injective 𝕜 E).module R _ coe_smul + -- TODO: define `has_Sup` too, from the skeleton at -- https://github.com/leanprover-community/mathlib/pull/11329#issuecomment-1008915345 noncomputable instance : has_sup (seminorm 𝕜 E) :=