1
1
mirror of https://github.com/anoma/juvix.git synced 2024-12-03 09:41:10 +03:00
juvix/test
Łukasz Czajka 83837b9c5f
Translate function bodies to Isabelle/HOL (#2868)
* Closes #2813 

Implements a translation from Juvix functions to Isabelle/HOL functions.
This extends the previous Juvix -> Isabelle translation which could
handle only type signatures.

Checklist
---------

- [x] Basic translation
- [x] Polymorphism
- [x] Arithmetic operators
- [x] Numeric literals
- [x] List literals
- [x] Comparison operators
- [x] Boolean operators
- [x] `if` translated to Isabelle `if`
- [x] `true` and `false` translated to Isabelle `True` and `False`
- [x] `zero` and `suc` translated to Isabelle `0` and `Suc`
- [x] `Maybe` translated to Isabelle `option`
- [x] Pairs translated to Isabelle tuples
- [x] Quote Isabelle identifier names (e.g. cannot begin with `_`)
- [x] Rename variables to avoid clashes (in Isabelle/HOL pattern
variables don't shadow function identifiers)
- [x] Common stdlib functions (`map`, `filter`, etc) translated to
corresponding Isabelle functions
- [x] Multiple assignments in a single `let`
- [x] CLI
- [x] Test
- The test is very fragile, similar to the markdown test. It just
compares the result of translation to Isabelle against a predefined
expected output file.

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:
* Higher-rank polymorphism or functions on types cannot be translated as
these features are not supported by Isabelle/HOL. Juvix programs using
these features will not be correctly translated (the generated output
may need manual adjustment).
* In cases where Juvix termination checking diverges from Isabelle/HOL
termination checking, providing a termination proof manually may be
necessary. Non-terminating Juvix functions cannot be automatically
translated and need to be manually modelled in Isabelle/HOL in a
different way (e.g. as relations).
* Comments (including judoc) are ignored. This is left for future work.
* Traits are not translated to Isabelle/HOL type classes / locales. This
is left for future work.
* Mutually recursive functions are not correctly translated. This is
left for future work.
* Record creation, update, field access and pattern matching are not
correctly translated. This is left for future work.
* Named patterns are not correctly translated. This is left for future
work.
* Side conditions in patterns are not supported. This is left for future
work.
* If a Juvix function in the translated module has the same name as some
function from the Isabelle/HOL standard library, there will be a name
clash in the generated code.

---------

Co-authored-by: Paul Cadman <git@paulcadman.dev>
2024-07-19 08:40:07 +01:00
..
Anoma Support Anoma representation of Maybe (#2856) 2024-06-26 12:39:36 +01:00
Asm Refactor pipeline functions for tests (#2864) 2024-06-28 12:15:51 +02:00
BackendMarkdown Improve performance of formatting a project (#2863) 2024-07-01 18:05:24 +02:00
Casm Add precondition to run tests (#2887) 2024-07-15 10:02:48 +02:00
Compilation Refactor pipeline functions for tests (#2864) 2024-06-28 12:15:51 +02:00
Core Adapt Anoma builtins to new Anoma Node API (#2861) 2024-07-01 18:44:02 +01:00
Examples Run test suite in parallel (#2507) 2023-11-16 16:19:52 +01:00
Formatter Improve performance of formatting a project (#2863) 2024-07-01 18:05:24 +02:00
Internal Bugfix: modules associated with inductive types should be declared after their inductive types (#2768) 2024-05-14 19:32:22 +02:00
Isabelle Translate function bodies to Isabelle/HOL (#2868) 2024-07-19 08:40:07 +01:00
Nockma Refactor pipeline functions for tests (#2864) 2024-06-28 12:15:51 +02:00
Package Parallel pipeline (#2779) 2024-05-31 12:41:30 +01:00
Parsing Fix typos (#2573) 2024-01-08 13:27:18 +01:00
Reg Dead code elimination in JuvixReg (#2835) 2024-06-24 13:56:50 +02:00
Repl Improve performance of formatting a project (#2863) 2024-07-01 18:05:24 +02:00
Resolver Fix typos (#2573) 2024-01-08 13:27:18 +01:00
Runtime Rust backend (#2787) 2024-05-29 13:34:04 +02:00
Rust Add precondition to run tests (#2887) 2024-07-15 10:02:48 +02:00
Scope Puns for named application (#2890) 2024-07-16 12:23:22 +02:00
Termination Fix typos (#2573) 2024-01-08 13:27:18 +01:00
Tree Adapt Anoma builtins to new Anoma Node API (#2861) 2024-07-01 18:44:02 +01:00
Typecheck Fixes crash when trying to normalize case expression (#2811) 2024-06-07 15:43:50 +02:00
VampIR Add precondition to run tests (#2887) 2024-07-15 10:02:48 +02:00
Anoma.hs Support compilation to Anoma compatible functions (#2652) 2024-02-23 12:54:22 +00:00
Asm.hs Translation from JuvixAsm to C (#1619) 2022-12-06 11:33:20 +01:00
BackendMarkdown.hs Add MarkdownInfo entry in Module Concrete Decl and proper errors (#2515) 2023-11-16 11:20:34 +01:00
Base.hs Add precondition to run tests (#2887) 2024-07-15 10:02:48 +02:00
Casm.hs Add precondition to run tests (#2887) 2024-07-15 10:02:48 +02:00
Compilation.hs Remove old typechecker (#2545) 2023-12-01 16:50:37 +01:00
Core.hs Implement core transformation let-hoisting (#2076) 2023-05-16 13:42:44 +02:00
Examples.hs Add a test suite for milestone examples (#1920) 2023-03-24 13:16:26 +00:00
Format.hs Improve performance of formatting a project (#2863) 2024-07-01 18:05:24 +02:00
Formatter.hs Add juvix format command (#1886) 2023-03-29 15:51:04 +02:00
Internal.hs Add translation from Internal to Core (#1567) 2022-11-07 14:47:56 +01:00
Isabelle.hs Translate function bodies to Isabelle/HOL (#2868) 2024-07-19 08:40:07 +01:00
Main.hs Translate function bodies to Isabelle/HOL (#2868) 2024-07-19 08:40:07 +01:00
Nockma.hs Nockma compile (#2570) 2024-01-17 11:15:38 +01:00
Package.hs Use JuvixError instead of Text for errors in Package file loading (#2459) 2023-10-23 19:01:36 +01:00
Parsing.hs Disallow tab characters as spaces (#1523) 2022-09-07 13:59:41 +02:00
Reg.hs JuvixReg recursors (#2641) 2024-02-19 08:58:19 +00:00
Repl.hs Update REPL artifacts with builtins from stored modules (#2639) 2024-02-26 16:19:04 +00:00
Resolver.hs Per-module compilation (#2468) 2023-12-30 20:15:35 +01:00
Runtime.hs Juvix C runtime (#1580) 2022-11-03 09:38:09 +01:00
Rust.hs Add precondition to run tests (#2887) 2024-07-15 10:02:48 +02:00
Scope.hs [ CI ] New jobs: ormolu and hlint 2022-04-05 19:57:21 +02:00
Termination.hs Add the termination checker to the pipeline (#111) 2022-05-30 13:40:52 +02:00
Tree.hs JuvixTree recursors and transformation framework (#2594) 2024-01-29 16:43:08 +00:00
Typecheck.hs Remove old typechecker (#2545) 2023-12-01 16:50:37 +01:00
VampIR.hs Add precondition to run tests (#2887) 2024-07-15 10:02:48 +02:00