14052
|
1 |
(* Title: ZF/UNITY/Distributor
|
|
2 |
ID: $Id$
|
|
3 |
Author: Sidi O Ehmety, Cambridge University Computer Laboratory
|
|
4 |
Copyright 2002 University of Cambridge
|
|
5 |
|
|
6 |
A multiple-client allocator from a single-client allocator:
|
|
7 |
Distributor specification
|
|
8 |
*)
|
|
9 |
Distributor = AllocBase + Follows + Guar + GenPrefix +
|
|
10 |
(** Distributor specification (the number of outputs is Nclients) ***)
|
|
11 |
(*spec (14)*)
|
|
12 |
constdefs
|
|
13 |
distr_follows :: [i, i, i, i =>i] =>i
|
|
14 |
"distr_follows(A, In, iIn, Out) ==
|
|
15 |
(lift(In) IncreasingWrt prefix(A)/list(A)) Int
|
|
16 |
(lift(iIn) IncreasingWrt prefix(nat)/list(nat)) Int
|
|
17 |
Always({s:state. ALL elt: set_of_list(s`iIn). elt < Nclients})
|
|
18 |
guarantees
|
|
19 |
(INT n: Nclients.
|
|
20 |
lift(Out(n))
|
|
21 |
Fols
|
|
22 |
(%s. sublist(s`In,
|
|
23 |
{k:nat. k<length(s`iIn) & nth(k, s`iIn) = n}))
|
|
24 |
Wrt prefix(A)/list(A))"
|
|
25 |
|
|
26 |
distr_allowed_acts :: [i=>i]=>i
|
|
27 |
"distr_allowed_acts(Out) ==
|
|
28 |
{D:program. AllowedActs(D) =
|
|
29 |
cons(id(state), UN G:(INT n:nat. preserves(lift(Out(n)))). Acts(G))}"
|
|
30 |
|
|
31 |
distr_spec :: [i, i, i, i =>i]=>i
|
|
32 |
"distr_spec(A, In, iIn, Out) ==
|
|
33 |
distr_follows(A, In, iIn, Out) Int distr_allowed_acts(Out)"
|
|
34 |
|
|
35 |
locale Distributor =
|
|
36 |
fixes In :: i (*items to distribute*)
|
|
37 |
iIn :: i (*destinations of items to distribute*)
|
|
38 |
Out :: i=>i (*distributed items*)
|
|
39 |
A :: i (*the type of items being distributed *)
|
|
40 |
D :: i
|
|
41 |
assumes
|
|
42 |
var_assumes "In:var & iIn:var & (ALL n. Out(n):var)"
|
|
43 |
all_distinct_vars "ALL n. all_distinct([In, iIn, iOut(n)])"
|
|
44 |
type_assumes "type_of(In)=list(A) & type_of(iIn)=list(nat) &
|
|
45 |
(ALL n. type_of(Out(n))=list(A))"
|
|
46 |
default_val_assumes "default_val(In)=Nil &
|
|
47 |
default_val(iIn)=Nil &
|
|
48 |
(ALL n. default_val(Out(n))=Nil)"
|
|
49 |
distr_spec "D:distr_spec(A, In, iIn, Out)"
|
|
50 |
end
|