Skip to content

Commit

Permalink
chore(algebra/group): make coe_norm_subgroup and `submodule.norm_co…
Browse files Browse the repository at this point in the history
…e` consistent (#11427)

The `simp` lemmas for norms in a subgroup and in a submodule disagreed: the first inserted a coercion to the larger group, the second deleted the coercion. Currently this is not a big deal, but it will become a real issue when defining `add_subgroup_class`. I want to make them consistent by pointing them in the same direction. The consensus in the [Zulip thread](https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/Simp.20normal.20form.3A.20coe_norm_subgroup.2C.20submodule.2Enorm_coe) suggests `simp` should insert a coercion here, so I went with that.

After making the changes, a few places need extra `simp [submodule.coe_norm]` on the local hypotheses, but nothing major.
  • Loading branch information
Vierkantor committed Feb 4, 2022
1 parent c3273aa commit a741585
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 11 deletions.
36 changes: 27 additions & 9 deletions src/analysis/normed/group/basic.lean
Expand Up @@ -656,8 +656,20 @@ semi_normed_group.induced s.subtype

/-- If `x` is an element of a subgroup `s` of a seminormed group `E`, its norm in `s` is equal to
its norm in `E`. -/
@[simp] lemma coe_norm_subgroup {E : Type*} [semi_normed_group E] {s : add_subgroup E} (x : s) :
∥x∥ = ∥(x:E)∥ :=
@[simp] lemma add_subgroup.coe_norm {E : Type*} [semi_normed_group E]
{s : add_subgroup E} (x : s) :
∥(x : s)∥ = ∥(x:E)∥ :=
rfl

/-- If `x` is an element of a subgroup `s` of a seminormed group `E`, its norm in `s` is equal to
its norm in `E`.
This is a reversed version of the `simp` lemma `add_subgroup.coe_norm` for use by `norm_cast`.
-/

@[norm_cast] lemma add_subgroup.norm_coe {E : Type*} [semi_normed_group E] {s : add_subgroup E}
(x : s) :
∥(x : E)∥ = ∥(x : s)∥ :=
rfl

/-- A submodule of a seminormed group is also a seminormed group, with the restriction of the norm.
Expand All @@ -668,18 +680,24 @@ instance submodule.semi_normed_group {𝕜 : Type*} {_ : ring 𝕜}
{ norm := λx, norm (x : E),
dist_eq := λx y, dist_eq_norm (x : E) (y : E) }

/-- If `x` is an element of a submodule `s` of a normed group `E`, its norm in `E` is equal to its
norm in `s`.
/-- If `x` is an element of a submodule `s` of a normed group `E`, its norm in `s` is equal to its
norm in `E`.
See note [implicit instance arguments]. -/
@[simp, norm_cast] lemma submodule.norm_coe {𝕜 : Type*} {_ : ring 𝕜}
@[simp] lemma submodule.coe_norm {𝕜 : Type*} {_ : ring 𝕜}
{E : Type*} [semi_normed_group E] {_ : module 𝕜 E} {s : submodule 𝕜 E} (x : s) :
∥(x : E)∥ = ∥x∥ :=
∥(x : s)∥ = ∥(x : E)∥ :=
rfl

@[simp] lemma submodule.norm_mk {𝕜 : Type*} {_ : ring 𝕜}
{E : Type*} [semi_normed_group E] {_ : module 𝕜 E} {s : submodule 𝕜 E} (x : E) (hx : x ∈ s) :
∥(⟨x, hx⟩ : s)∥ = ∥x∥ :=
/-- If `x` is an element of a submodule `s` of a normed group `E`, its norm in `E` is equal to its
norm in `s`.
This is a reversed version of the `simp` lemma `submodule.coe_norm` for use by `norm_cast`.
See note [implicit instance arguments]. -/
@[norm_cast] lemma submodule.norm_coe {𝕜 : Type*} {_ : ring 𝕜}
{E : Type*} [semi_normed_group E] {_ : module 𝕜 E} {s : submodule 𝕜 E} (x : s) :
∥(x : E)∥ = ∥(x : s)∥ :=
rfl

/-- seminormed group instance on the product of two seminormed groups, using the sup norm. -/
Expand Down
4 changes: 3 additions & 1 deletion src/geometry/manifold/instances/sphere.lean
Expand Up @@ -200,11 +200,13 @@ begin
-- the core of the problem is these two algebraic identities:
have h₁ : (2 ^ 2 / (1 - a) ^ 2 * ∥y∥ ^ 2 + 4)⁻¹ * 4 * (2 / (1 - a)) = 1,
{ field_simp,
simp only [submodule.coe_norm] at *,
nlinarith },
have h₂ : (2 ^ 2 / (1 - a) ^ 2 * ∥y∥ ^ 2 + 4)⁻¹ * (2 ^ 2 / (1 - a) ^ 2 * ∥y∥ ^ 2 - 4) = a,
{ field_simp,
transitivity (1 - a) ^ 2 * (a * (2 ^ 2 * ∥y∥ ^ 2 + 4 * (1 - a) ^ 2)),
{ congr,
simp only [submodule.coe_norm] at *,
nlinarith },
ring },
-- deduce the result
Expand Down Expand Up @@ -337,7 +339,7 @@ begin
have h_set : ∀ p : sphere (0:E) 1, p = v' ↔ ⟪(p:E), v'⟫_ℝ = 1,
{ simp [subtype.ext_iff, inner_eq_norm_mul_iff_of_norm_one] },
ext,
simp [h_set, hUv, hU'v', stereographic, real_inner_comm]
simp [h_set, hUv, hU'v', stereographic, real_inner_comm, ← submodule.coe_norm]
end

/-- The inclusion map (i.e., `coe`) from the sphere in `E` to `E` is smooth. -/
Expand Down
2 changes: 1 addition & 1 deletion src/measure_theory/function/simple_func_dense.lean
Expand Up @@ -569,7 +569,7 @@ local attribute [instance] simple_func.module
/-- If `E` is a normed space, `Lp.simple_func E p μ` is a normed space. Not declared as an
instance as it is (as of writing) used only in the construction of the Bochner integral. -/
protected def normed_space [fact (1 ≤ p)] : normed_space 𝕜 (Lp.simple_func E p μ) :=
⟨ λc f, by { rw [coe_norm_subgroup, coe_norm_subgroup, coe_smul, norm_smul] } ⟩
⟨ λc f, by { rw [add_subgroup.coe_norm, add_subgroup.coe_norm, coe_smul, norm_smul] } ⟩

end instances

Expand Down

0 comments on commit a741585

Please sign in to comment.