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

Quoting + erasure of primitive objects #527

Open
zoep opened this issue Dec 2, 2020 · 5 comments
Open

Quoting + erasure of primitive objects #527

zoep opened this issue Dec 2, 2020 · 5 comments

Comments

@zoep
Copy link

zoep commented Dec 2, 2020

It would be very useful to add support for primitive ints + floats in MetaCoq (so we can then realize such primitives in CertiCoq's backend). Are there any plans to do so?

@mattam82
Copy link
Member

mattam82 commented Dec 2, 2020

We have not looked at it deeply but it should mostly be a straightforward adaptation of Coq's handling of them. Note that we will need to have a way to translate the axiomatized definitions on the primitive types to something in CertiCoq. If you're eager to try we can certainly guide you a little :)

@zoep
Copy link
Author

zoep commented Dec 2, 2020

Hi Matthieu,

For CertiCoq, I'm working on adding support for extracting terms to specific C definitions (à la Extract Constant) and I think the same code can be used to handle compilation of primitive objects.

For MetaCoq, I don't think I'll get the time to try that soon. I might at some point if no one else wants to.

@mattam82
Copy link
Member

mattam82 commented Dec 3, 2020

Ok, we discussed this a bit today during a CUDW2020 working group, and we think ideally we'd like to support primitive types using their primitive representation in template-coq, but modify the translation to PCUIC to uses their models, to ensure correctness of axiomatisation (without introducing axioms in PCUIC). In the meantime, we can certainly hack some unsafe translation that keeps primitive objects untouched until LambdaBox. I'll give a try to this tomorrow.

@intoverflow
Copy link

@mattam82 Is this still open? I have time to work on this.

@mattam82
Copy link
Member

Hi @intoverflow, it's only somewhat open. We've added treatment of primitive objects to template-coq/pcuic/erasure already, so in erased terms you now get prim_model (https://github.com/MetaCoq/metacoq/blob/coq-8.11/pcuic/theories/PCUICPrimitive.v) values for primitive ints and floats. I think CertiCoq does not translate those yet.
They can be translated back to primitive values using:

Definition uint63_from_model (i : uint63_model) : Int63.int :=
  Int63.of_Z (proj1_sig i).

Definition float64_from_model (f : float64_model) : PrimFloat.float :=
  FloatOps.SF2Prim (proj1_sig f).

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

No branches or pull requests

3 participants