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

Add PCUIC versions of tmQuote and related template monad definitions #776

Merged
merged 7 commits into from
Jan 3, 2023

Conversation

JasonGross
Copy link
Contributor

On top of #774

This will allow easier creation of developments that reason about doubly-quoted terms and judgments. (In particular, I'm trying to prove Löb's theorem.)

This PR should compile, and I think it's basically ready, but I'm not terribly happy with the names, and it currently uses a hack to get a fixpoint combinator in the template monad. Please suggest better names, better organization, better implementations, etc.

Note that I needed Local Unset Universe Minimization ToSet. in a couple places to avoid universe inconsistencies.

@JasonGross JasonGross force-pushed the coq-8.16+template-trans branch from 3723202 to 36d10a1 Compare October 21, 2022 17:19
@TheoWinterhalter
Copy link
Member

I'm not sure I understand the goal of having the template monad in PCUIC. PCUIC does not have a runtime so what is it supposed to be?

To my mind, PCUIC should be plainly about the theory / specification, and Template should be about the implementation. In that respect, having the type checker in PCUIC is wrong but well…

@JasonGross
Copy link
Contributor Author

I guess calling it "a PCUIC version of the template monad" is perhaps a bit misleading or over-general; the thing I actually need here is "a PCUIC version of tmQuote".

I have written a Gallina function quote : Template.Ast.term -> Template.Ast.term whose behavior on ground terms is the same as the tactic quote_term. Judicious use of automation means that it only took 100 loc. I now want to prove that this function generates only well-typed terms, and in particular that it takes quoted sorts to doubly-quoted sorts, takes types to doubly-quoted types, and takes terms to well-typed doubly-quoted terms of the doubly-quoted type (at least in the empty context). As I understand it, typing judgments exist only on PCUICAst.term (is this right?), so I need a Gallina function quote that adds a layer of quotation for these ASTs (and typing judgments). In writing these functions, it's convenient to be able to bypass the template AST entirely and have quotation tactics that deal only with PCUIC, because that makes writing automation to build the quoter simpler.

Said another way, I'm trying to prove Löb's theorem about the theory. This is a lot nicer if I can leverage notations and tactics to to quotation for me rather than having to do it all by hand.

@JasonGross JasonGross changed the title Add PCUIC versions of the template monad Add PCUIC versions of tmQuote and related template monad definitions Oct 22, 2022
@TheoWinterhalter
Copy link
Member

Well, typing also exists for Template: https://github.com/MetaCoq/metacoq/blob/coq-8.16/template-coq/theories/Typing.v#L741 and the translations between Template and PCUIC are both shown to be type preserving I think.

@JasonGross
Copy link
Contributor Author

Ah, neat, thank you! How much of the theory is present for typing derivations in Template? (Is there a fueled axiom-free reflective typechecker for typing deriviations, for example?)

@JasonGross JasonGross force-pushed the coq-8.16+template-trans branch 2 times, most recently from e01490c to 5e202e8 Compare November 3, 2022 18:04
@JasonGross JasonGross mentioned this pull request Nov 3, 2022
@JasonGross JasonGross force-pushed the coq-8.16+template-trans branch from 1481cac to 71a4cc0 Compare November 4, 2022 18:10
@mattam82
Copy link
Member

I guess once we get the trailing whitespace one we can revisit this. Having a monad that works on the PCUIC presentation does not sound bad to me, it's a lot easier to program in Coq on PCUIC terms without having to worry about well-formendness than on "template" ones.

@JasonGross JasonGross force-pushed the coq-8.16+template-trans branch from 71a4cc0 to a3238c7 Compare November 21, 2022 17:20
@JasonGross JasonGross force-pushed the coq-8.16+template-trans branch 4 times, most recently from f3a8649 to e42648c Compare November 22, 2022 00:24
@JasonGross
Copy link
Contributor Author

I guess once we get the trailing whitespace one we can revisit this.

Trailing whitespace has been merged, and I've rebased this. Still on top of #790 and #789, but it should be reviewable now.

@JasonGross JasonGross force-pushed the coq-8.16+template-trans branch 3 times, most recently from 1c04a7e to a6bb058 Compare November 22, 2022 03:17
@mattam82
Copy link
Member

Let's have #789 and #790 first

This will allow easier creation of developments that reason about
doubly-quoted terms and judgments.
@JasonGross JasonGross force-pushed the coq-8.16+template-trans branch 2 times, most recently from 454e942 to 651aa9f Compare December 15, 2022 17:13
The updated version of MetaCoq#789 managed to define
`trans_mutual_inductive_entry`
@JasonGross
Copy link
Contributor Author

Dependencies have been merged, this should finally be ready for review and hopefully merging. I've added some tests to the test-suite as well.

@mattam82 mattam82 merged commit 0535106 into MetaCoq:coq-8.16 Jan 3, 2023
@mattam82
Copy link
Member

mattam82 commented Jan 3, 2023

LGTM !

@JasonGross JasonGross deleted the coq-8.16+template-trans branch January 3, 2023 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants