-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Expand file tree
/
Copy pathWithZero.lean
More file actions
88 lines (68 loc) · 2.94 KB
/
Copy pathWithZero.lean
File metadata and controls
88 lines (68 loc) · 2.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/-
Copyright (c) 2024 Kevin Buzzard. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kevin Buzzard
-/
module
public import Mathlib.Algebra.Order.GroupWithZero.Basic
public import Mathlib.Algebra.Order.GroupWithZero.Canonical
/-!
# Covariant instances on `WithZero`
Adding a zero to a type with a preorder and multiplication which satisfies some
axiom, gives us a new type which satisfies some variant of the axiom.
## Example
If `α` satisfies `b₁ < b₂ → a * b₁ < a * b₂` for all `a`,
then `WithZero α` satisfies `b₁ < b₂ → a * b₁ < a * b₂` for all `a > 0`,
which is `PosMulStrictMono (WithZero α)`.
## Application
The type `ℤᵐ⁰ := WithZero (Multiplicative ℤ)` is used a lot in mathlib's valuation
theory. These instances enable lemmas such as `mul_pos` to fire on `ℤᵐ⁰`.
-/
@[expose] public section
assert_not_exists Ring
-- this makes `mul_lt_mul_iff_right₀`, `mul_pos` etc. work on `ℤᵐ⁰`
instance {α : Type*} [Mul α] [Preorder α] [MulLeftStrictMono α] :
PosMulStrictMono (WithZero α) where
mul_lt_mul_of_pos_left
| (x : α), hx, 0, (b : α), _ => by simpa only [mul_zero] using! WithZero.zero_lt_coe _
| (x : α), hx, (a : α), (b : α), h => by norm_cast at h ⊢; gcongr
open Function in
instance {α : Type*} [Mul α] [Preorder α] [MulRightStrictMono α] :
MulPosStrictMono (WithZero α) where
mul_lt_mul_of_pos_right
| (x : α), hx, 0, (b : α), _ => by simpa only [mul_zero] using! WithZero.zero_lt_coe _
| (x : α), hx, (a : α), (b : α), h => by norm_cast at h ⊢; gcongr
instance {α : Type*} [Mul α] [Preorder α] [MulLeftMono α] :
PosMulMono (WithZero α) where
mul_le_mul_of_nonneg_left
| 0, _, a, b, _ => by simp
| (x : α), _, 0, _, _ => by simp
| (x : α), _, (a : α), 0, h => by simp at h
| (x : α), hx, (a : α), (b : α), h => by norm_cast at h ⊢; gcongr
-- This makes `lt_mul_of_le_of_one_lt'` work on `ℤᵐ⁰`
open Function in
instance {α : Type*} [Mul α] [Preorder α] [MulRightMono α] :
MulPosMono (WithZero α) where
mul_le_mul_of_nonneg_right
| 0, _, a, b, _ => by simp
| (x : α), _, 0, _, _ => by simp
| (x : α), _, (a : α), 0, h => by simp at h
| (x : α), hx, (a : α), (b : α), h => by norm_cast at h ⊢; gcongr
section Units
variable {α : Type*} [LinearOrderedCommGroupWithZero α]
open WithZero
lemma WithZero.withZeroUnitsEquiv_strictMono :
StrictMono (withZeroUnitsEquiv (G := α)) := by
intro a b
cases a <;> cases b <;>
simp
/-- Given any linearly ordered commutative group with zero `α`, this is the order isomorphism
between `WithZero αˣ` with `α`. -/
@[simps!]
def OrderIso.withZeroUnits : WithZero αˣ ≃o α where
__ := withZeroUnitsEquiv
map_rel_iff' := WithZero.withZeroUnitsEquiv_strictMono.le_iff_le
lemma WithZero.withZeroUnitsEquiv_symm_strictMono :
StrictMono (withZeroUnitsEquiv (G := α)).symm :=
OrderIso.withZeroUnits.symm.strictMono
end Units