src/HOL/UNITY/Token.thy
author paulson
Fri Jul 31 18:46:55 1998 +0200 (1998-07-31)
changeset 5232 e5a7cdd07ea5
parent 4776 1f9362e769c1
child 5253 82a5ca6290aa
permissions -rw-r--r--
Tidied; uses records
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@4776
    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@4776
    47
  skip "id: Acts"
paulson@4776
    48
paulson@4776
    49
  TR2  "constrains Acts (T i) (T i Un H i)"
paulson@4776
    50
paulson@4776
    51
  TR3  "constrains Acts (H i) (H i Un E i)"
paulson@4776
    52
paulson@4776
    53
  TR4  "constrains Acts (H i - HasTok i) (H i)"
paulson@4776
    54
paulson@4776
    55
  TR5  "constrains Acts (HasTok i) (HasTok i Un Compl(E i))"
paulson@4776
    56
paulson@4776
    57
  TR6  "leadsTo Acts (H i Int HasTok i) (E i)"
paulson@4776
    58
paulson@4776
    59
  TR7  "leadsTo Acts (HasTok i) (HasTok (next i))"
paulson@4776
    60
paulson@4776
    61
end