Skip to content

Commit 362209f

Browse files
feat(RingTheory/Valuation): add API (leanprover-community#36110)
Prerequisites for leanprover-community#26872. Co-authored by: @faenuccio. Co-authored-by: mariainesdff <mariaines.dff@gmail.com> Co-authored-by: faenuccio <filippo.nuccio@univ-st-etienne.fr>
1 parent e4c3741 commit 362209f

File tree

3 files changed

+148
-21
lines changed

3 files changed

+148
-21
lines changed

Mathlib/Algebra/GroupWithZero/Range.lean

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,15 @@ lemma restrict₀_of_ne_zero {a : A} (h : f a ≠ 0) :
151151
restrict₀ f a = (⟨Units.mk0 (f a) h, mem_valueGroup _ ⟨a, rfl⟩⟩ : valueGroup f) := by
152152
simp [h, restrict₀_apply]
153153

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

157+
@[simp]
158+
lemma restrict₀_eq_one_iff {a : A} : restrict₀ f a = 1 ↔ f a = 1 := by
159+
simp only [restrict₀_apply]
160+
split_ifs with H <;>
161+
simp [H, ← WithZero.coe_one, ← Units.mk0_one]
162+
156163
@[simp]
157164
lemma embedding_restrict₀ (a : A) : ValueGroup₀.embedding (restrict₀ f a) = f a := by
158165
simp only [restrict₀_apply, embedding_apply]
@@ -176,7 +183,8 @@ lemma valueMonoid_eq_valueGroup : (valueMonoid f) = (valueGroup f).toSubmonoid :
176183
simp [hy]
177184
· simp [Submonoid.closure_union]
178185

179-
variable (f) in
186+
variable (f)
187+
180188
lemma valueMonoid_eq_valueGroup' : (valueMonoid f : Set Bˣ) = valueGroup f := by
181189
rw [valueMonoid_eq_valueGroup, coe_toSubmonoid]
182190

@@ -191,6 +199,26 @@ lemma valueGroup_eq_range : Units.val '' (valueGroup f) = (range f \ {0}) := by
191199
refine ⟨Units.mk0 x hx₀, ?_, rfl⟩
192200
simpa [Units.val_mk0, mem_range] using ⟨y, hy⟩
193201

202+
@[simp]
203+
lemma ValueGroup₀.restrict₀_range_eq_top : range (ValueGroup₀.restrict₀ f) = ⊤ := by
204+
rw [top_eq_univ, range_eq_univ]
205+
intro x
206+
match x with
207+
| 0 => use 0; simp
208+
| some ⟨u, hu⟩ =>
209+
change u ∈ (valueGroup f : Set Bˣ) at hu
210+
rw [← valueMonoid_eq_valueGroup'] at hu
211+
obtain ⟨v, hv⟩ := hu
212+
use v
213+
simp [restrict₀_apply, hv, Units.ne_zero, WithZero.coe]
214+
215+
open Function
216+
217+
lemma ValueGroup₀.restrict₀_surjective : Surjective (ValueGroup₀.restrict₀ f) :=
218+
fun _ ↦ mem_range.mp (by simp [ValueGroup₀.restrict₀_range_eq_top])
219+
220+
open Function
221+
194222
end GroupWithZero
195223
section CommGroupWithZero
196224
--

Mathlib/Algebra/Order/GroupWithZero/Range.lean

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,32 +38,29 @@ lemma monoidWithZeroHom_strictMono :
3838
StrictMono (orderMonoidWithZeroHom f) :=
3939
map'_strictMono (Subtype.strictMono_coe _)
4040

41-
variable (f) in
42-
/-- The inclusion of `ValueGroup₀ f` into `WithZero Bˣ` as an order embedding. In general, prefer
43-
the use of `MonoidWithZeroHom` and apply the above lemma
44-
`MonoidWithZeroHom_strictMono` if properties about ordering are needed. -/
45-
def orderEmbedding : ValueGroup₀ f ↪o WithZero Bˣ where
46-
__ := orderMonoidWithZeroHom f
47-
inj' := monoidWithZeroHom_strictMono.injective
48-
map_rel_iff' := monoidWithZeroHom_strictMono.le_iff_le
49-
50-
@[simp]
51-
lemma orderEmbedding_apply (x : ValueGroup₀ f) :
52-
orderEmbedding f x = orderMonoidWithZeroHom f x := rfl
53-
54-
lemma orderEmbedding_mul (x y : ValueGroup₀ f) :
55-
orderEmbedding f (x * y) = orderEmbedding f x * orderEmbedding f y := by simp
41+
lemma embedding_strictMono : StrictMono (embedding (f := f)) := by
42+
intro x y hxy
43+
rw [← monoidWithZeroHom_strictMono.lt_iff_lt] at hxy
44+
simpa using (OrderEmbedding.lt_iff_lt (OrderIso.withZeroUnits.toOrderEmbedding)).mpr hxy
5645

5746
instance : IsOrderedMonoid (ValueGroup₀ f) :=
58-
Function.Injective.isOrderedMonoid (orderEmbedding f) orderEmbedding_mul
59-
<| OrderEmbedding.le_iff_le (orderEmbedding f)
47+
Function.Injective.isOrderedMonoid embedding (map_mul _) embedding_strictMono.le_iff_le
6048

6149
instance : LinearOrderedCommGroupWithZero (ValueGroup₀ f) where
6250
zero_le := by simp
6351
mul_lt_mul_of_pos_left a ha b c hbc := by
64-
simp only [← OrderEmbedding.lt_iff_lt (orderEmbedding f), orderEmbedding_mul] at *
52+
simp only [← (embedding_strictMono (f := f)).lt_iff_lt, map_mul] at *
6553
exact (mul_lt_mul_iff_of_pos_left ha).mpr hbc
6654

55+
lemma embedding_unit_pos (a : (ValueGroup₀ f)ˣ) :
56+
0 < embedding a.1 := by
57+
conv_lhs => rw [← map_zero f, ← ValueGroup₀.embedding_restrict₀ (0 : A)]
58+
rw [embedding_strictMono.lt_iff_lt]
59+
simp
60+
61+
lemma embedding_unit_ne_zero (a : (ValueGroup₀ f)ˣ) :
62+
embedding a.10 := (embedding_unit_pos a).ne.symm
63+
6764
end ValueGroup₀
6865

6966
end MonoidWithZeroHom

Mathlib/RingTheory/Valuation/Basic.lean

Lines changed: 104 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/-
22
Copyright (c) 2020 Johan Commelin. All rights reserved.
33
Released under Apache 2.0 license as described in the file LICENSE.
4-
Authors: Kevin Buzzard, Johan Commelin, Patrick Massot
4+
Authors: Kevin Buzzard, Johan Commelin, Patrick Massot, Filippo A. E. Nuccio
55
-/
66
module
77

8-
public import Mathlib.Algebra.GroupWithZero.Range
8+
public import Mathlib.Algebra.Order.GroupWithZero.Range
99
public import Mathlib.Algebra.Order.Hom.Monoid
1010
public import Mathlib.Algebra.Order.Ring.Basic
1111
public import Mathlib.Algebra.Ring.Torsion
@@ -453,6 +453,108 @@ lemma mem_leAddSubgroup_iff {v : Valuation R Γ₀} {γ : Γ₀} {x : R} :
453453
lemma leAddSubgroup_monotone (v : Valuation R Γ₀) : Monotone v.leAddSubgroup :=
454454
fun _ _ h _ ↦ h.trans'
455455

456+
open MonoidWithZeroHom MonoidWithZeroHom.ValueGroup₀
457+
458+
set_option backward.isDefEq.respectTransparency false in
459+
/-- The restriction of a valuation so that it takes values in its `valueGroup₀`. -/
460+
def restrict : Valuation R (MonoidWithZeroHom.ValueGroup₀ (v : R →*₀ Γ₀)) where
461+
__ := restrict₀ v
462+
map_add_le_max' x y := by
463+
by_cases H : v x ≠ 0 ∨ v y ≠ 0
464+
· rcases H with h | h <;>
465+
simp only [ZeroHom.toFun_eq_coe, toZeroHom_coe, restrict₀_apply, h, ↓reduceDIte] <;>
466+
· split_ifs with H _ hy
467+
all_goals simp [← Units.val_le_val]
468+
simpa using map_add_le _ (by simp_all) (by simp_all)
469+
· simp only [ne_eq, not_or, Decidable.not_not] at H
470+
simp only [ZeroHom.toFun_eq_coe, toZeroHom_coe, restrict₀_apply, H, ↓reduceDIte, max_self,
471+
le_zero_iff, dite_eq_left_iff, WithZero.coe_ne_zero, imp_false, Decidable.not_not]
472+
simpa using map_add_le _ (le_of_eq H.1) (le_of_eq H.2)
473+
474+
lemma restrict_def (x : R) : v.restrict x = restrict₀ v x := rfl
475+
476+
set_option backward.isDefEq.respectTransparency false in
477+
@[simp]
478+
lemma restrict_pos_iff (x : R) : 0 < v.restrict x ↔ 0 < v x := by
479+
simp only [restrict_def, restrict₀_apply]
480+
split_ifs with h <;>
481+
simp_all [zero_lt_iff.mpr]
482+
483+
set_option backward.isDefEq.respectTransparency false in
484+
@[simp]
485+
lemma restrict_lt_iff {x y : R} : v.restrict x < v.restrict y ↔ v x < v y := by
486+
simp only [restrict_def, restrict₀_apply]
487+
split_ifs with hx hy <;> simp_all [zero_lt_iff.mpr, ← Units.val_lt_val]
488+
489+
set_option backward.isDefEq.respectTransparency false in
490+
lemma restrict_lt_iff_lt_embedding {x : R} {g : ValueGroup₀ v} :
491+
v.restrict x < g ↔ v x < embedding g := by
492+
conv_rhs => rw [← ValueGroup₀.embedding_restrict₀ x]
493+
rw [embedding_strictMono.lt_iff_lt, restrict_def]
494+
495+
set_option backward.isDefEq.respectTransparency false in
496+
lemma restrict_le_iff_le_embedding {x : R} {g : ValueGroup₀ v} :
497+
v.restrict x ≤ g ↔ v x ≤ embedding g := by
498+
conv_rhs => rw [← ValueGroup₀.embedding_restrict₀ x]
499+
rw [embedding_strictMono.le_iff_le, restrict_def]
500+
501+
set_option backward.isDefEq.respectTransparency false in
502+
@[simp]
503+
lemma restrict_lt_one_iff {x : R} : v.restrict x < 1 ↔ v x < 1 := by
504+
rw [restrict_lt_iff_lt_embedding, map_one]
505+
506+
set_option backward.isDefEq.respectTransparency false in
507+
@[simp]
508+
lemma restrict_le_one_iff {x : R} : v.restrict x ≤ 1 ↔ v x ≤ 1 := by
509+
rw [restrict_le_iff_le_embedding, map_one]
510+
511+
set_option backward.isDefEq.respectTransparency false in
512+
@[simp]
513+
lemma restrict_eq_zero_iff {x : R} : v.restrict x = 0 ↔ v x = 0 := by
514+
rw [restrict_def,restrict₀_eq_zero_iff]
515+
516+
set_option backward.isDefEq.respectTransparency false in
517+
@[simp]
518+
lemma restrict_eq_one_iff {x : R} : v.restrict x = 1 ↔ v x = 1 := by
519+
rw [restrict_def,restrict₀_eq_one_iff]
520+
521+
set_option backward.isDefEq.respectTransparency false in
522+
@[simp]
523+
lemma restrict_le_iff {x y : R} : v.restrict x ≤ v.restrict y ↔ v x ≤ v y := by
524+
simp only [restrict_def, restrict₀_apply]
525+
split_ifs with hx hy <;> simp_all [← Units.val_le_val]
526+
527+
set_option backward.isDefEq.respectTransparency false in
528+
@[simp]
529+
lemma restrict_inj {x y : R} : v.restrict x = v.restrict y ↔ v x = v y := by
530+
simp only [restrict_def, restrict₀_apply]
531+
aesop
532+
533+
@[simp]
534+
lemma embedding_restrict (x : R) : ValueGroup₀.embedding (v.restrict x) = v x :=
535+
embedding_restrict₀ x
536+
537+
set_option backward.isDefEq.respectTransparency false in
538+
lemma exists_div_eq_of_unit (γ : (ValueGroup₀ v)ˣ) :
539+
∃ r s, 0 < v r ∧ 0 < v s ∧ v.restrict r / v.restrict s = γ.1 := by
540+
set u := WithZero.unzero (Units.ne_zero γ) with hu_def
541+
obtain ⟨a, ⟨ha, x, hax⟩⟩ := (mem_valueGroup_iff_of_comm _).mp u.2
542+
have hx : 0 < v x := by
543+
rw [← restrict_pos_iff, restrict_def, WithZero.pos_iff_ne_zero, ne_eq, restrict₀_eq_zero_iff]
544+
aesop
545+
use x, a, hx, zero_lt_iff.mpr ha
546+
have ha0 : v.restrict a ≠ 0 := by simp [ha]
547+
rw [div_eq_iff ha0, mul_comm, ← embedding_strictMono.injective.eq_iff, map_mul,
548+
embedding_restrict, embedding_restrict, ← hax]
549+
congr
550+
rw [← WithZero.coe_unzero (Units.ne_zero γ)]
551+
exact Eq.refl ..
552+
553+
lemma IsEquiv.restrict {Γ₀' : Type*} [LinearOrderedCommGroupWithZero Γ₀']
554+
{w : Valuation R Γ₀'} (h : v.IsEquiv w) : v.restrict.IsEquiv w.restrict := by
555+
simp only [IsEquiv] at h ⊢
556+
simp [restrict_le_iff, h]
557+
456558
/-- The subgroup of elements whose valuation is less than a certain unit. -/
457559
@[simps] def ltAddSubgroup (v : Valuation R Γ₀) (γ : Γ₀ˣ) : AddSubgroup R where
458560
carrier := { x | v x < γ }

0 commit comments

Comments
 (0)