src/HOL/UNITY/Alloc.thy
author paulson
Wed, 23 Feb 2000 10:45:08 +0100
changeset 8286 d4b895d3afa7
parent 8122 b43ad07660b9
child 8311 6218522253e7
permissions -rw-r--r--
not working yet. partial conversion to use "rename" instead of "extend"
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6815
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
     1
(*  Title:      HOL/UNITY/Alloc
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
     2
    ID:         $Id$
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
     4
    Copyright   1998  University of Cambridge
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
     5
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
     6
Specification of Chandy and Charpentier's Allocator
7537
875754b599df working snapshot
paulson
parents: 7361
diff changeset
     7
875754b599df working snapshot
paulson
parents: 7361
diff changeset
     8
CONSIDER CHANGING "sum" to work on type "int", not "nat"
875754b599df working snapshot
paulson
parents: 7361
diff changeset
     9
  --then can use subtraction in spec (1),
875754b599df working snapshot
paulson
parents: 7361
diff changeset
    10
  --but need invariants that values are non-negative
6815
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    11
*)
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    12
8041
e3237d8c18d6 working version with new theory ELT
paulson
parents: 7962
diff changeset
    13
Alloc = Follows + PPROD +
6815
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    14
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    15
(*Duplicated from HOL/ex/NatSum.thy.
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    16
  Maybe type should be  [nat=>int, nat] => int**)
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    17
consts sum     :: [nat=>nat, nat] => nat
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    18
primrec 
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    19
  "sum f 0 = 0"
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    20
  "sum f (Suc n) = f(n) + sum f n"
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    21
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    22
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    23
(*This function merely sums the elements of a list*)
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    24
consts tokens     :: nat list => nat
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    25
primrec 
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    26
  "tokens [] = 0"
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    27
  "tokens (x#xs) = x + tokens xs"
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    28
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    29
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    30
consts
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    31
  NbT      :: nat       (*Number of tokens in system*)
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    32
  Nclients :: nat       (*Number of clients*)
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    33
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    34
8055
bb15396278fb abolition of localTo: instead "guarantees" has local vars as extra argument
paulson
parents: 8041
diff changeset
    35
(** State definitions.  OUTPUT variables are locals **)
bb15396278fb abolition of localTo: instead "guarantees" has local vars as extra argument
paulson
parents: 8041
diff changeset
    36
6815
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    37
record clientState =
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    38
  giv :: nat list   (*client's INPUT history:  tokens GRANTED*)
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    39
  ask :: nat list   (*client's OUTPUT history: tokens REQUESTED*)
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    40
  rel :: nat list   (*client's OUTPUT history: tokens RELEASED*)
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    41
8286
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
    42
record 'a clientState_u =
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
    43
  clientState +
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
    44
  extra :: 'a       (*dummy field for new variables*)
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
    45
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
    46
consts
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
    47
  rClient  :: "(clientState * 'a) program"  (*DUMMY CONSTANT*)
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
    48
6815
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    49
record allocState =
8055
bb15396278fb abolition of localTo: instead "guarantees" has local vars as extra argument
paulson
parents: 8041
diff changeset
    50
  allocGiv :: nat => nat list   (*OUTPUT history: source of "giv" for i*)
bb15396278fb abolition of localTo: instead "guarantees" has local vars as extra argument
paulson
parents: 8041
diff changeset
    51
  allocAsk :: nat => nat list   (*INPUT: allocator's copy of "ask" for i*)
bb15396278fb abolition of localTo: instead "guarantees" has local vars as extra argument
paulson
parents: 8041
diff changeset
    52
  allocRel :: nat => nat list   (*INPUT: allocator's copy of "rel" for i*)
6815
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    53
8286
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
    54
record 'a allocState_u =
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
    55
  allocState +
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
    56
  extra    :: 'a                (*dummy field for new variables*)
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
    57
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
    58
record 'a systemState =
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
    59
  allocState +
6815
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    60
  client :: nat => clientState  (*states of all clients*)
8286
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
    61
  extra  :: 'a                  (*dummy field for new variables*)
6815
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    62
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    63
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    64
constdefs
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    65
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    66
(** Resource allocation system specification **)
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    67
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    68
  (*spec (1)*)
8286
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
    69
  system_safety :: 'a systemState program set
6815
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    70
    "system_safety ==
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    71
     Always {s. sum (%i. (tokens o giv o sub i o client) s) Nclients
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    72
	        <= NbT + sum (%i. (tokens o rel o sub i o client) s) Nclients}"
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    73
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    74
  (*spec (2)*)
8286
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
    75
  system_progress :: 'a systemState program set
6815
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    76
    "system_progress == INT i : lessThan Nclients.
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    77
			INT h. 
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    78
			  {s. h <= (ask o sub i o client)s} LeadsTo
6827
b69a2585ec0f guar; locale for the spec
paulson
parents: 6815
diff changeset
    79
			  {s. h pfixLe (giv o sub i o client) s}"
b69a2585ec0f guar; locale for the spec
paulson
parents: 6815
diff changeset
    80
8286
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
    81
  system_spec :: 'a systemState program set
6827
b69a2585ec0f guar; locale for the spec
paulson
parents: 6815
diff changeset
    82
    "system_spec == system_safety Int system_progress"
6815
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    83
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    84
(** Client specification (required) ***)
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    85
8055
bb15396278fb abolition of localTo: instead "guarantees" has local vars as extra argument
paulson
parents: 8041
diff changeset
    86
  (*spec (3)*)
8286
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
    87
  client_increasing :: 'a clientState_u program set
6815
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    88
    "client_increasing ==
8055
bb15396278fb abolition of localTo: instead "guarantees" has local vars as extra argument
paulson
parents: 8041
diff changeset
    89
         UNIV guarantees[funPair rel ask]
bb15396278fb abolition of localTo: instead "guarantees" has local vars as extra argument
paulson
parents: 8041
diff changeset
    90
         Increasing ask Int Increasing rel"
6815
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    91
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    92
  (*spec (4)*)
8286
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
    93
  client_bounded :: 'a clientState_u program set
6815
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    94
    "client_bounded ==
8055
bb15396278fb abolition of localTo: instead "guarantees" has local vars as extra argument
paulson
parents: 8041
diff changeset
    95
         UNIV guarantees[ask]
bb15396278fb abolition of localTo: instead "guarantees" has local vars as extra argument
paulson
parents: 8041
diff changeset
    96
         Always {s. ALL elt : set (ask s). elt <= NbT}"
6815
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    97
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    98
  (*spec (5)*)
8286
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
    99
  client_progress :: 'a clientState_u program set
6815
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
   100
    "client_progress ==
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
   101
	 Increasing giv
8055
bb15396278fb abolition of localTo: instead "guarantees" has local vars as extra argument
paulson
parents: 8041
diff changeset
   102
	 guarantees[funPair rel ask]
6827
b69a2585ec0f guar; locale for the spec
paulson
parents: 6815
diff changeset
   103
	 (INT h. {s. h <= giv s & h pfixGe ask s}
8286
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
   104
		 LeadsTo {s. tokens h <= (tokens o rel) s})"
6815
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
   105
8065
658e0d4e4ed9 first working version to Alloc/System_Client_Progress;
paulson
parents: 8055
diff changeset
   106
  (*spec: preserves part*)
8286
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
   107
    client_preserves :: 'a clientState_u program set
8065
658e0d4e4ed9 first working version to Alloc/System_Client_Progress;
paulson
parents: 8055
diff changeset
   108
    "client_preserves == preserves giv"
658e0d4e4ed9 first working version to Alloc/System_Client_Progress;
paulson
parents: 8055
diff changeset
   109
8286
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
   110
  client_spec :: 'a clientState_u program set
8065
658e0d4e4ed9 first working version to Alloc/System_Client_Progress;
paulson
parents: 8055
diff changeset
   111
    "client_spec == client_increasing Int client_bounded Int client_progress
658e0d4e4ed9 first working version to Alloc/System_Client_Progress;
paulson
parents: 8055
diff changeset
   112
                    Int client_preserves"
6827
b69a2585ec0f guar; locale for the spec
paulson
parents: 6815
diff changeset
   113
6815
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
   114
(** Allocator specification (required) ***)
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
   115
8055
bb15396278fb abolition of localTo: instead "guarantees" has local vars as extra argument
paulson
parents: 8041
diff changeset
   116
  (*spec (6)*)
8286
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
   117
  alloc_increasing :: 'a allocState_u program set
6815
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
   118
    "alloc_increasing ==
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
   119
	 UNIV
8055
bb15396278fb abolition of localTo: instead "guarantees" has local vars as extra argument
paulson
parents: 8041
diff changeset
   120
         guarantees[allocGiv]
7540
8af61a565a4a working Safety proof for the system at last
paulson
parents: 7537
diff changeset
   121
	 (INT i : lessThan Nclients. Increasing (sub i o allocGiv))"
6815
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
   122
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
   123
  (*spec (7)*)
8286
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
   124
  alloc_safety :: 'a allocState_u program set
6815
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
   125
    "alloc_safety ==
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
   126
	 (INT i : lessThan Nclients. Increasing (sub i o allocRel))
8055
bb15396278fb abolition of localTo: instead "guarantees" has local vars as extra argument
paulson
parents: 8041
diff changeset
   127
         guarantees[allocGiv]
6815
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
   128
	 Always {s. sum (%i. (tokens o sub i o allocGiv) s) Nclients
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
   129
	         <= NbT + sum (%i. (tokens o sub i o allocRel) s) Nclients}"
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
   130
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
   131
  (*spec (8)*)
8286
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
   132
  alloc_progress :: 'a allocState_u program set
6815
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
   133
    "alloc_progress ==
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
   134
	 (INT i : lessThan Nclients. Increasing (sub i o allocAsk) Int
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
   135
	                             Increasing (sub i o allocRel))
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
   136
         Int
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
   137
         Always {s. ALL i : lessThan Nclients.
8075
93b62f856af7 tidied, with a bit more progress
paulson
parents: 8069
diff changeset
   138
		     ALL elt : set ((sub i o allocAsk) s). elt <= NbT}
6815
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
   139
         Int
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
   140
         (INT i : lessThan Nclients. 
6827
b69a2585ec0f guar; locale for the spec
paulson
parents: 6815
diff changeset
   141
	  INT h. {s. h <= (sub i o allocGiv)s & h pfixGe (sub i o allocAsk)s}
8075
93b62f856af7 tidied, with a bit more progress
paulson
parents: 8069
diff changeset
   142
		 LeadsTo
93b62f856af7 tidied, with a bit more progress
paulson
parents: 8069
diff changeset
   143
	         {s. tokens h <= (tokens o sub i o allocRel)s})
8055
bb15396278fb abolition of localTo: instead "guarantees" has local vars as extra argument
paulson
parents: 8041
diff changeset
   144
         guarantees[allocGiv]
6815
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
   145
	     (INT i : lessThan Nclients.
8069
19b9f92ca503 working with weak LeadsTo in guarantees precondition\!
paulson
parents: 8065
diff changeset
   146
	      INT h. {s. h <= (sub i o allocAsk) s}
8122
b43ad07660b9 working version, with Alloc now working on the same state space as the whole
paulson
parents: 8075
diff changeset
   147
	             LeadsTo
6827
b69a2585ec0f guar; locale for the spec
paulson
parents: 6815
diff changeset
   148
	             {s. h pfixLe (sub i o allocGiv) s})"
b69a2585ec0f guar; locale for the spec
paulson
parents: 6815
diff changeset
   149
8065
658e0d4e4ed9 first working version to Alloc/System_Client_Progress;
paulson
parents: 8055
diff changeset
   150
  (*spec: preserves part*)
8286
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
   151
    alloc_preserves :: 'a allocState_u program set
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
   152
    "alloc_preserves == preserves (funPair allocRel allocAsk)"
8065
658e0d4e4ed9 first working version to Alloc/System_Client_Progress;
paulson
parents: 8055
diff changeset
   153
  
8286
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
   154
  alloc_spec :: 'a allocState_u program set
8065
658e0d4e4ed9 first working version to Alloc/System_Client_Progress;
paulson
parents: 8055
diff changeset
   155
    "alloc_spec == alloc_increasing Int alloc_safety Int alloc_progress Int
658e0d4e4ed9 first working version to Alloc/System_Client_Progress;
paulson
parents: 8055
diff changeset
   156
                   alloc_preserves"
6815
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
   157
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
   158
(** Network specification ***)
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
   159
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
   160
  (*spec (9.1)*)
8286
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
   161
  network_ask :: 'a systemState program set
6815
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
   162
    "network_ask == INT i : lessThan Nclients.
8075
93b62f856af7 tidied, with a bit more progress
paulson
parents: 8069
diff changeset
   163
			Increasing (ask o sub i o client)
93b62f856af7 tidied, with a bit more progress
paulson
parents: 8069
diff changeset
   164
			guarantees[allocAsk]
93b62f856af7 tidied, with a bit more progress
paulson
parents: 8069
diff changeset
   165
			((sub i o allocAsk) Fols (ask o sub i o client))"
6815
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
   166
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
   167
  (*spec (9.2)*)
8286
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
   168
  network_giv :: 'a systemState program set
6815
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
   169
    "network_giv == INT i : lessThan Nclients.
8075
93b62f856af7 tidied, with a bit more progress
paulson
parents: 8069
diff changeset
   170
			Increasing (sub i o allocGiv)
93b62f856af7 tidied, with a bit more progress
paulson
parents: 8069
diff changeset
   171
			guarantees[giv o sub i o client]
93b62f856af7 tidied, with a bit more progress
paulson
parents: 8069
diff changeset
   172
			((giv o sub i o client) Fols (sub i o allocGiv))"
6815
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
   173
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
   174
  (*spec (9.3)*)
8286
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
   175
  network_rel :: 'a systemState program set
6815
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
   176
    "network_rel == INT i : lessThan Nclients.
8075
93b62f856af7 tidied, with a bit more progress
paulson
parents: 8069
diff changeset
   177
			Increasing (rel o sub i o client)
93b62f856af7 tidied, with a bit more progress
paulson
parents: 8069
diff changeset
   178
			guarantees[allocRel]
93b62f856af7 tidied, with a bit more progress
paulson
parents: 8069
diff changeset
   179
			((sub i o allocRel) Fols (rel o sub i o client))"
6815
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
   180
8065
658e0d4e4ed9 first working version to Alloc/System_Client_Progress;
paulson
parents: 8055
diff changeset
   181
  (*spec: preserves part*)
8286
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
   182
    network_preserves :: 'a systemState program set
8075
93b62f856af7 tidied, with a bit more progress
paulson
parents: 8069
diff changeset
   183
    "network_preserves == preserves allocGiv  Int
8065
658e0d4e4ed9 first working version to Alloc/System_Client_Progress;
paulson
parents: 8055
diff changeset
   184
                          (INT i : lessThan Nclients.
658e0d4e4ed9 first working version to Alloc/System_Client_Progress;
paulson
parents: 8055
diff changeset
   185
                           preserves (funPair rel ask o sub i o client))"
658e0d4e4ed9 first working version to Alloc/System_Client_Progress;
paulson
parents: 8055
diff changeset
   186
  
8286
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
   187
  network_spec :: 'a systemState program set
8065
658e0d4e4ed9 first working version to Alloc/System_Client_Progress;
paulson
parents: 8055
diff changeset
   188
    "network_spec == network_ask Int network_giv Int
658e0d4e4ed9 first working version to Alloc/System_Client_Progress;
paulson
parents: 8055
diff changeset
   189
                     network_rel Int network_preserves"
6827
b69a2585ec0f guar; locale for the spec
paulson
parents: 6815
diff changeset
   190
b69a2585ec0f guar; locale for the spec
paulson
parents: 6815
diff changeset
   191
b69a2585ec0f guar; locale for the spec
paulson
parents: 6815
diff changeset
   192
(** State mappings **)
8286
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
   193
  sysOfAlloc :: "((nat => clientState) * 'a) allocState_u => 'a systemState"
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
   194
    "sysOfAlloc == %s. let (cl,xtr) = allocState_u.extra s
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
   195
                       in (| allocGiv = allocGiv s,
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
   196
			     allocAsk = allocAsk s,
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
   197
			     allocRel = allocRel s,
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
   198
			     client   = cl,
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
   199
			     extra    = xtr|)"
6827
b69a2585ec0f guar; locale for the spec
paulson
parents: 6815
diff changeset
   200
8286
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
   201
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
   202
  sysOfClient :: "(nat => clientState) * 'a allocState_u => 'a systemState"
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
   203
    "sysOfClient == %(cl,al). (| allocGiv = allocGiv al,
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
   204
			         allocAsk = allocAsk al,
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
   205
			         allocRel = allocRel al,
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
   206
			         client   = cl,
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
   207
			         systemState.extra = allocState_u.extra al|)"
6827
b69a2585ec0f guar; locale for the spec
paulson
parents: 6815
diff changeset
   208
b69a2585ec0f guar; locale for the spec
paulson
parents: 6815
diff changeset
   209
b69a2585ec0f guar; locale for the spec
paulson
parents: 6815
diff changeset
   210
locale System =
b69a2585ec0f guar; locale for the spec
paulson
parents: 6815
diff changeset
   211
  fixes 
8286
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
   212
    Alloc   :: 'a allocState program
6827
b69a2585ec0f guar; locale for the spec
paulson
parents: 6815
diff changeset
   213
    Client  :: clientState program
8286
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
   214
    Network :: 'a systemState program
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
   215
    System  :: 'a systemState program
6827
b69a2585ec0f guar; locale for the spec
paulson
parents: 6815
diff changeset
   216
  
b69a2585ec0f guar; locale for the spec
paulson
parents: 6815
diff changeset
   217
  assumes
b69a2585ec0f guar; locale for the spec
paulson
parents: 6815
diff changeset
   218
    Alloc   "Alloc   : alloc_spec"
b69a2585ec0f guar; locale for the spec
paulson
parents: 6815
diff changeset
   219
    Client  "Client  : client_spec"
b69a2585ec0f guar; locale for the spec
paulson
parents: 6815
diff changeset
   220
    Network "Network : network_spec"
b69a2585ec0f guar; locale for the spec
paulson
parents: 6815
diff changeset
   221
b69a2585ec0f guar; locale for the spec
paulson
parents: 6815
diff changeset
   222
  defines
b69a2585ec0f guar; locale for the spec
paulson
parents: 6815
diff changeset
   223
    System_def
8286
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
   224
      "System == rename sysOfAlloc Alloc Join Network Join
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
   225
                 (rename sysOfClient (plam x: lessThan Nclients. Client))"
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
   226
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
   227
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
   228
6815
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
   229
end