src/HOL/UNITY/Token.thy
author paulson
Wed, 18 Nov 1998 15:10:46 +0100
changeset 5931 325300576da7
parent 5782 7559f116cb10
child 6536 281d44905cab
permissions -rw-r--r--
Finally removing "Compl" from HOL
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
     1
(*  Title:      HOL/UNITY/Token
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
     2
    ID:         $Id$
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
     4
    Copyright   1998  University of Cambridge
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
     5
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
     6
The Token Ring.
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
     7
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
     8
From Misra, "A Logic for Concurrent Programming" (1994), sections 5.2 and 13.2.
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
     9
*)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    10
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    11
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5253
diff changeset
    12
Token = WFair + 
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    13
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    14
(*process states*)
5232
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 4776
diff changeset
    15
datatype pstate = Hungry | Eating | Thinking
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    16
5232
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 4776
diff changeset
    17
record state =
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 4776
diff changeset
    18
  token :: nat
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 4776
diff changeset
    19
  proc  :: nat => pstate
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    20
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    21
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    22
constdefs
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    23
  HasTok :: nat => state set
5232
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 4776
diff changeset
    24
    "HasTok i == {s. token s = i}"
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    25
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    26
  H :: nat => state set
5232
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 4776
diff changeset
    27
    "H i == {s. proc s i = Hungry}"
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    28
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    29
  E :: nat => state set
5232
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 4776
diff changeset
    30
    "E i == {s. proc s i = Eating}"
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    31
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    32
  T :: nat => state set
5232
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 4776
diff changeset
    33
    "T i == {s. proc s i = Thinking}"
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    34
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    35
5420
b48ab3281944 New approach, using a locale
paulson
parents: 5277
diff changeset
    36
locale Token =
b48ab3281944 New approach, using a locale
paulson
parents: 5277
diff changeset
    37
  fixes
b48ab3281944 New approach, using a locale
paulson
parents: 5277
diff changeset
    38
    N         :: nat	 (*number of nodes in the ring*)
5648
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
    39
    F         :: state program
5420
b48ab3281944 New approach, using a locale
paulson
parents: 5277
diff changeset
    40
    nodeOrder :: "nat => (nat*nat)set"
b48ab3281944 New approach, using a locale
paulson
parents: 5277
diff changeset
    41
    next      :: nat => nat
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    42
5420
b48ab3281944 New approach, using a locale
paulson
parents: 5277
diff changeset
    43
  assumes
b48ab3281944 New approach, using a locale
paulson
parents: 5277
diff changeset
    44
    N_positive "0<N"
b48ab3281944 New approach, using a locale
paulson
parents: 5277
diff changeset
    45
5782
7559f116cb10 locales now implicitly quantify over free variables
paulson
parents: 5648
diff changeset
    46
    TR2  "F : constrains (T i) (T i Un H i)"
5420
b48ab3281944 New approach, using a locale
paulson
parents: 5277
diff changeset
    47
5782
7559f116cb10 locales now implicitly quantify over free variables
paulson
parents: 5648
diff changeset
    48
    TR3  "F : constrains (H i) (H i Un E i)"
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    49
5782
7559f116cb10 locales now implicitly quantify over free variables
paulson
parents: 5648
diff changeset
    50
    TR4  "F : constrains (H i - HasTok i) (H i)"
5420
b48ab3281944 New approach, using a locale
paulson
parents: 5277
diff changeset
    51
5931
325300576da7 Finally removing "Compl" from HOL
paulson
parents: 5782
diff changeset
    52
    TR5  "F : constrains (HasTok i) (HasTok i Un -(E i))"
5420
b48ab3281944 New approach, using a locale
paulson
parents: 5277
diff changeset
    53
5782
7559f116cb10 locales now implicitly quantify over free variables
paulson
parents: 5648
diff changeset
    54
    TR6  "F : leadsTo (H i Int HasTok i) (E i)"
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    55
5782
7559f116cb10 locales now implicitly quantify over free variables
paulson
parents: 5648
diff changeset
    56
    TR7  "F : leadsTo (HasTok i) (HasTok (next i))"
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    57
5420
b48ab3281944 New approach, using a locale
paulson
parents: 5277
diff changeset
    58
  defines
b48ab3281944 New approach, using a locale
paulson
parents: 5277
diff changeset
    59
    nodeOrder_def
b48ab3281944 New approach, using a locale
paulson
parents: 5277
diff changeset
    60
      "nodeOrder j == (inv_image less_than (%i. ((j+N)-i) mod N))  Int
b48ab3281944 New approach, using a locale
paulson
parents: 5277
diff changeset
    61
		      (lessThan N Times lessThan N)"
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    62
5420
b48ab3281944 New approach, using a locale
paulson
parents: 5277
diff changeset
    63
    next_def
b48ab3281944 New approach, using a locale
paulson
parents: 5277
diff changeset
    64
      "next i == (Suc i) mod N"
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    65
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    66
end