Skip to content

Commit 4e349b1

Browse files
authored
Addition on real numbers (#1336)
Decided I'm just going to fold it all together. Depends on #1306.
1 parent 0671c30 commit 4e349b1

16 files changed

+1225
-201
lines changed

src/elementary-number-theory/addition-rational-numbers.lagda.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ open import elementary-number-theory.addition-integer-fractions
1313
open import elementary-number-theory.addition-integers
1414
open import elementary-number-theory.integer-fractions
1515
open import elementary-number-theory.integers
16+
open import elementary-number-theory.natural-numbers
1617
open import elementary-number-theory.rational-numbers
1718
open import elementary-number-theory.reduced-integer-fractions
1819
@@ -161,6 +162,21 @@ abstract
161162
commutative-add-ℚ x (neg-ℚ x) ∙ left-inverse-law-add-ℚ x
162163
```
163164

165+
### If `p + q = 0`, then `p = -q`
166+
167+
```agda
168+
abstract
169+
unique-left-neg-ℚ : (p q : ℚ) → p +ℚ q = zero-ℚ → p = neg-ℚ q
170+
unique-left-neg-ℚ p q p+q=0 =
171+
equational-reasoning
172+
p
173+
= p +ℚ zero-ℚ by inv (right-unit-law-add-ℚ p)
174+
= p +ℚ (q +ℚ neg-ℚ q) by ap (p +ℚ_) (inv (right-inverse-law-add-ℚ q))
175+
= (p +ℚ q) +ℚ neg-ℚ q by inv (associative-add-ℚ _ _ _)
176+
= zero-ℚ +ℚ neg-ℚ q by ap (_+ℚ neg-ℚ q) p+q=0
177+
= neg-ℚ q by left-unit-law-add-ℚ _
178+
```
179+
164180
### The negatives of rational numbers distribute over addition
165181

166182
```agda
@@ -276,6 +292,15 @@ abstract
276292
succ-rational-ℤ = add-rational-ℤ one-ℤ
277293
```
278294

295+
### The embedding of the successor of a natural number is the successor of its embedding
296+
297+
```agda
298+
abstract
299+
succ-rational-int-ℕ :
300+
(n : ℕ) → succ-ℚ (rational-ℤ (int-ℕ n)) = rational-ℤ (int-ℕ (succ-ℕ n))
301+
succ-rational-int-ℕ n = succ-rational-ℤ _ ∙ ap rational-ℤ (succ-int-ℕ n)
302+
```
303+
279304
## See also
280305

281306
- The additive group structure on the rational numbers is defined in

src/elementary-number-theory/positive-rational-numbers.lagda.md

Lines changed: 43 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -205,13 +205,14 @@ module _
205205
(x y : ℚ) (H : le-ℚ x y)
206206
where
207207
208-
is-positive-diff-le-ℚ : is-positive-ℚ (y -ℚ x)
209-
is-positive-diff-le-ℚ =
210-
is-positive-le-zero-ℚ
211-
( y -ℚ x)
212-
( backward-implication
213-
( iff-translate-diff-le-zero-ℚ x y)
214-
( H))
208+
abstract
209+
is-positive-diff-le-ℚ : is-positive-ℚ (y -ℚ x)
210+
is-positive-diff-le-ℚ =
211+
is-positive-le-zero-ℚ
212+
( y -ℚ x)
213+
( backward-implication
214+
( iff-translate-diff-le-zero-ℚ x y)
215+
( H))
215216
216217
positive-diff-le-ℚ : ℚ⁺
217218
positive-diff-le-ℚ = y -ℚ x , is-positive-diff-le-ℚ
@@ -656,12 +657,13 @@ mediant-zero-ℚ⁺ x =
656657
( rational-ℚ⁺ x)
657658
( le-zero-is-positive-ℚ (rational-ℚ⁺ x) (is-positive-rational-ℚ⁺ x))))
658659
659-
le-mediant-zero-ℚ⁺ : (x : ℚ⁺) → le-ℚ⁺ (mediant-zero-ℚ⁺ x) x
660-
le-mediant-zero-ℚ⁺ x =
661-
le-right-mediant-ℚ
662-
( zero-ℚ)
663-
( rational-ℚ⁺ x)
664-
( le-zero-is-positive-ℚ (rational-ℚ⁺ x) (is-positive-rational-ℚ⁺ x))
660+
abstract
661+
le-mediant-zero-ℚ⁺ : (x : ℚ⁺) → le-ℚ⁺ (mediant-zero-ℚ⁺ x) x
662+
le-mediant-zero-ℚ⁺ x =
663+
le-right-mediant-ℚ
664+
( zero-ℚ)
665+
( rational-ℚ⁺ x)
666+
( le-zero-is-positive-ℚ (rational-ℚ⁺ x) (is-positive-rational-ℚ⁺ x))
665667
```
666668

667669
### Any positive rational number is the sum of two positive rational numbers
@@ -678,16 +680,40 @@ module _
678680
right-summand-split-ℚ⁺ =
679681
le-diff-ℚ⁺ (mediant-zero-ℚ⁺ x) x (le-mediant-zero-ℚ⁺ x)
680682
681-
eq-add-split-ℚ⁺ :
682-
left-summand-split-ℚ⁺ +ℚ⁺ right-summand-split-ℚ⁺ = x
683-
eq-add-split-ℚ⁺ =
684-
right-diff-law-add-ℚ⁺ (mediant-zero-ℚ⁺ x) x (le-mediant-zero-ℚ⁺ x)
683+
abstract
684+
eq-add-split-ℚ⁺ :
685+
left-summand-split-ℚ⁺ +ℚ⁺ right-summand-split-ℚ⁺ = x
686+
eq-add-split-ℚ⁺ =
687+
right-diff-law-add-ℚ⁺ (mediant-zero-ℚ⁺ x) x (le-mediant-zero-ℚ⁺ x)
685688
686689
split-ℚ⁺ : Σ ℚ⁺ (λ u → Σ ℚ⁺ (λ v → u +ℚ⁺ v = x))
687690
split-ℚ⁺ =
688691
left-summand-split-ℚ⁺ ,
689692
right-summand-split-ℚ⁺ ,
690693
eq-add-split-ℚ⁺
694+
695+
abstract
696+
le-add-split-ℚ⁺ :
697+
(p q r s : ℚ) →
698+
le-ℚ p (q +ℚ rational-ℚ⁺ left-summand-split-ℚ⁺) →
699+
le-ℚ r (s +ℚ rational-ℚ⁺ right-summand-split-ℚ⁺) →
700+
le-ℚ (p +ℚ r) ((q +ℚ s) +ℚ rational-ℚ⁺ x)
701+
le-add-split-ℚ⁺ p q r s p<q+left r<s+right =
702+
tr
703+
( le-ℚ (p +ℚ r))
704+
( interchange-law-add-add-ℚ
705+
( q)
706+
( rational-ℚ⁺ left-summand-split-ℚ⁺)
707+
( s)
708+
( rational-ℚ⁺ right-summand-split-ℚ⁺) ∙
709+
ap ((q +ℚ s) +ℚ_) (ap rational-ℚ⁺ eq-add-split-ℚ⁺))
710+
( preserves-le-add-ℚ
711+
{ p}
712+
{ q +ℚ rational-ℚ⁺ left-summand-split-ℚ⁺}
713+
{ r}
714+
{ s +ℚ rational-ℚ⁺ right-summand-split-ℚ⁺}
715+
( p<q+left)
716+
( r<s+right))
691717
```
692718

693719
### Any two positive rational numbers have a positive rational number strictly less than both

src/elementary-number-theory/strict-inequality-rational-numbers.lagda.md

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,13 @@ module _
127127
(x y z : ℚ)
128128
where
129129
130-
transitive-le-ℚ : le-ℚ y z → le-ℚ x y → le-ℚ x z
131-
transitive-le-ℚ =
132-
transitive-le-fraction-ℤ
133-
( fraction-ℚ x)
134-
( fraction-ℚ y)
135-
( fraction-ℚ z)
130+
abstract
131+
transitive-le-ℚ : le-ℚ y z → le-ℚ x y → le-ℚ x z
132+
transitive-le-ℚ =
133+
transitive-le-fraction-ℤ
134+
( fraction-ℚ x)
135+
( fraction-ℚ y)
136+
( fraction-ℚ z)
136137
```
137138

138139
### Concatenation rules for inequality and strict inequality on the rational numbers
@@ -320,15 +321,16 @@ module _
320321
### Addition on the rational numbers preserves strict inequality
321322

322323
```agda
323-
preserves-le-add-ℚ :
324-
{a b c d : ℚ} → le-ℚ a b → le-ℚ c d → le-ℚ (a +ℚ c) (b +ℚ d)
325-
preserves-le-add-ℚ {a} {b} {c} {d} H K =
326-
transitive-le-ℚ
327-
( a +ℚ c)
328-
( b +ℚ c)
329-
( b +ℚ d)
330-
( preserves-le-right-add-ℚ b c d K)
331-
( preserves-le-left-add-ℚ c a b H)
324+
abstract
325+
preserves-le-add-ℚ :
326+
{a b c d : ℚ} → le-ℚ a b → le-ℚ c d → le-ℚ (a +ℚ c) (b +ℚ d)
327+
preserves-le-add-ℚ {a} {b} {c} {d} H K =
328+
transitive-le-ℚ
329+
( a +ℚ c)
330+
( b +ℚ c)
331+
( b +ℚ d)
332+
( preserves-le-right-add-ℚ b c d K)
333+
( preserves-le-left-add-ℚ c a b H)
332334
```
333335

334336
### The rational numbers have no lower or upper bound

src/foundation.lagda.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ open import foundation.functoriality-cartesian-product-types public
205205
open import foundation.functoriality-coproduct-types public
206206
open import foundation.functoriality-dependent-function-types public
207207
open import foundation.functoriality-dependent-pair-types public
208+
open import foundation.functoriality-disjunction public
208209
open import foundation.functoriality-fibers-of-maps public
209210
open import foundation.functoriality-function-types public
210211
open import foundation.functoriality-morphisms-arrows public
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Functoriality of disjunction
2+
3+
```agda
4+
module foundation.functoriality-disjunction where
5+
```
6+
7+
<details><summary>Imports</summary>
8+
9+
```agda
10+
open import foundation.disjunction
11+
open import foundation.function-types
12+
open import foundation.propositions
13+
open import foundation.universe-levels
14+
```
15+
16+
</details>
17+
18+
## Idea
19+
20+
Any two implications `f : A ⇒ B` and `g : C ⇒ D` induce an implication
21+
`map-disjunction f g : (A ∨ B) ⇒ (C ∨ D)`.
22+
23+
## Definitions
24+
25+
### The functorial action of disjunction
26+
27+
```agda
28+
module _
29+
{l1 l2 l3 l4 : Level} (A : Prop l1) (B : Prop l2) (C : Prop l3) (D : Prop l4)
30+
(f : type-Prop (A ⇒ B)) (g : type-Prop (C ⇒ D))
31+
where
32+
33+
map-disjunction : type-Prop ((A ∨ C) ⇒ (B ∨ D))
34+
map-disjunction =
35+
elim-disjunction (B ∨ D) (inl-disjunction ∘ f) (inr-disjunction ∘ g)
36+
```

src/group-theory/abelian-groups.lagda.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -612,17 +612,18 @@ module _
612612
{l : Level} (A : Ab l)
613613
where
614614
615-
is-identity-left-conjugation-Ab :
616-
(x : type-Ab A) → left-conjugation-Ab A x ~ id
617-
is-identity-left-conjugation-Ab x y =
618-
( ap (add-Ab' A (neg-Ab A x)) (commutative-add-Ab A x y)) ∙
619-
( is-retraction-right-subtraction-Ab A x y)
620-
621-
is-identity-right-conjugation-Ab :
622-
(x : type-Ab A) → right-conjugation-Ab A x ~ id
623-
is-identity-right-conjugation-Ab x =
624-
inv-htpy (left-right-conjugation-Ab A x) ∙h
625-
is-identity-left-conjugation-Ab x
615+
abstract
616+
is-identity-left-conjugation-Ab :
617+
(x : type-Ab A) → left-conjugation-Ab A x ~ id
618+
is-identity-left-conjugation-Ab x y =
619+
( ap (add-Ab' A (neg-Ab A x)) (commutative-add-Ab A x y)) ∙
620+
( is-retraction-right-subtraction-Ab A x y)
621+
622+
is-identity-right-conjugation-Ab :
623+
(x : type-Ab A) → right-conjugation-Ab A x ~ id
624+
is-identity-right-conjugation-Ab x =
625+
inv-htpy (left-right-conjugation-Ab A x) ∙h
626+
is-identity-left-conjugation-Ab x
626627
627628
is-identity-conjugation-Ab :
628629
(x : type-Ab A) → conjugation-Ab A x ~ id

src/logic/functoriality-existential-quantification.lagda.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ module logic.functoriality-existential-quantification where
77
<details><summary>Imports</summary>
88

99
```agda
10+
open import foundation.dependent-pair-types
1011
open import foundation.existential-quantification
12+
open import foundation.function-types
13+
open import foundation.logical-equivalences
1114
open import foundation.universe-levels
12-
13-
open import foundation-core.function-types
1415
```
1516

1617
</details>
@@ -107,6 +108,19 @@ module _
107108
map-tot-exists g = map-exists C id g
108109
```
109110

111+
### The functorial action of existential quantification on families of logical equivalences
112+
113+
```agda
114+
module _
115+
{l1 l2 l3 : Level} {A : UU l1} {B : A → UU l2} {C : A → UU l3}
116+
where
117+
118+
iff-tot-exists :
119+
(g : (x : A) → B x ↔ C x) → exists-structure A B ↔ exists-structure A C
120+
pr1 (iff-tot-exists g) = map-tot-exists (forward-implication ∘ g)
121+
pr2 (iff-tot-exists g) = map-tot-exists (backward-implication ∘ g)
122+
```
123+
110124
### The functorial action of existential quantification on maps of the base
111125

112126
```agda

src/real-numbers.lagda.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ module real-numbers where
77
88
open import real-numbers.absolute-value-real-numbers public
99
open import real-numbers.addition-lower-dedekind-real-numbers public
10+
open import real-numbers.addition-real-numbers public
1011
open import real-numbers.addition-upper-dedekind-real-numbers public
1112
open import real-numbers.apartness-real-numbers public
1213
open import real-numbers.arithmetically-located-dedekind-cuts public
1314
open import real-numbers.dedekind-real-numbers public
15+
open import real-numbers.difference-real-numbers public
1416
open import real-numbers.inequality-lower-dedekind-real-numbers public
1517
open import real-numbers.inequality-real-numbers public
1618
open import real-numbers.inequality-upper-dedekind-real-numbers public

0 commit comments

Comments
 (0)