Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit b5baf55

Browse files
committed
feat(algebra/linear_ordered_comm_group_with_zero) define linear_ordered_comm_group_with_zero (#3072)
1 parent 48c4f40 commit b5baf55

File tree

3 files changed

+127
-0
lines changed

3 files changed

+127
-0
lines changed
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
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, Johan Commelin, Patrick Massot
5+
-/
6+
7+
import algebra.ordered_group
8+
import algebra.group_with_zero
9+
10+
/-!
11+
# Linearly ordered commutative groups with a zero element adjoined
12+
13+
This file sets up a special class of linearly ordered commutative monoids
14+
that show up as the target of so-called “valuations” in algebraic number theory.
15+
16+
Usually, in the informal literature, these objects are constructed
17+
by taking a linearly ordered commutative group Γ and formally adjoining a zero element: Γ ∪ {0}.
18+
19+
The disadvantage is that a type such as `nnreal` is not of that form,
20+
whereas it is a very common target for valuations.
21+
The solutions is to use a typeclass, and that is exactly what we do in this file.
22+
-/
23+
24+
set_option old_structure_cmd true
25+
set_option default_priority 100 -- see Note [default priority]
26+
27+
/-- A linearly ordered commutative group with a zero element. -/
28+
class linear_ordered_comm_group_with_zero (α : Type*)
29+
extends linear_order α, comm_group_with_zero α :=
30+
(mul_le_mul_left : ∀ {a b : α}, a ≤ b → ∀ c : α, c * a ≤ c * b)
31+
(zero_le_one : (0:α) ≤ 1)
32+
33+
variables {α : Type*} [linear_ordered_comm_group_with_zero α]
34+
variables {a b c d x y z : α}
35+
36+
local attribute [instance] classical.prop_decidable
37+
38+
/-- Every linearly ordered commutative group with zero is an ordered commutative monoid.-/
39+
instance linear_ordered_comm_group_with_zero.to_ordered_comm_monoid : ordered_comm_monoid α :=
40+
{ lt_of_mul_lt_mul_left := λ a b c h, by { contrapose! h,
41+
exact linear_ordered_comm_group_with_zero.mul_le_mul_left h a }
42+
.. ‹linear_ordered_comm_group_with_zero α› }
43+
44+
lemma zero_le_one' : (0 : α) ≤ 1 :=
45+
linear_ordered_comm_group_with_zero.zero_le_one
46+
47+
lemma zero_lt_one' : (0 : α) < 1 :=
48+
lt_of_le_of_ne zero_le_one' zero_ne_one
49+
50+
@[simp] lemma zero_le' : 0 ≤ a :=
51+
by simpa only [mul_zero, mul_one] using mul_le_mul_left' zero_le_one'
52+
53+
@[simp] lemma not_lt_zero' : ¬a < 0 :=
54+
not_lt_of_le zero_le'
55+
56+
@[simp] lemma le_zero_iff : a ≤ 0 ↔ a = 0 :=
57+
⟨λ h, le_antisymm h zero_le', λ h, h ▸ le_refl _⟩
58+
59+
lemma zero_lt_iff : 0 < a ↔ a ≠ 0 :=
60+
⟨ne_of_gt, λ h, lt_of_le_of_ne zero_le' h.symm⟩
61+
62+
lemma le_of_le_mul_right (h : c ≠ 0) (hab : a * c ≤ b * c) : a ≤ b :=
63+
by simpa [h] using (mul_le_mul_right' hab : a * c * c⁻¹ ≤ b * c * c⁻¹)
64+
65+
lemma le_mul_inv_of_mul_le (h : c ≠ 0) (hab : a * c ≤ b) : a ≤ b * c⁻¹ :=
66+
le_of_le_mul_right h (by simpa [h] using hab)
67+
68+
lemma mul_inv_le_of_le_mul (h : c ≠ 0) (hab : a ≤ b * c) : a * c⁻¹ ≤ b :=
69+
le_of_le_mul_right h (by simpa [h] using hab)
70+
71+
lemma div_le_div' (a b c d : α) (hb : b ≠ 0) (hd : d ≠ 0) :
72+
a * b⁻¹ ≤ c * d⁻¹ ↔ a * d ≤ c * b :=
73+
begin
74+
by_cases ha : a = 0, { simp [ha] },
75+
by_cases hc : c = 0, { simp [inv_ne_zero hb, hc, hd], },
76+
exact (div_le_div_iff' (units.mk0 a ha) (units.mk0 b hb) (units.mk0 c hc) (units.mk0 d hd)),
77+
end
78+
79+
lemma ne_zero_of_lt (h : b < a) : a ≠ 0 :=
80+
λ h1, not_lt_zero' $ show b < 0, from h1 ▸ h
81+
82+
@[simp] lemma zero_lt_unit (u : units α) : (0 : α) < u :=
83+
zero_lt_iff.2 $ unit_ne_zero u
84+
85+
lemma mul_lt_mul'''' (hab : a < b) (hcd : c < d) : a * c < b * d :=
86+
have hb : b ≠ 0 := ne_zero_of_lt hab,
87+
have hd : d ≠ 0 := ne_zero_of_lt hcd,
88+
if ha : a = 0 then by { rw [ha, zero_mul, zero_lt_iff], exact mul_ne_zero'' hb hd } else
89+
if hc : c = 0 then by { rw [hc, mul_zero, zero_lt_iff], exact mul_ne_zero'' hb hd } else
90+
@mul_lt_mul''' _ _ (units.mk0 a ha) (units.mk0 b hb) (units.mk0 c hc) (units.mk0 d hd) hab hcd
91+
92+
lemma mul_inv_lt_of_lt_mul' (h : x < y * z) : x * z⁻¹ < y :=
93+
have hz : z ≠ 0 := (mul_ne_zero_iff.1 $ ne_zero_of_lt h).2,
94+
by { contrapose! h, simpa only [inv_inv'] using mul_inv_le_of_le_mul (inv_ne_zero hz) h }
95+
96+
lemma mul_lt_right' (c : α) (h : a < b) (hc : c ≠ 0) : a * c < b * c :=
97+
by { contrapose! h, exact le_of_le_mul_right hc h }
98+
99+
lemma inv_lt_inv'' (ha : a ≠ 0) (hb : b ≠ 0) : a⁻¹ < b⁻¹ ↔ b < a :=
100+
@inv_lt_inv_iff _ _ (units.mk0 a ha) (units.mk0 b hb)
101+
102+
lemma inv_le_inv'' (ha : a ≠ 0) (hb : b ≠ 0) : a⁻¹ ≤ b⁻¹ ↔ b ≤ a :=
103+
@inv_le_inv_iff _ _ (units.mk0 a ha) (units.mk0 b hb)

src/algebra/ordered_group.lean

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -837,6 +837,13 @@ class ordered_comm_group (α : Type u) extends comm_group α, partial_order α :
837837

838838
attribute [to_additive ordered_add_comm_group] ordered_comm_group
839839

840+
/--The units of an ordered commutative monoid form an ordered commutative group. -/
841+
@[to_additive]
842+
instance units.ordered_comm_group [ordered_comm_monoid α] : ordered_comm_group (units α) :=
843+
{ mul_le_mul_left := λ a b h c, mul_le_mul_left' h,
844+
.. units.partial_order,
845+
.. (infer_instance : comm_group (units α)) }
846+
840847
section ordered_comm_group
841848
variables [ordered_comm_group α] {a b c d : α}
842849

@@ -1165,6 +1172,16 @@ by rwa inv_mul_cancel_left at this
11651172
lemma inv_mul_lt_iff_lt_mul_right : c⁻¹ * a < b ↔ a < b * c :=
11661173
by rw [inv_mul_lt_iff_lt_mul, mul_comm]
11671174

1175+
@[to_additive sub_le_sub_iff]
1176+
lemma div_le_div_iff' (a b c d : α) : a * b⁻¹ ≤ c * d⁻¹ ↔ a * d ≤ c * b :=
1177+
begin
1178+
split ; intro h,
1179+
have := mul_le_mul_right'' (mul_le_mul_right'' h b) d,
1180+
rwa [inv_mul_cancel_right, mul_assoc _ _ b, mul_comm _ b, ← mul_assoc, inv_mul_cancel_right] at this,
1181+
have := mul_le_mul_right'' (mul_le_mul_right'' h d⁻¹) b⁻¹,
1182+
rwa [mul_inv_cancel_right, _root_.mul_assoc, _root_.mul_comm d⁻¹ b⁻¹, ← mul_assoc, mul_inv_cancel_right] at this,
1183+
end
1184+
11681185
end ordered_comm_group
11691186

11701187
section ordered_add_comm_group

src/data/real/nnreal.lean

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Authors: Johan Commelin
55
66
Nonnegative real numbers.
77
-/
8+
import algebra.linear_ordered_comm_group_with_zero
89
import data.real.basic
910

1011
noncomputable theory
@@ -196,6 +197,12 @@ instance : canonically_ordered_comm_semiring ℝ≥0 :=
196197
.. nnreal.canonically_ordered_add_monoid,
197198
.. nnreal.comm_semiring }
198199

200+
instance : linear_ordered_comm_group_with_zero ℝ≥0 :=
201+
{ mul_le_mul_left := assume a b h c, mul_le_mul (le_refl c) h (zero_le a) (zero_le c),
202+
zero_le_one := zero_le 1,
203+
.. nnreal.linear_ordered_semiring,
204+
.. nnreal.comm_group_with_zero }
205+
199206
instance : densely_ordered ℝ≥0 :=
200207
⟨assume a b (h : (a : ℝ) < b), let ⟨c, hac, hcb⟩ := dense h in
201208
⟨⟨c, le_trans a.property $ le_of_lt $ hac⟩, hac, hcb⟩⟩

0 commit comments

Comments
 (0)