More Archimedean lemmas#1510
Conversation
|
|
||
| Lemma floor_def x m : m%:~R <= x < (m + 1)%:~R -> floor x = m. | ||
| Lemma to_real_floor_idP x n : | ||
| reflect (floor x = n) (n%:~R <= to_real x < (n + 1)%:~R). |
There was a problem hiding this comment.
@affeldt-aist @proux01 @hoheinzollern To answer your question (#1377 (comment)), floor_def and real_floor_itv are more or less the converses of each other. This lemma to_real_floor_idP (also real_floor_idP and floor_idP below) reformulates them using reflect.
However, real_floor_idP below does not nicely subsume floor_def, because the assumption x \is Num.real is deduced from n%:~R <= x in the proof of the latter.
There was a problem hiding this comment.
(Now I think floor_idP is not the right name... floor_itvP?)
There was a problem hiding this comment.
I renamed it to (to_real_)floor_itvP.
|
MCA still uses Definition bound (x : R) := (truncn `|x|).+1. |
f0fac3a to
24c11d8
Compare
24c11d8 to
934a425
Compare
934a425 to
2188e06
Compare
|
Rebased. I will take a fresh look at the PR and fix the naming issue this afternoon. |
2188e06 to
84df4f1
Compare
| (* TODO1: rename to real_eq_floor? *) | ||
| (* TODO2: add a general version using to_real, and derive (to_)real_floor_itvP from it *) | ||
| Lemma real_floor_eq x n : x \is real_num -> | ||
| (floor x == n) = (n%:~R <= x < (n + 1)%:~R). | ||
| Proof. by move=> ?; apply/eqP/real_floor_itvP. Qed. | ||
|
|
||
| (* TODO: rename? *) | ||
| Lemma floor_def x n : n%:~R <= x < (n + 1)%:~R -> floor x = n. |
There was a problem hiding this comment.
Any opinion on the renaming of these lemmas? I think real_floor_eq should be called something like real_eq_floor or real_eq_floor_itv, cf., meet_idPl and eq_meetl.
There was a problem hiding this comment.
IMO, floor_def is almost the definition of floor, but only for the case where x \is real_num.
There was a problem hiding this comment.
and floor_default: x \isn't real_num -> floor x = 0
There was a problem hiding this comment.
@CohenCyril Am I right that your suggestion was to rename (real_)floor_eq to (real_)eq_floor and then rename floor_def to floor_eq? (We can do the latter renaming only after releasing MC 2.7.)
There was a problem hiding this comment.
And I prefer to add floor_default in a subsequent PR.
84df4f1 to
16f0e30
Compare
|
@CohenCyril @affeldt-aist @proux01 @hoheinzollern While this PR is far from ready, I think I have done almost everything I can. Since this PR addresses the issue you reported (#1377) or implements the solution you proposed (#1377 (comment)), your input is necessary at this point. |
16f0e30 to
8bc40dc
Compare
2401b4f to
5677272
Compare
5677272 to
56f1f2e
Compare
56f1f2e to
35d1b4f
Compare
pi8027
left a comment
There was a problem hiding this comment.
I made some progress. I isolated the renaming of existing lemmas into the first commit. We can consider merging it first.
| #[deprecated(since="mathcomp 2.7.0", use=real_floor_gez)] | ||
| Notation real_floor_ge_int := real_floor_gez (only parsing). | ||
| #[deprecated(since="mathcomp 2.7.0", use=real_floor_ltz)] | ||
| Notation real_floor_lt_int := real_floor_ltz (only parsing). | ||
| #[deprecated(since="mathcomp 2.7.0", use=real_ceil_lez)] | ||
| Notation real_ceil_le_int := real_ceil_lez (only parsing). | ||
| #[deprecated(since="mathcomp 2.7.0", use=real_ceil_gtz)] | ||
| Notation real_ceil_gt_int := real_ceil_gtz (only parsing). |
There was a problem hiding this comment.
Following Cyril's suggestion during the meeting, I replaced _int with z in these names.
| Notation truncn_ge_nat := truncn_gen (only parsing). | ||
| #[deprecated(since="mathcomp 2.7.0", use=truncn_gtn)] | ||
| Notation truncn_gt_nat := truncn_gtn (only parsing). | ||
| #[deprecated(since="mathcomp 2.7.0", use=truncn_ltn)] | ||
| Notation truncn_lt_nat := truncn_ltn (only parsing). | ||
| #[deprecated(since="mathcomp 2.7.0", use=real_truncn_len)] | ||
| Notation real_truncn_le_nat := real_truncn_len (only parsing). |
There was a problem hiding this comment.
Similarly, I replaced _nat with n here.
There was a problem hiding this comment.
Shouldn't the suffixes _gen and _len by _geq and _leq like in ssrnat.v?
There was a problem hiding this comment.
I was hesitating between the two. To be honest, I don't know. @CohenCyril
There was a problem hiding this comment.
For example, the way I would read truncn_len is: truncn x is less than or equal to n, for some x and natural number n. I'm unsure if we can read it in the same way if we replace n with q.
There was a problem hiding this comment.
That being said, I think _gen and _len are confusing. What about _ge(q)_n and _le(q)_n?
There was a problem hiding this comment.
After thinking about it twice, I decided to use _leq and _geq.
|
|
||
| (* Factories *) | ||
|
|
||
| HB.factory Record NumDomain_hasFloorCeilTruncn R & Num.NumDomain R := { |
There was a problem hiding this comment.
This was the mixin of the Archimedean structures before this PR, and this should be deprecated and eventually removed. What is the right suffix (like _truncn_abs_floor) for this one?
5c2589f to
fc46e67
Compare
fc46e67 to
b2f972b
Compare
pi8027
left a comment
There was a problem hiding this comment.
I think this PR is ready for another round of review. Currently, the first commit does all the renamings of existing lemmas, and the second commit does the other changes. Perhaps the former part can be merged quickly. (If it is the case, I will split the PR.)
| Lemma truncnD : | ||
| {in nat_num & nneg_num, {morph truncn : x y / x + y >-> (x + y)%N}}. |
There was a problem hiding this comment.
I renamed this to truncnDnr to introduce truncnDrn. I'm unsure if they are the right name since this r has to be non-negative.
There was a problem hiding this comment.
Looking at CONTRIBUTING.md and num_theory/, the shorthand for nneg_num seems to be wp (weak positive ?). So they should probably be called truncnDn(_)wp and truncnDwp(_)n. Any opinion?
There was a problem hiding this comment.
Another option is to use D as an infix symbol like M in rMn: truncn_nDwp and truncn_wpDn. But, we need to rename similar lemmas for floor and ceil too.
There was a problem hiding this comment.
We can also postpone introducing truncnDrn to address this naming issue later.
b2f972b to
9195dc8
Compare
|
@CohenCyril @affeldt-aist @proux01 @hoheinzollern This PR is waiting for review. |
|
I'll do it but this may take me a bit of time to get to it. |
Motivation for this change
This PR adds some lemmas for
archiNumDomainTypeandarchiRealDomainTypeusingto_real(alsoto_nneg) suggested by @CohenCyril (cf. #1377 (comment)).Most of these lemmas for
floorandceilgeneralize existing lemmas requiring theNum.realcondition on a variable. Since the names of these lemmas have the prefixreal_, the names of their general versions replace it withto_real_for the moment. Similarly, some of the new lemmas fortruncnhave the prefixto_nneg_. (We probably need to think a bit more about the naming convention here.)In the end, I didn't find
floorP,ceilP, andtruncnPstated usingspecdatatypes very useful (cf. #1377 (comment)). I keep their statements as comments for the moment.I suggest extensively testing the new lemmas in MCA before merging this PR.
(Eventually) Fix #1377
Dependencies
archimedean.v#1526Minimal TODO list
doc/changelog/make-entry.shSee this Checklist for details.
Automatic note to reviewers
Read this Checklist.