Skip to content

Commit 0671c30

Browse files
Absolute value of real numbers (#1385)
Doesn't have nearly as much content as #1381 , but that's because we don't even have addition yet on the real numbers. Still, this is, I think, enough to continue on #1353 . --------- Co-authored-by: Fredrik Bakke <[email protected]>
1 parent c6d3efe commit 0671c30

7 files changed

+275
-36
lines changed

src/elementary-number-theory/absolute-value-integers.lagda.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ open import foundation.unit-type
2828

2929
## Idea
3030

31-
The {{#concept "absolute value" Disambiguation="of an integer" Agda=abs-ℤ}} of
32-
an integer is the natural number with the same distance from `0`.
31+
The
32+
{{#concept "absolute value" Disambiguation="of an integer" Agda=abs-ℤ WD="absolute value" WDID=Q120812}}
33+
of an integer is the natural number with the same distance from `0`.
3334

3435
## Definition
3536

src/order-theory/least-upper-bounds-large-posets.lagda.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ module order-theory.least-upper-bounds-large-posets where
88

99
```agda
1010
open import foundation.dependent-pair-types
11+
open import foundation.function-types
1112
open import foundation.logical-equivalences
13+
open import foundation.type-arithmetic-cartesian-product-types
1214
open import foundation.universe-levels
1315
1416
open import order-theory.dependent-products-large-posets
@@ -39,6 +41,15 @@ Similarly, a
3941
of a family of elements `a : I → P` in a large poset `P` is an element `x` in
4042
`P` such that the logical equivalence
4143

44+
```text
45+
is-binary-upper-bound-Large-Poset P a b y ↔ (x ≤ y)
46+
```
47+
48+
holds for every `y` in `P`.
49+
50+
Similarly, a least upper bound of a family of elements `a : I → P` in a large
51+
poset `P` is an element `x` in `P` such that the logical equivalence
52+
4253
```text
4354
is-upper-bound-family-of-elements-Large-Poset P a y ↔ (x ≤ y)
4455
```
@@ -130,6 +141,24 @@ module _
130141
backward-implication (H _) (refl-leq-Large-Poset P _)
131142
```
132143

144+
### The least upper bound of `x` and `y` is the least upper bound of `y` and `x`
145+
146+
```agda
147+
module _
148+
{α : Level → Level} {β : Level → Level → Level}
149+
(P : Large-Poset α β)
150+
{l1 l2 : Level} (a : type-Large-Poset P l1) (b : type-Large-Poset P l2)
151+
where
152+
153+
abstract
154+
is-binary-least-upper-bound-swap-Large-Poset :
155+
{l3 : Level} (y : type-Large-Poset P l3) →
156+
is-least-binary-upper-bound-Large-Poset P a b y →
157+
is-least-binary-upper-bound-Large-Poset P b a y
158+
is-binary-least-upper-bound-swap-Large-Poset _ H z =
159+
H z ∘iff iff-equiv commutative-product
160+
```
161+
133162
### Binary least upper bounds are unique up to similarity of elements
134163

135164
```agda

src/real-numbers.lagda.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
```agda
66
module real-numbers where
77
8+
open import real-numbers.absolute-value-real-numbers public
89
open import real-numbers.addition-lower-dedekind-real-numbers public
910
open import real-numbers.addition-upper-dedekind-real-numbers public
1011
open import real-numbers.apartness-real-numbers public
@@ -23,6 +24,7 @@ open import real-numbers.minimum-real-numbers public
2324
open import real-numbers.minimum-upper-dedekind-real-numbers public
2425
open import real-numbers.negation-lower-upper-dedekind-real-numbers public
2526
open import real-numbers.negation-real-numbers public
27+
open import real-numbers.nonnegative-real-numbers public
2628
open import real-numbers.raising-universe-levels-real-numbers public
2729
open import real-numbers.rational-lower-dedekind-real-numbers public
2830
open import real-numbers.rational-real-numbers public
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# The absolute value of real numbers
2+
3+
```agda
4+
{-# OPTIONS --lossy-unification #-}
5+
6+
module real-numbers.absolute-value-real-numbers where
7+
```
8+
9+
<details><summary>Imports</summary>
10+
11+
```agda
12+
open import elementary-number-theory.rational-numbers
13+
14+
open import foundation.action-on-identifications-functions
15+
open import foundation.dependent-pair-types
16+
open import foundation.disjunction
17+
open import foundation.empty-types
18+
open import foundation.function-types
19+
open import foundation.identity-types
20+
open import foundation.transport-along-identifications
21+
open import foundation.universe-levels
22+
23+
open import real-numbers.dedekind-real-numbers
24+
open import real-numbers.inequality-real-numbers
25+
open import real-numbers.maximum-real-numbers
26+
open import real-numbers.negation-real-numbers
27+
open import real-numbers.nonnegative-real-numbers
28+
```
29+
30+
</details>
31+
32+
## Idea
33+
34+
The
35+
{{#concept "absolute value" Disambiguation="of a real number" Agda=abs-ℝ WD="absolute value" WDID=Q120812}}
36+
of a [real number](real-numbers.dedekind-real-numbers.md) is the
37+
[maximum](real-numbers.maximum-real-numbers.md) of it and its
38+
[negation](real-numbers.negation-real-numbers.md).
39+
40+
```agda
41+
abs-ℝ : {l : Level} → ℝ l → ℝ l
42+
abs-ℝ x = binary-max-ℝ x (neg-ℝ x)
43+
```
44+
45+
## Properties
46+
47+
### The absolute value of a real number is nonnegative
48+
49+
```agda
50+
abstract
51+
is-nonnegative-abs-ℝ : {l : Level} → (x : ℝ l) → is-nonnegative-ℝ (abs-ℝ x)
52+
is-nonnegative-abs-ℝ x q q<0 =
53+
elim-disjunction
54+
( lower-cut-ℝ (abs-ℝ x) q)
55+
( id)
56+
( λ (x<0 , 0<x) → ex-falso (is-disjoint-cut-ℝ x zero-ℚ (0<x , x<0)))
57+
( is-located-lower-upper-cut-ℝ (abs-ℝ x) q zero-ℚ q<0)
58+
```
59+
60+
### The absolute value of the negation of a real number is its absolute value
61+
62+
```agda
63+
abstract
64+
abs-neg-ℝ : {l : Level} → (x : ℝ l) → abs-ℝ (neg-ℝ x) = abs-ℝ x
65+
abs-neg-ℝ x =
66+
ap (binary-max-ℝ (neg-ℝ x)) (neg-neg-ℝ x) ∙ commutative-binary-max-ℝ _ _
67+
```
68+
69+
### `x` is between `-|x|` and `|x|`
70+
71+
```agda
72+
module _
73+
{l : Level} (x : ℝ l)
74+
where
75+
76+
abstract
77+
leq-abs-ℝ : leq-ℝ x (abs-ℝ x)
78+
leq-abs-ℝ = leq-left-binary-max-ℝ x (neg-ℝ x)
79+
80+
neg-leq-abs-ℝ : leq-ℝ (neg-ℝ x) (abs-ℝ x)
81+
neg-leq-abs-ℝ = leq-right-binary-max-ℝ x (neg-ℝ x)
82+
83+
leq-neg-abs-ℝ : leq-ℝ (neg-ℝ (abs-ℝ x)) x
84+
leq-neg-abs-ℝ =
85+
tr
86+
( leq-ℝ (neg-ℝ (abs-ℝ x)))
87+
( neg-neg-ℝ x)
88+
( neg-leq-ℝ (neg-ℝ x) (abs-ℝ x) neg-leq-abs-ℝ)
89+
90+
neg-leq-neg-abs-ℝ : leq-ℝ (neg-ℝ (abs-ℝ x)) (neg-ℝ x)
91+
neg-leq-neg-abs-ℝ = neg-leq-ℝ x (abs-ℝ x) leq-abs-ℝ
92+
```

src/real-numbers/inequality-real-numbers.lagda.md

Lines changed: 52 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ open import foundation.coproduct-types
1616
open import foundation.dependent-pair-types
1717
open import foundation.empty-types
1818
open import foundation.existential-quantification
19+
open import foundation.function-types
1920
open import foundation.identity-types
2021
open import foundation.logical-equivalences
2122
open import foundation.propositions
@@ -75,41 +76,47 @@ module _
7576
leq-ℝ' : UU (l1 ⊔ l2)
7677
leq-ℝ' = type-Prop leq-ℝ-Prop'
7778
78-
leq-iff-ℝ' : leq-ℝ x y ↔ leq-ℝ'
79-
pr1 (leq-iff-ℝ') lx⊆ly q q-in-uy =
80-
elim-exists
81-
( upper-cut-ℝ x q)
82-
( λ p (p<q , p≮y) →
83-
subset-upper-cut-upper-complement-lower-cut-ℝ
84-
( x)
85-
( q)
86-
( intro-exists
87-
( p)
88-
( p<q ,
89-
reverses-order-complement-subtype
90-
( lower-cut-ℝ x)
91-
( lower-cut-ℝ y)
92-
( lx⊆ly)
93-
( p)
94-
( p≮y))))
95-
( subset-upper-complement-lower-cut-upper-cut-ℝ y q q-in-uy)
96-
pr2 leq-iff-ℝ' uy⊆ux p p-in-lx =
97-
elim-exists
98-
( lower-cut-ℝ y p)
99-
( λ q (p<q , x≮q) →
100-
subset-lower-cut-lower-complement-upper-cut-ℝ
101-
( y)
102-
( p)
103-
( intro-exists
79+
abstract
80+
leq'-leq-ℝ : leq-ℝ x y → leq-ℝ'
81+
leq'-leq-ℝ lx⊆ly q y<q =
82+
elim-exists
83+
( upper-cut-ℝ x q)
84+
( λ p (p<q , p≮y) →
85+
subset-upper-cut-upper-complement-lower-cut-ℝ
86+
( x)
10487
( q)
105-
( p<q ,
106-
reverses-order-complement-subtype
107-
( upper-cut-ℝ y)
108-
( upper-cut-ℝ x)
109-
( uy⊆ux)
110-
( q)
111-
( x≮q))))
112-
( subset-lower-complement-upper-cut-lower-cut-ℝ x p p-in-lx)
88+
( intro-exists
89+
( p)
90+
( p<q ,
91+
reverses-order-complement-subtype
92+
( lower-cut-ℝ x)
93+
( lower-cut-ℝ y)
94+
( lx⊆ly)
95+
( p)
96+
( p≮y))))
97+
( subset-upper-complement-lower-cut-upper-cut-ℝ y q y<q)
98+
99+
leq-leq'-ℝ : leq-ℝ' → leq-ℝ x y
100+
leq-leq'-ℝ uy⊆ux p p<x =
101+
elim-exists
102+
( lower-cut-ℝ y p)
103+
( λ q (p<q , x≮q) →
104+
subset-lower-cut-lower-complement-upper-cut-ℝ
105+
( y)
106+
( p)
107+
( intro-exists
108+
( q)
109+
( p<q ,
110+
reverses-order-complement-subtype
111+
( upper-cut-ℝ y)
112+
( upper-cut-ℝ x)
113+
( uy⊆ux)
114+
( q)
115+
( x≮q))))
116+
( subset-lower-complement-upper-cut-lower-cut-ℝ x p p<x)
117+
118+
leq-iff-ℝ' : leq-ℝ x y ↔ leq-ℝ'
119+
leq-iff-ℝ' = (leq'-leq-ℝ , leq-leq'-ℝ)
113120
```
114121

115122
### Inequality on the real numbers is reflexive
@@ -186,6 +193,17 @@ iff-leq-real-ℚ : (x y : ℚ) → leq-ℚ x y ↔ leq-ℝ (real-ℚ x) (real-
186193
iff-leq-real-ℚ = iff-leq-lower-real-ℚ
187194
```
188195

196+
### Negation reverses inequality on the real numbers
197+
198+
```agda
199+
module _
200+
{l1 l2 : Level} (x : ℝ l1) (y : ℝ l2)
201+
where
202+
203+
neg-leq-ℝ : leq-ℝ x y → leq-ℝ (neg-ℝ y) (neg-ℝ x)
204+
neg-leq-ℝ x≤y = leq-leq'-ℝ (neg-ℝ y) (neg-ℝ x) (x≤y ∘ neg-ℚ)
205+
```
206+
189207
## References
190208

191209
{{#bibliography}}

src/real-numbers/maximum-real-numbers.lagda.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ module real-numbers.maximum-real-numbers where
1212
open import foundation.dependent-pair-types
1313
open import foundation.disjunction
1414
open import foundation.empty-types
15+
open import foundation.identity-types
1516
open import foundation.propositions
1617
open import foundation.universe-levels
1718
@@ -23,6 +24,7 @@ open import real-numbers.inequality-real-numbers
2324
open import real-numbers.lower-dedekind-real-numbers
2425
open import real-numbers.maximum-lower-dedekind-real-numbers
2526
open import real-numbers.maximum-upper-dedekind-real-numbers
27+
open import real-numbers.similarity-real-numbers
2628
open import real-numbers.upper-dedekind-real-numbers
2729
```
2830

@@ -111,6 +113,61 @@ module _
111113
( lower-real-ℝ z)
112114
```
113115

116+
### The binary maximum is a binary upper bound
117+
118+
```agda
119+
module _
120+
{l1 l2 : Level}
121+
(x : ℝ l1) (y : ℝ l2)
122+
where
123+
124+
abstract
125+
leq-left-binary-max-ℝ : leq-ℝ x (binary-max-ℝ x y)
126+
leq-left-binary-max-ℝ =
127+
pr1
128+
( is-binary-upper-bound-is-least-binary-upper-bound-Large-Poset
129+
( ℝ-Large-Poset)
130+
( x)
131+
( y)
132+
( is-least-binary-upper-bound-binary-max-ℝ x y))
133+
134+
leq-right-binary-max-ℝ : leq-ℝ y (binary-max-ℝ x y)
135+
leq-right-binary-max-ℝ =
136+
pr2
137+
( is-binary-upper-bound-is-least-binary-upper-bound-Large-Poset
138+
( ℝ-Large-Poset)
139+
( x)
140+
( y)
141+
( is-least-binary-upper-bound-binary-max-ℝ x y))
142+
```
143+
144+
### The binary maximum is commutative
145+
146+
```agda
147+
module _
148+
{l1 l2 : Level}
149+
(x : ℝ l1) (y : ℝ l2)
150+
where
151+
152+
opaque
153+
unfolding sim-ℝ
154+
155+
commutative-binary-max-ℝ : binary-max-ℝ x y = binary-max-ℝ y x
156+
commutative-binary-max-ℝ =
157+
eq-sim-ℝ
158+
( sim-is-least-binary-upper-bound-Large-Poset
159+
( ℝ-Large-Poset)
160+
( x)
161+
( y)
162+
( is-least-binary-upper-bound-binary-max-ℝ x y)
163+
( is-binary-least-upper-bound-swap-Large-Poset
164+
( ℝ-Large-Poset)
165+
( y)
166+
( x)
167+
( binary-max-ℝ y x)
168+
( is-least-binary-upper-bound-binary-max-ℝ y x)))
169+
```
170+
114171
### The large poset of real numbers has joins
115172

116173
```agda
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Nonnegative real numbers
2+
3+
```agda
4+
{-# OPTIONS --lossy-unification #-}
5+
6+
module real-numbers.nonnegative-real-numbers where
7+
```
8+
9+
<details><summary>Imports</summary>
10+
11+
```agda
12+
open import foundation.propositions
13+
open import foundation.subtypes
14+
open import foundation.universe-levels
15+
16+
open import real-numbers.dedekind-real-numbers
17+
open import real-numbers.inequality-real-numbers
18+
open import real-numbers.rational-real-numbers
19+
```
20+
21+
</details>
22+
23+
## Idea
24+
25+
A real number `x` is
26+
{{#concept "nonnegative" Disambiguation="real number" Agda=is-nonnegative-ℝ}} if
27+
`0 ≤ x`.
28+
29+
## Definitions
30+
31+
```agda
32+
is-nonnegative-ℝ : {l : Level} → ℝ l → UU l
33+
is-nonnegative-ℝ = leq-ℝ zero-ℝ
34+
35+
is-nonnegative-prop-ℝ : {l : Level} → ℝ l → Prop l
36+
is-nonnegative-prop-ℝ = leq-ℝ-Prop zero-ℝ
37+
38+
nonnegative-ℝ : (l : Level) → UU (lsuc l)
39+
nonnegative-ℝ l = type-subtype (is-nonnegative-prop-ℝ {l})
40+
```

0 commit comments

Comments
 (0)