/
inequality-integers.lagda.md
157 lines (126 loc) · 4.67 KB
/
inequality-integers.lagda.md
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# Inequality on the integers
```agda
module elementary-number-theory.inequality-integers where
```
<details><summary>Imports</summary>
```agda
open import elementary-number-theory.addition-integers
open import elementary-number-theory.difference-integers
open import elementary-number-theory.inequality-natural-numbers
open import elementary-number-theory.integers
open import elementary-number-theory.natural-numbers
open import foundation.action-on-identifications-functions
open import foundation.coproduct-types
open import foundation.function-types
open import foundation.functoriality-coproduct-types
open import foundation.identity-types
open import foundation.propositions
open import foundation.transport
open import foundation.unit-type
open import foundation.universe-levels
```
</details>
## Definition
```agda
leq-ℤ-Prop : ℤ → ℤ → Prop lzero
leq-ℤ-Prop x y = is-nonnegative-ℤ-Prop (y -ℤ x)
leq-ℤ : ℤ → ℤ → UU lzero
leq-ℤ x y = type-Prop (leq-ℤ-Prop x y)
is-prop-leq-ℤ : (x y : ℤ) → is-prop (leq-ℤ x y)
is-prop-leq-ℤ x y = is-prop-type-Prop (leq-ℤ-Prop x y)
```
## Properties
```agda
refl-leq-ℤ : (k : ℤ) → leq-ℤ k k
refl-leq-ℤ k = tr is-nonnegative-ℤ (inv (right-inverse-law-add-ℤ k)) star
antisymmetric-leq-ℤ : {x y : ℤ} → leq-ℤ x y → leq-ℤ y x → x = y
antisymmetric-leq-ℤ {x} {y} H K =
eq-diff-ℤ
( is-zero-is-nonnegative-ℤ K
( is-nonnegative-eq-ℤ (inv (distributive-neg-diff-ℤ x y)) H))
trans-leq-ℤ : (k l m : ℤ) → leq-ℤ k l → leq-ℤ l m → leq-ℤ k m
trans-leq-ℤ k l m p q =
tr is-nonnegative-ℤ
( triangle-diff-ℤ m l k)
( is-nonnegative-add-ℤ
( m +ℤ (neg-ℤ l))
( l +ℤ (neg-ℤ k))
( q)
( p))
decide-leq-ℤ :
{x y : ℤ} → (leq-ℤ x y) + (leq-ℤ y x)
decide-leq-ℤ {x} {y} =
map-coprod
( id)
( is-nonnegative-eq-ℤ (distributive-neg-diff-ℤ y x))
( decide-is-nonnegative-ℤ {y -ℤ x})
succ-leq-ℤ : (k : ℤ) → leq-ℤ k (succ-ℤ k)
succ-leq-ℤ k =
is-nonnegative-eq-ℤ
( inv
( ( left-successor-law-add-ℤ k (neg-ℤ k)) ∙
( ap succ-ℤ (right-inverse-law-add-ℤ k))))
( star)
leq-ℤ-succ-leq-ℤ : (k l : ℤ) → leq-ℤ k l → leq-ℤ k (succ-ℤ l)
leq-ℤ-succ-leq-ℤ k l p = trans-leq-ℤ k l (succ-ℤ l) p (succ-leq-ℤ l)
concatenate-eq-leq-eq-ℤ :
{x' x y y' : ℤ} → x' = x → leq-ℤ x y → y = y' → leq-ℤ x' y'
concatenate-eq-leq-eq-ℤ refl H refl = H
concatenate-leq-eq-ℤ :
(x : ℤ) {y y' : ℤ} → leq-ℤ x y → y = y' → leq-ℤ x y'
concatenate-leq-eq-ℤ x H refl = H
concatenate-eq-leq-ℤ :
{x x' : ℤ} (y : ℤ) → x' = x → leq-ℤ x y → leq-ℤ x' y
concatenate-eq-leq-ℤ y refl H = H
```
### The strict ordering on ℤ
```agda
le-ℤ-Prop : ℤ → ℤ → Prop lzero
le-ℤ-Prop x y = is-positive-ℤ-Prop (x -ℤ y)
le-ℤ : ℤ → ℤ → UU lzero
le-ℤ x y = type-Prop (le-ℤ-Prop x y)
is-prop-le-ℤ : (x y : ℤ) → is-prop (le-ℤ x y)
is-prop-le-ℤ x y = is-prop-type-Prop (le-ℤ-Prop x y)
```
### ℤ is an ordered ring
```agda
preserves-order-add-ℤ' :
{x y : ℤ} (z : ℤ) → leq-ℤ x y → leq-ℤ (x +ℤ z) (y +ℤ z)
preserves-order-add-ℤ' {x} {y} z =
is-nonnegative-eq-ℤ (inv (right-translation-diff-ℤ y x z))
preserves-order-add-ℤ :
{x y : ℤ} (z : ℤ) → leq-ℤ x y → leq-ℤ (z +ℤ x) (z +ℤ y)
preserves-order-add-ℤ {x} {y} z =
is-nonnegative-eq-ℤ (inv (left-translation-diff-ℤ y x z))
preserves-leq-add-ℤ :
{a b c d : ℤ} → leq-ℤ a b → leq-ℤ c d → leq-ℤ (a +ℤ c) (b +ℤ d)
preserves-leq-add-ℤ {a} {b} {c} {d} H K =
trans-leq-ℤ
( a +ℤ c)
( b +ℤ c)
( b +ℤ d)
( preserves-order-add-ℤ' {a} {b} c H)
( preserves-order-add-ℤ b K)
reflects-order-add-ℤ' :
{x y z : ℤ} → leq-ℤ (x +ℤ z) (y +ℤ z) → leq-ℤ x y
reflects-order-add-ℤ' {x} {y} {z} =
is-nonnegative-eq-ℤ (right-translation-diff-ℤ y x z)
reflects-order-add-ℤ :
{x y z : ℤ} → leq-ℤ (z +ℤ x) (z +ℤ y) → leq-ℤ x y
reflects-order-add-ℤ {x} {y} {z} =
is-nonnegative-eq-ℤ (left-translation-diff-ℤ y x z)
```
### Inclusion of ℕ into ℤ preserves order
```agda
leq-int-ℕ : (x y : ℕ) → leq-ℕ x y → leq-ℤ (int-ℕ x) (int-ℕ y)
leq-int-ℕ zero-ℕ y H =
tr
( is-nonnegative-ℤ)
( inv (right-unit-law-add-ℤ (int-ℕ y)))
( is-nonnegative-int-ℕ y)
leq-int-ℕ (succ-ℕ x) (succ-ℕ y) H = tr (is-nonnegative-ℤ)
( inv (diff-succ-ℤ (int-ℕ y) (int-ℕ x)) ∙
( ap (_-ℤ (succ-ℤ (int-ℕ x))) (succ-int-ℕ y) ∙
ap ((int-ℕ (succ-ℕ y)) -ℤ_) (succ-int-ℕ x)))
(leq-int-ℕ x y H)
```