Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Break the Dedekind reals into lower and upper Dedekind reals #1314

Merged
merged 63 commits into from
Feb 16, 2025
Merged
Show file tree
Hide file tree
Changes from 50 commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
6a9f837
Define lower Dedekind cuts/reals
lowasser Feb 9, 2025
ef39dd3
make pre-commit
lowasser Feb 9, 2025
59195c9
Define upper Dedekind reals
lowasser Feb 9, 2025
4233e28
make pre-commit
lowasser Feb 9, 2025
6ad62d5
Rename things
lowasser Feb 9, 2025
6bfb619
Formatting
lowasser Feb 9, 2025
fd8f384
Add new file
lowasser Feb 9, 2025
fb0d5d3
Fix line length
lowasser Feb 9, 2025
efaf647
Merge branch 'lower-upper-dedekind' into lower-upper-rational-dedekind
lowasser Feb 9, 2025
f21b948
Add rational upper reals
lowasser Feb 9, 2025
a3d3af9
Progress
lowasser Feb 9, 2025
ba687cd
Merge branch 'lower-upper-rational-dedekind' into lower-upper-inequality
lowasser Feb 9, 2025
fb18a45
Preservation of inequality
lowasser Feb 9, 2025
0aa663c
Define normal Dedekind reals in terms of lower and upper cuts
lowasser Feb 9, 2025
1f9f502
Merge branch 'lower-upper-inequality' into lower-upper-dedekind
lowasser Feb 9, 2025
7499c7c
Start negation
lowasser Feb 9, 2025
2185e18
Inequality on upper reals
lowasser Feb 9, 2025
f2da896
overhaul
lowasser Feb 10, 2025
70f181c
make pre-commit
lowasser Feb 10, 2025
9268779
a -> an
lowasser Feb 10, 2025
e40e90b
Merge branch 'master' into lower-upper-neg
lowasser Feb 10, 2025
1b9d81b
Rename some things
lowasser Feb 10, 2025
d40a43a
Merge branch 'master' into lower-upper-neg
lowasser Feb 10, 2025
f75209b
Some more theorems
lowasser Feb 11, 2025
6d17056
Merge branch 'master' into lower-upper-neg
lowasser Feb 11, 2025
098d4e8
Finish gaps
lowasser Feb 11, 2025
b3b72b2
Progress
lowasser Feb 11, 2025
56c4fe3
Merge remote-tracking branch 'origin/lower-upper-neg' into lower-uppe…
lowasser Feb 11, 2025
faaa937
Merge branch 'master' into lower-upper-neg
lowasser Feb 11, 2025
1f9d73a
Recover all the previous results
lowasser Feb 11, 2025
7857a80
Merge branch 'master' into lower-upper-neg
lowasser Feb 11, 2025
263f367
make pre-commit
lowasser Feb 11, 2025
a3da42d
Merge remote-tracking branch 'origin/lower-upper-neg' into lower-uppe…
lowasser Feb 11, 2025
3669840
Merge branch 'master' into lower-upper-neg
lowasser Feb 11, 2025
f235570
Remove empty bibliography
lowasser Feb 11, 2025
827111e
Review changes
lowasser Feb 11, 2025
f734874
Fix names
lowasser Feb 12, 2025
53e54d8
Fix links
lowasser Feb 12, 2025
71479ca
Fix naming
lowasser Feb 12, 2025
e535435
make pre-commit
lowasser Feb 12, 2025
178808f
Merge branch 'master' into lower-upper-neg
lowasser Feb 13, 2025
9a2c3d6
Merge branch 'master' into lower-upper-neg
lowasser Feb 13, 2025
7ad5d5f
Merge remote-tracking branch 'origin/lower-upper-neg' into lower-uppe…
lowasser Feb 13, 2025
23a33d3
Apply suggestions from code review
lowasser Feb 13, 2025
f2c3f76
renaming
lowasser Feb 13, 2025
3673163
make pre-commit
lowasser Feb 13, 2025
324595a
Respond to review comments
lowasser Feb 14, 2025
10a0a36
Inline explanations of lower and upper cuts
lowasser Feb 14, 2025
6430f86
Reword
lowasser Feb 14, 2025
e64c537
Merge branch 'master' into lower-upper-neg
lowasser Feb 14, 2025
69430a2
Update src/real-numbers/arithmetically-located-dedekind-cuts.lagda.md
lowasser Feb 14, 2025
8c1ad11
Progress
lowasser Feb 14, 2025
9f4197c
Review comments
lowasser Feb 14, 2025
d6da824
reword negation
lowasser Feb 14, 2025
0a2691c
Apply suggestions from code review
lowasser Feb 14, 2025
f462be5
Fix compile
lowasser Feb 14, 2025
4b9e12f
Merge branch 'master' into lower-upper-neg
lowasser Feb 14, 2025
54f1668
Merge branch 'master' into lower-upper-neg
lowasser Feb 14, 2025
4f06d7d
Merge remote-tracking branch 'origin/lower-upper-neg' into lower-uppe…
lowasser Feb 14, 2025
b0431f5
Apply suggestions from code review
lowasser Feb 14, 2025
d50feff
Follow ups from review
lowasser Feb 14, 2025
1d6c62a
Merge branch 'master' into lower-upper-neg
lowasser Feb 14, 2025
507492a
make pre-commit
lowasser Feb 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
256 changes: 133 additions & 123 deletions src/elementary-number-theory/inequality-rational-numbers.lagda.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,33 +103,35 @@ refl-leq-ℚ x =
### Inequality on the rational numbers is antisymmetric

```agda
antisymmetric-leq-ℚ : (x y : ℚ) → leq-ℚ x y → leq-ℚ y x → x = y
antisymmetric-leq-ℚ x y H H' =
( inv (is-retraction-rational-fraction-ℚ x)) ∙
( eq-ℚ-sim-fraction-ℤ
( fraction-ℚ x)
( fraction-ℚ y)
( is-sim-antisymmetric-leq-fraction-ℤ
abstract
antisymmetric-leq-ℚ : (x y : ℚ) → leq-ℚ x y → leq-ℚ y x → x = y
antisymmetric-leq-ℚ x y H H' =
( inv (is-retraction-rational-fraction-ℚ x)) ∙
( eq-ℚ-sim-fraction-ℤ
( fraction-ℚ x)
( fraction-ℚ y)
( H)
( H'))) ∙
( is-retraction-rational-fraction-ℚ y)
( is-sim-antisymmetric-leq-fraction-ℤ
( fraction-ℚ x)
( fraction-ℚ y)
( H)
( H'))) ∙
( is-retraction-rational-fraction-ℚ y)
```

### Inequality on the rational numbers is linear

```agda
linear-leq-ℚ : (x y : ℚ) → (leq-ℚ x y) + (leq-ℚ y x)
linear-leq-ℚ x y =
map-coproduct
( id)
( is-nonnegative-eq-ℤ
(distributive-neg-diff-ℤ
( numerator-ℚ y *ℤ denominator-ℚ x)
( numerator-ℚ x *ℤ denominator-ℚ y)))
( decide-is-nonnegative-is-nonnegative-neg-ℤ
{ cross-mul-diff-fraction-ℤ (fraction-ℚ x) (fraction-ℚ y)})
abstract
linear-leq-ℚ : (x y : ℚ) → (leq-ℚ x y) + (leq-ℚ y x)
linear-leq-ℚ x y =
map-coproduct
( id)
( is-nonnegative-eq-ℤ
(distributive-neg-diff-ℤ
( numerator-ℚ y *ℤ denominator-ℚ x)
( numerator-ℚ x *ℤ denominator-ℚ y)))
( decide-is-nonnegative-is-nonnegative-neg-ℤ
{ cross-mul-diff-fraction-ℤ (fraction-ℚ x) (fraction-ℚ y)})
```

### Inequality on the rational numbers is transitive
Expand All @@ -139,12 +141,13 @@ module _
(x y z : ℚ)
where

transitive-leq-ℚ : leq-ℚ y z → leq-ℚ x y → leq-ℚ x z
transitive-leq-ℚ =
transitive-leq-fraction-ℤ
( fraction-ℚ x)
( fraction-ℚ y)
( fraction-ℚ z)
abstract
transitive-leq-ℚ : leq-ℚ y z → leq-ℚ x y → leq-ℚ x z
transitive-leq-ℚ =
transitive-leq-fraction-ℤ
( fraction-ℚ x)
( fraction-ℚ y)
( fraction-ℚ z)
```

### The partially ordered set of rational numbers ordered by inequality
Expand All @@ -165,70 +168,73 @@ module _
(p q : fraction-ℤ)
where

preserves-leq-rational-fraction-ℤ :
leq-fraction-ℤ p q → leq-ℚ (rational-fraction-ℤ p) (rational-fraction-ℤ q)
preserves-leq-rational-fraction-ℤ =
preserves-leq-sim-fraction-ℤ
( p)
( q)
( reduce-fraction-ℤ p)
( reduce-fraction-ℤ q)
( sim-reduced-fraction-ℤ p)
( sim-reduced-fraction-ℤ q)
abstract
preserves-leq-rational-fraction-ℤ :
leq-fraction-ℤ p q → leq-ℚ (rational-fraction-ℤ p) (rational-fraction-ℤ q)
preserves-leq-rational-fraction-ℤ =
preserves-leq-sim-fraction-ℤ
( p)
( q)
( reduce-fraction-ℤ p)
( reduce-fraction-ℤ q)
( sim-reduced-fraction-ℤ p)
( sim-reduced-fraction-ℤ q)

module _
(x : ℚ) (p : fraction-ℤ)
where

preserves-leq-right-rational-fraction-ℤ :
leq-fraction-ℤ (fraction-ℚ x) p → leq-ℚ x (rational-fraction-ℤ p)
preserves-leq-right-rational-fraction-ℤ H =
concatenate-leq-sim-fraction-ℤ
( fraction-ℚ x)
( p)
( fraction-ℚ ( rational-fraction-ℤ p))
( H)
( sim-reduced-fraction-ℤ p)

reflects-leq-right-rational-fraction-ℤ :
leq-ℚ x (rational-fraction-ℤ p) → leq-fraction-ℤ (fraction-ℚ x) p
reflects-leq-right-rational-fraction-ℤ H =
concatenate-leq-sim-fraction-ℤ
( fraction-ℚ x)
( reduce-fraction-ℤ p)
( p)
( H)
( symmetric-sim-fraction-ℤ
abstract
preserves-leq-right-rational-fraction-ℤ :
leq-fraction-ℤ (fraction-ℚ x) p → leq-ℚ x (rational-fraction-ℤ p)
preserves-leq-right-rational-fraction-ℤ H =
concatenate-leq-sim-fraction-ℤ
( fraction-ℚ x)
( p)
( fraction-ℚ ( rational-fraction-ℤ p))
( H)
( sim-reduced-fraction-ℤ p)

reflects-leq-right-rational-fraction-ℤ :
leq-ℚ x (rational-fraction-ℤ p) → leq-fraction-ℤ (fraction-ℚ x) p
reflects-leq-right-rational-fraction-ℤ H =
concatenate-leq-sim-fraction-ℤ
( fraction-ℚ x)
( reduce-fraction-ℤ p)
( sim-reduced-fraction-ℤ p))
( p)
( H)
( symmetric-sim-fraction-ℤ
( p)
( reduce-fraction-ℤ p)
( sim-reduced-fraction-ℤ p))

iff-leq-right-rational-fraction-ℤ :
leq-fraction-ℤ (fraction-ℚ x) p ↔ leq-ℚ x (rational-fraction-ℤ p)
pr1 iff-leq-right-rational-fraction-ℤ =
preserves-leq-right-rational-fraction-ℤ
pr2 iff-leq-right-rational-fraction-ℤ = reflects-leq-right-rational-fraction-ℤ

preserves-leq-left-rational-fraction-ℤ :
leq-fraction-ℤ p (fraction-ℚ x) → leq-ℚ (rational-fraction-ℤ p) x
preserves-leq-left-rational-fraction-ℤ =
concatenate-sim-leq-fraction-ℤ
( fraction-ℚ ( rational-fraction-ℤ p))
( p)
( fraction-ℚ x)
( symmetric-sim-fraction-ℤ
( p)
abstract
preserves-leq-left-rational-fraction-ℤ :
leq-fraction-ℤ p (fraction-ℚ x) → leq-ℚ (rational-fraction-ℤ p) x
preserves-leq-left-rational-fraction-ℤ =
concatenate-sim-leq-fraction-ℤ
( fraction-ℚ ( rational-fraction-ℤ p))
( sim-reduced-fraction-ℤ p))

reflects-leq-left-rational-fraction-ℤ :
leq-ℚ (rational-fraction-ℤ p) x → leq-fraction-ℤ p (fraction-ℚ x)
reflects-leq-left-rational-fraction-ℤ =
concatenate-sim-leq-fraction-ℤ
( p)
( reduce-fraction-ℤ p)
( fraction-ℚ x)
( sim-reduced-fraction-ℤ p)
( p)
( fraction-ℚ x)
( symmetric-sim-fraction-ℤ
( p)
( fraction-ℚ ( rational-fraction-ℤ p))
( sim-reduced-fraction-ℤ p))

reflects-leq-left-rational-fraction-ℤ :
leq-ℚ (rational-fraction-ℤ p) x → leq-fraction-ℤ p (fraction-ℚ x)
reflects-leq-left-rational-fraction-ℤ =
concatenate-sim-leq-fraction-ℤ
( p)
( reduce-fraction-ℤ p)
( fraction-ℚ x)
( sim-reduced-fraction-ℤ p)

iff-leq-left-rational-fraction-ℤ :
leq-fraction-ℤ p (fraction-ℚ x) ↔ leq-ℚ (rational-fraction-ℤ p) x
Expand All @@ -243,26 +249,29 @@ module _
(x y : ℚ)
where

iff-translate-diff-leq-zero-ℚ : leq-ℚ zero-ℚ (y -ℚ x) ↔ leq-ℚ x y
iff-translate-diff-leq-zero-ℚ =
logical-equivalence-reasoning
leq-ℚ zero-ℚ (y -ℚ x)
↔ leq-fraction-ℤ
( zero-fraction-ℤ)
( add-fraction-ℤ (fraction-ℚ y) (neg-fraction-ℤ (fraction-ℚ x)))
by
inv-iff
( iff-leq-right-rational-fraction-ℤ
( zero-ℚ)
( add-fraction-ℤ (fraction-ℚ y) (neg-fraction-ℤ (fraction-ℚ x))))
↔ leq-ℚ x y
by
inv-tr
( _↔ leq-ℚ x y)
( eq-translate-diff-leq-zero-fraction-ℤ
( fraction-ℚ x)
( fraction-ℚ y))
( id-iff)
abstract
iff-translate-diff-leq-zero-ℚ : leq-ℚ zero-ℚ (y -ℚ x) ↔ leq-ℚ x y
iff-translate-diff-leq-zero-ℚ =
logical-equivalence-reasoning
leq-ℚ zero-ℚ (y -ℚ x)
↔ leq-fraction-ℤ
( zero-fraction-ℤ)
( add-fraction-ℤ (fraction-ℚ y) (neg-fraction-ℤ (fraction-ℚ x)))
by
inv-iff
( iff-leq-right-rational-fraction-ℤ
( zero-ℚ)
( add-fraction-ℤ
( fraction-ℚ y)
( neg-fraction-ℤ (fraction-ℚ x))))
↔ leq-ℚ x y
by
inv-tr
( _↔ leq-ℚ x y)
( eq-translate-diff-leq-zero-fraction-ℤ
( fraction-ℚ x)
( fraction-ℚ y))
( id-iff)
```

### Inequality on the rational numbers is invariant by translation
Expand All @@ -272,34 +281,35 @@ module _
(z x y : ℚ)
where

iff-translate-left-leq-ℚ : leq-ℚ (z +ℚ x) (z +ℚ y) ↔ leq-ℚ x y
iff-translate-left-leq-ℚ =
logical-equivalence-reasoning
leq-ℚ (z +ℚ x) (z +ℚ y)
↔ leq-ℚ zero-ℚ ((z +ℚ y) -ℚ (z +ℚ x))
by (inv-iff (iff-translate-diff-leq-zero-ℚ (z +ℚ x) (z +ℚ y)))
↔ leq-ℚ zero-ℚ (y -ℚ x)
by
( inv-tr
( _↔ leq-ℚ zero-ℚ (y -ℚ x))
( ap (leq-ℚ zero-ℚ) (left-translation-diff-ℚ y x z))
( id-iff))
↔ leq-ℚ x y
by (iff-translate-diff-leq-zero-ℚ x y)

iff-translate-right-leq-ℚ : leq-ℚ (x +ℚ z) (y +ℚ z) ↔ leq-ℚ x y
iff-translate-right-leq-ℚ =
logical-equivalence-reasoning
leq-ℚ (x +ℚ z) (y +ℚ z)
↔ leq-ℚ zero-ℚ ((y +ℚ z) -ℚ (x +ℚ z))
by (inv-iff (iff-translate-diff-leq-zero-ℚ (x +ℚ z) (y +ℚ z)))
↔ leq-ℚ zero-ℚ (y -ℚ x)
by
( inv-tr
( _↔ leq-ℚ zero-ℚ (y -ℚ x))
( ap (leq-ℚ zero-ℚ) (right-translation-diff-ℚ y x z))
( id-iff))
↔ leq-ℚ x y by (iff-translate-diff-leq-zero-ℚ x y)
abstract
iff-translate-left-leq-ℚ : leq-ℚ (z +ℚ x) (z +ℚ y) ↔ leq-ℚ x y
iff-translate-left-leq-ℚ =
logical-equivalence-reasoning
leq-ℚ (z +ℚ x) (z +ℚ y)
↔ leq-ℚ zero-ℚ ((z +ℚ y) -ℚ (z +ℚ x))
by (inv-iff (iff-translate-diff-leq-zero-ℚ (z +ℚ x) (z +ℚ y)))
↔ leq-ℚ zero-ℚ (y -ℚ x)
by
( inv-tr
( _↔ leq-ℚ zero-ℚ (y -ℚ x))
( ap (leq-ℚ zero-ℚ) (left-translation-diff-ℚ y x z))
( id-iff))
↔ leq-ℚ x y
by (iff-translate-diff-leq-zero-ℚ x y)

iff-translate-right-leq-ℚ : leq-ℚ (x +ℚ z) (y +ℚ z) ↔ leq-ℚ x y
iff-translate-right-leq-ℚ =
logical-equivalence-reasoning
leq-ℚ (x +ℚ z) (y +ℚ z)
↔ leq-ℚ zero-ℚ ((y +ℚ z) -ℚ (x +ℚ z))
by (inv-iff (iff-translate-diff-leq-zero-ℚ (x +ℚ z) (y +ℚ z)))
↔ leq-ℚ zero-ℚ (y -ℚ x)
by
( inv-tr
( _↔ leq-ℚ zero-ℚ (y -ℚ x))
( ap (leq-ℚ zero-ℚ) (right-translation-diff-ℚ y x z))
( id-iff))
↔ leq-ℚ x y by (iff-translate-diff-leq-zero-ℚ x y)

preserves-leq-left-add-ℚ : leq-ℚ x y → leq-ℚ (x +ℚ z) (y +ℚ z)
preserves-leq-left-add-ℚ = backward-implication iff-translate-right-leq-ℚ
Expand Down
17 changes: 9 additions & 8 deletions src/elementary-number-theory/rational-numbers.lagda.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,15 @@ mediant-ℚ x y =
### The rational images of two similar integer fractions are equal

```agda
eq-ℚ-sim-fraction-ℤ :
(x y : fraction-ℤ) → (H : sim-fraction-ℤ x y) →
rational-fraction-ℤ x = rational-fraction-ℤ y
eq-ℚ-sim-fraction-ℤ x y H =
eq-pair-Σ'
( pair
( unique-reduce-fraction-ℤ x y H)
( eq-is-prop (is-prop-is-reduced-fraction-ℤ (reduce-fraction-ℤ y))))
abstract
eq-ℚ-sim-fraction-ℤ :
(x y : fraction-ℤ) → (H : sim-fraction-ℤ x y) →
rational-fraction-ℤ x = rational-fraction-ℤ y
eq-ℚ-sim-fraction-ℤ x y H =
eq-pair-Σ'
( pair
( unique-reduce-fraction-ℤ x y H)
( eq-is-prop (is-prop-is-reduced-fraction-ℤ (reduce-fraction-ℤ y))))
```

### The type of rationals is a set
Expand Down
7 changes: 7 additions & 0 deletions src/real-numbers.lagda.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,17 @@ module real-numbers where
open import real-numbers.apartness-real-numbers public
open import real-numbers.arithmetically-located-dedekind-cuts public
open import real-numbers.dedekind-real-numbers public
open import real-numbers.inequality-lower-dedekind-real-numbers public
open import real-numbers.inequality-real-numbers public
open import real-numbers.inequality-upper-dedekind-real-numbers public
open import real-numbers.lower-dedekind-real-numbers public
open import real-numbers.metric-space-of-real-numbers public
open import real-numbers.negation-lower-upper-dedekind-real-numbers public
open import real-numbers.negation-real-numbers public
open import real-numbers.rational-lower-dedekind-real-numbers public
open import real-numbers.rational-real-numbers public
open import real-numbers.rational-upper-dedekind-real-numbers public
open import real-numbers.similarity-real-numbers public
open import real-numbers.strict-inequality-real-numbers public
open import real-numbers.upper-dedekind-real-numbers public
```
Loading
Loading