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

Refactoring positive integers #1059

Merged
merged 117 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
117 commits
Select commit Hold shift + click to select a range
e772784
signed integers
malarbol Feb 28, 2024
f68d579
split and rename signed-integers module
malarbol Mar 4, 2024
f22755b
remove positivity et al. from `integers` module
malarbol Mar 5, 2024
457dbc9
typo: put back parenthesis
malarbol Mar 5, 2024
51bb18c
redefine types
malarbol Mar 6, 2024
afc78f3
fix indentation
malarbol Mar 6, 2024
eb6c70d
fix indentation
malarbol Mar 6, 2024
244c942
cleanup
malarbol Mar 6, 2024
9d35ab0
explanation
malarbol Mar 6, 2024
1c7f8c3
Set properties
malarbol Mar 6, 2024
3276b51
cleanup
malarbol Mar 6, 2024
8dd492a
decidability properties
malarbol Mar 6, 2024
ad138be
rename and clean
malarbol Mar 7, 2024
afff8f4
Merge branch 'UniMath:master' into signed-integers
malarbol Mar 7, 2024
bb2028f
refactor `eq-sim-unit-is-nonnegative-ℤ`
malarbol Mar 7, 2024
66e5b2c
remove positivity properties from `addition-integers` module
malarbol Mar 7, 2024
af888eb
Update src/elementary-number-theory/integers.lagda.md
malarbol Mar 7, 2024
fdb6384
Update src/elementary-number-theory/multiplication-integers.lagda.md
malarbol Mar 7, 2024
9da8e03
Update src/elementary-number-theory/positive-and-negative-integers.la…
malarbol Mar 7, 2024
509e4e5
Update src/elementary-number-theory/negative-integers.lagda.md
malarbol Mar 7, 2024
884f70c
move single-concepts properties
malarbol Mar 7, 2024
bc4d715
cleanup
malarbol Mar 7, 2024
4fedaad
implicit arguments and cleanup
malarbol Mar 7, 2024
f2b5647
addition negative integers
malarbol Mar 7, 2024
5694133
shorter names
malarbol Mar 7, 2024
dd7ecab
fix name
malarbol Mar 7, 2024
a86c476
remove positivity properties from `multiplication-integers` module
malarbol Mar 8, 2024
60d5e0d
fix pre-commit
malarbol Mar 8, 2024
6bbd474
full signed addition tables and re-organize
malarbol Mar 9, 2024
2a40405
fix typo
malarbol Mar 9, 2024
ef992b7
full signed multiplication table and rules
malarbol Mar 9, 2024
2aaceba
refactor for illustration
malarbol Mar 9, 2024
862aded
descriptive headers
malarbol Mar 9, 2024
cbc83f2
fix typo
malarbol Mar 9, 2024
eb3e0bf
strict inequality implies inequality
malarbol Mar 9, 2024
2ddec64
re-organize inequality integers
malarbol Mar 9, 2024
65b1d01
move is-nonzero-is-positive-ℤ
malarbol Mar 9, 2024
ce731bf
signed neg-ℤ
malarbol Mar 9, 2024
5251cf4
fix names, headers and re-organize
malarbol Mar 10, 2024
0e612c4
remove negatives-add-ℤ
malarbol Mar 10, 2024
8104bba
fix names and types
malarbol Mar 10, 2024
40ba992
fix indentation
malarbol Mar 10, 2024
bc1474b
canonical equivalences between natural numbers and signed integers
malarbol Mar 10, 2024
2b4b03e
remove unused imports
malarbol Mar 10, 2024
37ff62f
cleanup
malarbol Mar 10, 2024
7b917db
strict inequality implies inequality
malarbol Mar 10, 2024
f222c99
fix indentation
malarbol Mar 11, 2024
7a13a34
decidability of orderings
malarbol Mar 11, 2024
e4b4713
fix names and type signatures
malarbol Mar 16, 2024
70d87ba
Update src/elementary-number-theory/addition-positive-and-negative-in…
malarbol Mar 19, 2024
cb34096
Update src/elementary-number-theory/addition-positive-and-negative-in…
malarbol Mar 19, 2024
a6290a8
Update src/elementary-number-theory/reduced-integer-fractions.lagda.md
malarbol Mar 19, 2024
84d51f6
Update src/elementary-number-theory/nonzero-integers.lagda.md
malarbol Mar 19, 2024
04da8db
Update src/elementary-number-theory/positive-integers.lagda.md
malarbol Mar 19, 2024
3854c4e
Update src/elementary-number-theory/positive-integers.lagda.md
malarbol Mar 19, 2024
dc0f5cf
Update src/elementary-number-theory/positive-and-negative-integers.la…
malarbol Mar 19, 2024
47bea08
Update src/elementary-number-theory/positive-and-negative-integers.la…
malarbol Mar 19, 2024
2179a9d
Update src/elementary-number-theory/positive-and-negative-integers.la…
malarbol Mar 19, 2024
09c7c3e
Update src/elementary-number-theory/positive-and-negative-integers.la…
malarbol Mar 19, 2024
a1020b4
Update src/elementary-number-theory/positive-and-negative-integers.la…
malarbol Mar 19, 2024
772f45a
Update src/elementary-number-theory/inequality-integers.lagda.md
malarbol Mar 19, 2024
0709cf1
Update src/elementary-number-theory/mediant-integer-fractions.lagda.md
malarbol Mar 19, 2024
403ffb7
Apply suggestions from code review
malarbol Mar 19, 2024
13b2859
Update src/elementary-number-theory/positive-integers.lagda.md
malarbol Mar 19, 2024
cabd20a
fix name
malarbol Mar 19, 2024
6a9924a
WIP review
malarbol Mar 23, 2024
8fc4f59
strict-inequality-integers module
malarbol Mar 23, 2024
184a3fd
decidable total order integers
malarbol Mar 23, 2024
ec06c68
fix headers
malarbol Mar 23, 2024
593311e
lint
malarbol Mar 23, 2024
7b4eadb
decidable total order rational numbers
malarbol Mar 23, 2024
7d930ad
reorganize
malarbol Mar 23, 2024
d80f95d
see also
malarbol Mar 23, 2024
f06dd2e
headers
malarbol Mar 23, 2024
af2318b
fix headers (concepts)
malarbol Mar 23, 2024
fdf34ac
strict-inequality-rational-numbers
malarbol Mar 23, 2024
7bd0623
Merge branch 'master' into signed-integers
malarbol Mar 23, 2024
7de3d93
fix name
malarbol Mar 23, 2024
ee1cc1b
cleanup ideas
malarbol Mar 23, 2024
4e1f7bf
strict inequality on integer fractions
malarbol Mar 25, 2024
1fcd3a2
fix typo fractions-Z / fraction-Z
malarbol Mar 25, 2024
068bf80
fix typo fractions-Z / fraction-Z
malarbol Mar 25, 2024
a6278be
fix broken link
malarbol Mar 25, 2024
8b4c716
fix broken link
malarbol Mar 25, 2024
4b8e6f1
Merge branch 'master' into signed-integers
malarbol Mar 25, 2024
4d17292
Merge branch 'master' into signed-integers
malarbol Mar 26, 2024
764c324
Update src/elementary-number-theory/inequality-integers.lagda.md
malarbol Mar 27, 2024
2c6f06f
Update src/elementary-number-theory/strict-inequality-rational-number…
malarbol Mar 27, 2024
a7ce8fe
Update src/elementary-number-theory/strict-inequality-integers.lagda.md
malarbol Mar 27, 2024
0c84e91
Update src/elementary-number-theory/strict-inequality-integer-fractio…
malarbol Mar 27, 2024
930dcc8
Update src/elementary-number-theory/strict-inequality-integer-fractio…
malarbol Mar 27, 2024
2570928
Update src/elementary-number-theory/positive-integers.lagda.md
malarbol Mar 27, 2024
dab2c55
Update src/elementary-number-theory/positive-and-negative-integers.la…
malarbol Mar 27, 2024
3070b77
Update src/elementary-number-theory/nonnegative-integers.lagda.md
malarbol Mar 27, 2024
3f8bd30
Apply suggestions from code review
malarbol Mar 27, 2024
2d04be0
Update src/elementary-number-theory/addition-integers.lagda.md
malarbol Mar 27, 2024
4424681
Update src/elementary-number-theory/multiplication-positive-and-negat…
malarbol Mar 27, 2024
588c9b5
Update src/elementary-number-theory/addition-positive-and-negative-in…
malarbol Mar 27, 2024
dd96315
Update src/elementary-number-theory/multiplication-positive-and-negat…
malarbol Mar 27, 2024
3729baa
Update src/elementary-number-theory/addition-positive-and-negative-in…
malarbol Mar 27, 2024
2c40345
fix parentheses
malarbol Mar 27, 2024
9b4ff03
Update src/elementary-number-theory/inequality-integers.lagda.md
malarbol Mar 27, 2024
8b16ac2
Update src/elementary-number-theory/integers.lagda.md
malarbol Mar 27, 2024
f4a477f
fix headers
malarbol Mar 27, 2024
27ed6d3
fix headers
malarbol Mar 27, 2024
edab26f
Update src/elementary-number-theory/inequality-natural-numbers.lagda.md
malarbol Mar 27, 2024
309aa1a
lint
malarbol Mar 27, 2024
05421f4
fix see also
malarbol Mar 27, 2024
e89a650
strict inequality on integer fractions is dense and located
malarbol Mar 27, 2024
f4d365e
fix parentheses
malarbol Mar 28, 2024
cd2de6b
better header
malarbol Mar 28, 2024
5bc5f96
fix inequality headers
malarbol Mar 28, 2024
5823072
Update src/elementary-number-theory/inequality-integer-fractions.lagd…
malarbol Mar 28, 2024
ee50426
Update src/elementary-number-theory/inequality-integer-fractions.lagd…
malarbol Mar 28, 2024
dc16837
fix headers
malarbol Mar 28, 2024
cce4d39
fix headers -- remove standard
malarbol Mar 28, 2024
794197c
Apply suggestions from code review
malarbol Mar 28, 2024
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
5 changes: 5 additions & 0 deletions src/elementary-number-theory.lagda.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,18 @@ open import elementary-number-theory.multiplicative-units-integers public
open import elementary-number-theory.multiplicative-units-standard-cyclic-rings public
open import elementary-number-theory.multiset-coefficients public
open import elementary-number-theory.natural-numbers public
open import elementary-number-theory.negative-integers public
open import elementary-number-theory.nonnegative-integers public
open import elementary-number-theory.nonpositive-integers public
open import elementary-number-theory.nonzero-integers public
open import elementary-number-theory.nonzero-natural-numbers public
open import elementary-number-theory.ordinal-induction-natural-numbers public
open import elementary-number-theory.parity-natural-numbers public
open import elementary-number-theory.peano-arithmetic public
open import elementary-number-theory.pisano-periods public
open import elementary-number-theory.poset-of-natural-numbers-ordered-by-divisibility public
open import elementary-number-theory.positive-and-negative-integers public
open import elementary-number-theory.positive-integers public
open import elementary-number-theory.powers-integers public
open import elementary-number-theory.powers-of-two public
open import elementary-number-theory.prime-numbers public
Expand Down
2 changes: 2 additions & 0 deletions src/elementary-number-theory/absolute-value-integers.lagda.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ open import elementary-number-theory.integers
open import elementary-number-theory.multiplication-integers
open import elementary-number-theory.multiplication-natural-numbers
open import elementary-number-theory.natural-numbers
open import elementary-number-theory.nonnegative-integers
open import elementary-number-theory.positive-integers

open import foundation.action-on-identifications-functions
open import foundation.coproduct-types
Expand Down
14 changes: 9 additions & 5 deletions src/elementary-number-theory/addition-integers.lagda.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ module elementary-number-theory.addition-integers where
open import elementary-number-theory.addition-natural-numbers
open import elementary-number-theory.integers
open import elementary-number-theory.natural-numbers
open import elementary-number-theory.nonnegative-integers
open import elementary-number-theory.positive-and-negative-integers
open import elementary-number-theory.positive-integers

open import foundation.action-on-identifications-binary-functions
open import foundation.action-on-identifications-functions
Expand All @@ -23,6 +26,7 @@ open import foundation.function-types
open import foundation.identity-types
open import foundation.injective-maps
open import foundation.interchange-law
open import foundation.transport-along-identifications
open import foundation.unit-type
```

Expand Down Expand Up @@ -516,12 +520,12 @@ is-nonnegative-add-ℤ (inr (inl star)) (inr (inl star)) p q = star
is-nonnegative-add-ℤ (inr (inl star)) (inr (inr n)) p q = star
is-nonnegative-add-ℤ (inr (inr zero-ℕ)) (inr (inl star)) p q = star
is-nonnegative-add-ℤ (inr (inr (succ-ℕ n))) (inr (inl star)) star star =
is-nonnegative-succ-ℤ
is-nonnegative-succ-is-nonnegative-
( (inr (inr n)) +ℤ (inr (inl star)))
( is-nonnegative-add-ℤ (inr (inr n)) (inr (inl star)) star star)
is-nonnegative-add-ℤ (inr (inr zero-ℕ)) (inr (inr m)) star star = star
is-nonnegative-add-ℤ (inr (inr (succ-ℕ n))) (inr (inr m)) star star =
is-nonnegative-succ-ℤ
is-nonnegative-succ-is-nonnegative-
( (inr (inr n)) +ℤ (inr (inr m)))
( is-nonnegative-add-ℤ (inr (inr n)) (inr (inr m)) star star)
```
Expand All @@ -533,9 +537,9 @@ is-positive-add-ℤ :
{x y : ℤ} → is-positive-ℤ x → is-positive-ℤ y → is-positive-ℤ (x +ℤ y)
is-positive-add-ℤ {inr (inr zero-ℕ)} {inr (inr y)} H K = star
is-positive-add-ℤ {inr (inr (succ-ℕ x))} {inr (inr y)} H K =
is-positive-succ-ℤ
( is-nonnegative-is-positive-ℤ
( is-positive-add-ℤ {inr (inr x)} {inr (inr y)} star star))
is-positive-succ-is-positive-
( add-ℤ (inr (inr x)) (inr (inr y)))
( is-positive-add-ℤ {inr (inr x)} {inr (inr y)} H K)

is-positive-add-nonnegative-positive-ℤ :
{x y : ℤ} → is-nonnegative-ℤ x → is-positive-ℤ y → is-positive-ℤ (x +ℤ y)
Expand Down
16 changes: 10 additions & 6 deletions src/elementary-number-theory/bezouts-lemma-integers.lagda.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ open import elementary-number-theory.integers
open import elementary-number-theory.multiplication-integers
open import elementary-number-theory.multiplication-natural-numbers
open import elementary-number-theory.natural-numbers
open import elementary-number-theory.nonnegative-integers
open import elementary-number-theory.positive-and-negative-integers
open import elementary-number-theory.positive-integers

open import foundation.action-on-identifications-functions
open import foundation.coproduct-types
Expand Down Expand Up @@ -194,25 +197,26 @@ bezouts-lemma-refactor-hypotheses x y H K =
x-product-nonneg :
is-nonnegative-ℤ
( int-ℕ (minimal-positive-distance-x-coeff (abs-ℤ x) (abs-ℤ y) P) *ℤ x)
x-product-nonneg = is-nonnegative-mul-ℤ
(is-nonnegative-int-ℕ
( minimal-positive-distance-x-coeff (abs-ℤ x) (abs-ℤ y) P))
(is-nonnegative-is-positive-ℤ H)
x-product-nonneg =
is-nonnegative-mul-ℤ
( is-nonnegative-int-ℕ
( minimal-positive-distance-x-coeff (abs-ℤ x) (abs-ℤ y) P))
( is-nonnegative-is-positive-ℤ x H)
y-product-nonneg :
is-nonnegative-ℤ
( int-ℕ (minimal-positive-distance-y-coeff (abs-ℤ x) (abs-ℤ y) P) *ℤ y)
y-product-nonneg =
is-nonnegative-mul-ℤ
( is-nonnegative-int-ℕ
( minimal-positive-distance-y-coeff (abs-ℤ x) (abs-ℤ y) P))
( is-nonnegative-is-positive-ℤ K)
( is-nonnegative-is-positive-ℤ y K)

bezouts-lemma-pos-ints :
(x y : ℤ) (H : is-positive-ℤ x) (K : is-positive-ℤ y) →
Σ ℤ (λ s → Σ ℤ (λ t → (s *ℤ x) +ℤ (t *ℤ y) = gcd-ℤ x y))
bezouts-lemma-pos-ints x y H K =
sx-ty-nonneg-case-split
( decide-is-nonnegative-ℤ {(s *ℤ x) -ℤ (t *ℤ y)})
( decide-is-nonnegative-is-nonnegative-neg-ℤ {(s *ℤ x) -ℤ (t *ℤ y)})
where
s : ℤ
s = int-ℕ (minimal-positive-distance-x-coeff
Expand Down
63 changes: 36 additions & 27 deletions src/elementary-number-theory/bezouts-lemma-natural-numbers.lagda.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ open import elementary-number-theory.modular-arithmetic
open import elementary-number-theory.multiplication-integers
open import elementary-number-theory.multiplication-natural-numbers
open import elementary-number-theory.natural-numbers
open import elementary-number-theory.nonnegative-integers
open import elementary-number-theory.positive-and-negative-integers
open import elementary-number-theory.strict-inequality-natural-numbers
open import elementary-number-theory.well-ordering-principle-natural-numbers

Expand Down Expand Up @@ -311,7 +313,7 @@ is-distance-between-multiples-div-mod-ℕ :
(x y z : ℕ) →
div-ℤ-Mod x (mod-ℕ x y) (mod-ℕ x z) → is-distance-between-multiples-ℕ x y z
is-distance-between-multiples-div-mod-ℕ zero-ℕ y z (u , p) =
u-nonneg-case-split (decide-is-nonnegative-ℤ {u})
u-nonneg-case-split (decide-is-nonnegative-is-nonnegative-neg-ℤ {u})
where
u-nonneg-case-split :
(is-nonnegative-ℤ u + is-nonnegative-ℤ (neg-ℤ u)) →
Expand Down Expand Up @@ -339,7 +341,7 @@ is-distance-between-multiples-div-mod-ℕ zero-ℕ y z (u , p) =
( is-nonnegative-mul-ℤ neg (is-nonnegative-int-ℕ y))))))

is-distance-between-multiples-div-mod-ℕ (succ-ℕ x) y z (u , p) =
uy-z-case-split (decide-is-nonnegative-ℤ
uy-z-case-split (decide-is-nonnegative-is-nonnegative-neg-
{ ((int-ℤ-Mod (succ-ℕ x) u) *ℤ (int-ℕ y)) +ℤ (neg-ℤ (int-ℕ z))})
where
a : ℤ
Expand Down Expand Up @@ -714,31 +716,38 @@ is-distance-between-multiples-div-mod-ℕ (succ-ℕ x) y z (u , p) =
= z by abs-int-ℕ z))
where
neg-a-is-nonnegative-ℤ : is-nonnegative-ℤ (neg-ℤ a)
neg-a-is-nonnegative-ℤ = (is-nonnegative-left-factor-mul-ℤ
(tr is-nonnegative-ℤ
(equational-reasoning
neg-ℤ (((int-ℤ-Mod (succ-ℕ x) u) *ℤ (int-ℕ y)) +ℤ
(neg-ℤ (int-ℕ z)))
= (neg-ℤ ((int-ℤ-Mod (succ-ℕ x) u) *ℤ (int-ℕ y))) +ℤ
(neg-ℤ (neg-ℤ (int-ℕ z)))
by (distributive-neg-add-ℤ
((int-ℤ-Mod (succ-ℕ x) u) *ℤ (int-ℕ y))
(neg-ℤ (int-ℕ z)))
= (neg-ℤ ((int-ℤ-Mod (succ-ℕ x) u) *ℤ (int-ℕ y))) +ℤ
(int-ℕ z)
by ap ((neg-ℤ ((int-ℤ-Mod (succ-ℕ x) u) *ℤ (int-ℕ y))) +ℤ_)
(neg-neg-ℤ (int-ℕ z))
= add-ℤ (int-ℕ z)
(neg-ℤ ((int-ℤ-Mod (succ-ℕ x) u) *ℤ (int-ℕ y)))
by commutative-add-ℤ
(neg-ℤ ((int-ℤ-Mod (succ-ℕ x) u) *ℤ (int-ℕ y)))
(int-ℕ z)
= (neg-ℤ a) *ℤ (int-ℕ (succ-ℕ x))
by inv (pr2
(symmetric-cong-ℤ (int-ℕ (succ-ℕ x))
((int-ℤ-Mod (succ-ℕ x) u) *ℤ (int-ℕ y)) (int-ℕ z)
(cong-div-mod-ℤ (succ-ℕ x) y z (u , p)))))
z-uy) (is-nonnegative-int-ℕ (succ-ℕ x)))
neg-a-is-nonnegative-ℤ =
is-nonnegative-left-factor-mul-ℤ
( tr is-nonnegative-ℤ
( equational-reasoning
( neg-ℤ (((int-ℤ-Mod (succ-ℕ x) u) *ℤ (int-ℕ y)) +ℤ
( neg-ℤ (int-ℕ z))))
= ( neg-ℤ ((int-ℤ-Mod (succ-ℕ x) u) *ℤ (int-ℕ y))) +ℤ
( neg-ℤ (neg-ℤ (int-ℕ z)))
by
( distributive-neg-add-ℤ
( (int-ℤ-Mod (succ-ℕ x) u) *ℤ (int-ℕ y))
( neg-ℤ (int-ℕ z)))
= ( neg-ℤ ((int-ℤ-Mod (succ-ℕ x) u) *ℤ (int-ℕ y))) +ℤ
( int-ℕ z)
by
ap
( (neg-ℤ ((int-ℤ-Mod (succ-ℕ x) u) *ℤ (int-ℕ y))) +ℤ_)
( neg-neg-ℤ (int-ℕ z))
= add-ℤ
( int-ℕ z)
( neg-ℤ ((int-ℤ-Mod (succ-ℕ x) u) *ℤ (int-ℕ y)))
by
commutative-add-ℤ
( neg-ℤ ((int-ℤ-Mod (succ-ℕ x) u) *ℤ (int-ℕ y)))
( int-ℕ z)
= (neg-ℤ a) *ℤ (int-ℕ (succ-ℕ x))
by inv (pr2
( symmetric-cong-ℤ (int-ℕ (succ-ℕ x))
( (int-ℤ-Mod (succ-ℕ x) u) *ℤ (int-ℕ y)) (int-ℕ z)
( cong-div-mod-ℤ (succ-ℕ x) y z (u , p)))))
( z-uy))
( is-nonnegative-int-ℕ (succ-ℕ x))
```

### The type `is-distance-between-multiples-ℕ x y z` is decidable
Expand Down
3 changes: 3 additions & 0 deletions src/elementary-number-theory/distance-integers.lagda.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ open import elementary-number-theory.difference-integers
open import elementary-number-theory.distance-natural-numbers
open import elementary-number-theory.integers
open import elementary-number-theory.natural-numbers
open import elementary-number-theory.nonnegative-integers
open import elementary-number-theory.positive-and-negative-integers
open import elementary-number-theory.positive-integers

open import foundation.action-on-identifications-binary-functions
open import foundation.action-on-identifications-functions
Expand Down
39 changes: 20 additions & 19 deletions src/elementary-number-theory/divisibility-integers.lagda.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ open import elementary-number-theory.equality-integers
open import elementary-number-theory.integers
open import elementary-number-theory.multiplication-integers
open import elementary-number-theory.natural-numbers
open import elementary-number-theory.nonnegative-integers
open import elementary-number-theory.nonpositive-integers
open import elementary-number-theory.nonzero-integers
open import elementary-number-theory.positive-and-negative-integers

open import foundation.action-on-identifications-functions
open import foundation.binary-relations
Expand Down Expand Up @@ -657,23 +660,21 @@ is-plus-or-minus-sim-unit-ℤ {x} {y} H | inr nz | inr p =
```agda
eq-sim-unit-is-nonnegative-ℤ :
{a b : ℤ} → is-nonnegative-ℤ a → is-nonnegative-ℤ b → sim-unit-ℤ a b → a = b
eq-sim-unit-is-nonnegative-ℤ {a} {b} H H' K
with is-plus-or-minus-sim-unit-ℤ K
eq-sim-unit-is-nonnegative-ℤ {a} {b} H H' K | inl pos = pos
eq-sim-unit-is-nonnegative-ℤ {a} {b} H H' K | inr neg
with is-decidable-is-zero-ℤ a
eq-sim-unit-is-nonnegative-ℤ {a} {b} H H' K | inr neg | inl z =
equational-reasoning
a
= zero-ℤ
by z
= neg-ℤ a
by inv (ap neg-ℤ z)
= b
by neg
eq-sim-unit-is-nonnegative-ℤ {a} {b} H H' K | inr neg | inr nz =
ex-falso
( nz
( is-zero-is-nonnegative-neg-is-nonnegative-ℤ
a H (tr is-nonnegative-ℤ (inv neg) H')))
eq-sim-unit-is-nonnegative-ℤ {a} {b} H H' K with is-plus-or-minus-sim-unit-ℤ K
...| inl p = p
...| inr m = α ∙ inv β
where
α : is-zero-ℤ a
α =
is-zero-is-nonnegative-is-nonpositive-ℤ a H
( is-nonpositive-eq-ℤ
( inv (ap neg-ℤ m) ∙ (neg-neg-ℤ a))
( is-nonpositive-neg-is-nonnegative-ℤ b H'))

β : is-zero-ℤ b
β =
is-zero-is-nonnegative-is-nonpositive-ℤ b H'
( is-nonpositive-eq-ℤ
( m)
( is-nonpositive-neg-is-nonnegative-ℤ a H))
malarbol marked this conversation as resolved.
Show resolved Hide resolved
```
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ open import elementary-number-theory.equality-integers
open import elementary-number-theory.greatest-common-divisor-natural-numbers
open import elementary-number-theory.integers
open import elementary-number-theory.natural-numbers
open import elementary-number-theory.nonnegative-integers
open import elementary-number-theory.positive-and-negative-integers
open import elementary-number-theory.positive-integers

open import foundation.action-on-identifications-functions
open import foundation.cartesian-product-types
Expand Down Expand Up @@ -234,7 +237,7 @@ div-gcd-is-common-divisor-ℤ x y k H =
is-positive-gcd-is-positive-left-ℤ :
(x y : ℤ) → is-positive-ℤ x → is-positive-ℤ (gcd-ℤ x y)
is-positive-gcd-is-positive-left-ℤ x y H =
is-positive-int-ℕ
is-positive-int-is-nonzero-
( gcd-ℕ (abs-ℤ x) (abs-ℤ y))
( is-nonzero-gcd-ℕ
( abs-ℤ x)
Expand All @@ -247,7 +250,7 @@ is-positive-gcd-is-positive-left-ℤ x y H =
is-positive-gcd-is-positive-right-ℤ :
(x y : ℤ) → is-positive-ℤ y → is-positive-ℤ (gcd-ℤ x y)
is-positive-gcd-is-positive-right-ℤ x y H =
is-positive-int-ℕ
is-positive-int-is-nonzero-
( gcd-ℕ (abs-ℤ x) (abs-ℤ y))
( is-nonzero-gcd-ℕ
( abs-ℤ x)
Expand Down
26 changes: 20 additions & 6 deletions src/elementary-number-theory/inequality-integer-fractions.lagda.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ open import elementary-number-theory.integer-fractions
open import elementary-number-theory.integers
open import elementary-number-theory.mediant-integer-fractions
open import elementary-number-theory.multiplication-integers
open import elementary-number-theory.nonnegative-integers
open import elementary-number-theory.nonpositive-integers
open import elementary-number-theory.positive-and-negative-integers
open import elementary-number-theory.positive-integers

open import foundation.action-on-identifications-functions
open import foundation.cartesian-product-types
Expand Down Expand Up @@ -80,11 +84,14 @@ module _
sim-fraction-ℤ x y
is-sim-antisymmetric-leq-fraction-ℤ H H' =
sim-is-zero-coss-mul-diff-fraction-ℤ x y
( is-zero-is-nonnegative-ℤ
( is-zero-is-nonnegative-is-nonpositive-ℤ
( cross-mul-diff-fraction-ℤ x y)
( H)
( is-nonnegative-eq-ℤ
( inv ( skew-commutative-cross-mul-diff-fraction-ℤ x y))
( H')))
( is-nonpositive-eq-ℤ
( skew-commutative-cross-mul-diff-fraction-ℤ y x)
( is-nonpositive-neg-is-nonnegative-ℤ
( cross-mul-diff-fraction-ℤ y x)
( H'))))
malarbol marked this conversation as resolved.
Show resolved Hide resolved
```

### Strict inequality on integer fractions is asymmetric
Expand Down Expand Up @@ -123,10 +130,12 @@ transitive-leq-fraction-ℤ p q r H H' =
( denominator-fraction-ℤ r *ℤ cross-mul-diff-fraction-ℤ p q)
( is-nonnegative-mul-ℤ
( is-nonnegative-is-positive-ℤ
( denominator-fraction-ℤ p)
( is-positive-denominator-fraction-ℤ p))
( H'))
( is-nonnegative-mul-ℤ
( is-nonnegative-is-positive-ℤ
( denominator-fraction-ℤ r)
( is-positive-denominator-fraction-ℤ r))
( H))))
( is-positive-denominator-fraction-ℤ q)
Expand Down Expand Up @@ -172,6 +181,7 @@ module _
( is-positive-add-nonnegative-positive-ℤ
( is-nonnegative-mul-ℤ
( is-nonnegative-is-positive-ℤ
( denominator-fraction-ℤ p)
( is-positive-denominator-fraction-ℤ p))
( H'))
( is-positive-mul-ℤ
Expand All @@ -193,6 +203,7 @@ module _
( H'))
( is-nonnegative-mul-ℤ
( is-nonnegative-is-positive-ℤ
( denominator-fraction-ℤ r)
( is-positive-denominator-fraction-ℤ r))
( H))))
( is-positive-denominator-fraction-ℤ q)
Expand All @@ -214,7 +225,8 @@ module _
( is-positive-eq-ℤ
( lemma-left-sim-cross-mul-diff-fraction-ℤ p q r H)
( is-positive-mul-ℤ
( is-positive-denominator-fraction-ℤ p) H'))
( is-positive-denominator-fraction-ℤ p)
( H')))
( is-positive-denominator-fraction-ℤ q)

concatenate-le-sim-fraction-ℤ :
Expand All @@ -225,7 +237,9 @@ module _
is-positive-right-factor-mul-ℤ
( is-positive-eq-ℤ
( inv ( lemma-right-sim-cross-mul-diff-fraction-ℤ p q r H'))
( is-positive-mul-ℤ (is-positive-denominator-fraction-ℤ r) H))
( is-positive-mul-ℤ
( is-positive-denominator-fraction-ℤ r)
( H)))
( is-positive-denominator-fraction-ℤ q)
```

Expand Down
Loading
Loading