GithubHelp home page GithubHelp logo

isabelle-utp / utp-main Goto Github PK

View Code? Open in Web Editor NEW
34.0 13.0 9.0 159.07 MB

An implementation of Hoare and He's Unifying Theories of Programming in Isabelle

License: Other

Isabelle 84.26% TeX 11.81% Standard ML 1.74% Shell 0.18% OCaml 0.04% Makefile 0.07% C++ 0.57% C 0.24% Python 1.08%
isabelle utp theory unifying-theories hol

utp-main's Introduction

Isabelle/UTP

This is a semantic embedding of Hoare and He's Unifying Theories of Programming (UTP) in the Isabelle/HOL proof assistant. We base this particular implementation on the shallow embedding first created by Feliachi, Gaudel, and Wolff (2010), but we also integrates a number of ideas from the alternative deep model of the UTP in Isabelle by Foster, Zeyda, and Woodcock (2015). In particular we recast variables to characterised by lenses (see Foster, Zeyda, and Woodcock (2016)), and add semantic approximations of syntactic notions like fresh variables (unrestriction) and substitution, and also add a form of "deep variables" that provides a more flexible form of alphabet extension (whilst being subject to certain cardinality constraints).

Isabelle/UTP is very much still a work in progress, and currently requires some Isabelle expertise to use effectively. For viewing the git repository I highly recommend the Matisa plugin by York colleague Pedro Ribeiro which allows Isabelle symbols to be pretty-printed in the browser and can be obtained from the Google Chrome store or Firefox Add-ons.

Installation

Isabelle/UTP currently works on Isabelle2021-1.

First, you need to install the Archive of Formal Proofs (AFP) archive by following the instructions on https://www.isa-afp.org/using.html. The AFP has an older and incompatible version of Isabelle/UTP, which needs to be removed. You can do this by editing the file afp/thys/ROOTS and removing the line with "UTP" on it, but otherwise leaving the file unchanged.

Second, you need to install Z_Toolkit from https://github.com/isabelle-utp/Z_Toolkit and Total_Recall from https://github.com/isabelle-utp/Total_Recall. You can do this by cloning the repositories, or downloading a snaphot, extracting the archive, and then editing your main Isabelle ROOTS file to include the location of Z_Toolkit and Total_Recall.

Finally, you can clone the Isabelle/UTP repository. You can then either add this directory to your ROOTS file, or start Isabelle using the command isabelle jedit -d. from the UTP installation directory.

Repository overview

The core UTP Isabelle theories are located under the utp/ directory. In particular, this contains the following key UTP theories:

Additionally, under the theories/ directory a number of UTP theories that we have developed can be found, including:

Various heap images exist including:

  • UTP - the core UTP components
  • UTP-Designs - imperative programs with total correctness
  • UTP-Reactive - UTP theory of Generalised Reactive Processes
  • UTP-Reactive-Designs - Reactive Designs
  • UTP-Circus - Circus modelling language
  • UTP-Hybrid - hybrid relational calculus

This repository is constantly a work in progress, so not all laws have yet been proved, though the number is constantly growing. Additionally to the UTP theories there is a number of contributed UTP theories included under the contrib/ directory. Notably this includes an adapted version of Armstrong and Struth's Kleene Algebra library, which is a dependency and thus is included for convenience.

Under the vdm/ directory a prototype implementation of VDM-SL, as an embedding into the theory of designs, may be found. Moreover, under hybrid/ a mechanisation of our hybrid relational calculus can be found which enables us to give denotational semantics to hybrid systems languages like Modelica and Simulink.

Usage

Isabelle/UTP is documented by a number of tutorial theories under the tutorial/ directory. First and foremost it is worth checking the UTP tutorial theory which attempts to give an overview of the UTP in Isabelle. You can view the associated PDF of the tutorial as well. You can also check out Boyle's law for a very basic UTP theory. An example of usage of the theory of designs for proving properties about programs can be found in the library example. You can also check out the proof document. We also provide some preliminary usage notes below.

Parser

As for the former deep model we make every effort to preserve the standard UTP syntax as presented in the UTP book and other publications. Unlike the deep model of UTP we do not employ a backtick parser, but rather use the top-level Isabelle expression grammar for UTP expressions. This achieved, firstly by (adhoc) overloading operators where possible. For example we overload the HOL predicate operators (like conjunction, negation etc.) with UTP versions. This means that we have to use the type system of Isabelle to disambiguate expressions, and so sometimes type annotations are required (though not often). Where it is not possible or feasible to override we instead use the UTP operator with a u subscript. For example, it does not seem sensible to override the HOL equality operator as this would compromise the elegance of Isar for equational proofs, and so we call it =_u. Incidentally subscripts in Isabelle can be written using the \<^sub> code. In general where an operator is polymorphic (e.g. arithmetic operators) we just use standard syntax. See the UTP expression theory for more examples.

Variables are a potential source of confusion. There are three main syntaxes for variables in UTP predicates:

  • &x -- a variable in a non-relational predicate
  • $x -- an input variable in a relational predicate
  • $x\<^acute> -- an output variable in a relational predicate

The reason we have to have three is to do with the type system of Isabelle -- since alphabets are types, a relation has a different type to a flat predicate and so variables in these constructions also have different types.

For more details of the Isabelle/UTP grammar please see the syntax reference document.

Proof support

We employ a number of proof tactics for UTP:

  • pred_auto -- for predicate conjectures
  • rel_auto -- for relational conjectures
  • subst_tac -- apply substitution laws in a predicate

There is actually little difference between the predicate and relational tactic; if one doesn't work try the other. When you define your own operators you need to add them to the tactic's simplification set(s) in order for the tactic to correct simplify the construct. You can do this for example by writing something like:

declare my_op_def [upred_defs]

The simplification sets corresponding to the tactics are, respectively:

  • upred_defs
  • urel_defs
  • usubst

We've also loaded a number of equational laws into the simplifier, so try simp out if it seems the obvious thing to do, or maybe even auto. Additionally there is always sledgehammer available which often works well when suitable algebraic laws have been proven (see http://isabelle.in.tum.de/dist/doc/sledgehammer.pdf). You can also try to combine sledgehammer with a UTP tactic. Probably more tactics will be written and the existing ones will continue to improve.

Have fun!

References

  • C. A. R. Hoare and He Jifeng. Unifying Theories of Programming. Prentice Hall 1998. http://unifyingtheories.org/
  • Simon Foster, Frank Zeyda, and Jim Woodcock. Unifying Heterogeneous State-Spaces with Lenses. Proc. 13th Intl. Colloquium on Theoretical Aspects of Computing (ICTAC 2016). Paper link
  • Frank Zeyda, Simon Foster, and Leo Freitas. An Axiomatic Value Model for Isabelle/UTP. Proc. 6th Intl. UTP Symposium, 2016. Paper link
  • Simon Foster and Jim Woodcock. Towards Verification of Cyber-Physical Systems with UTP and Isabelle/HOL. In Concurrency, Security, and Puzzles, January 2017. Paper link
  • Abderrahmane Feliachi, Marie-Claude Gaudel, and Burkhart Wolff. Unifying Theories in Isabelle/HOL. Proc. 3rd Intl. UTP Symposium, 2010. Paper link
  • Simon Foster, Frank Zeyda, and Jim Woodcock. Isabelle/UTP: A Mechanised Theory Engineering Framework. Proc. 5th Intl. UTP Symposium, 2014. [Paper link]http://link.springer.com/chapter/10.1007%2F978-3-319-14806-9_2

utp-main's People

Contributors

pefribeiro avatar simondfoster avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

utp-main's Issues

Use of readlink in bin/build.sh not portable to BSD/OSX.

Just getting my isabelle-utp installation up to date with the 2017 version of Isabelle.

I really like the build script, but I've found a minor issue which may be worth having in mind in the future:readlink -f is not portable to BSD/OSX-land. Not sure what else to suggest given the difficulty of emulating this. An alternative is to install the GNU version of readlink.

ISABELLE_UTP=${ISABELLE_UTP:-$(readlink -f $(dirname $0))/..}

Instead, I set export ISABELLE_UTP=`pwd` from my clone folder of the repo and then ran the bin/build.sh file just fine.

Build problem with KAT_and_DRA/ROOT

Running into this problem using Isabelle2019

./bin/build.sh
Checking and obtaining Isabelle/UTP AFP dependencies... 
...
AFP entry Show is already installed.
AFP entry Transformer_Semantics is already installed.
AFP entry Triangle is already installed.
AFP entry Trie is already installed.

Building Isabelle/UTP sessions... 

*** [line 4 of "/home/logan_rj/Isabelle2019/src/utp-main-master/contrib/KAT_and_DRA/ROOT"] error: bad input
*** 
*** 
*** ^

Root structure not compatible with Isabelle2020

When running bin/build.sh with Isabelle2020 it errors with message:

*** Duplicate use of directory "/home/chris/Documents/UTP/utp/models"
***   for session "UTP-Axm" (line 187 of "/home/chris/Documents/UTP/ROOT")
***   vs. session "UTP-Deep" (line 179 of "/home/chris/Documents/UTP/ROOT")

I believe this is because of a change that disallows sharing of directories between sessions. From the NEWS page on the Isabelle website:

  • Session ROOT files need to specify explicit 'directories' for import
    of theory files. Directories cannot be shared by different sessions.
    (Recall that import of theories from other sessions works via
    session-qualified theory names, together with suitable 'sessions'
    declarations in the ROOT.)

Error when building UTP theories

When building the UTP theories with isabelle jedit -d path/utp-main/ -l UTP
I get the following error:

UTP FAILED
(see also C:\Users\ctha.isabelle\Isabelle2016\heaps\polyml-5.6_x86-windows\log\UTP)


***                                                   

*** l.1 \BOOKMARK [1][-]{section.1}{UTP variables}{}

***                                                 % 1

*** !  ==> Fatal error occurred, no output PDF file produced!

*** Transcript written on root.log.

*** Document preparation failure in directory 'output/document'
*** 
*** Failed to build document "/cygdrive/c/source/isabelle/utp-main/utp/output/document.pdf"
*** Undefined fact: "list_minus_anhil" (line 349 of "/cygdrive/c/source/isabelle/utp-main/utp/utp_csp.thy")
*** At command "using" (line 349 of "/cygdrive/c/source/isabelle/utp-main/utp/utp_csp.thy")
*** Undefined fact: "list_minus_anhil" (line 367 of "/cygdrive/c/source/isabelle/utp-main/utp/utp_csp.thy")
*** At command "apply" (line 367 of "/cygdrive/c/source/isabelle/utp-main/utp/utp_csp.thy")
*** Undefined fact: "list_minus_anhil" (line 301 of "/cygdrive/c/source/isabelle/utp-main/utp/utp_csp.thy")
*** At command "using" (line 301 of "/cygdrive/c/source/isabelle/utp-main/utp/utp_csp.thy")
Unfinished session(s): UTP
Return code: 2

Session build failed -- prover process remains inactive!

It seems to be related to this commit: fdf555e

Map numeral representation to VDM expressions

The error you've got is very unhelpful - it means that we have not instantiated the "numeral" type class which allows you to map numeral representations (e.g. 1,3,5,808) to a given type, in this case VDM expressions. Actually that class should be instantiated the same way that the UTP expression equivalent is

Enhancement: Build with Isabelle 2016-1

Not an issue, but an enhancement:

I just tried out the new Isabelle 2016-1 and tried to load UTP using:
isabelle jedit -d path/utp-main/ -l UTP

It fails with the following:
"Bad parent session "HOL-Multivariate_Analysis" for "Kleene_Algebra" (line 1 of "../source/isabelle/utp-main/ROOT")"

UTP-IMPORTS fails to build on shallow

Most of the time I've been using the Kleene_Algebra heap image. But due to the sheer amount of .thy files it loads (not all are relevant to what I'm doing) I switched to UTP-IMPORTS. This however doesn't seem to complete the build on my machine, though.

UTP-IMPORTS FAILED
(see also /Users/wv8579/.isabelle/Isabelle2015/heaps/polyml-5.5.2_x86-darwin/log/UTP-IMPORTS)

infinite ?S = (EX f. inj f & range f <= ?S)
inj_on ?f ?A ==> card (?f ` ?A) = card ?A
[| ?P 0; !!n. ?P n ==> ?P (2 * n); !!n. ?P n ==> ?P (Suc (2 * n)) |]
==> ?P ?n
"binseq"
:: "(nat => bit) => nat => real"
rbseq ?x = (%i. of_int (floor (?x * 2 ^ (i + 1)) mod 2))
"bij_betw"
:: "('a => 'b) => 'a set => 'b set => bool"
[| xs' ~= ?ys; length xs' = length ?ys |]
==> EX k<length xs'. (ALL i<k. xs' ! i = ?ys ! i) & xs' ! k ~= ?ys ! k
x # xs' = ys
length (x # xs') = length ys
"bin_real"
:: "(nat => bit) => real"
"BitSeqs"
:: "(nat => bit) set"
[| bij_betw ?f ?A ?B; bij_betw ?g ?B ?C |] ==> bij_betw (?g o ?f) ?A ?C
*** SMT: Solver "z3": Timed out (setting the configuration option "smt_timeout" might help)
*** At command "by" (line 216 of "
/git/utp-main/utils/Real_Bit.thy")
Unfinished session(s): UTP-IMPORTS
Return code: 2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.