Skip to content

Commit 8f059f3

Browse files
authored
Merge branch 'master' into min-max-lower-upper
2 parents 70959e0 + 54a5397 commit 8f059f3

File tree

49 files changed

+1391
-368
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1391
-368
lines changed

.github/workflows/pages.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ jobs:
8484
crate: mdbook-catppuccin
8585
version: '1.2.0'
8686

87+
- name: Install Graphviz
88+
run: sudo apt-get install -y graphviz
89+
8790
- uses: actions/setup-python@v5
8891
with:
8992
python-version: '3.8'

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,3 +430,4 @@ SUMMARY.md
430430
CONTRIBUTORS.md
431431
MAINTAINERS.md
432432
/website/css/Agda-highlight.css
433+
/website/images/agda_dependency_graph.svg

HOWTO-INSTALL.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ In order to contribute to the agda-unimath library you will additionally need:
2121
1. `git`
2222
2. `make`
2323
3. `python` version 3.8 or newer
24-
4. The python libraries `pre-commit`, `pybtex`, `requests` and `tomli`. Those
25-
can be installed by running
24+
4. The python libraries `pre-commit`, `pybtex`, `requests`, `tomli`, and
25+
`graphviz`. These can be installed by running
2626
```shell
2727
python3 -m pip install -r scripts/requirements.txt
2828
```
@@ -33,6 +33,7 @@ In order to contribute to the agda-unimath library you will additionally need:
3333
```shell
3434
make install-website-dev
3535
```
36+
7. `graphviz`
3637

3738
All of these can also be installed in one go by using `nix`. In the section
3839
[Creating a setup for contributors](#contributor-setup) we will walk you through

Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,12 @@ CONTRIBUTORS.md: ${AGDAFILES} ${CONTRIBUTORS_FILE} ./scripts/generate_contributo
145145
website/css/Agda-highlight.css: ./scripts/generate_agda_css.py ./theme/catppuccin.css
146146
@python3 ./scripts/generate_agda_css.py
147147

148+
website/images/agda_dependency_graph.svg: ${AGDAFILES}
149+
@python3 ./scripts/generate_dependency_graph_rendering.py website/images/agda_dependency_graph svg || true
150+
148151
.PHONY: website-prepare
149-
website-prepare: agda-html ./SUMMARY.md ./CONTRIBUTORS.md ./MAINTAINERS.md ./website/css/Agda-highlight.css
152+
website-prepare: agda-html ./SUMMARY.md ./CONTRIBUTORS.md ./MAINTAINERS.md \
153+
./website/css/Agda-highlight.css ./website/images/agda_dependency_graph.svg
150154
@cp $(METAFILES) ./docs/
151155
@mkdir -p ./docs/website
152156
@cp -r ./website/images ./docs/website/
@@ -157,7 +161,6 @@ website-prepare: agda-html ./SUMMARY.md ./CONTRIBUTORS.md ./MAINTAINERS.md ./web
157161
.PHONY: website
158162
website: website-prepare
159163
@mdbook build
160-
@python3 ./scripts/generate_dependency_graph_rendering.py website/images/agda_dependency_graph svg || true
161164

162165
.PHONY: serve-website
163166
serve-website: website-prepare

scripts/generate_dependency_graph_rendering.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def count_imports(graph):
9999
import_counts[dep] += 1
100100
return import_counts
101101

102-
def build_dependency_graph(root_dir, min_rank_imports=20):
102+
def build_dependency_graph(root_dir, most_imported_drop_count=20):
103103
"""Construct a dependency graph from Agda files."""
104104
graph = defaultdict(set)
105105
file_sizes = {}
@@ -117,7 +117,7 @@ def build_dependency_graph(root_dir, min_rank_imports=20):
117117

118118
# Count imports and find top imported modules
119119
import_counts = count_imports(graph)
120-
_top_imports = sorted(import_counts, key=import_counts.get, reverse=True)[:min_rank_imports]
120+
_top_imports = sorted(import_counts, key=import_counts.get, reverse=True)[:most_imported_drop_count]
121121
top_imports = set(_top_imports)
122122

123123
eprint("Excluding modules:")
@@ -143,6 +143,7 @@ def render_graph(graph, file_sizes, output_file, format, repo):
143143
dot.attr(splines="false", overlap="prism10000", bgcolor="#FFFFFF00", K="0.3", repulsiveforce="0.3") #sfdp
144144

145145
max_lines = max(file_sizes.values(), default=1)
146+
eprint("Maximum lines of code:", max_lines)
146147
node_sizes = {node: max(0.05, 0.3 * math.sqrt(file_sizes.get(node, 0) / max_lines)) for node in graph}
147148
node_colors = {node: module_based_color(node[:node.rfind(".")], label_colors) for node in graph}
148149

@@ -158,14 +159,14 @@ def render_graph(graph, file_sizes, output_file, format, repo):
158159

159160
if __name__ == "__main__":
160161
root_dir = "src"
161-
min_rank_imports = 20
162+
most_imported_drop_count = 20
162163

163164
parser = argparse.ArgumentParser(description="Generate Agda dependency graph.")
164165
parser.add_argument("output_file", type=str, help="Path to save the output graph.")
165166
parser.add_argument("format", type=str, choices=["svg", "png", "pdf"], help="Output format of the graph.")
166167

167168
args = parser.parse_args()
168169

169-
graph, file_sizes = build_dependency_graph(root_dir, min_rank_imports=min_rank_imports)
170+
graph, file_sizes = build_dependency_graph(root_dir, most_imported_drop_count=most_imported_drop_count)
170171
render_graph(graph, file_sizes, args.output_file, format=args.format, repo=GITHUB_REPO)
171172
eprint(f"Graph saved as {args.output_file}.{args.format}")

src/elementary-number-theory.lagda.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ open import elementary-number-theory.additive-group-of-rational-numbers public
2020
open import elementary-number-theory.archimedean-property-integer-fractions public
2121
open import elementary-number-theory.archimedean-property-integers public
2222
open import elementary-number-theory.archimedean-property-natural-numbers public
23+
open import elementary-number-theory.archimedean-property-positive-rational-numbers public
2324
open import elementary-number-theory.archimedean-property-rational-numbers public
2425
open import elementary-number-theory.arithmetic-functions public
2526
open import elementary-number-theory.based-induction-natural-numbers public
@@ -59,6 +60,7 @@ open import elementary-number-theory.divisibility-standard-finite-types public
5960
open import elementary-number-theory.equality-conatural-numbers public
6061
open import elementary-number-theory.equality-integers public
6162
open import elementary-number-theory.equality-natural-numbers public
63+
open import elementary-number-theory.equality-rational-numbers public
6264
open import elementary-number-theory.euclid-mullin-sequence public
6365
open import elementary-number-theory.euclidean-division-natural-numbers public
6466
open import elementary-number-theory.eulers-totient-function public
@@ -174,6 +176,7 @@ open import elementary-number-theory.triangular-numbers public
174176
open import elementary-number-theory.twin-prime-conjecture public
175177
open import elementary-number-theory.type-arithmetic-natural-numbers public
176178
open import elementary-number-theory.unit-elements-standard-finite-types public
179+
open import elementary-number-theory.unit-fractions-rational-numbers public
177180
open import elementary-number-theory.unit-similarity-standard-finite-types public
178181
open import elementary-number-theory.universal-property-conatural-numbers public
179182
open import elementary-number-theory.universal-property-integers public

src/elementary-number-theory/archimedean-property-integer-fractions.lagda.md

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ open import elementary-number-theory.strict-inequality-integers
2323
open import foundation.dependent-pair-types
2424
open import foundation.existential-quantification
2525
open import foundation.identity-types
26+
open import foundation.propositional-truncations
2627
open import foundation.transport-along-identifications
2728
```
2829

@@ -36,28 +37,31 @@ than `n` as an integer fraction times `x`.
3637

3738
```agda
3839
abstract
40+
bound-archimedean-property-fraction-ℤ :
41+
(x y : fraction-ℤ) →
42+
is-positive-fraction-ℤ x →
43+
Σ ℕ (λ n → le-fraction-ℤ y (in-fraction-ℤ (int-ℕ n) *fraction-ℤ x))
44+
bound-archimedean-property-fraction-ℤ
45+
x@(px , qx , pos-qx) y@(py , qy , pos-qy) pos-px =
46+
let
47+
(n , H) =
48+
bound-archimedean-property-ℤ
49+
( px *ℤ qy)
50+
( py *ℤ qx)
51+
( is-positive-mul-ℤ pos-px pos-qy)
52+
in
53+
n ,
54+
tr
55+
( le-ℤ (py *ℤ qx))
56+
( inv (associative-mul-ℤ (int-ℕ n) px qy))
57+
( H)
58+
3959
archimedean-property-fraction-ℤ :
4060
(x y : fraction-ℤ) →
4161
is-positive-fraction-ℤ x →
4262
exists
4363
4464
(λ n → le-fraction-ℤ-Prop y (in-fraction-ℤ (int-ℕ n) *fraction-ℤ x))
45-
archimedean-property-fraction-ℤ
46-
x@(px , qx , pos-qx) y@(py , qy , pos-qy) pos-px =
47-
elim-exists
48-
(∃
49-
( ℕ)
50-
( λ n →
51-
le-fraction-ℤ-Prop y (in-fraction-ℤ (int-ℕ n) *fraction-ℤ x)))
52-
( λ n H →
53-
intro-exists
54-
( n)
55-
( tr
56-
( le-ℤ (py *ℤ qx))
57-
( inv (associative-mul-ℤ (int-ℕ n) px qy))
58-
( H)))
59-
( archimedean-property-ℤ
60-
( px *ℤ qy)
61-
( py *ℤ qx)
62-
( is-positive-mul-ℤ pos-px pos-qy))
65+
archimedean-property-fraction-ℤ x y pos-x =
66+
unit-trunc-Prop (bound-archimedean-property-fraction-ℤ x y pos-x)
6367
```

src/elementary-number-theory/archimedean-property-integers.lagda.md

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ open import foundation.coproduct-types
2424
open import foundation.dependent-pair-types
2525
open import foundation.existential-quantification
2626
open import foundation.identity-types
27+
open import foundation.propositional-truncations
2728
open import foundation.transport-along-identifications
28-
open import foundation.unit-type
2929
```
3030

3131
</details>
@@ -40,35 +40,40 @@ integer `y`, there is an `n : ℕ` such that `y < int-ℕ n *ℤ x`.
4040

4141
```agda
4242
abstract
43+
bound-archimedean-property-ℤ :
44+
(x y : ℤ) → is-positive-ℤ x → Σ ℕ (λ n → le-ℤ y (int-ℕ n *ℤ x))
45+
bound-archimedean-property-ℤ x y pos-x
46+
with decide-is-negative-is-nonnegative-ℤ {y}
47+
... | inl neg-y = zero-ℕ , le-zero-is-negative-ℤ y neg-y
48+
... | inr nonneg-y =
49+
let
50+
(nx , nonzero-nx , nx=x) = pos-ℤ-to-ℕ x pos-x
51+
(n , ny<n*nx) =
52+
bound-archimedean-property-ℕ
53+
( nx)
54+
( nat-nonnegative-ℤ (y , nonneg-y))
55+
( nonzero-nx)
56+
in
57+
n ,
58+
binary-tr
59+
( le-ℤ)
60+
( ap pr1 (is-section-nat-nonnegative-ℤ (y , nonneg-y)))
61+
( inv (mul-int-ℕ n nx) ∙ ap (int-ℕ n *ℤ_) nx=x)
62+
( le-natural-le-ℤ
63+
( nat-nonnegative-ℤ (y , nonneg-y))
64+
( n *ℕ nx)
65+
( ny<n*nx))
66+
where
67+
pos-ℤ-to-ℕ :
68+
(z : ℤ) →
69+
is-positive-ℤ z →
70+
Σ ℕ (λ n → is-nonzero-ℕ n × (int-ℕ n = z))
71+
pos-ℤ-to-ℕ (inr (inr n)) H = succ-ℕ n , (λ ()) , refl
72+
4373
archimedean-property-ℤ :
4474
(x y : ℤ) → is-positive-ℤ x → exists ℕ (λ n → le-ℤ-Prop y (int-ℕ n *ℤ x))
45-
archimedean-property-ℤ x y pos-x with decide-is-negative-is-nonnegative-ℤ {y}
46-
... | inl neg-y = intro-exists zero-ℕ (le-zero-is-negative-ℤ y neg-y)
47-
... | inr nonneg-y =
48-
ind-Σ
49-
( λ nx (nonzero-nx , nx=x) →
50-
elim-exists
51-
(∃ ℕ (λ n → le-ℤ-Prop y (int-ℕ n *ℤ x)))
52-
( λ n ny<n*nx →
53-
intro-exists
54-
( n)
55-
( binary-tr
56-
( le-ℤ)
57-
( ap pr1 (is-section-nat-nonnegative-ℤ (y , nonneg-y)))
58-
( inv (mul-int-ℕ n nx) ∙ ap (int-ℕ n *ℤ_) nx=x)
59-
( le-natural-le-ℤ
60-
( nat-nonnegative-ℤ (y , nonneg-y))
61-
( n *ℕ nx)
62-
( ny<n*nx))))
63-
( archimedean-property-ℕ
64-
( nx)
65-
( nat-nonnegative-ℤ (y , nonneg-y)) nonzero-nx))
66-
(pos-ℤ-to-ℕ x pos-x)
67-
where pos-ℤ-to-ℕ :
68-
(z : ℤ) →
69-
is-positive-ℤ z →
70-
Σ ℕ (λ n → is-nonzero-ℕ n × (int-ℕ n = z))
71-
pos-ℤ-to-ℕ (inr (inr n)) H = succ-ℕ n , (λ ()) , refl
75+
archimedean-property-ℤ x y pos-x =
76+
unit-trunc-Prop (bound-archimedean-property-ℤ x y pos-x)
7277
```
7378

7479
## External links

src/elementary-number-theory/archimedean-property-natural-numbers.lagda.md

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ module elementary-number-theory.archimedean-property-natural-numbers where
77
<details><summary>Imports</summary>
88

99
```agda
10-
open import elementary-number-theory.equality-natural-numbers
1110
open import elementary-number-theory.euclidean-division-natural-numbers
1211
open import elementary-number-theory.multiplication-natural-numbers
1312
open import elementary-number-theory.natural-numbers
@@ -16,6 +15,7 @@ open import elementary-number-theory.strict-inequality-natural-numbers
1615
1716
open import foundation.dependent-pair-types
1817
open import foundation.existential-quantification
18+
open import foundation.propositional-truncations
1919
open import foundation.transport-along-identifications
2020
```
2121

@@ -31,19 +31,23 @@ for any nonzero natural number `x` and any natural number `y`, there is an
3131

3232
```agda
3333
abstract
34+
bound-archimedean-property-ℕ :
35+
(x y : ℕ) → is-nonzero-ℕ x → Σ ℕ (λ n → le-ℕ y (n *ℕ x))
36+
bound-archimedean-property-ℕ x y nonzero-x =
37+
succ-ℕ (quotient-euclidean-division-ℕ x y) ,
38+
tr
39+
( λ z → z <-ℕ succ-ℕ (quotient-euclidean-division-ℕ x y) *ℕ x)
40+
( eq-euclidean-division-ℕ x y)
41+
( preserves-le-left-add-ℕ
42+
( quotient-euclidean-division-ℕ x y *ℕ x)
43+
( remainder-euclidean-division-ℕ x y)
44+
( x)
45+
( strict-upper-bound-remainder-euclidean-division-ℕ x y nonzero-x))
46+
3447
archimedean-property-ℕ :
3548
(x y : ℕ) → is-nonzero-ℕ x → exists ℕ (λ n → le-ℕ-Prop y (n *ℕ x))
3649
archimedean-property-ℕ x y nonzero-x =
37-
intro-exists
38-
(succ-ℕ (quotient-euclidean-division-ℕ x y))
39-
( tr
40-
( λ z → z <-ℕ succ-ℕ (quotient-euclidean-division-ℕ x y) *ℕ x)
41-
( eq-euclidean-division-ℕ x y)
42-
( preserves-le-left-add-ℕ
43-
( quotient-euclidean-division-ℕ x y *ℕ x)
44-
( remainder-euclidean-division-ℕ x y)
45-
( x)
46-
( strict-upper-bound-remainder-euclidean-division-ℕ x y nonzero-x)))
50+
unit-trunc-Prop (bound-archimedean-property-ℕ x y nonzero-x)
4751
```
4852

4953
## External links
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# The Archimedean property of the positive rational numbers
2+
3+
```agda
4+
{-# OPTIONS --lossy-unification #-}
5+
6+
module elementary-number-theory.archimedean-property-positive-rational-numbers where
7+
```
8+
9+
<details><summary>Imports</summary>
10+
11+
```agda
12+
open import elementary-number-theory.archimedean-property-rational-numbers
13+
open import elementary-number-theory.integers
14+
open import elementary-number-theory.multiplication-rational-numbers
15+
open import elementary-number-theory.multiplicative-group-of-positive-rational-numbers
16+
open import elementary-number-theory.natural-numbers
17+
open import elementary-number-theory.nonzero-natural-numbers
18+
open import elementary-number-theory.positive-rational-numbers
19+
open import elementary-number-theory.rational-numbers
20+
open import elementary-number-theory.strict-inequality-rational-numbers
21+
22+
open import foundation.action-on-identifications-functions
23+
open import foundation.binary-transport
24+
open import foundation.dependent-pair-types
25+
open import foundation.existential-quantification
26+
open import foundation.identity-types
27+
open import foundation.propositional-truncations
28+
open import foundation.transport-along-identifications
29+
```
30+
31+
</details>
32+
33+
## Definition
34+
35+
The
36+
{{#concept "Archimedean property" Disambiguation="positive rational numbers" Agda=archimedean-property-ℚ⁺}}
37+
of `ℚ⁺` is that for any two
38+
[positive rational numbers](elementary-number-theory.positive-rational-numbers.md)
39+
`x y : ℚ⁺`, there is a
40+
[nonzero natural number](elementary-number-theory.nonzero-natural-numbers.md)
41+
`n` such that `y` is
42+
[less than](elementary-number-theory.strict-inequality-rational-numbers.md) `n`
43+
times `x`.
44+
45+
```agda
46+
abstract
47+
bound-archimedean-property-ℚ⁺ :
48+
(x y : ℚ⁺) →
49+
Σ ℕ⁺ (λ n → le-ℚ⁺ y (positive-rational-ℕ⁺ n *ℚ⁺ x))
50+
bound-archimedean-property-ℚ⁺ (x , pos-x) (y , pos-y) =
51+
let
52+
(n , y<nx) = bound-archimedean-property-ℚ x y pos-x
53+
n≠0 : is-nonzero-ℕ n
54+
n≠0 n=0 =
55+
asymmetric-le-ℚ
56+
( zero-ℚ)
57+
( y)
58+
( le-zero-is-positive-ℚ y pos-y)
59+
( tr
60+
( le-ℚ y)
61+
( equational-reasoning
62+
rational-ℤ (int-ℕ n) *ℚ x
63+
= rational-ℤ (int-ℕ 0) *ℚ x
64+
by ap (λ m → rational-ℤ (int-ℕ m) *ℚ x) n=0
65+
= zero-ℚ by left-zero-law-mul-ℚ x)
66+
y<nx)
67+
in (n , n≠0) , y<nx
68+
69+
archimedean-property-ℚ⁺ :
70+
(x y : ℚ⁺) →
71+
exists ℕ⁺ (λ n → le-prop-ℚ⁺ y (positive-rational-ℕ⁺ n *ℚ⁺ x))
72+
archimedean-property-ℚ⁺ x y =
73+
unit-trunc-Prop (bound-archimedean-property-ℚ⁺ x y)
74+
```

0 commit comments

Comments
 (0)