-
Notifications
You must be signed in to change notification settings - Fork 57
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
Translate function bodies to Isabelle/HOL #2868
Conversation
79d5d11
to
a315307
Compare
Co-authored-by: Paul Cadman <[email protected]>
As I didn't see any task in the CI that could check the test, I did it myself and can tell that the output for tests/positive/Isabelle/isabelle/Program.juvix typechecks with Isabelle2023 yey. Please add Isabelle to the CI for macOSX; you probably want to use something like this. On the other hand, I tested this translation with some examples from the Specs we are writing. I noticed that many fragments (using literals) now have a well-formed Isabelle term that they didn't have before, that's good. However, many examples are still not supported in the translation. So, even when I'm not asking to solve them in this PR, unless you want, let me mention some issues I find crucial.
Or something like this, and the output
|
We don't currently run the MacOS CI, because it doesn't work with RISC0. Let's defer adding Isabelle to the Linux CI for later, because I don't know how to reliably install Isabelle as a single command on Linux. |
I don't understand what's the problem with axioms. Axiom translation is supported. The above axiom is translated to:
|
But "!undefined" is not a valid Isabelle identifier name. I think it needs to begin with a letter. I'll improve the quoting. |
How do you want this to be translated, in principle? There is no |
I improved the quoting |
I added basic support for imports. All imports are now translated in the way you mentioned to Isabelle/HOL imports, except imports from |
Perhaps this could be simulated with locales somehow, but this needs more fundamental work. |
:) Let's merge this. And, yes, I tested the last changes you made. As a next step, we could start working on supporting comments, mutually recursive functions and type syn. definitions that use further defined other types, such as
And yes, record manipulation. Of course, the rest you mentioned in the PR description would be nice to have. |
* Adds pragmas and builtins needed for the translation to Isabelle/HOL. * Depends on anoma/juvix#2868
Implements a translation from Juvix functions to Isabelle/HOL functions. This extends the previous Juvix -> Isabelle translation which could handle only type signatures.
Checklist
if
translated to Isabelleif
true
andfalse
translated to IsabelleTrue
andFalse
zero
andsuc
translated to Isabelle0
andSuc
Maybe
translated to Isabelleoption
_
)map
,filter
, etc) translated to corresponding Isabelle functionslet
Limitations
The translation is not designed to be completely correct under all circumstances. There are aspects of the Juvix language that cannot be straightforwardly translated to Isabelle/HOL, and these are not planned to ever be properly handled. There are other aspects that are difficult but not impossible to translate, and these are left for future work. Occasionally, the generated code may need manual adjustments to type-check in Isabelle/HOL.
In particular: