6828
|
1 |
(* Title: HOL/UNITY/Alloc
|
|
2 |
ID: $Id$
|
|
3 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory
|
|
4 |
Copyright 1998 University of Cambridge
|
|
5 |
|
|
6 |
Specification of Chandy and Charpentier's Allocator
|
|
7 |
*)
|
|
8 |
|
6815
|
9 |
Addsimps [sub_def];
|
6828
|
10 |
|
|
11 |
Goalw [sysOfAlloc_def] "inj sysOfAlloc";
|
|
12 |
by (rtac injI 1);
|
|
13 |
by Auto_tac;
|
|
14 |
qed "inj_sysOfAlloc";
|
|
15 |
|
|
16 |
Goalw [sysOfAlloc_def] "surj sysOfAlloc";
|
|
17 |
by (res_inst_tac [("f", "%s. ((| allocGiv = allocGiv s, \
|
|
18 |
\ allocAsk = allocAsk s, \
|
|
19 |
\ allocRel = allocRel s |), \
|
|
20 |
\ client s)")] surjI 1);
|
|
21 |
by Auto_tac;
|
|
22 |
qed "surj_sysOfAlloc";
|
|
23 |
|
|
24 |
AddIffs [inj_sysOfAlloc, surj_sysOfAlloc];
|
|
25 |
|
|
26 |
|
|
27 |
Open_locale "System";
|
|
28 |
|
|
29 |
val Alloc = thm "Alloc";
|
|
30 |
val Client = thm "Client";
|
|
31 |
val Network = thm "Network";
|
|
32 |
val System_def = thm "System_def";
|
|
33 |
|
|
34 |
AddIffs [finite_lessThan];
|
|
35 |
|
|
36 |
(*could move to PPROD.ML, but function "sub" is needed there*)
|
|
37 |
Goal "lift_set i {s. P (f s)} = {s. P (f (sub i s))}";
|
|
38 |
by (asm_simp_tac (simpset() addsimps [lift_set_def]) 1);
|
|
39 |
qed "lift_set_sub";
|
|
40 |
|
|
41 |
(*ONE OF THESE IS REDUNDANT!*)
|
|
42 |
Goal "lift_set i {s. P (f s)} = {s. P (f (s i))}";
|
|
43 |
by (asm_simp_tac (simpset() addsimps [lift_set_def]) 1);
|
|
44 |
qed "lift_set_sub2";
|
|
45 |
|
|
46 |
Goalw [Increasing_def]
|
|
47 |
"[| i: I; finite I |] \
|
|
48 |
\ ==> ((PPI x:I. F) : Increasing (f o sub i)) = (F : Increasing f)";
|
|
49 |
by (subgoal_tac "ALL z. {s. z <= (f o sub i) s} = lift_set i {s. z <= f s}" 1);
|
|
50 |
by (asm_simp_tac (simpset() addsimps [lift_set_sub]) 2);
|
|
51 |
by (asm_full_simp_tac (simpset() addsimps [PFUN_Stable]) 1);
|
|
52 |
qed "PFUN_Increasing";
|
|
53 |
|
|
54 |
(*FUN.ML*)
|
|
55 |
(*left-to-right inclusion holds even if I is empty*)
|
|
56 |
Goalw [inj_on_def]
|
|
57 |
"[| inj_on f C; ALL i:I. B i <= C; j:I |] \
|
|
58 |
\ ==> f `` (INT i:I. B i) = (INT i:I. f `` B i)";
|
|
59 |
by (Blast_tac 1);
|
|
60 |
qed "inj_on_image_INT";
|
|
61 |
|
|
62 |
|
|
63 |
|
|
64 |
Goal "lift_prog i `` Increasing f <= Increasing (f o sub i)";
|
|
65 |
by (asm_simp_tac
|
|
66 |
(simpset() addsimps [Increasing_def,
|
|
67 |
inj_lift_prog RS inj_on_image_INT]) 1);
|
|
68 |
auto();
|
|
69 |
by (dres_inst_tac [("x","z")] spec 1);
|
|
70 |
auto();
|
|
71 |
by (asm_simp_tac (simpset() addsimps [lift_set_sub2 RS sym,
|
|
72 |
lift_prog_Stable_eq]) 1);
|
|
73 |
qed "image_lift_prog_Increasing";
|
|
74 |
|
|
75 |
|
|
76 |
Goal "i < Nclients ==> \
|
|
77 |
\ lift_prog i Client : range (lift_prog i) guar Increasing (rel o sub i)";
|
|
78 |
|
|
79 |
|
|
80 |
|
|
81 |
Goal "i < Nclients ==> System : Increasing (sub i o allocRel)";
|
|
82 |
by (cut_facts_tac [Client] 1);
|
|
83 |
by (full_simp_tac
|
|
84 |
(simpset() addsimps [System_def,
|
|
85 |
client_spec_def, client_increasing_def,
|
|
86 |
guarantees_Int_right]) 1);
|
|
87 |
by Auto_tac;
|
|
88 |
by (dtac lift_prog_guarantees 1);
|
|
89 |
by (dtac (UNIV_I RSN (2, guaranteesD)) 1);
|
|
90 |
back();
|
|
91 |
by (dtac (lessThan_iff RS iffD2 RS PFUN_Increasing RS iffD2) 1);
|
|
92 |
by Auto_tac;
|
|
93 |
|
|
94 |
|
|
95 |
by (full_simp_tac (simpset() addsimps [read_instantiate [("f1","rel"),("I1","lessThan Nclients")] (PFUN_Increasing RS sym)]) 1);
|
|
96 |
|
|
97 |
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx;
|
|
98 |
|
|
99 |
|
|
100 |
Goal "System : system_spec";
|
|
101 |
|
|
102 |
by (full_simp_tac
|
|
103 |
(simpset() addsimps [alloc_spec_def, alloc_safety_def, System_def]) 1);
|
|
104 |
|
|
105 |
|
|
106 |
|
|
107 |
|
|
108 |
|
|
109 |
|
|
110 |
(*partial system...*)
|
|
111 |
Goal "[| Alloc : alloc_spec; Network : network_spec |] \
|
|
112 |
\ ==> (extend sysOfAlloc Alloc) Join Network : system_spec";
|
|
113 |
|
|
114 |
(*partial system...*)
|
|
115 |
Goal "[| Client : client_spec; Network : network_spec |] \
|
|
116 |
\ ==> (extend sysOfClient (PPI x: lessThan Nclients. Client)) \
|
|
117 |
\ Join Network : system_spec";
|
|
118 |
|
|
119 |
|
|
120 |
|
|
121 |
Goal "[| Alloc : alloc_spec; Client : client_spec; \
|
|
122 |
\ Network : network_spec |] \
|
|
123 |
\ ==> (extend sysOfAlloc Alloc) \
|
|
124 |
\ Join (extend sysOfClient (PPI x: lessThan Nclients. Client)) \
|
|
125 |
\ Join Network : system_spec";
|
|
126 |
by (full_simp_tac
|
|
127 |
(simpset() addsimps [system_spec_def, system_safety_def]) 1);
|
|
128 |
by Auto_tac;
|
|
129 |
by (full_simp_tac
|
|
130 |
(simpset() addsimps [client_spec_def, client_increasing_def,
|
|
131 |
guarantees_Int_right]) 1);
|
|
132 |
by Auto_tac;
|
|
133 |
by (dtac (UNIV_I RSN (2, guaranteesD)) 1);
|
|
134 |
back();
|
|
135 |
by (full_simp_tac
|
|
136 |
(simpset() addsimps [network_spec_def, network_rel_def]) 1);
|
|
137 |
|
|
138 |
by (subgoal_tac "" 1);
|
|
139 |
by (full_simp_tac
|
|
140 |
(simpset() addsimps [alloc_spec_def, alloc_safety_def]) 1);
|
|
141 |
by Auto_tac;
|
|
142 |
|
|
143 |
by (Simp_tac 1);
|
|
144 |
|
|
145 |
|
|
146 |
|
|
147 |
|
|
148 |
(*Generalized version allowing different clients*)
|
|
149 |
Goal "[| Alloc : alloc_spec; \
|
|
150 |
\ Client : (lessThan Nclients) funcset client_spec; \
|
|
151 |
\ Network : network_spec |] \
|
|
152 |
\ ==> (extend sysOfAlloc Alloc) \
|
|
153 |
\ Join (extend sysOfClient (PPROD (lessThan Nclients) Client)) \
|
|
154 |
\ Join Network : system_spec";
|
|
155 |
|