src/HOL/UNITY/Alloc.thy
author wenzelm
Tue, 13 Jun 2000 18:33:34 +0200
changeset 9058 7856a01119fb
parent 8985 13ad7ce031bb
child 9109 0085c32a533b
permissions -rw-r--r--
qed_spec_mp: strip_shyps_warning;
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
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
     7
*)
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
     8
8930
cb419b8498e5 removal of lessThan; use of AllocBase
paulson
parents: 8311
diff changeset
     9
Alloc = AllocBase + PPROD +
6815
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    10
8055
bb15396278fb abolition of localTo: instead "guarantees" has local vars as extra argument
paulson
parents: 8041
diff changeset
    11
(** State definitions.  OUTPUT variables are locals **)
bb15396278fb abolition of localTo: instead "guarantees" has local vars as extra argument
paulson
parents: 8041
diff changeset
    12
6815
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    13
record clientState =
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    14
  giv :: nat list   (*client's INPUT history:  tokens GRANTED*)
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    15
  ask :: nat list   (*client's OUTPUT history: tokens REQUESTED*)
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    16
  rel :: nat list   (*client's OUTPUT history: tokens RELEASED*)
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    17
8286
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
    18
record 'a clientState_u =
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
    19
  clientState +
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
    20
  extra :: 'a       (*dummy field for new variables*)
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
    21
8311
6218522253e7 new mostly working version; Alloc nearly converted to "Rename"
paulson
parents: 8286
diff changeset
    22
constdefs
6218522253e7 new mostly working version; Alloc nearly converted to "Rename"
paulson
parents: 8286
diff changeset
    23
  (*DUPLICATED FROM Client.thy, but with "tok" removed*)
6218522253e7 new mostly working version; Alloc nearly converted to "Rename"
paulson
parents: 8286
diff changeset
    24
  (*Maybe want a special theory section to declare such maps*)
6218522253e7 new mostly working version; Alloc nearly converted to "Rename"
paulson
parents: 8286
diff changeset
    25
  non_extra :: 'a clientState_u => clientState
6218522253e7 new mostly working version; Alloc nearly converted to "Rename"
paulson
parents: 8286
diff changeset
    26
    "non_extra s == (|giv = giv s, ask = ask s, rel = rel s|)"
8286
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
    27
8311
6218522253e7 new mostly working version; Alloc nearly converted to "Rename"
paulson
parents: 8286
diff changeset
    28
  (*Renaming map to put a Client into the standard form*)
6218522253e7 new mostly working version; Alloc nearly converted to "Rename"
paulson
parents: 8286
diff changeset
    29
  client_map :: "'a clientState_u => clientState*'a"
6218522253e7 new mostly working version; Alloc nearly converted to "Rename"
paulson
parents: 8286
diff changeset
    30
    "client_map == funPair non_extra extra"
6218522253e7 new mostly working version; Alloc nearly converted to "Rename"
paulson
parents: 8286
diff changeset
    31
6218522253e7 new mostly working version; Alloc nearly converted to "Rename"
paulson
parents: 8286
diff changeset
    32
  
6815
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    33
record allocState =
8055
bb15396278fb abolition of localTo: instead "guarantees" has local vars as extra argument
paulson
parents: 8041
diff changeset
    34
  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
    35
  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
    36
  allocRel :: nat => nat list   (*INPUT: allocator's copy of "rel" for i*)
6815
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    37
8286
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
    38
record 'a allocState_u =
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
    39
  allocState +
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
    40
  extra    :: 'a                (*dummy field for new variables*)
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
    41
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
    42
record 'a systemState =
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
    43
  allocState +
6815
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    44
  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
    45
  extra  :: 'a                  (*dummy field for new variables*)
6815
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    46
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    47
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    48
constdefs
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    49
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    50
(** Resource allocation system specification **)
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    51
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    52
  (*spec (1)*)
8286
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
    53
  system_safety :: 'a systemState program set
6815
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    54
    "system_safety ==
8930
cb419b8498e5 removal of lessThan; use of AllocBase
paulson
parents: 8311
diff changeset
    55
     Always {s. sum_below (%i. (tokens o giv o sub i o client) s) Nclients
cb419b8498e5 removal of lessThan; use of AllocBase
paulson
parents: 8311
diff changeset
    56
        <= NbT + sum_below (%i. (tokens o rel o sub i o client) s) Nclients}"
6815
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    57
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    58
  (*spec (2)*)
8286
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
    59
  system_progress :: 'a systemState program set
8985
13ad7ce031bb restored some of the lessThans
paulson
parents: 8930
diff changeset
    60
    "system_progress == INT i : lessThan Nclients.
6815
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    61
			INT h. 
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    62
			  {s. h <= (ask o sub i o client)s} LeadsTo
6827
b69a2585ec0f guar; locale for the spec
paulson
parents: 6815
diff changeset
    63
			  {s. h pfixLe (giv o sub i o client) s}"
b69a2585ec0f guar; locale for the spec
paulson
parents: 6815
diff changeset
    64
8286
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
    65
  system_spec :: 'a systemState program set
6827
b69a2585ec0f guar; locale for the spec
paulson
parents: 6815
diff changeset
    66
    "system_spec == system_safety Int system_progress"
6815
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    67
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    68
(** Client specification (required) ***)
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    69
8055
bb15396278fb abolition of localTo: instead "guarantees" has local vars as extra argument
paulson
parents: 8041
diff changeset
    70
  (*spec (3)*)
8286
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
    71
  client_increasing :: 'a clientState_u program set
6815
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    72
    "client_increasing ==
8055
bb15396278fb abolition of localTo: instead "guarantees" has local vars as extra argument
paulson
parents: 8041
diff changeset
    73
         UNIV guarantees[funPair rel ask]
bb15396278fb abolition of localTo: instead "guarantees" has local vars as extra argument
paulson
parents: 8041
diff changeset
    74
         Increasing ask Int Increasing rel"
6815
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    75
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    76
  (*spec (4)*)
8286
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
    77
  client_bounded :: 'a clientState_u program set
6815
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    78
    "client_bounded ==
8055
bb15396278fb abolition of localTo: instead "guarantees" has local vars as extra argument
paulson
parents: 8041
diff changeset
    79
         UNIV guarantees[ask]
bb15396278fb abolition of localTo: instead "guarantees" has local vars as extra argument
paulson
parents: 8041
diff changeset
    80
         Always {s. ALL elt : set (ask s). elt <= NbT}"
6815
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    81
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    82
  (*spec (5)*)
8286
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
    83
  client_progress :: 'a clientState_u program set
6815
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    84
    "client_progress ==
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    85
	 Increasing giv
8055
bb15396278fb abolition of localTo: instead "guarantees" has local vars as extra argument
paulson
parents: 8041
diff changeset
    86
	 guarantees[funPair rel ask]
6827
b69a2585ec0f guar; locale for the spec
paulson
parents: 6815
diff changeset
    87
	 (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
    88
		 LeadsTo {s. tokens h <= (tokens o rel) s})"
6815
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    89
8065
658e0d4e4ed9 first working version to Alloc/System_Client_Progress;
paulson
parents: 8055
diff changeset
    90
  (*spec: preserves part*)
8286
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
    91
    client_preserves :: 'a clientState_u program set
8311
6218522253e7 new mostly working version; Alloc nearly converted to "Rename"
paulson
parents: 8286
diff changeset
    92
    "client_preserves == preserves (funPair giv clientState_u.extra)"
8065
658e0d4e4ed9 first working version to Alloc/System_Client_Progress;
paulson
parents: 8055
diff changeset
    93
8286
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
    94
  client_spec :: 'a clientState_u program set
8065
658e0d4e4ed9 first working version to Alloc/System_Client_Progress;
paulson
parents: 8055
diff changeset
    95
    "client_spec == client_increasing Int client_bounded Int client_progress
658e0d4e4ed9 first working version to Alloc/System_Client_Progress;
paulson
parents: 8055
diff changeset
    96
                    Int client_preserves"
6827
b69a2585ec0f guar; locale for the spec
paulson
parents: 6815
diff changeset
    97
6815
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    98
(** Allocator specification (required) ***)
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
    99
8055
bb15396278fb abolition of localTo: instead "guarantees" has local vars as extra argument
paulson
parents: 8041
diff changeset
   100
  (*spec (6)*)
8286
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
   101
  alloc_increasing :: 'a allocState_u program set
6815
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
   102
    "alloc_increasing ==
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
   103
	 UNIV
8055
bb15396278fb abolition of localTo: instead "guarantees" has local vars as extra argument
paulson
parents: 8041
diff changeset
   104
         guarantees[allocGiv]
8985
13ad7ce031bb restored some of the lessThans
paulson
parents: 8930
diff changeset
   105
	 (INT i : lessThan Nclients. Increasing (sub i o allocGiv))"
6815
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
   106
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
   107
  (*spec (7)*)
8286
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
   108
  alloc_safety :: 'a allocState_u program set
6815
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
   109
    "alloc_safety ==
8985
13ad7ce031bb restored some of the lessThans
paulson
parents: 8930
diff changeset
   110
	 (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
   111
         guarantees[allocGiv]
8930
cb419b8498e5 removal of lessThan; use of AllocBase
paulson
parents: 8311
diff changeset
   112
	 Always {s. sum_below (%i. (tokens o sub i o allocGiv) s) Nclients
cb419b8498e5 removal of lessThan; use of AllocBase
paulson
parents: 8311
diff changeset
   113
	      <= NbT + sum_below (%i. (tokens o sub i o allocRel) s) Nclients}"
6815
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
   114
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
   115
  (*spec (8)*)
8286
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
   116
  alloc_progress :: 'a allocState_u program set
6815
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
   117
    "alloc_progress ==
8985
13ad7ce031bb restored some of the lessThans
paulson
parents: 8930
diff changeset
   118
	 (INT i : lessThan Nclients. Increasing (sub i o allocAsk) Int
6815
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
   119
	                             Increasing (sub i o allocRel))
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
   120
         Int
8930
cb419b8498e5 removal of lessThan; use of AllocBase
paulson
parents: 8311
diff changeset
   121
         Always {s. ALL i. i<Nclients -->
cb419b8498e5 removal of lessThan; use of AllocBase
paulson
parents: 8311
diff changeset
   122
		     (ALL elt : set ((sub i o allocAsk) s). elt <= NbT)}
6815
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
   123
         Int
8985
13ad7ce031bb restored some of the lessThans
paulson
parents: 8930
diff changeset
   124
         (INT i : lessThan Nclients. 
6827
b69a2585ec0f guar; locale for the spec
paulson
parents: 6815
diff changeset
   125
	  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
   126
		 LeadsTo
93b62f856af7 tidied, with a bit more progress
paulson
parents: 8069
diff changeset
   127
	         {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
   128
         guarantees[allocGiv]
8985
13ad7ce031bb restored some of the lessThans
paulson
parents: 8930
diff changeset
   129
	     (INT i : lessThan Nclients.
8069
19b9f92ca503 working with weak LeadsTo in guarantees precondition\!
paulson
parents: 8065
diff changeset
   130
	      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
   131
	             LeadsTo
6827
b69a2585ec0f guar; locale for the spec
paulson
parents: 6815
diff changeset
   132
	             {s. h pfixLe (sub i o allocGiv) s})"
b69a2585ec0f guar; locale for the spec
paulson
parents: 6815
diff changeset
   133
8065
658e0d4e4ed9 first working version to Alloc/System_Client_Progress;
paulson
parents: 8055
diff changeset
   134
  (*spec: preserves part*)
8286
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
   135
    alloc_preserves :: 'a allocState_u program set
8311
6218522253e7 new mostly working version; Alloc nearly converted to "Rename"
paulson
parents: 8286
diff changeset
   136
    "alloc_preserves == preserves (funPair allocRel
6218522253e7 new mostly working version; Alloc nearly converted to "Rename"
paulson
parents: 8286
diff changeset
   137
				   (funPair allocAsk allocState_u.extra))"
8065
658e0d4e4ed9 first working version to Alloc/System_Client_Progress;
paulson
parents: 8055
diff changeset
   138
  
8286
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
   139
  alloc_spec :: 'a allocState_u program set
8065
658e0d4e4ed9 first working version to Alloc/System_Client_Progress;
paulson
parents: 8055
diff changeset
   140
    "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
   141
                   alloc_preserves"
6815
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
   142
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
   143
(** Network specification ***)
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
   144
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
   145
  (*spec (9.1)*)
8286
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
   146
  network_ask :: 'a systemState program set
8985
13ad7ce031bb restored some of the lessThans
paulson
parents: 8930
diff changeset
   147
    "network_ask == INT i : lessThan Nclients.
8075
93b62f856af7 tidied, with a bit more progress
paulson
parents: 8069
diff changeset
   148
			Increasing (ask o sub i o client)
93b62f856af7 tidied, with a bit more progress
paulson
parents: 8069
diff changeset
   149
			guarantees[allocAsk]
93b62f856af7 tidied, with a bit more progress
paulson
parents: 8069
diff changeset
   150
			((sub i o allocAsk) Fols (ask o sub i o client))"
6815
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
   151
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
   152
  (*spec (9.2)*)
8286
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
   153
  network_giv :: 'a systemState program set
8985
13ad7ce031bb restored some of the lessThans
paulson
parents: 8930
diff changeset
   154
    "network_giv == INT i : lessThan Nclients.
8075
93b62f856af7 tidied, with a bit more progress
paulson
parents: 8069
diff changeset
   155
			Increasing (sub i o allocGiv)
93b62f856af7 tidied, with a bit more progress
paulson
parents: 8069
diff changeset
   156
			guarantees[giv o sub i o client]
93b62f856af7 tidied, with a bit more progress
paulson
parents: 8069
diff changeset
   157
			((giv o sub i o client) Fols (sub i o allocGiv))"
6815
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
   158
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
   159
  (*spec (9.3)*)
8286
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
   160
  network_rel :: 'a systemState program set
8985
13ad7ce031bb restored some of the lessThans
paulson
parents: 8930
diff changeset
   161
    "network_rel == INT i : lessThan Nclients.
8075
93b62f856af7 tidied, with a bit more progress
paulson
parents: 8069
diff changeset
   162
			Increasing (rel o sub i o client)
93b62f856af7 tidied, with a bit more progress
paulson
parents: 8069
diff changeset
   163
			guarantees[allocRel]
93b62f856af7 tidied, with a bit more progress
paulson
parents: 8069
diff changeset
   164
			((sub i o allocRel) Fols (rel o sub i o client))"
6815
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
   165
8065
658e0d4e4ed9 first working version to Alloc/System_Client_Progress;
paulson
parents: 8055
diff changeset
   166
  (*spec: preserves part*)
8286
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
   167
    network_preserves :: 'a systemState program set
8075
93b62f856af7 tidied, with a bit more progress
paulson
parents: 8069
diff changeset
   168
    "network_preserves == preserves allocGiv  Int
8985
13ad7ce031bb restored some of the lessThans
paulson
parents: 8930
diff changeset
   169
                          (INT i : lessThan Nclients.
8065
658e0d4e4ed9 first working version to Alloc/System_Client_Progress;
paulson
parents: 8055
diff changeset
   170
                           preserves (funPair rel ask o sub i o client))"
658e0d4e4ed9 first working version to Alloc/System_Client_Progress;
paulson
parents: 8055
diff changeset
   171
  
8286
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
   172
  network_spec :: 'a systemState program set
8065
658e0d4e4ed9 first working version to Alloc/System_Client_Progress;
paulson
parents: 8055
diff changeset
   173
    "network_spec == network_ask Int network_giv Int
658e0d4e4ed9 first working version to Alloc/System_Client_Progress;
paulson
parents: 8055
diff changeset
   174
                     network_rel Int network_preserves"
6827
b69a2585ec0f guar; locale for the spec
paulson
parents: 6815
diff changeset
   175
b69a2585ec0f guar; locale for the spec
paulson
parents: 6815
diff changeset
   176
b69a2585ec0f guar; locale for the spec
paulson
parents: 6815
diff changeset
   177
(** State mappings **)
8286
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
   178
  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
   179
    "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
   180
                       in (| allocGiv = allocGiv s,
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
   181
			     allocAsk = allocAsk s,
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
   182
			     allocRel = allocRel s,
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
   183
			     client   = cl,
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
   184
			     extra    = xtr|)"
6827
b69a2585ec0f guar; locale for the spec
paulson
parents: 6815
diff changeset
   185
8286
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
   186
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
   187
  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
   188
    "sysOfClient == %(cl,al). (| allocGiv = allocGiv al,
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
   189
			         allocAsk = allocAsk al,
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
   190
			         allocRel = allocRel al,
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
   191
			         client   = cl,
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
   192
			         systemState.extra = allocState_u.extra al|)"
6827
b69a2585ec0f guar; locale for the spec
paulson
parents: 6815
diff changeset
   193
8311
6218522253e7 new mostly working version; Alloc nearly converted to "Rename"
paulson
parents: 8286
diff changeset
   194
consts 
6218522253e7 new mostly working version; Alloc nearly converted to "Rename"
paulson
parents: 8286
diff changeset
   195
    Alloc   :: 'a allocState_u program
6218522253e7 new mostly working version; Alloc nearly converted to "Rename"
paulson
parents: 8286
diff changeset
   196
    Client  :: 'a clientState_u program
8286
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
   197
    Network :: 'a systemState program
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
   198
    System  :: 'a systemState program
6827
b69a2585ec0f guar; locale for the spec
paulson
parents: 6815
diff changeset
   199
  
8311
6218522253e7 new mostly working version; Alloc nearly converted to "Rename"
paulson
parents: 8286
diff changeset
   200
rules
6218522253e7 new mostly working version; Alloc nearly converted to "Rename"
paulson
parents: 8286
diff changeset
   201
    Alloc   "Alloc   : alloc_spec"
6218522253e7 new mostly working version; Alloc nearly converted to "Rename"
paulson
parents: 8286
diff changeset
   202
    Client  "Client  : client_spec"
6218522253e7 new mostly working version; Alloc nearly converted to "Rename"
paulson
parents: 8286
diff changeset
   203
    Network "Network : network_spec"
6218522253e7 new mostly working version; Alloc nearly converted to "Rename"
paulson
parents: 8286
diff changeset
   204
6218522253e7 new mostly working version; Alloc nearly converted to "Rename"
paulson
parents: 8286
diff changeset
   205
defs
6218522253e7 new mostly working version; Alloc nearly converted to "Rename"
paulson
parents: 8286
diff changeset
   206
    System_def
6218522253e7 new mostly working version; Alloc nearly converted to "Rename"
paulson
parents: 8286
diff changeset
   207
      "System == rename sysOfAlloc Alloc Join Network Join
6218522253e7 new mostly working version; Alloc nearly converted to "Rename"
paulson
parents: 8286
diff changeset
   208
                 (rename sysOfClient
8985
13ad7ce031bb restored some of the lessThans
paulson
parents: 8930
diff changeset
   209
		  (plam x: lessThan Nclients. rename client_map Client))"
8311
6218522253e7 new mostly working version; Alloc nearly converted to "Rename"
paulson
parents: 8286
diff changeset
   210
6218522253e7 new mostly working version; Alloc nearly converted to "Rename"
paulson
parents: 8286
diff changeset
   211
6218522253e7 new mostly working version; Alloc nearly converted to "Rename"
paulson
parents: 8286
diff changeset
   212
(**
6218522253e7 new mostly working version; Alloc nearly converted to "Rename"
paulson
parents: 8286
diff changeset
   213
locale System =
6218522253e7 new mostly working version; Alloc nearly converted to "Rename"
paulson
parents: 8286
diff changeset
   214
  fixes 
6218522253e7 new mostly working version; Alloc nearly converted to "Rename"
paulson
parents: 8286
diff changeset
   215
    Alloc   :: 'a allocState_u program
6218522253e7 new mostly working version; Alloc nearly converted to "Rename"
paulson
parents: 8286
diff changeset
   216
    Client  :: 'a clientState_u program
6218522253e7 new mostly working version; Alloc nearly converted to "Rename"
paulson
parents: 8286
diff changeset
   217
    Network :: 'a systemState program
6218522253e7 new mostly working version; Alloc nearly converted to "Rename"
paulson
parents: 8286
diff changeset
   218
    System  :: 'a systemState program
6218522253e7 new mostly working version; Alloc nearly converted to "Rename"
paulson
parents: 8286
diff changeset
   219
6827
b69a2585ec0f guar; locale for the spec
paulson
parents: 6815
diff changeset
   220
  assumes
b69a2585ec0f guar; locale for the spec
paulson
parents: 6815
diff changeset
   221
    Alloc   "Alloc   : alloc_spec"
b69a2585ec0f guar; locale for the spec
paulson
parents: 6815
diff changeset
   222
    Client  "Client  : client_spec"
b69a2585ec0f guar; locale for the spec
paulson
parents: 6815
diff changeset
   223
    Network "Network : network_spec"
b69a2585ec0f guar; locale for the spec
paulson
parents: 6815
diff changeset
   224
b69a2585ec0f guar; locale for the spec
paulson
parents: 6815
diff changeset
   225
  defines
b69a2585ec0f guar; locale for the spec
paulson
parents: 6815
diff changeset
   226
    System_def
8311
6218522253e7 new mostly working version; Alloc nearly converted to "Rename"
paulson
parents: 8286
diff changeset
   227
      "System == rename sysOfAlloc Alloc
6218522253e7 new mostly working version; Alloc nearly converted to "Rename"
paulson
parents: 8286
diff changeset
   228
                 Join
6218522253e7 new mostly working version; Alloc nearly converted to "Rename"
paulson
parents: 8286
diff changeset
   229
                 Network
6218522253e7 new mostly working version; Alloc nearly converted to "Rename"
paulson
parents: 8286
diff changeset
   230
                 Join
6218522253e7 new mostly working version; Alloc nearly converted to "Rename"
paulson
parents: 8286
diff changeset
   231
                 (rename sysOfClient
8985
13ad7ce031bb restored some of the lessThans
paulson
parents: 8930
diff changeset
   232
		  (plam x: lessThan Nclients. rename client_map Client))"
8311
6218522253e7 new mostly working version; Alloc nearly converted to "Rename"
paulson
parents: 8286
diff changeset
   233
**)
8286
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
   234
d4b895d3afa7 not working yet. partial conversion to use "rename" instead of "extend"
paulson
parents: 8122
diff changeset
   235
6815
de4d358bf01e The Allocator example: specifications
paulson
parents:
diff changeset
   236
end