|
| 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) |
0 commit comments