Exporting ocaml from imandra

After verifying our code with Imandra, Imandra allows to export the verified code to native OCaml for better performance and easier deployment. Note that the extracted OCaml code uses arbitrary precision integers instead of floats, it retains exactly the same semantics as Imandra’s language.

For extracting OCaml code, we can use imandra-extract file_name.iml > file_name.ml on each file, but for multi-file development it is easier to set up a dune project.

Dune project setup

Directory structure:

project-root
|-- dune-project
|-- src/
	|-- lib1/
		|-- dune
		|-- lib1.iml
	|-- lib2/
		|-- dune
		|-- lib2.iml
	|-- executable/
		|-- dune
		|-- main.iml

cf. FIX engine repo

Content of dune-project:

(lang dune 2.2)
(name imandra-marabou-proof-checker)

  
(dialect
	(name imandra)
	(implementation
		(extension iml)
		(preprocess (system "imandra-extract %{input-file}"))
	(format (system "ocamlformat %{input-file}")))
	(interface (extension "imli")))

We use a dialect stanza to apply imandra-extract to all iml files.

Example content of a dune file for an executable:

(executable
	(name main)
	(flags :standard -open Imandra_prelude -warn-error -A+8+39 -w -33-58)
	(libraries decoders-yojson decoders yojson imandra-prelude))

Relative Imports

There are no notes linking to this note.

There are no papers linking to this note.


Here are all the notes in this garden, along with their links, visualized as a graph.

Adversarial perturbation to...Can we (and should we)...Certified compilers and proof...Constructive logicCurry Howard correspondenceDuelling banjos drama in the...Equivalence checkingExporting ocaml from imandraHalf marathon afterthoughtsHow to set up a plausible...How to make a sunrise alarm...How to make a sunrise alarm...How to make a sunrise alarm...Jupyter notebook launch...Lairg to john'o'groats bike...Marabou Imandra interfacingMarkov process modelMethodologyMonte carlo processNeural network verification ...Ocaml decoder libraryProof production for neural...Reading listType theory with agdaUbuntu housekeepingUseful imandra tipsUseful git commandsUseful vim tips and tricksUsefull miscellaneous snippetsVerifying an algorithm with...On the Dangers of Stochastic...Intuitionistic Type TheorySpinoza on ModalityAttention is All you NeedFormal Monotony Analysis...