src/ZF/UNITY/UNITY.thy
author kleing
Tue, 13 May 2003 08:59:21 +0200
changeset 14024 213dcc39358f
parent 12195 ed2893765a08
child 14046 6616e6c53d48
permissions -rw-r--r--
HOL-Real -> HOL-Complex
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
     1
(*  Title:      ZF/UNITY/UNITY.thy
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
     2
    ID:         $Id$
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
     3
    Author:     Sidi O Ehmety, Computer Laboratory
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
     4
    Copyright   2001  University of Cambridge
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
     5
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
     6
The basic UNITY theory (revised version, based upon the "co" operator)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
     7
From Misra, "A Logic for Concurrent Programming", 1994
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
     8
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
     9
Theory ported from HOL.
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    10
*)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    11
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 11479
diff changeset
    12
UNITY = State +
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    13
consts
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    14
  constrains :: "[i, i] => i"  (infixl "co"     60)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    15
  op_unless  :: "[i, i] => i"  (infixl "unless" 60)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    16
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    17
constdefs
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    18
   program  :: i 
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 11479
diff changeset
    19
  "program == {<init, acts, allowed>:
ed2893765a08 *** empty log message ***
ehmety
parents: 11479
diff changeset
    20
	       Pow(state)*Pow(Pow(state*state))*Pow(Pow(state*state)).
ed2893765a08 *** empty log message ***
ehmety
parents: 11479
diff changeset
    21
	       id(state):acts & id(state):allowed}"
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    22
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 11479
diff changeset
    23
  (* The definition below yields a program thanks to the coercions
ed2893765a08 *** empty log message ***
ehmety
parents: 11479
diff changeset
    24
  init Int state, acts Int Pow(state*state), etc. *)
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    25
  mk_program :: [i,i,i]=>i 
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    26
  "mk_program(init, acts, allowed) ==
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 11479
diff changeset
    27
    <init Int state, cons(id(state), acts Int Pow(state*state)),
ed2893765a08 *** empty log message ***
ehmety
parents: 11479
diff changeset
    28
              cons(id(state), allowed Int Pow(state*state))>"
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    29
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    30
  SKIP :: i
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 11479
diff changeset
    31
  "SKIP == mk_program(state, 0, Pow(state*state))"
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    32
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 11479
diff changeset
    33
  (* Coercion from anything to program *)
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    34
  programify :: i=>i
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    35
  "programify(F) == if F:program then F else SKIP"
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 11479
diff changeset
    36
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    37
  RawInit :: i=>i
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    38
  "RawInit(F) == fst(F)"
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    39
  
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    40
  Init :: i=>i
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    41
  "Init(F) == RawInit(programify(F))"
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    42
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    43
  RawActs :: i=>i
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 11479
diff changeset
    44
  "RawActs(F) == cons(id(state), fst(snd(F)))"
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    45
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    46
  Acts :: i=>i
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    47
  "Acts(F) == RawActs(programify(F))"
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    48
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    49
  RawAllowedActs :: i=>i
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 11479
diff changeset
    50
  "RawAllowedActs(F) == cons(id(state), snd(snd(F)))"
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    51
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    52
  AllowedActs :: i=>i
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    53
  "AllowedActs(F) == RawAllowedActs(programify(F))"
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    54
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    55
  
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    56
  Allowed :: i =>i
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    57
  "Allowed(F) == {G:program. Acts(G) <= AllowedActs(F)}"
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    58
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 11479
diff changeset
    59
  initially :: i=>i
ed2893765a08 *** empty log message ***
ehmety
parents: 11479
diff changeset
    60
  "initially(A) == {F:program. Init(F)<=A}"
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    61
  
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    62
  stable     :: i=>i
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    63
   "stable(A) == A co A"
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    64
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    65
  strongest_rhs :: [i, i] => i
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    66
  "strongest_rhs(F, A) == Inter({B:Pow(state). F:A co B})"
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    67
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    68
  invariant :: i => i
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 11479
diff changeset
    69
  "invariant(A) == initially(A) Int stable(A)"
ed2893765a08 *** empty log message ***
ehmety
parents: 11479
diff changeset
    70
    
ed2893765a08 *** empty log message ***
ehmety
parents: 11479
diff changeset
    71
  (* The `increasing' relation of Charpentier. Increasing's parameters are:
ed2893765a08 *** empty log message ***
ehmety
parents: 11479
diff changeset
    72
   a state function f, a domain A and an order relation r over the domain A. *)
ed2893765a08 *** empty log message ***
ehmety
parents: 11479
diff changeset
    73
  
ed2893765a08 *** empty log message ***
ehmety
parents: 11479
diff changeset
    74
  increasing :: [i,i, i] => i 
ed2893765a08 *** empty log message ***
ehmety
parents: 11479
diff changeset
    75
  "increasing(A, r, f) ==  INT a:A. stable({s:state.  <a, f`s>:r})"
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    76
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 11479
diff changeset
    77
  (* The definition of a partial order in ZF (predicate part_ord in theory Order)
ed2893765a08 *** empty log message ***
ehmety
parents: 11479
diff changeset
    78
     describes a strict order: irreflexive and transitive.
ed2893765a08 *** empty log message ***
ehmety
parents: 11479
diff changeset
    79
     However, the order used in association with Charpentier's increasing
ed2893765a08 *** empty log message ***
ehmety
parents: 11479
diff changeset
    80
     relation is not, hence the definition below: *)
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    81
  part_order :: [i, i] => o
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    82
  "part_order(A, r) == refl(A,r) & trans[A](r) & antisym(r)"
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    83
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    84
defs
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 11479
diff changeset
    85
  (* Condition `st_set(A)' makes the definition slightly stronger than the HOL one *)
ed2893765a08 *** empty log message ***
ehmety
parents: 11479
diff changeset
    86
  constrains_def "A co B == {F:program. (ALL act:Acts(F). act``A<=B) & st_set(A)}"
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    87
  unless_def     "A unless B == (A - B) co (A Un B)"
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    88
end
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    89