Reversible coercions#15693
Conversation
|
🔴 CI failure at commit 246cc44 without any failure in the test-suite ✔️ Corresponding job for the base commit 3786a4a succeeded ❔ Ask me to try to extract a minimal test case that can be added to the test-suite 🏃
|
|
Quite high compatibility (elpi is testing the absence of this feature) |
|
🔴 CI failure at commit 246cc44 without any failure in the test-suite ✔️ Corresponding job for the base commit 3786a4a succeeded ❔ Ask me to try to extract a minimal test case that can be added to the test-suite 🏃
|
|
The bench is noise, indeed we cover a case which was a hard failure in developments with no ltac proof search. |
4647a9c to
06afcfd
Compare
| (* XXX this order relation is not total ... *) | ||
| let r = List.sort (fun c1 c2 -> if ClTypSet.mem c1 (reachable_from c2) then 1 else -1) r in |
There was a problem hiding this comment.
@pi8027 do you know what happens if List.sort is given an "non order" relation (like this one, which is not total and not anti-symmetric)?
There was a problem hiding this comment.
There is a stable_sort close to sort https://ocaml.org/api/List.html#VALsort so List.sort may or may not be stable, that's unspecified.
There was a problem hiding this comment.
In some sense, if it returns a permutation of the input given a random relation, it is still ok, if it asserts false... it is not
There was a problem hiding this comment.
That should be fine (the above doc doesn't expect a total order, any preorder is fine).
There was a problem hiding this comment.
And looking at the current implementation, it cannot throw an exception https://github.com/ocaml/ocaml/blob/trunk/stdlib/list.ml#L320
There was a problem hiding this comment.
There is a
stable_sortclose to sort https://ocaml.org/api/List.html#VALsort soList.sortmay or may not be stable, that's unspecified.
@proux01 Well if we start trusting implementations rather than specifications now, we see that sort = stable_sort... 😆
|
@charguer this PR also makes your example in this discourse post by declaring a default canonical structure (the eta expansion of the record) (plus the magic done here). |
|
|
||
| (* Above, it would be nice to write [eapply (T A)], or just [eapply T]. | ||
| For that, we'd need to coerce [A:Type] to the type [IType] | ||
| by applying on-the-fly the operation [IType_make A _]. Thus, we need something like: | ||
| [Coercion (fun (A:Type) => IType_make A _) : Sortclass >-> IType.] | ||
| Would that be possible? | ||
|
|
||
| I understand that [IType_type] is already a reverse coercion from [IType] to [Type], | ||
| but I don't see why it would necessarily cause trouble to have cycles | ||
| in the coercion graphs. *) | ||
|
|
||
|
|
There was a problem hiding this comment.
We can remove this part of the test file :)
There was a problem hiding this comment.
(FTR, you can push to this branch on my GH space)
|
|
||
| Arguments IType_make IType_type {IType_inhab}. |
|
I broke this test |
|
And we broke mathcomp, but I did not investigate why. |
actually... the test suite is broken ;) |
|
This last commit is the fix I had initially in mind. It just avoids to use reverse coercions if the two endpoints are the same |
|
🔴 CI failure at commit 1ff839b without any failure in the test-suite ✔️ Corresponding job for the base commit dc5e355 succeeded ❔ Ask me to try to extract a minimal test case that can be added to the test-suite 🏃
|
|
We re back on track, maybe you can play a bit more with mathcomp to test this better? |
|
🔴 CI failure at commit 1ff839b without any failure in the test-suite ✔️ Corresponding job for the base commit dc5e355 succeeded ❔ Ask me to try to extract a minimal test case that can be added to the test-suite 🏃
|
Sure, I'd like to play a bit with mathcomp on HB & categories on HB actually... but I'm struggling to compile coq-elpi on my computer 😢 |
|
Hum, the PR was just accepted in nixpkgs. For coq-elpi master you need a new elpi |
Which one? |
|
1.14.x (it should be the default on nix as well since that PR) |
|
Do you know what I am doing wrong? File "src/coq_elpi_vernacular.ml", line 767, characters 8-36:
767 | try ComExtraDeps.query_extra_dep id
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: Unbound module ComExtraDeps
make[1]: *** [Makefile.coq:735: src/coq_elpi_vernacular.cmo] Error 2
make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:38: build] Error 2 |
|
you are using the coq-master branch of coq elpi against coq 8.15 I guess |
|
No, the problem is that elpi-master moved because of a PR, but this branch was not rebased. I'm doing it now |
481345b to
1a29053
Compare
516cef9 to
5cf4262
Compare
|
rebased together with the overlay |
|
ping |
|
You should probably ping @mattam82 directly. If he doesn't answer soon, I can take over if needed. It's just a matter of merging it so... |
doc/changelog/02-specification-language/15693-reverse-coercions.rst
Outdated
Show resolved
Hide resolved
|
@gares OK, I'm taking over, but before merging I'll wait for the doc tweaks. |
|
@ppedrot I was waiting for the doc changes as well, so whoever comes first when they're here can merge :) |
|
I'm fine with the changes but I won't be able to work on them today, not tomorrow. @CohenCyril @proux01 if you could step in for that last change... |
|
Thanks |
|
@coqbot merge now |
|
@ppedrot: You can't merge the PR because it hasn't been approved yet. |
|
@coqbot merge now |
|
@ppedrot: Please take care of the following overlays:
|
356: Adapt to rocq-prover/rocq#15693 r=Janno a=proux01 To be merged in sync with the upstream PR rocq-prover/rocq#15693 Co-authored-by: Pierre Roux <pierre@roux01.fr>
356: Adapt to rocq-prover/rocq#15693 r=Janno a=proux01 To be merged in sync with the upstream PR rocq-prover/rocq#15693 Co-authored-by: Pierre Roux <pierre@roux01.fr>
Intro:
This PR implements a feature along the lines of https://arxiv.org/abs/1103.3320 where any term
t(even a type) can be elaborated to another termswhenevert ~c~> t'via regular a coercion pathc(even of length 0) andt' <~rc~ svia a reversible coercion pathrc. Reversible coercions are coercions that are also equipped with canonical inference. The elaboration is obtained by solving the unification problemc t ==?== rc ?s(t'isc t,rcis a canonical projection).As a result a function
ftaking a record argument (eg aneqType) can be passed a naked type (egnat) and be elaborated tof nat_eqType(in this casechas length 0,t'isnatalready). In the usual coercion jargon this isSortclass >-> eqTypewhich cannot be a type theoretic function (you can't match on inhabitants ofType), hence the unification and its hints are defining how this "coercion" is computed.In the presence of a hierarchy with a diamond (made of
leftrightbottomtop), a function can expect theleftstructure and be passed the an inhabitant of therightstructure, since that term can be directly coerced to thebottomstructure and enriched back (reverse coerced) to theleftone. We try to compute the pushout if it exists, that is, ifbottomhas a coercion to a simpler structurelower(bottominheritslower), we don't coerce tolowerand enrich back toleft(we try to lose as little information as possible via direct coercions).TODO:
(fun _ => the_new_term)MAYBE another PR:
(x : R) >-> S <~< Tto enrichxtoTlowering it down first toS.Overlays to be merged after the PR
Overlays to be merged before the PR
Overlays to be merged in sync with the PR
CC @CohenCyril @pi8027 @SkySkimmer