src/ZF/UNITY/ClientImpl.thy
author paulson
Fri, 20 Jun 2003 12:10:45 +0200
changeset 14060 c0c4af41fa3b
parent 14057 57de6d68389e
child 14061 abcb32a7b212
permissions -rw-r--r--
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14053
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
     1
(*  Title:      ZF/UNITY/ClientImpl.thy
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
     2
    ID:         $Id$
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
     3
    Author:     Sidi O Ehmety, Cambridge University Computer Laboratory
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
     4
    Copyright   2002  University of Cambridge
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
     5
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
     6
Distributed Resource Management System:  Client Implementation
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
     7
*)
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
     8
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
     9
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    10
ClientImpl = AllocBase + Guar +
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    11
consts
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    12
  ask :: i (* input history:  tokens requested *)
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    13
  giv :: i (* output history: tokens granted *)
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    14
  rel :: i (* input history: tokens released *)
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    15
  tok :: i (* the number of available tokens *)
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    16
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    17
translations
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    18
  "ask" == "Var(Nil)"
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    19
  "giv" == "Var([0])"
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    20
  "rel" == "Var([1])"
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    21
  "tok" == "Var([2])"
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    22
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    23
rules
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    24
  type_assumes
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    25
  "type_of(ask) = list(tokbag) & type_of(giv) = list(tokbag) & 
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    26
   type_of(rel) = list(tokbag) & type_of(tok) = nat"
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    27
  default_val_assumes
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    28
  "default_val(ask) = Nil & default_val(giv)  = Nil & 
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    29
   default_val(rel)  = Nil & default_val(tok)  = 0"
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    30
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    31
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    32
(*Array indexing is translated to list indexing as A[n] == nth(n-1,A). *)
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    33
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    34
constdefs
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    35
 (** Release some client_tokens **)
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    36
  
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    37
  client_rel_act ::i
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    38
    "client_rel_act ==
14057
57de6d68389e x-symbols (mostly)
paulson
parents: 14053
diff changeset
    39
     {<s,t> \\<in> state*state.
57de6d68389e x-symbols (mostly)
paulson
parents: 14053
diff changeset
    40
      \\<exists>nrel \\<in> nat. nrel = length(s`rel) &
57de6d68389e x-symbols (mostly)
paulson
parents: 14053
diff changeset
    41
                   t = s(rel:=(s`rel)@[nth(nrel, s`giv)]) &
57de6d68389e x-symbols (mostly)
paulson
parents: 14053
diff changeset
    42
                   nrel < length(s`giv) &
57de6d68389e x-symbols (mostly)
paulson
parents: 14053
diff changeset
    43
                   nth(nrel, s`ask) le nth(nrel, s`giv)}"
14053
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    44
  
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    45
  (** Choose a new token requirement **)
14057
57de6d68389e x-symbols (mostly)
paulson
parents: 14053
diff changeset
    46
  (** Including t=s suppresses fairness, allowing the non-trivial part
14053
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    47
      of the action to be ignored **)
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    48
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    49
  client_tok_act :: i
14057
57de6d68389e x-symbols (mostly)
paulson
parents: 14053
diff changeset
    50
 "client_tok_act == {<s,t> \\<in> state*state. t=s |
57de6d68389e x-symbols (mostly)
paulson
parents: 14053
diff changeset
    51
		     t = s(tok:=succ(s`tok mod NbT))}"
14053
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    52
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    53
  client_ask_act :: i
14057
57de6d68389e x-symbols (mostly)
paulson
parents: 14053
diff changeset
    54
  "client_ask_act == {<s,t> \\<in> state*state. t=s | (t=s(ask:=s`ask@[s`tok]))}"
14053
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    55
  
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    56
  client_prog :: i
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    57
  "client_prog ==
14057
57de6d68389e x-symbols (mostly)
paulson
parents: 14053
diff changeset
    58
   mk_program({s \\<in> state. s`tok le NbT & s`giv = Nil &
14053
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    59
	               s`ask = Nil & s`rel = Nil},
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    60
                    {client_rel_act, client_tok_act, client_ask_act},
14057
57de6d68389e x-symbols (mostly)
paulson
parents: 14053
diff changeset
    61
                   \\<Union>G \\<in> preserves(lift(rel)) Int
14053
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    62
			 preserves(lift(ask)) Int
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    63
	                 preserves(lift(tok)).  Acts(G))"
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    64
end