This is the Coq formalization of guarded interaction trees, associated examples and case studies.
To install the formalization you will need the Iris, std++, and Equations packages. The dependencies can be easily installed using Opam with the following commands:
opam repo add coq-released https://coq.inria.fr/opam/released
opam update
opam install . --deps-only
Then the formalization can be compiled with make and installed with
make install. You can pass the additional parameters to compile the
formalization using multiple cores, e.g. make -j 3 for compiling
using 3 threads.
All the code lives in the theories folder. Below is the quick guide
to the code structure.
gitree/-- contains the core definitions related to guarded interaction treesinput_lang/-- formalization of the language with io, the soundness and adequacyinput_lang_callcc/-- formalization of the language with io, throw and call/cc, the soundness and adequacyaffine_lang/-- formalization of the affine language, type safety of the language interoperabilityexamples/-- some other smaller exampleslang_generic.v-- generic facts about languages with binders and their interpretations, shared byinput_langandaffine_langlang_generic_sem.v-- generic facts about languages with a different representation of binders and their interpretations, used forinput_lang_callccprelude.v-- some stuff that is missing from Iris
- Section 3
- Definition of guarded interaction trees, constructors, the
recursion principle, and the destructors are in
gitree/core.v - Signtures for IO and higher-order store are in
examples/store.vandinput_lang/interp.v - The programming operations are in
gitree/lambda.vandexamples/while.v - The factorial example is in
examples/factorial.v, and the pairs example is inexamples/pairs.v
- Definition of guarded interaction trees, constructors, the
recursion principle, and the destructors are in
- Section 4
- The definition of context-dependent versions of reifiers and the reify function are in
gitree/reify.v - The reduction relation is in
gitree/reductions.v - The specific reifiers for IO and state are in
examples/store.vandinput_lang/interp.v
- The definition of context-dependent versions of reifiers and the reify function are in
- Section 5
- The syntax for λrec,io is in
input_lang/lang.v - The interpretation and the soundness proof are in
input_lang/interp.v
- The syntax for λrec,io is in
- Section 6
- The definition of the weakest precondition and the basic rules are
in
gitree/weakestpre.v - The additional weakest precondition rules are in
program_logic.vandexamples/store.v - The
iterexample is inexamples/iter.v
- The definition of the weakest precondition and the basic rules are
in
- Section 7
- The logical relation and the adequacy proof are in
input_lang/logrel.v
- The logical relation and the adequacy proof are in
- Section 8
- The notion of a subeffect is in
gitree/core.v - The notion of a subreifier and the associated definitions are in
gitree/greifiers.v - The
fact_ioexample is inexamples/factorial.v
- The notion of a subeffect is in
- Section 9
- The syntax for λ⊸,ref is in
affine_lang/lang.v - The logical relations for the type safety of λ⊸,ref and λrec,io
are in
affine_lang/logrel1.vandinput_lang/logpred.v - The logical relation for the combined language is in
affine_lang/logrel2.v
- The syntax for λ⊸,ref is in
For the representation of languages with binders, we follow the
approach of (Benton, Hur, Kennedy, McBride, JAR 2012) with well-scoped
terms and substitutions/renamings. (input_lang, affine_lang)
For input_lang_callcc we use a binder library, implemented by Filip
Sieczkowski and Piotr Polesiuk.
Some results in the formalization make use of the disjunction property of Iris: if (P ∨ Q) is provable, then either P or Q are provable on their own. This propery is used to show safety of the weakest precondition, and it is related to the difference between internal and external reductions.
The internal reductions of GITrees is the relation istep, as defined
in the paper, and it has type iProp as it is an internal relatin.
There is also a similar external reduction relation sstep which
lives in Coq's Prop. We use the istep relation in our definitions
(since it is an internal relation), but we want to state the safety
result w.r.t. the external relation sstep, which we take to be the
'proper definition' of the reductions for GITrees.
Showing that istep-safety implies sstep-safety (i.e. that if a
GITree can do an istep then it can also do a sstep) requires the
disjunction propety. The disjunction property for Iris can be shown
assuming classical axioms (e.g. LEM) on the Prop-level.
In order not to introduce classical axioms into the whole
formalization, we added the disjunction propety as an assumption to
the safety theorem (wp_safety) and all of its instances (e.g. in
logical relations).
One other difference with the paper worth mentioning, is that in the
formalization we "hardcode" the type Err of errors, whereas in the
paper we leave it parameterized. That is why in the affine_lang case
study we use OtherError to represent linearity violations, instead
of Err(Lin).