src/HOL/UNITY/Handshake.thy
author paulson
Thu, 03 Dec 1998 10:45:06 +0100
changeset 6012 1894bfc4aee9
parent 5648 fe887910e32e
child 6295 351b3c2b0d83
permissions -rw-r--r--
Addition of the States component; parts of Comp not working

(*  Title:      HOL/UNITY/Handshake.thy
    ID:         $Id$
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
    Copyright   1998  University of Cambridge

Handshake Protocol

From Misra, "Asynchronous Compositions of Programs", Section 5.3.2
*)

Handshake = Union +

record state =
  BB :: bool
  NF :: nat
  NG :: nat

constdefs
  (*F's program*)
  cmdF :: "(state*state) set"
    "cmdF == {(s,s'). s' = s (|NF:= Suc(NF s), BB:=False|) & BB s}"

  F :: "state program"
    "F == mk_program (UNIV, {s. NF s = 0 & BB s}, {cmdF})"

  (*G's program*)
  cmdG :: "(state*state) set"
    "cmdG == {(s,s'). s' = s (|NG:= Suc(NG s), BB:=True|) & ~ BB s}"

  G :: "state program"
    "G == mk_program (UNIV, {s. NG s = 0 & BB s}, {cmdG})"

  (*the joint invariant*)
  invFG :: "state set"
    "invFG == {s. NG s <= NF s & NF s <= Suc (NG s) & (BB s = (NF s = NG s))}"

end