Skip to content

Commit 0b74e84

Browse files
refactor(NumberTheory/Ostrowski): use AbsoluteValue instead of MulRingNorm (#20362)
This PR * replaces `MulRingNorm R` by `AbsoluteValue R ℝ` in the material developed in `Mathlib.NumberTheory.Ostrowski` * does some cleanup (naming convention, remove redundant name parts etc.) * and also some golfing... In addition, it * creates a new folder `Mathlib.Algebra.Order.AbsoluteValue` * moves `Mathlib.Algebra.Order.AbsoluteValue` to `Mathlib.Algebra.Order.AbsoluteValue.Basic` and `Mathlib.Algebra.Order.EuclideanAbsoluteValue`to `Mathlib.Algebra.Order.AbsoluteValue.Euclidean` * adds some API for `AbsoluteValue` to match `MulRingNorm` (in `Mathlib.Algebra.Order.AbsoluteValue.Basic`) * adds a new file `Mathlib.Algebra.Order.AbsoluteValue.Equivalence` with material on equivalence of real-valued absolute values. See the [discussion](https://leanprover.zulipchat.com/#narrow/channel/287929-mathlib4/topic/MulRingNorm.20vs.2E.20AbsoluteValue/near/491324423) on Zulip. Co-authored-by: Michael Stoll <99838730+MichaelStollBayreuth@users.noreply.github.com>
1 parent 670870b commit 0b74e84

File tree

14 files changed

+354
-269
lines changed

14 files changed

+354
-269
lines changed

Mathlib.lean

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,9 @@ import Mathlib.Algebra.NoZeroSMulDivisors.Pi
628628
import Mathlib.Algebra.NoZeroSMulDivisors.Prod
629629
import Mathlib.Algebra.Notation
630630
import Mathlib.Algebra.Opposites
631-
import Mathlib.Algebra.Order.AbsoluteValue
631+
import Mathlib.Algebra.Order.AbsoluteValue.Basic
632+
import Mathlib.Algebra.Order.AbsoluteValue.Equivalence
633+
import Mathlib.Algebra.Order.AbsoluteValue.Euclidean
632634
import Mathlib.Algebra.Order.AddGroupWithTop
633635
import Mathlib.Algebra.Order.AddTorsor
634636
import Mathlib.Algebra.Order.Algebra
@@ -654,7 +656,6 @@ import Mathlib.Algebra.Order.CauSeq.BigOperators
654656
import Mathlib.Algebra.Order.CauSeq.Completion
655657
import Mathlib.Algebra.Order.Chebyshev
656658
import Mathlib.Algebra.Order.CompleteField
657-
import Mathlib.Algebra.Order.EuclideanAbsoluteValue
658659
import Mathlib.Algebra.Order.Field.Basic
659660
import Mathlib.Algebra.Order.Field.Canonical.Basic
660661
import Mathlib.Algebra.Order.Field.Canonical.Defs

Mathlib/Algebra/Order/AbsoluteValue.lean renamed to Mathlib/Algebra/Order/AbsoluteValue/Basic.lean

Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,12 @@ protected theorem eq_zero {x : R} : abv x = 0 ↔ x = 0 :=
9393
protected theorem add_le (x y : R) : abv (x + y) ≤ abv x + abv y :=
9494
abv.add_le' x y
9595

96+
/-- The triangle inequality for an `AbsoluteValue` applied to a list. -/
97+
lemma listSum_le (l : List R) : abv l.sum ≤ (l.map abv).sum := by
98+
induction l with
99+
| nil => simp
100+
| cons head tail ih => exact (abv.add_le ..).trans <| add_le_add_left ih (abv head)
101+
96102
@[simp]
97103
protected theorem map_mul (x y : R) : abv (x * y) = abv x * abv y :=
98104
abv.map_mul' x y
@@ -174,6 +180,20 @@ theorem coe_toMonoidHom : ⇑abv.toMonoidHom = abv :=
174180
protected theorem map_pow (a : R) (n : ℕ) : abv (a ^ n) = abv a ^ n :=
175181
abv.toMonoidHom.map_pow a n
176182

183+
omit [Nontrivial R] in
184+
/-- An absolute value satisfies `f (n : R) ≤ n` for every `n : ℕ`. -/
185+
lemma apply_nat_le_self (n : ℕ) : abv n ≤ n := by
186+
cases subsingleton_or_nontrivial R
187+
· simp [Subsingleton.eq_zero (n : R)]
188+
induction n with
189+
| zero => simp
190+
| succ n hn =>
191+
simp only [Nat.cast_succ]
192+
calc
193+
abv (n + 1) ≤ abv n + abv 1 := abv.add_le ..
194+
_ = abv n + 1 := congrArg (abv n + ·) abv.map_one
195+
_ ≤ n + 1 := add_le_add_right hn 1
196+
177197
end IsDomain
178198

179199
end Semiring
@@ -191,8 +211,8 @@ end Ring
191211
end OrderedRing
192212

193213
section OrderedCommRing
194-
variable [OrderedCommRing S] [Ring R] (abv : AbsoluteValue R S)
195-
variable [NoZeroDivisors S]
214+
215+
variable [OrderedCommRing S] [Ring R] (abv : AbsoluteValue R S) [NoZeroDivisors S]
196216

197217
@[simp]
198218
protected theorem map_neg (a : R) : abv (-a) = abv a := by
@@ -219,6 +239,18 @@ instance [Nontrivial R] [IsDomain S] : MulRingNormClass (AbsoluteValue R S) R S
219239
map_neg_eq_map := fun f => f.map_neg
220240
eq_zero_of_map_eq_zero := fun f _ => f.eq_zero.1 }
221241

242+
open Int in
243+
lemma apply_natAbs_eq (x : ℤ) : abv (natAbs x) = abv x := by
244+
obtain ⟨_, rfl | rfl⟩ := eq_nat_or_neg x <;> simp
245+
246+
open Int in
247+
/-- Values of an absolute value coincide on the image of `ℕ` in `R`
248+
if and only if they coincide on the image of `ℤ` in `R`. -/
249+
lemma eq_on_nat_iff_eq_on_int {f g : AbsoluteValue R S} :
250+
(∀ n : ℕ , f n = g n) ↔ ∀ n : ℤ , f n = g n := by
251+
refine ⟨fun h z ↦ ?_, fun a n ↦ mod_cast a n⟩
252+
obtain ⟨n , rfl | rfl⟩ := eq_nat_or_neg z <;> simp [h n]
253+
222254
end OrderedCommRing
223255

224256
section LinearOrderedRing
@@ -249,6 +281,37 @@ theorem abs_abv_sub_le_abv_sub (a b : R) : abs (abv a - abv b) ≤ abv (a - b) :
249281

250282
end LinearOrderedCommRing
251283

284+
section trivial
285+
286+
variable {R : Type*} [Semiring R] [DecidablePred fun x : R ↦ x = 0] [NoZeroDivisors R]
287+
variable {S : Type*} [OrderedSemiring S] [Nontrivial S]
288+
289+
/-- The *trivial* absolute value takes the value `1` on all nonzero elements. -/
290+
protected
291+
def trivial: AbsoluteValue R S where
292+
toFun x := if x = 0 then 0 else 1
293+
map_mul' x y := by
294+
rcases eq_or_ne x 0 with rfl | hx
295+
· simp
296+
rcases eq_or_ne y 0 with rfl | hy
297+
· simp
298+
simp [hx, hy]
299+
nonneg' x := by rcases eq_or_ne x 0 with hx | hx <;> simp [hx]
300+
eq_zero' x := by rcases eq_or_ne x 0 with hx | hx <;> simp [hx]
301+
add_le' x y := by
302+
rcases eq_or_ne x 0 with rfl | hx
303+
· simp
304+
rcases eq_or_ne y 0 with rfl | hy
305+
· simp
306+
simp only [hx, ↓reduceIte, hy, one_add_one_eq_two]
307+
rcases eq_or_ne (x + y) 0 with hxy | hxy <;> simp [hxy, one_le_two]
308+
309+
@[simp]
310+
lemma trivial_apply {x : R} (hx : x ≠ 0) : AbsoluteValue.trivial (S := S) x = 1 :=
311+
if_neg hx
312+
313+
end trivial
314+
252315
end AbsoluteValue
253316

254317
-- Porting note: Removed [] in fields, see
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/-
2+
Copyright (c) 2025 Michael Stoll. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Michael Stoll
5+
-/
6+
import Mathlib.Analysis.SpecialFunctions.Pow.Real
7+
8+
/-!
9+
# Equivalence of real-valued absolute values
10+
11+
Two absolute values `v₁, v₂ : AbsoluteValue R ℝ` are *equivalent* if there exists a
12+
positive real number `c` such that `v₁ x ^ c = v₂ x` for all `x : R`.
13+
-/
14+
15+
namespace AbsoluteValue
16+
17+
variable {R : Type*} [Semiring R]
18+
19+
/-- Two absolute values `f, g` on `R` with values in `ℝ` are *equivalent* if there exists
20+
a positive real constant `c` such that for all `x : R`, `(f x)^c = g x`. -/
21+
def Equiv (f g : AbsoluteValue R ℝ) : Prop :=
22+
∃ c : ℝ, 0 < c ∧ (f · ^ c) = g
23+
24+
/-- Equivalence of absolute values is reflexive. -/
25+
lemma equiv_refl (f : AbsoluteValue R ℝ) : Equiv f f :=
26+
1, Real.zero_lt_one, funext fun x ↦ Real.rpow_one (f x)⟩
27+
28+
/-- Equivalence of absolute values is symmetric. -/
29+
lemma equiv_symm {f g : AbsoluteValue R ℝ} (hfg : Equiv f g) : Equiv g f := by
30+
rcases hfg with ⟨c, hcpos, h⟩
31+
refine ⟨1 / c, one_div_pos.mpr hcpos, ?_⟩
32+
simp [← h, Real.rpow_rpow_inv (apply_nonneg f _) (ne_of_lt hcpos).symm]
33+
34+
/-- Equivalence of absolute values is transitive. -/
35+
lemma equiv_trans {f g k : AbsoluteValue R ℝ} (hfg : Equiv f g) (hgk : Equiv g k) :
36+
Equiv f k := by
37+
rcases hfg with ⟨c, hcPos, hfg⟩
38+
rcases hgk with ⟨d, hdPos, hgk⟩
39+
refine ⟨c * d, mul_pos hcPos hdPos, ?_⟩
40+
simp [← hgk, ← hfg, Real.rpow_mul (apply_nonneg f _)]
41+
42+
/-- An absolute value is equivalent to the trivial iff it is trivial itself. -/
43+
@[simp]
44+
lemma eq_trivial_of_equiv_trivial [DecidablePred fun x : R ↦ x = 0] [NoZeroDivisors R]
45+
(f : AbsoluteValue R ℝ) :
46+
f.Equiv .trivial ↔ f = .trivial := by
47+
refine ⟨fun ⟨c, hc₀, hc⟩ ↦ ext fun x ↦ ?_, fun H ↦ H ▸ equiv_refl f⟩
48+
apply_fun (· x) at hc
49+
rcases eq_or_ne x 0 with rfl | hx
50+
· simp
51+
· simp only [ne_eq, hx, not_false_eq_true, trivial_apply] at hc ⊢
52+
exact (Real.rpow_left_inj (f.nonneg x) zero_le_one hc₀.ne').mp <| (Real.one_rpow c).symm ▸ hc
53+
54+
instance : Setoid (AbsoluteValue R ℝ) where
55+
r := Equiv
56+
iseqv := {
57+
refl := equiv_refl
58+
symm := equiv_symm
59+
trans := equiv_trans
60+
}
61+
62+
end AbsoluteValue

Mathlib/Algebra/Order/EuclideanAbsoluteValue.lean renamed to Mathlib/Algebra/Order/AbsoluteValue/Euclidean.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Copyright (c) 2021 Anne Baanen. All rights reserved.
33
Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Anne Baanen
55
-/
6-
import Mathlib.Algebra.Order.AbsoluteValue
6+
import Mathlib.Algebra.Order.AbsoluteValue.Basic
77
import Mathlib.Algebra.EuclideanDomain.Int
88

99
/-!

Mathlib/Algebra/Order/BigOperators/Ring/Finset.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Floris van Doorn
55
-/
66
import Mathlib.Algebra.BigOperators.Ring
7-
import Mathlib.Algebra.Order.AbsoluteValue
7+
import Mathlib.Algebra.Order.AbsoluteValue.Basic
88
import Mathlib.Algebra.Order.BigOperators.Group.Finset
99
import Mathlib.Algebra.Order.BigOperators.Ring.Multiset
1010
import Mathlib.Tactic.Ring

Mathlib/Algebra/Order/CauSeq/Basic.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Mario Carneiro
55
-/
66
import Mathlib.Algebra.Group.Action.Pi
7-
import Mathlib.Algebra.Order.AbsoluteValue
7+
import Mathlib.Algebra.Order.AbsoluteValue.Basic
88
import Mathlib.Algebra.Order.Field.Basic
99
import Mathlib.Algebra.Order.Group.MinMax
1010
import Mathlib.Algebra.Ring.Pi

Mathlib/Algebra/Polynomial/Degree/CardPowDegree.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Copyright (c) 2021 Anne Baanen. All rights reserved.
33
Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Anne Baanen
55
-/
6-
import Mathlib.Algebra.Order.EuclideanAbsoluteValue
6+
import Mathlib.Algebra.Order.AbsoluteValue.Euclidean
77
import Mathlib.Algebra.Order.Ring.Basic
88
import Mathlib.Algebra.Polynomial.FieldDivision
99

Mathlib/Analysis/Normed/Ring/WithAbs.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Salvatore Mercuri
55
-/
66
import Mathlib.Algebra.Group.Basic
7-
import Mathlib.Algebra.Order.AbsoluteValue
7+
import Mathlib.Algebra.Order.AbsoluteValue.Basic
88
import Mathlib.Analysis.Normed.Field.Basic
99
import Mathlib.Analysis.Normed.Module.Completion
1010

Mathlib/Data/Int/AbsoluteValue.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Authors: Anne Baanen
55
-/
66
import Mathlib.Algebra.GroupWithZero.Action.Units
77
import Mathlib.Algebra.Module.Basic
8-
import Mathlib.Algebra.Order.AbsoluteValue
8+
import Mathlib.Algebra.Order.AbsoluteValue.Basic
99
import Mathlib.Algebra.Ring.Int.Units
1010
import Mathlib.Data.Int.Cast.Lemmas
1111

Mathlib/NumberTheory/ClassNumber/AdmissibleAbsoluteValue.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Authors: Anne Baanen
55
-/
66
import Mathlib.Data.Real.Basic
77
import Mathlib.Combinatorics.Pigeonhole
8-
import Mathlib.Algebra.Order.EuclideanAbsoluteValue
8+
import Mathlib.Algebra.Order.AbsoluteValue.Euclidean
99

1010
/-!
1111
# Admissible absolute values

0 commit comments

Comments
 (0)