# GRATchk complete distribution

Distribution of GRATchk with complete Isabelle/HOL formalization.

## Prerequisites
  * Working installation of [Isabelle/HOL](https://isabelle.in.tum.de) with the [Archive of Formal Proofs](https://www.isa-afp.org) installed 
    as described [here](https://www.isa-afp.org/using.shtml). We require version = Isabelle-2018, which, at the time of writing, is the current version.
  * To compile the actual executable GRATchk: An [MLton](http://mlton.org/) compiler version >= 20100608.

## Building
  Run 
      isabelle build -D.
  This will invoke Isabelle to check all proofs and re-generate the exported code, which is written to <code>code/gratchk_export.sml</code>

  Moreover, the proof document and proof outline will be regenerated.

  In order to generate the gratchk executable, change to the <code>code/</code> folder and run <code>make</code> there. See also the [code/README.md](code/README.md) file.

## Inspecting the Proof
  The best way to inspect the proof is to load it into the Isabelle IDE. In this directory, type
      isabelle jedit -d . -l Sepref_IICF Grat_Check_Code_Exporter.thy
  On the first invocation of this command, a base image with the required libraries is built, which may take several minutes.
  When invoked, the IDE will display the last theory of the formal development, where the exported code is generated, and 
  a self-contained correctness theorem down to the integer sequence representing a formula is proved. 
  Moreover, the IDE will start to verify all dependent theories. If verification is finished (may take another few minutes), 
  you can use the navigation features of the IDE to navigate the formalization and inspect the proof state.
 
  ### Proof document
  For a quick inspection of the theories, you may use the [proof outline](output/outline.pdf) and [proof document](output/document.pdf) pdf files generated by Isabelle. 
  We have included them in the distribution, such that no prior checking of the proof is required.
