Skip to content

About

Compiling Agda's internal syntax to λ-box terms.

Resources

Stars

11 stars

Watchers

2 watching

Forks

Repository files navigation

agda2lambox

An Agda backend to generate MetaCoq λ□ (LambdaBox) programs for further verified extraction to WASM or Rust using the Peregrine tool. The backend builds off Agda 2.9.0.

To install the backend, setup GHC (tested with 9.10.1) and cabal.

git clone git@github.com:agda/agda2lambox.git
cd agda2lambox
cabal install
agda2lambox [AGDAFLAGS] [--out-dir DIR] [--typed] [--rocq] [--export-all] FILE

Only the definitions reachable from those marked with {-# COMPILE AGDA2LAMBOX f #-} get compiled; to extract a library instead, --export-all compiles the whole module.

Then, use the following tool to further compile the generated .ast files to WASM, C, LLVM, OCaml, CakeML, Rust, Koka, Lean and F#. With --rocq, the backend also generates a .v file that checks the well-formedness of the λ□ program and evaluates it in Rocq, and --typed generates typed λ□ instead (which Peregrine needs for Rust and typed Koka). See HACKING.md for an overview of the implementation.

Testing

The test modules live in test/agda2lambox, test/agda2rust and test/agda2hs; each defines an entry point test, marked with {-# COMPILE AGDA2LAMBOX test #-}, and states its expected value as _ : test ≡ v.

  • make test compiles every module to untyped and typed λ□ under test/dist/, and validates both with peregrine validate.
  • make gen compiles λ□ to every Peregrine target under test/gen/.
  • make run evaluates λ□ in Rocq, runs every target's output, and tallies the results in test/gen/stats.log.
  • make html renders the test modules and all of their outputs as a website under test/html/.

The last three are thin wrappers around test/targets.sh, which lists the tools each target needs. Evaluating λ□ in Rocq needs the Rocq, MetaRocq and CertiRocq versions that Peregrine is built with (c.f. the pinned commit in CI), as well as compiling the theories in theories/ with make coq.

References

About

Compiling Agda's internal syntax to λ-box terms.

Resources

Stars

11 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages