Skip to content

Commit 21c773a

Browse files
committed
feat: Port/RingTheory.Valuation.Integers (#2966)
mostly simple fixes: proofs to sub for `trans_rel_right` and moving instance declarations into namespace.
1 parent c973255 commit 21c773a

File tree

2 files changed

+144
-0
lines changed

2 files changed

+144
-0
lines changed

Mathlib.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,6 +1286,7 @@ import Mathlib.RingTheory.Subring.Pointwise
12861286
import Mathlib.RingTheory.Subsemiring.Basic
12871287
import Mathlib.RingTheory.Subsemiring.Pointwise
12881288
import Mathlib.RingTheory.Valuation.Basic
1289+
import Mathlib.RingTheory.Valuation.Integers
12891290
import Mathlib.SetTheory.Cardinal.Basic
12901291
import Mathlib.SetTheory.Cardinal.Cofinality
12911292
import Mathlib.SetTheory.Cardinal.Continuum
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
/-
2+
Copyright (c) 2020 Kenny Lau. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Kenny Lau
5+
6+
! This file was ported from Lean 3 source module ring_theory.valuation.integers
7+
! leanprover-community/mathlib commit 7b7da89322fe46a16bf03eeb345b0acfc73fe10e
8+
! Please do not edit these lines, except to modify the commit id
9+
! if you have ported upstream changes.
10+
-/
11+
import Mathlib.RingTheory.Valuation.Basic
12+
13+
/-!
14+
# Ring of integers under a given valuation
15+
16+
The elements with valuation less than or equal to 1.
17+
18+
TODO: Define characteristic predicate.
19+
-/
20+
21+
22+
universe u v w
23+
24+
namespace Valuation
25+
26+
section Ring
27+
28+
variable {R : Type u} {Γ₀ : Type v} [Ring R] [LinearOrderedCommGroupWithZero Γ₀]
29+
30+
variable (v : Valuation R Γ₀)
31+
32+
/-- The ring of integers under a given valuation is the subring of elements with valuation ≤ 1. -/
33+
def integer : Subring R where
34+
carrier := { x | v x ≤ 1 }
35+
one_mem' := le_of_eq v.map_one
36+
mul_mem' {x y} hx hy := by simp only [Set.mem_setOf_eq, _root_.map_mul, mul_le_one' hx hy]
37+
zero_mem' := by simp only [Set.mem_setOf_eq, _root_.map_zero, zero_le']
38+
add_mem' {x y} hx hy := le_trans (v.map_add x y) (max_le hx hy)
39+
neg_mem' {x} hx :=by simp only [Set.mem_setOf_eq] at hx; simpa only [Set.mem_setOf_eq, map_neg]
40+
#align valuation.integer Valuation.integer
41+
42+
end Ring
43+
44+
section CommRing
45+
46+
variable {R : Type u} {Γ₀ : Type v} [CommRing R] [LinearOrderedCommGroupWithZero Γ₀]
47+
48+
variable (v : Valuation R Γ₀)
49+
50+
variable (O : Type w) [CommRing O] [Algebra O R]
51+
52+
/-- Given a valuation v : R → Γ₀ and a ring homomorphism O →+* R, we say that O is the integers of v
53+
if f is injective, and its range is exactly `v.integer`. -/
54+
structure Integers : Prop where
55+
hom_inj : Function.Injective (algebraMap O R)
56+
map_le_one : ∀ x, v (algebraMap O R x) ≤ 1
57+
exists_of_le_one : ∀ ⦃r⦄, v r ≤ 1 → ∃ x, algebraMap O R x = r
58+
#align valuation.integers Valuation.Integers
59+
60+
-- typeclass shortcut
61+
instance : Algebra v.integer R :=
62+
Algebra.ofSubring v.integer
63+
64+
theorem integer.integers : v.Integers v.integer :=
65+
{ hom_inj := Subtype.coe_injective
66+
map_le_one := fun r => r.2
67+
exists_of_le_one := fun r hr => ⟨⟨r, hr⟩, rfl⟩ }
68+
#align valuation.integer.integers Valuation.integer.integers
69+
70+
namespace Integers
71+
72+
variable {v O} [CommRing O] [Algebra O R] (hv : Integers v O)
73+
74+
75+
theorem one_of_isUnit {x : O} (hx : IsUnit x) : v (algebraMap O R x) = 1 :=
76+
let ⟨u, hu⟩ := hx
77+
le_antisymm (hv.2 _) <|
78+
by
79+
rw [← v.map_one, ← (algebraMap O R).map_one, ← u.mul_inv, ← mul_one (v (algebraMap O R x)), hu,
80+
(algebraMap O R).map_mul, v.map_mul]
81+
exact mul_le_mul_left' (hv.2 (u⁻¹ : Units O)) _
82+
#align valuation.integers.one_of_is_unit Valuation.Integers.one_of_isUnit
83+
84+
theorem isUnit_of_one {x : O} (hx : IsUnit (algebraMap O R x)) (hvx : v (algebraMap O R x) = 1) :
85+
IsUnit x :=
86+
let ⟨u, hu⟩ := hx
87+
have h1 : v u ≤ 1 := hu.symm ▸ hv.2 x
88+
have h2 : v (u⁻¹ : Rˣ) ≤ 1 := by
89+
rw [← one_mul (v _), ← hvx, ← v.map_mul, ← hu, u.mul_inv, hu, hvx, v.map_one]
90+
let ⟨r1, hr1⟩ := hv.3 h1
91+
let ⟨r2, hr2⟩ := hv.3 h2
92+
⟨⟨r1, r2, hv.1 <| by rw [RingHom.map_mul, RingHom.map_one, hr1, hr2, Units.mul_inv],
93+
hv.1 <| by rw [RingHom.map_mul, RingHom.map_one, hr1, hr2, Units.inv_mul]⟩,
94+
hv.1 <| hr1.trans hu⟩
95+
#align valuation.integers.is_unit_of_one Valuation.Integers.isUnit_of_one
96+
97+
theorem le_of_dvd {x y : O} (h : x ∣ y) : v (algebraMap O R y) ≤ v (algebraMap O R x) := by
98+
let ⟨z, hz⟩ := h
99+
rw [← mul_one (v (algebraMap O R x)), hz, RingHom.map_mul, v.map_mul]
100+
exact mul_le_mul_left' (hv.2 z) _
101+
#align valuation.integers.le_of_dvd Valuation.Integers.le_of_dvd
102+
103+
end Integers
104+
105+
end CommRing
106+
107+
section Field
108+
109+
variable {F : Type u} {Γ₀ : Type v} [Field F] [LinearOrderedCommGroupWithZero Γ₀]
110+
111+
variable {v : Valuation F Γ₀} {O : Type w} [CommRing O] [Algebra O F] (hv : Integers v O)
112+
113+
namespace Integers
114+
115+
theorem dvd_of_le {x y : O} (h : v (algebraMap O F x) ≤ v (algebraMap O F y)) : y ∣ x :=
116+
by_cases
117+
(fun hy : algebraMap O F y = 0 =>
118+
have hx : x = 0 :=
119+
hv.1 <|
120+
(algebraMap O F).map_zero.symm ▸ (v.zero_iff.1 <| le_zero_iff.1 (v.map_zero ▸ hy ▸ h))
121+
hx.symm ▸ dvd_zero y)
122+
fun hy : algebraMap O F y ≠ 0 =>
123+
have : v ((algebraMap O F y)⁻¹ * algebraMap O F x) ≤ 1 :=
124+
by
125+
rw [← v.map_one, ← inv_mul_cancel hy, v.map_mul, v.map_mul]
126+
exact mul_le_mul_left' h _
127+
let ⟨z, hz⟩ := hv.3 this
128+
⟨z, hv.1 <| ((algebraMap O F).map_mul y z).symm ▸ hz.symm ▸ (mul_inv_cancel_left₀ hy _).symm⟩
129+
#align valuation.integers.dvd_of_le Valuation.Integers.dvd_of_le
130+
131+
theorem dvd_iff_le {x y : O} : x ∣ y ↔ v (algebraMap O F y) ≤ v (algebraMap O F x) :=
132+
⟨hv.le_of_dvd, hv.dvd_of_le⟩
133+
#align valuation.integers.dvd_iff_le Valuation.Integers.dvd_iff_le
134+
135+
theorem le_iff_dvd {x y : O} : v (algebraMap O F x) ≤ v (algebraMap O F y) ↔ y ∣ x :=
136+
⟨hv.dvd_of_le, hv.le_of_dvd⟩
137+
#align valuation.integers.le_iff_dvd Valuation.Integers.le_iff_dvd
138+
139+
end Integers
140+
141+
end Field
142+
143+
end Valuation

0 commit comments

Comments
 (0)