Skip to content
Snippets Groups Projects
Commit 402f2d6a authored by Robbert Krebbers's avatar Robbert Krebbers
Browse files

Merge branch 'robbert/Qp' into 'master'

Extend the theory of positive rationals `Qp`

See merge request !188
parents 10f2dd99 420e57f6
No related branches found
No related tags found
1 merge request!188Extend the theory of positive rationals `Qp`
Pipeline #36667 passed
...@@ -15,12 +15,36 @@ Coq 8.8 and 8.9 are no longer supported. ...@@ -15,12 +15,36 @@ Coq 8.8 and 8.9 are no longer supported.
`zip_with` and `Forall2` versions of `∪`, `∖`, and `##`. `zip_with` and `Forall2` versions of `∪`, `∖`, and `##`.
- Remove unused type classes `DisjointE`, `DisjointList`, `LookupE`, and - Remove unused type classes `DisjointE`, `DisjointList`, `LookupE`, and
`InsertE`. `InsertE`.
- Overhaul of the theory of positive rationals `Qp`:
+ Add the orders `Qp_le` and `Qp_lt`.
+ Rename `Qp_plus` into `Qp_add` and `Qp_mult` into `Qp_mul` to be consistent
with the corresponding names for `nat`, `N`, and `Z`.
+ Add a function `Qp_inv` for the multiplicative inverse.
+ Define the division function `Qp_div` in terms of `Qp_inv`, and generalize
the second argument from `positive` to `Qp`.
+ Add a function `pos_to_Qp` that converts a `positive` into a positive
rational `Qp`.
+ Add many lemmas and missing type class instances, especially for orders,
multiplication, multiplicative inverse, division, and the conversion.
+ Remove the coercion from `Qp` to `Qc`. This follows our recent tradition of
getting rid of coercions since they are more often confusing than useful.
+ Rename the conversion from `Qp_car : Qp → Qc` into `Qp_to_Qc` to be
consistent with other conversion functions in std++. Also rename the lemma
`Qp_eq` into `Qp_to_Qc_inj_iff`.
+ Use `let '(..) = ...` in the definitions of `Qp_plus`, `Qp_mult`, `Qp_inv`,
`Qp_le` and `Qp_lt` to avoid Coq tactics (like `injection`) to unfold these
definitions eagerly.
+ Define the `Qp` literals 1, 2, 3, 4 in terms of `pos_to_Qp` instead of
iterated addition.
+ Rename and restate many lemmas so as to be consistent with the conventions
for Coq's number types `nat`, `N`, and `Z`.
The following `sed` script should perform most of the renaming The following `sed` script should perform most of the renaming
(on macOS, replace `sed` by `gsed`, installed via e.g. `brew install gnu-sed`): (on macOS, replace `sed` by `gsed`, installed via e.g. `brew install gnu-sed`):
``` ```
sed -i ' sed -i '
s/\bQp_not_plus_q_ge_1\b/Qp_not_plus_ge/g s/\bQp_plus/Qp_add/g
s/\bQp_mult/Qp_mul/g
' $(find theories -name "*.v") ' $(find theories -name "*.v")
``` ```
......
...@@ -269,11 +269,11 @@ Qed. ...@@ -269,11 +269,11 @@ Qed.
Program Instance Qp_countable : Countable Qp := Program Instance Qp_countable : Countable Qp :=
inj_countable inj_countable
Qp_car Qp_to_Qc
(λ p : Qc, guard (0 < p)%Qc as Hp; Some (mk_Qp p Hp)) _. (λ p : Qc, guard (0 < p)%Qc as Hp; Some (mk_Qp p Hp)) _.
Next Obligation. Next Obligation.
intros [p Hp]. unfold mguard, option_guard; simpl. intros [p Hp]. unfold mguard, option_guard; simpl.
case_match; [|done]. f_equal. by apply Qp_eq. case_match; [|done]. f_equal. by apply Qp_to_Qc_inj_iff.
Qed. Qed.
Program Instance fin_countable n : Countable (fin n) := Program Instance fin_countable n : Countable (fin n) :=
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment