src/HOL/UNITY/Token.thy
author paulson
Thu Aug 06 15:47:26 1998 +0200 (1998-08-06)
changeset 5277 e4297d03e5d2
parent 5253 82a5ca6290aa
child 5420 b48ab3281944
permissions -rw-r--r--
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson@4776
     1
(*  Title:      HOL/UNITY/Token
paulson@4776
     2
    ID:         $Id$
paulson@4776
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
paulson@4776
     4
    Copyright   1998  University of Cambridge
paulson@4776
     5
paulson@4776
     6
The Token Ring.
paulson@4776
     7
paulson@4776
     8
From Misra, "A Logic for Concurrent Programming" (1994), sections 5.2 and 13.2.
paulson@4776
     9
*)
paulson@4776
    10
paulson@4776
    11
paulson@5277
    12
Token = WFair + 
paulson@4776
    13
paulson@4776
    14
(*process states*)
paulson@5232
    15
datatype pstate = Hungry | Eating | Thinking
paulson@4776
    16
paulson@5232
    17
record state =
paulson@5232
    18
  token :: nat
paulson@5232
    19
  proc  :: nat => pstate
paulson@4776
    20
paulson@4776
    21
consts
paulson@4776
    22
  N :: nat	(*number of nodes in the ring*)
paulson@4776
    23
paulson@4776
    24
constdefs
paulson@4776
    25
  nodeOrder :: "nat => (nat*nat)set"
paulson@4776
    26
    "nodeOrder j == (inv_image less_than (%i. ((j+N)-i) mod N))  Int
paulson@4776
    27
                    (lessThan N Times lessThan N)"
paulson@4776
    28
paulson@4776
    29
  next      :: nat => nat
paulson@4776
    30
    "next i == (Suc i) mod N"
paulson@4776
    31
paulson@4776
    32
  HasTok :: nat => state set
paulson@5232
    33
    "HasTok i == {s. token s = i}"
paulson@4776
    34
paulson@4776
    35
  H :: nat => state set
paulson@5232
    36
    "H i == {s. proc s i = Hungry}"
paulson@4776
    37
paulson@4776
    38
  E :: nat => state set
paulson@5232
    39
    "E i == {s. proc s i = Eating}"
paulson@4776
    40
paulson@4776
    41
  T :: nat => state set
paulson@5232
    42
    "T i == {s. proc s i = Thinking}"
paulson@4776
    43
paulson@4776
    44
rules
paulson@4776
    45
  N_positive "0<N"
paulson@4776
    46
paulson@5253
    47
  skip "id: acts"
paulson@4776
    48
paulson@5253
    49
  TR2  "constrains acts (T i) (T i Un H i)"
paulson@4776
    50
paulson@5253
    51
  TR3  "constrains acts (H i) (H i Un E i)"
paulson@4776
    52
paulson@5253
    53
  TR4  "constrains acts (H i - HasTok i) (H i)"
paulson@4776
    54
paulson@5253
    55
  TR5  "constrains acts (HasTok i) (HasTok i Un Compl(E i))"
paulson@4776
    56
paulson@5253
    57
  TR6  "leadsTo acts (H i Int HasTok i) (E i)"
paulson@4776
    58
paulson@5253
    59
  TR7  "leadsTo acts (HasTok i) (HasTok (next i))"
paulson@4776
    60
paulson@4776
    61
end