Interactions Trees (ITrees) are coinductive structures used to represent interactions between a system and its environment in the style of a process algebra.
This repository contains a mechanisation of ITrees in Isabelle/HOL, for the purpose of verifying reactive systems and generating code for animation purposes.
You can find a number of examples under examples/
, and in particular the Haskell code can be executed in GHCi for animation purposes.
RoboChart theories and examples are under RoboChart
and RoboChart/examples
. There are also instructions and documents inside the folder. The latest development of RoboChart related theories is in the branch robochart_nondeterminism_resolving.
The theories have been developed in Isabelle2021-1. This instruction is based on Ubuntu/Linux. It would be similar on other operation systems.
Steps:
- Install GHC for Haskell, see here for details,
- Clone this repository, and
- use Isabelle/UTP distributions with prebuild heap images on Linux or Standard procedure to install Isabelle/HOL.
The prebuilt version comes with a patched Isabelle/HOL to have a console for animation, which is more convenient.
- Clone and enter the folder of this probabilistic relations
/path/to/yourfolder $ git clone https://github.com/isabelle-utp/interaction-trees.git
/path/to/yourfolder $ cd interaction-trees
We use /path/to/interaction-trees/
to denote the path to this particular directory.
- Download Isabelle/UTP distributions from here and choose
Isabelle2021-1 on Linux (January 26th 2023)
, it isIsabelle2021-1-CyPhyAssure-20230126.tar.bz2
in this case - Uncompress it inside a folder, such as "/path/to/yourfolder":
/path/to/yourfolder $ tar -xvjf Isabelle2021-1-CyPhyAssure-20230126.tar.bz2
/path/to/yourfolder $ cd Isabelle2021-1-CyPhyAssure/
- Launch Isabelle/UTP with session
ITree_VCG
/path/to/yourfolder/Isabelle2021-1-CyPhyAssure/ $ ./bin/isabelle jedit -l ITree_VCG
- Download Isabelle2021-1_linux.tar.gz from here.
- Uncompress it inside a folder, such as "/path/to/yourfolder":
/path/to/yourfolder $ tar zxvf Isabelle2021-1_linux.tar.gz
- Clone CyPhyAssure meta-repository (which is updated periodically to sync and try to keep in a stable state) from here and checkout all submodules
/path/to/yourfolder $ git clone https://github.com/isabelle-utp/CyPhyAssure.git
/path/to/yourfolder $ cd CyPhyAssure
/path/to/yourfolder/CyPhyAssure (main) $ git submodule update --init --recursive
- Launch Isabelle/UTP with session
ITree_VCG
/path/to/yourfolder $ ./Isabelle2021-1/bin/isabelle jedit -d CyPhyAssure -l ITree_VCG
With the prebuild version, animation would be simpler.
Load the theory for animation, then move your cursor to a line starting with animate
, such as animate D_PatrolMod_p_sim
to animate a definition D_PatrolMod_p_sim
. When the cursor stops there, code generator starts to generate Haskell code, and compile. Usually, we will see below on the Output
window.
See theory exports
Compiling animation...
See theory exports
Start animation
Then click Start animation
.
General steps are shown below. Please see instructions in each specific example for further considerations.
- Open the main theory file for a model
- Go to a line starting with command export_code, which exports generated Haskell code.
- Click the
Output
window and you will see See theory exports, then double click the area theory exports, and now the exported code will be displayed onFile Browser
. UseFile Browser
to copy the generated files to the local physical file system, such as/path/to/simulation
. - Go to a line starting with command export_generated_files, which exports two raw Haskell files
simulation.hs
andmain.hs
. - Click the
Output
window and you will see See theory exports, then double click the area theory exports, and now the two exported files will be displayed onFile Browser
. UseFile Browser
to copy the generated files to the local physical file system/path/to/simulation
. - Open a terminal and cd to
/path/to/simulation
.
$ cd /path/to/simulation
- Use GHCi for animation and load the
main.hs
, then runmain
.
$ ghci main.hs
*Main> main
- Or use GHC to compile generated code, then run executable.
$ ghc -g main.hs
$ ./main