src/ZF/UNITY/UNITY.thy
author wenzelm
Wed, 15 Aug 2001 22:20:30 +0200
changeset 11501 3b6415035d1a
parent 11479 697dcaaf478f
child 12195 ed2893765a08
permissions -rw-r--r--
support for absolute namespace entry paths;
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
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    12
UNITY = State + UNITYMisc +
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 
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    19
  "program == {<init, acts, allowed>:condition*actionSet*actionSet.
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    20
	       Id:acts & Id:allowed}"
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    21
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    22
  mk_program :: [i,i,i]=>i 
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    23
  "mk_program(init, acts, allowed) ==
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    24
     <init Int state, cons(Id, acts Int action), cons(Id, allowed Int action)>"
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    25
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    26
  SKIP :: i
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    27
  "SKIP == mk_program(state, 0, action)"
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    28
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    29
  (** Coercion from anything to program **)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    30
  programify :: i=>i
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    31
  "programify(F) == if F:program then F else SKIP"
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    32
  
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    33
  RawInit :: i=>i
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    34
  "RawInit(F) == fst(F)"
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    35
  
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    36
  Init :: i=>i
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    37
  "Init(F) == RawInit(programify(F))"
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    38
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    39
  RawActs :: i=>i
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    40
  "RawActs(F) == cons(Id, fst(snd(F)))"
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    41
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    42
  Acts :: i=>i
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    43
  "Acts(F) == RawActs(programify(F))"
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    44
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    45
  RawAllowedActs :: i=>i
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    46
  "RawAllowedActs(F) == cons(Id, snd(snd(F)))"
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    47
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    48
  AllowedActs :: i=>i
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    49
  "AllowedActs(F) == RawAllowedActs(programify(F))"
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    50
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    51
  
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    52
  Allowed :: i =>i
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    53
  "Allowed(F) == {G:program. Acts(G) <= AllowedActs(F)}"
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    54
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    55
  (* initially property, used by some UNITY authors *)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    56
  initially   :: i => i
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    57
  "initially(A) == {F:program. Init(F)<= A & A:condition}"
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    58
  
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    59
  stable     :: i=>i
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    60
   "stable(A) == A co A"
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    61
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    62
  strongest_rhs :: [i, i] => i
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    63
  "strongest_rhs(F, A) == Inter({B:Pow(state). F:A co B})"
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    64
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    65
  invariant :: i => i
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    66
  "invariant(A) == {F:program. Init(F)<=A} Int stable(A)"
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    67
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    68
  part_order :: [i, i] => o
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    69
  "part_order(A, r) == refl(A,r) & trans[A](r) & antisym(r)"
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    70
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    71
  nat_order :: i
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    72
  "nat_order == {<i,j>:nat*nat. i le j}"
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    73
  
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    74
  (*
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    75
  The constant increasing_on defines the Charpentier's increasing notion.
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    76
  It should not be confused with the ZF's increasing constant
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    77
  which have a different meaning.
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    78
  Increasing_on's parameters: a state function f, a domain A and
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    79
  a order relation r over the domain A 
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    80
  Should f be a meta function instead ?
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    81
  *)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    82
  increasing_on :: [i,i, i] => i  ("increasing[_]'(_,_')") 
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    83
  "increasing[A](f, r) ==
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    84
     {F:program. f:state->A & part_order(A,r) & F:
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    85
                       (INT z:A. stable({s:state.  <z, f`s>:r}))}"
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    86
   
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    87
defs
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    88
  (* The typing requirements `A:condition & B:condition'
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    89
     make the definition stronger than the original ones in HOL. *)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    90
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    91
  constrains_def "A co B ==
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    92
		   {F:program. (ALL act:Acts(F). act``A <= B)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    93
		    & A:condition & B:condition}"
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    94
  
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    95
  unless_def     "A unless B == (A - B) co (A Un B)"
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    96
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    97
end
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    98