Eine aufbereitete Darstellung der Quelle

 
     
 
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung


Quelle  Range.lean   Sprache: Lean

 

/-
Copyright (c) 2025 Antoine Chambert-Loir and Filippo Nuccio. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Antoine Chambert-Loir, María Inés de Frutos-Fernández, Filippo A. E. Nuccio
-/

module

public import Mathlib.Algebra.Group.Subgroup.Pointwise
public import Mathlib.Algebra.GroupWithZero.Submonoid.Instances
public import Mathlib.Algebra.GroupWithZero.WithZero

/-! # The range of a MonoidWithZeroHom
Given a `MonoidWithZeroHom` `f : A → B` whose codomain `B` is a `MonoidWithZero`, we define the
type `MonoidWithZeroHom.valueMonoid` as the submonoid of `Bˣ` generated by the invertible elements
in the range of `f`. For example, if `A = ℕ`, `f` is the natural cast to `B` where `B` is
* `ℝ≥0`, then `MonoidWithZero.valueMonoid` are the positive natural numbers in `ℝ≥0`;
* `WithZero ℤ`, then `MonoidWithZero.valueMonoid = {1}`.

`MonoidWithZeroHom.ValueMonoid₀` is the `MonoidWithZero` obtained by
adjoining `0` to the previous type.

Likewise, `MonoidWithZeroHom.valueGroup` is the *subgroup* of `Bˣ` generated by the invertible
elements in `range f` and `MonoidWithZeroHom.ValueGroup₀` adds a `0` to the previous group.

When `B` is commutative, then both `MonoidWithZeroHom.valueGroup f` and
`MonoidWithZeroHom.ValueGroup₀ f` are also commutative and the former can be described more
explicitly (see `MonoidWithZeroHom.mem_valueGroup_iff_of_comm` and `mem_valueGroup_iff_of_comm'`).

## Main declarations

* `valueMonoid f` is the smallest submonoid of `Bˣ` containing the range of `f`;
* `ValueMonoid₀ f` is the smallest monoid with `0` containing the range of `f`;
* `valueGroup f` is the smallest subgroup of `Bˣ` containing the range of `f`;
* `ValueMonoid₀ f` is the smallest group with `0` containing the range of `f`;
* When `B` is a group with zero, rather than merely a monoid with zero, the above definitions
  all coincide: see `valueMonoid_eq_valueGroup` for an equality as submonoids and
  `valueMonoid_eq_valueGroup'` for an equality as subsets.
* When `B` is a *commutative* group with zero, `MonoidWithZeroHom.valueGroup` can be
  explicitly described as the elements that are ratios of terms in `range f`, see
  `MonoidWithZeroHom.mem_valueGroup_iff_of_comm`.

## Implementation details
`MonoidWithZeroHom.valueMonoid` is defined explicitly in terms of its carrier, by proving the
required properties; that it coincides with the submonoid generated by the closure is proven in
`MonoidWithZeroHom.valueMonoid_eq_closure`, but using the latter as definition yields to unwanted
unfolding.
-/


@[expose] public section

namespace MonoidWithZeroHom

open Set Subgroup Submonoid

section mrange

variable {G H : Type*} [MulZeroOneClass G] [MulZeroOneClass H] [Nontrivial H] (f : G →*₀ H)

lemma mrange_nontrivial :
    Nontrivial (MonoidHom.mrange f) :=
  ⟨1, 0, by simp [Subtype.ext_iff]⟩

lemma range_nontrivial :
    (Set.range f).Nontrivial :=
  Set.nontrivial_coe_sort.mp f.mrange_nontrivial

end mrange

variable {A B : Type*}

section MonoidWithZeroHom

variable [MonoidWithZero A] [MonoidWithZero B] (f : A →*₀ B)

/-- For a morphism of monoids with zero `f`, this is a smallest submonoid of the invertible
elements in the codomain containing the range of `f`. -/

def valueMonoid : Submonoid Bˣ where
  carrier := (↑) ⁻¹' (range f)
  mul_mem' hb hb' := by
    obtain ⟨y, hy⟩ := hb
    obtain ⟨y', hy'⟩ := hb'
    use y * y'
    rw [map_mul, hy, hy', Units.val_mul]
  one_mem' := ⟨1, by simp⟩

lemma one_mem_valueMonoid : 1 ∈ valueMonoid f := ⟨1, map_one ..⟩

lemma coe_one : (⟨(1 : Bˣ), one_mem_valueMonoid f⟩ : valueMonoid f) = 1 := rfl

lemma mem_valueMonoid_iff {b : Bˣ} : b ∈ valueMonoid f ↔ b ∈ (↑) ⁻¹' (range f) := Iff.rfl

lemma valueMonoid_eq_closure : valueMonoid f = Submonoid.closure ((↑) ⁻¹' (range f)) :=
  (valueMonoid f).closure_eq.symm

/-- For a morphism of monoids with zero `f`, this is the smallest subgroup of the invertible
elements in the codomain containing the range of `f`. -/

def valueGroup : Subgroup Bˣ := closure (valueMonoid f)

lemma valueGroup_def : valueGroup f = Subgroup.closure (valueMonoid f) := rfl

/-- For a morphism of monoids with zero `f`, this is the smallest submonoid with zero of the
codomain containing the range of `f`. -/

abbrev ValueMonoid₀ := WithZero (valueMonoid f)

/-- For a morphism of monoids with zero `f`, this is a smallest subgroup with zero of the
codomain containing the range of `f`. -/

abbrev ValueGroup₀ := WithZero (valueGroup f)

lemma mem_valueMonoid {b : Bˣ} (hb : b.val ∈ range f) : b ∈ valueMonoid f := by
  tauto

lemma mem_valueGroup {b : Bˣ} (hb : b.val ∈ range f) : b ∈ valueGroup f := by
  suffices b ∈ valueMonoid f from Subgroup.mem_closure.mpr fun _ a ↦ a this
  exact mem_valueMonoid _ hb

lemma inv_mem_valueGroup {b : Bˣ} (hb : b.val ∈ range f) : b⁻¹ ∈ valueGroup f :=
  Subgroup.inv_mem _ (mem_valueGroup f hb)

end MonoidWithZeroHom

noncomputable section Restrict

variable [MonoidWithZero A] [GroupWithZero B] {f : A →*₀ B}

/-- The inclusion of the subgroup with zero generated by the range of a monoid with zero
hom `f : A →*₀ B` into the codomain `B`. -/

@[simps! -isSimp]
def ValueGroup₀.embedding : ValueGroup₀ f →*₀ B :=
  letI : DecidablePred fun b : B ↦ b = 0 := Classical.decPred fun b ↦ b = 0
  comp (WithZero.withZeroUnitsEquiv (G := B)) <| WithZero.map' (valueGroup f).subtype

variable (f) in
/-- This is the restriction of `f` as a function taking values in `valueGroup₀ f`. -/
@[simps! -isSimp]
def ValueGroup₀.restrict₀ : A →*₀ ValueGroup₀ f where
  toFun a :=
    letI : DecidablePred fun b : B ↦ b = 0 := Classical.decPred fun b ↦ b = 0
    if h : f a = 0 then 0 else (⟨Units.mk0 (f a) h, mem_valueGroup _ ⟨a, rfl⟩⟩ : valueGroup f)
  map_one' := by simp [← WithZero.coe_one]
  map_mul' := by aesop
  map_zero' := by simp

namespace ValueGroup₀

lemma embedding_injective : Function.Injective (embedding (f := f)) := by
  simp [embedding, WithZero.map'_injective_iff]

@[simp]
lemma embedding_inj {a b : ValueGroup₀ f} : embedding a = embedding b ↔ a = b :=
  ⟨fun h ↦ embedding_injective h, congrArg _⟩

lemma restrict₀_of_ne_zero {a : A} (h : f a ≠ 0) :
    restrict₀ f a = (⟨Units.mk0 (f a) h, mem_valueGroup _ ⟨a, rfl⟩⟩ : valueGroup f) := by
  simp [h, restrict₀_apply]

@[simp]
lemma restrict₀_eq_zero_iff {a : A} : restrict₀ f a = 0 ↔ f a = 0 := by simp [restrict₀_apply]

@[simp]
lemma restrict₀_eq_one_iff {a : A} : restrict₀ f a = 1 ↔ f a = 1 := by
  simp only [restrict₀_apply]
  split_ifs with H <;>
  simp [H, ← WithZero.coe_one, ← Units.mk0_one]

@[simp]
lemma embedding_restrict₀ (a : A) : ValueGroup₀.embedding (restrict₀ f a) = f a := by
  simp only [restrict₀_apply, embedding_apply]
  aesop

@[simp]
theorem restrict₀_inj {a b : A} :
    restrict₀ f a = restrict₀ f b ↔ f a = f b := by
  simp only [restrict₀_apply]
  aesop

end ValueGroup₀

end Restrict

section GroupWithZero

variable [GroupWithZero A] [GroupWithZero B] {f : A →*₀ B}

/--
When the *domain* is itself a group with zero, the `valueMonoid` and the `valueGroup` coincide. -/

lemma valueMonoid_eq_valueGroup : (valueMonoid f) = (valueGroup f).toSubmonoid := by
  rw [valueGroup_def, Subgroup.closure_toSubmonoid, Eq.comm]
  apply Submonoid.closure_eq_of_le
  · simp only [union_subset_iff, subset_refl, true_and]
    intro _ ⟨y, hy⟩
    use y⁻¹
    simp [hy]
  · simp [Submonoid.closure_union]

variable (f)

lemma valueMonoid_eq_valueGroup' : (valueMonoid f : Set Bˣ) = valueGroup f := by
  rw [valueMonoid_eq_valueGroup, coe_toSubmonoid]

lemma valueGroup_eq_range : Units.val '' (valueGroup f) = (range f \ {0}) := by
  ext x
  simp only [mem_sdiff, mem_range, mem_singleton_iff, ← valueMonoid_eq_valueGroup' f, mem_image,
    SetLike.mem_coe, mem_valueMonoid_iff, mem_preimage, mem_range]
  constructor
  · rintro ⟨y, hy, rfl⟩
    simp only [Units.ne_zero, not_false_eq_true, and_true, hy]
  · rintro ⟨⟨y, hy⟩, hx₀⟩
    refine ⟨Units.mk0 x hx₀, ?_, rfl⟩
    simpa [Units.val_mk0, mem_range] using ⟨y, hy⟩

set_option backward.isDefEq.respectTransparency false in
@[simp]
lemma ValueGroup₀.restrict₀_range_eq_top : range (ValueGroup₀.restrict₀ f) = ⊤ := by
  rw [top_eq_univ, range_eq_univ]
  intro x
  match x with
  | 0 => use 0; simp
  | some ⟨u, hu⟩ =>
    change u ∈ (valueGroup f : Set Bˣ) at hu
    rw [← valueMonoid_eq_valueGroup'] at hu
    obtain ⟨v, hv⟩ := hu
    use v
    simp [restrict₀_apply, hv, Units.ne_zero, WithZero.coe]

open Function

lemma ValueGroup₀.restrict₀_surjective : Surjective (ValueGroup₀.restrict₀ f) :=
  fun _ ↦ mem_range.mp (by simp [ValueGroup₀.restrict₀_range_eq_top])

end GroupWithZero
section CommGroupWithZero

variable [MonoidWithZero A] [CommGroupWithZero B] (f : A →*₀ B)

/-- See also `mem_valueGroup_iff_of_comm'` for a version proving that `f x ≠ 0`. -/
theorem mem_valueGroup_iff_of_comm {y : Bˣ} :
    y ∈ valueGroup f ↔ ∃ a, f a ≠ 0 ∧ ∃ x, f a * y = f x := by
  refine ⟨fun hy ↦ ?_, fun ⟨a, ha, x, hy⟩ ↦ ?_⟩
  · simp only [valueGroup, valueMonoid] at hy
    induction hy using Subgroup.closure_induction with
    | mem _ h =>
      obtain ⟨a, ha⟩ := h
      exact ⟨a, ha.symm ▸ Units.ne_zero _, ⟨a * a, by simp [← ha]⟩⟩
    | one => exact ⟨1, by simp, 1, by simp⟩
    | mul c d hc hd hcy hdy =>
      obtain ⟨u, hu, a, ha⟩ := hcy
      obtain ⟨v, hv, b, hb⟩ := hdy
      refine ⟨u * v, by simp [hu, hv], a * b, ?_⟩
      simpa [map_mul, Units.val_mul, ← hb, ← ha] using mul_mul_mul_comm ..
    | inv c hc hcy =>
      obtain ⟨u, hu, a, ha⟩ := hcy
      exact ⟨a, by simp [← ha, hu], u, by simp [← ha]⟩
  · have hv : f x ≠ 0 := by
      simp only [← hy, ne_eq, mul_eq_zero, ha, Units.ne_zero, or_self, not_false_eq_true]
    let v := (Ne.isUnit hv).unit
    have hv₀ : f x = ↑v := IsUnit.unit_spec (Ne.isUnit hv)
    let u := (Ne.isUnit ha).unit
    have ha₀ : f a = ↑u := IsUnit.unit_spec (Ne.isUnit ha)
    rw_mod_cast [hv₀, ha₀, Eq.comm, ← inv_mul_eq_iff_eq_mul] at hy
    rw [← hy]
    apply Subgroup.mul_mem
    · apply inv_mem_valueGroup
      use a
    · apply mem_valueGroup
      use x

theorem mem_valueGroup_iff_of_comm' {y : Bˣ} :
    y ∈ valueGroup f ↔ ∃ a, f a ≠ 0 ∧ ∃ x, f x ≠ 0 ∧ f a * y = f x := by
  rw [mem_valueGroup_iff_of_comm]
  exact ⟨fun ⟨a, ha, x, hax⟩ ↦ ⟨a, ha, x, by aesop, hax⟩, fun ⟨a, ha, x, hx, hax⟩ ↦ ⟨a, ha, x, hax⟩⟩

namespace valueGroup

variable {r₁ s₁ r₂ s₂ : A}

/-- The map sending a pair of nonzero `r s : A` to the element `(v r)⁻¹ * (v s)`
of `ValueGroup₀ v`. -/

def mk (r s : A) (hr : f r ≠ 0) (hs : f s ≠ 0) : valueGroup f :=
    (⟨(.mk0 _ hr)⁻¹ * (.mk0 _ hs), mul_mem (inv_mem (mem_valueGroup _ (by simp)))
    (mem_valueGroup _ (by simp))⟩ : valueGroup f)

@[simp] theorem mk_inj {hr₁ : f r₁ ≠ 0} {hs₁ : f s₁ ≠ 0} {hr₂ : f r₂ ≠ 0} {hs₂ : f s₂ ≠ 0} :
    mk f r₁ s₁ hr₁ hs₁ = mk f r₂ s₂ hr₂ hs₂ ↔ f (r₁ * s₂) = f (r₂ * s₁) := by
  simp only [mk, Subtype.mk.injEq, map_mul]
  rw [inv_mul_eq_inv_mul_iff_mul_eq_mul, eq_comm]
  simp [Units.ext_iff, mul_comm (f r₂), mul_comm (f s₂)]

@[simp] theorem mk_mul {hr₁ : f r₁ ≠ 0} {hs₁ : f s₁ ≠ 0} {hr₂ : f r₂ ≠ 0} {hs₂ : f s₂ ≠ 0} :
    mk f r₁ s₁ hr₁ hs₁ * mk f r₂ s₂ hr₂ hs₂ =
      mk f (r₁ * r₂) (s₁ * s₂) (by simp_all) (by simp_all) := by
  simp only [mk, map_mul, MulMemClass.mk_mul_mk, Units.mk0_mul, Subtype.mk.injEq]
  rw [mul_mul_mul_comm, mul_inv]

@[simp]
lemma mk_eq_div {r s : A} (hr : f r ≠ 0) (hs : f s ≠ 0) :
    (valueGroup.mk f r s hr hs : Bˣ) = f s / f r := by
  simp [valueGroup.mk, inv_mul_eq_div]

theorem exists_mk (f : A →*₀ B) (x : f.valueGroup) :
    ∃ r s hr hs, x = valueGroup.mk f r s hr hs := by
  obtain ⟨r, hr, s, hs, hrs⟩ := (mem_valueGroup_iff_of_comm' f).mp x.2
  exact ⟨r, s, hr, hs, by simp [valueGroup.mk, ← hrs]⟩

end valueGroup

theorem mem_valueGroup_iff_exists_mk_of_comm (f : A →*₀ B) {y : Bˣ} :
    y ∈ f.valueGroup ↔ ∃ r s hr hs, y = valueGroup.mk f r s hr hs := by
  refine ⟨fun hy ↦ ?_, fun ⟨r, s, hr, hs, hy⟩ ↦ by aesop⟩
  obtain ⟨r, s, hr, hs, h⟩ := valueGroup.exists_mk f ⟨y, hy⟩
  exact ⟨r, s, hr, hs, Subtype.ext_iff.mp h⟩

namespace ValueGroup₀

/-- The map sending a pair of nonzero `r s : A` to the element `(v r)⁻¹ * (v s)`
of `ValueGroup₀ v`. -/

def mk [DecidablePred fun b : B ↦ b = 0] (r s : A) : ValueGroup₀ f :=
    if h : f r = 0 ∨ f s = 0 then 0 else
    valueGroup.mk f r s ((not_or.mp h).1) ((not_or.mp h).2)

lemma mk_eq_of_ne_zero [DecidablePred fun b : B ↦ b = 0] (r s : A) (hr : f r ≠ 0) (hs : f s ≠ 0) :
    ValueGroup₀.mk f r s = valueGroup.mk f r s hr hs := by
  simp [ValueGroup₀.mk, hr, hs]

theorem zero_or_exists_mk (x : ValueGroup₀ f) :
    x = 0 ∨ ∃ r s hr hs, x = valueGroup.mk f r s hr hs := by
  obtain _ | ⟨x, hx⟩ := x
  · left; rfl
  · rw [mem_valueGroup_iff_of_comm'] at hx
    obtain ⟨r, hr, s, hs, hrs⟩ := hx
    refine .inr ⟨r, s, hr, hs, Option.some_inj.mpr <| by
      simp only [valueGroup.mk, Subtype.mk.injEq]
      rw [eq_inv_mul_iff_mul_eq]
      simp [← hrs, mul_comm]⟩

theorem zero_or_exists_mk' (x : ValueGroup₀ f) :
    x = 0 ∨ ∃ d : {xy : A × A // f xy.1 ≠ 0 ∧ f xy.2 ≠ 0}, x =
      valueGroup.mk f d.1.1 d.1.2 d.2.1 d.2.2 :=
  x.zero_or_exists_mk.imp _root_.id fun ⟨r, s, hr, hs, hx⟩ ↦ ⟨⟨(r, s), ⟨hr, hs⟩⟩, hx⟩

end ValueGroup₀

instance : CommGroupWithZero (ValueGroup₀ f) where

end CommGroupWithZero

end MonoidWithZeroHom

Messung
CHZG
9410010097

¤ Dauer der Verarbeitung: 0.10 Sekunden  ¤

*© Formatika GbR, Deutschland







                                                                                                                                                                                                                                                                                                                                                                                                     

 

Neuigkeiten

Aktuelles
Motto des Tages

Open Source Software


Gedichte
Musik
Bilder

Jenseits des Üblichen

Besucherstatistik

Besucherstatistik

Statistik
#Sources=1,188,109
#Domains=862,984