author | wenzelm |
Sat, 28 Jun 2008 21:21:13 +0200 | |
changeset 27381 | 19ae7064f00f |
parent 26289 | 9d2c375e242b |
child 32960 | 69916a850301 |
permissions | -rw-r--r-- |
26289 | 1 |
(* Title: ZF/UNITY/AllocImpl.thy |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
2 |
ID: $Id$ |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
3 |
Author: Sidi O Ehmety, Cambridge University Computer Laboratory |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
4 |
Copyright 2002 University of Cambridge |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
5 |
|
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
6 |
Single-client allocator implementation |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
7 |
Charpentier and Chandy, section 7 (page 17). |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
8 |
*) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
9 |
|
16417 | 10 |
theory AllocImpl imports ClientImpl begin |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
11 |
|
24892 | 12 |
abbreviation |
13 |
NbR :: i (*number of consumed messages*) where |
|
14 |
"NbR == Var([succ(2)])" |
|
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
15 |
|
24892 | 16 |
abbreviation |
17 |
available_tok :: i (*number of free tokens (T in paper)*) where |
|
18 |
"available_tok == Var([succ(succ(2))])" |
|
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
19 |
|
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
20 |
axioms |
14071 | 21 |
alloc_type_assumes [simp]: |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
22 |
"type_of(NbR) = nat & type_of(available_tok)=nat" |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
23 |
|
14071 | 24 |
alloc_default_val_assumes [simp]: |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
25 |
"default_val(NbR) = 0 & default_val(available_tok)=0" |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
26 |
|
24893 | 27 |
definition |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
28 |
"alloc_giv_act == |
14072
f932be305381
Conversion of UNITY/Distributor to Isar script. General tidy-up.
paulson
parents:
14071
diff
changeset
|
29 |
{<s, t> \<in> state*state. |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
30 |
\<exists>k. k = length(s`giv) & |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
31 |
t = s(giv := s`giv @ [nth(k, s`ask)], |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
32 |
available_tok := s`available_tok #- nth(k, s`ask)) & |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
33 |
k < length(s`ask) & nth(k, s`ask) le s`available_tok}" |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
34 |
|
24893 | 35 |
definition |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
36 |
"alloc_rel_act == |
14072
f932be305381
Conversion of UNITY/Distributor to Isar script. General tidy-up.
paulson
parents:
14071
diff
changeset
|
37 |
{<s, t> \<in> state*state. |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
38 |
t = s(available_tok := s`available_tok #+ nth(s`NbR, s`rel), |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
39 |
NbR := succ(s`NbR)) & |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
40 |
s`NbR < length(s`rel)}" |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
41 |
|
24893 | 42 |
definition |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
43 |
(*The initial condition s`giv=[] is missing from the |
14072
f932be305381
Conversion of UNITY/Distributor to Isar script. General tidy-up.
paulson
parents:
14071
diff
changeset
|
44 |
original definition: S. O. Ehmety *) |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
45 |
"alloc_prog == |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
46 |
mk_program({s:state. s`available_tok=NbT & s`NbR=0 & s`giv=Nil}, |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
47 |
{alloc_giv_act, alloc_rel_act}, |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
48 |
\<Union>G \<in> preserves(lift(available_tok)) \<inter> |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
49 |
preserves(lift(NbR)) \<inter> |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
50 |
preserves(lift(giv)). Acts(G))" |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
51 |
|
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
52 |
|
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
53 |
lemma available_tok_value_type [simp,TC]: "s\<in>state ==> s`available_tok \<in> nat" |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
54 |
apply (unfold state_def) |
14071 | 55 |
apply (drule_tac a = available_tok in apply_type, auto) |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
56 |
done |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
57 |
|
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
58 |
lemma NbR_value_type [simp,TC]: "s\<in>state ==> s`NbR \<in> nat" |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
59 |
apply (unfold state_def) |
14071 | 60 |
apply (drule_tac a = NbR in apply_type, auto) |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
61 |
done |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
62 |
|
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
63 |
(** The Alloc Program **) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
64 |
|
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
65 |
lemma alloc_prog_type [simp,TC]: "alloc_prog \<in> program" |
14071 | 66 |
by (simp add: alloc_prog_def) |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
67 |
|
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
68 |
declare alloc_prog_def [THEN def_prg_Init, simp] |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
69 |
declare alloc_prog_def [THEN def_prg_AllowedActs, simp] |
24051
896fb015079c
replaced program_defs_ref by proper context data (via attribute "program");
wenzelm
parents:
16417
diff
changeset
|
70 |
declare alloc_prog_def [program] |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
71 |
|
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
72 |
declare alloc_giv_act_def [THEN def_act_simp, simp] |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
73 |
declare alloc_rel_act_def [THEN def_act_simp, simp] |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
74 |
|
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
75 |
|
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
76 |
lemma alloc_prog_ok_iff: |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
77 |
"\<forall>G \<in> program. (alloc_prog ok G) <-> |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
78 |
(G \<in> preserves(lift(giv)) & G \<in> preserves(lift(available_tok)) & |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
79 |
G \<in> preserves(lift(NbR)) & alloc_prog \<in> Allowed(G))" |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
80 |
by (auto simp add: ok_iff_Allowed alloc_prog_def [THEN def_prg_Allowed]) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
81 |
|
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
82 |
|
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
83 |
lemma alloc_prog_preserves: |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
84 |
"alloc_prog \<in> (\<Inter>x \<in> var-{giv, available_tok, NbR}. preserves(lift(x)))" |
14071 | 85 |
apply (rule Inter_var_DiffI, force) |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
86 |
apply (rule ballI) |
16183
052d9aba392d
renamed "constrains" to "safety" to avoid keyword clash
paulson
parents:
15481
diff
changeset
|
87 |
apply (rule preservesI, safety) |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
88 |
done |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
89 |
|
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
90 |
(* As a special case of the rule above *) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
91 |
|
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
92 |
lemma alloc_prog_preserves_rel_ask_tok: |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
93 |
"alloc_prog \<in> |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
94 |
preserves(lift(rel)) \<inter> preserves(lift(ask)) \<inter> preserves(lift(tok))" |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
95 |
apply auto |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
96 |
apply (insert alloc_prog_preserves) |
14071 | 97 |
apply (drule_tac [3] x = tok in Inter_var_DiffD) |
98 |
apply (drule_tac [2] x = ask in Inter_var_DiffD) |
|
99 |
apply (drule_tac x = rel in Inter_var_DiffD, auto) |
|
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
100 |
done |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
101 |
|
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
102 |
lemma alloc_prog_Allowed: |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
103 |
"Allowed(alloc_prog) = |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
104 |
preserves(lift(giv)) \<inter> preserves(lift(available_tok)) \<inter> preserves(lift(NbR))" |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
105 |
apply (cut_tac v="lift(giv)" in preserves_type) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
106 |
apply (auto simp add: Allowed_def client_prog_def [THEN def_prg_Allowed] |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
107 |
cons_Int_distrib safety_prop_Acts_iff) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
108 |
done |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
109 |
|
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
110 |
(* In particular we have *) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
111 |
lemma alloc_prog_ok_client_prog: "alloc_prog ok client_prog" |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
112 |
apply (auto simp add: ok_iff_Allowed) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
113 |
apply (cut_tac alloc_prog_preserves) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
114 |
apply (cut_tac [2] client_prog_preserves) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
115 |
apply (auto simp add: alloc_prog_Allowed client_prog_Allowed) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
116 |
apply (drule_tac [6] B = "preserves (lift (NbR))" in InterD) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
117 |
apply (drule_tac [5] B = "preserves (lift (available_tok))" in InterD) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
118 |
apply (drule_tac [4] B = "preserves (lift (giv))" in InterD) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
119 |
apply (drule_tac [3] B = "preserves (lift (tok))" in InterD) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
120 |
apply (drule_tac [2] B = "preserves (lift (ask))" in InterD) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
121 |
apply (drule_tac B = "preserves (lift (rel))" in InterD) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
122 |
apply auto |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
123 |
done |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
124 |
|
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
125 |
(** Safety property: (28) **) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
126 |
lemma alloc_prog_Increasing_giv: "alloc_prog \<in> program guarantees Incr(lift(giv))" |
26289 | 127 |
apply (auto intro!: increasing_imp_Increasing simp add: guar_def |
128 |
Increasing.increasing_def alloc_prog_ok_iff alloc_prog_Allowed, safety+) |
|
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
129 |
apply (auto dest: ActsD) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
130 |
apply (drule_tac f = "lift (giv) " in preserves_imp_eq) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
131 |
apply auto |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
132 |
done |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
133 |
|
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
134 |
lemma giv_Bounded_lamma1: |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
135 |
"alloc_prog \<in> stable({s\<in>state. s`NbR \<le> length(s`rel)} \<inter> |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
136 |
{s\<in>state. s`available_tok #+ tokens(s`giv) = |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
137 |
NbT #+ tokens(take(s`NbR, s`rel))})" |
16183
052d9aba392d
renamed "constrains" to "safety" to avoid keyword clash
paulson
parents:
15481
diff
changeset
|
138 |
apply safety |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
139 |
apply auto |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
140 |
apply (simp add: diff_add_0 add_commute diff_add_inverse add_assoc add_diff_inverse) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
141 |
apply (simp (no_asm_simp) add: take_succ) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
142 |
done |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
143 |
|
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
144 |
lemma giv_Bounded_lemma2: |
14072
f932be305381
Conversion of UNITY/Distributor to Isar script. General tidy-up.
paulson
parents:
14071
diff
changeset
|
145 |
"[| G \<in> program; alloc_prog ok G; alloc_prog \<squnion> G \<in> Incr(lift(rel)) |] |
f932be305381
Conversion of UNITY/Distributor to Isar script. General tidy-up.
paulson
parents:
14071
diff
changeset
|
146 |
==> alloc_prog \<squnion> G \<in> Stable({s\<in>state. s`NbR \<le> length(s`rel)} \<inter> |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
147 |
{s\<in>state. s`available_tok #+ tokens(s`giv) = |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
148 |
NbT #+ tokens(take(s`NbR, s`rel))})" |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
149 |
apply (cut_tac giv_Bounded_lamma1) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
150 |
apply (cut_tac alloc_prog_preserves_rel_ask_tok) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
151 |
apply (auto simp add: Collect_conj_eq [symmetric] alloc_prog_ok_iff) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
152 |
apply (subgoal_tac "G \<in> preserves (fun_pair (lift (available_tok), fun_pair (lift (NbR), lift (giv))))") |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
153 |
apply (rotate_tac -1) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
154 |
apply (cut_tac A = "nat * nat * list(nat)" |
14071 | 155 |
and P = "%<m,n,l> y. n \<le> length(y) & |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
156 |
m #+ tokens(l) = NbT #+ tokens(take(n,y))" |
14071 | 157 |
and g = "lift(rel)" and F = alloc_prog |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
158 |
in stable_Join_Stable) |
14071 | 159 |
prefer 3 apply assumption |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
160 |
apply (auto simp add: Collect_conj_eq) |
14071 | 161 |
apply (frule_tac g = length in imp_Increasing_comp) |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
162 |
apply (blast intro: mono_length) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
163 |
apply (auto simp add: refl_prefix) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
164 |
apply (drule_tac a=xa and f = "length comp lift(rel)" in Increasing_imp_Stable) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
165 |
apply assumption |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
166 |
apply (auto simp add: Le_def length_type) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
167 |
apply (auto dest: ActsD simp add: Stable_def Constrains_def constrains_def) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
168 |
apply (drule_tac f = "lift (rel) " in preserves_imp_eq) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
169 |
apply assumption+ |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
170 |
apply (force dest: ActsD) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
171 |
apply (erule_tac V = "\<forall>x \<in> Acts (alloc_prog) Un Acts (G). ?P(x)" in thin_rl) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
172 |
apply (erule_tac V = "alloc_prog \<in> stable (?u)" in thin_rl) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
173 |
apply (drule_tac a = "xc`rel" and f = "lift (rel)" in Increasing_imp_Stable) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
174 |
apply (auto simp add: Stable_def Constrains_def constrains_def) |
14071 | 175 |
apply (drule bspec, force) |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
176 |
apply (drule subsetD) |
14071 | 177 |
apply (rule imageI, assumption) |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
178 |
apply (auto simp add: prefix_take_iff) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
179 |
apply (rotate_tac -1) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
180 |
apply (erule ssubst) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
181 |
apply (auto simp add: take_take min_def) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
182 |
done |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
183 |
|
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
184 |
(*Property (29), page 18: |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
185 |
the number of tokens in circulation never exceeds NbT*) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
186 |
lemma alloc_prog_giv_Bounded: "alloc_prog \<in> Incr(lift(rel)) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
187 |
guarantees Always({s\<in>state. tokens(s`giv) \<le> NbT #+ tokens(s`rel)})" |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
188 |
apply (cut_tac NbT_pos) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
189 |
apply (auto simp add: guar_def) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
190 |
apply (rule Always_weaken) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
191 |
apply (rule AlwaysI) |
14071 | 192 |
apply (rule_tac [2] giv_Bounded_lemma2, auto) |
193 |
apply (rule_tac j = "NbT #+ tokens(take (x` NbR, x`rel))" in le_trans) |
|
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
194 |
apply (erule subst) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
195 |
apply (auto intro!: tokens_mono simp add: prefix_take_iff min_def length_take) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
196 |
done |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
197 |
|
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
198 |
(*Property (30), page 18: the number of tokens given never exceeds the number |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
199 |
asked for*) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
200 |
lemma alloc_prog_ask_prefix_giv: |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
201 |
"alloc_prog \<in> Incr(lift(ask)) guarantees |
14072
f932be305381
Conversion of UNITY/Distributor to Isar script. General tidy-up.
paulson
parents:
14071
diff
changeset
|
202 |
Always({s\<in>state. <s`giv, s`ask> \<in> prefix(tokbag)})" |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
203 |
apply (auto intro!: AlwaysI simp add: guar_def) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
204 |
apply (subgoal_tac "G \<in> preserves (lift (giv))") |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
205 |
prefer 2 apply (simp add: alloc_prog_ok_iff) |
14072
f932be305381
Conversion of UNITY/Distributor to Isar script. General tidy-up.
paulson
parents:
14071
diff
changeset
|
206 |
apply (rule_tac P = "%x y. <x,y> \<in> prefix(tokbag)" and A = "list(nat)" |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
207 |
in stable_Join_Stable) |
16183
052d9aba392d
renamed "constrains" to "safety" to avoid keyword clash
paulson
parents:
15481
diff
changeset
|
208 |
apply safety |
14071 | 209 |
prefer 2 apply (simp add: lift_def, clarify) |
210 |
apply (drule_tac a = k in Increasing_imp_Stable, auto) |
|
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
211 |
done |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
212 |
|
14071 | 213 |
subsection{* Towards proving the liveness property, (31) *} |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
214 |
|
14071 | 215 |
subsubsection{*First, we lead up to a proof of Lemma 49, page 28.*} |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
216 |
|
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
217 |
lemma alloc_prog_transient_lemma: |
14071 | 218 |
"[|G \<in> program; k\<in>nat|] |
14072
f932be305381
Conversion of UNITY/Distributor to Isar script. General tidy-up.
paulson
parents:
14071
diff
changeset
|
219 |
==> alloc_prog \<squnion> G \<in> |
14071 | 220 |
transient({s\<in>state. k \<le> length(s`rel)} \<inter> |
221 |
{s\<in>state. succ(s`NbR) = k})" |
|
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
222 |
apply auto |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
223 |
apply (erule_tac V = "G\<notin>?u" in thin_rl) |
14071 | 224 |
apply (rule_tac act = alloc_rel_act in transientI) |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
225 |
apply (simp (no_asm) add: alloc_prog_def [THEN def_prg_Acts]) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
226 |
apply (simp (no_asm) add: alloc_rel_act_def [THEN def_act_eq, THEN act_subset]) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
227 |
apply (auto simp add: alloc_prog_def [THEN def_prg_Acts] domain_def) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
228 |
apply (rule ReplaceI) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
229 |
apply (rule_tac x = "x (available_tok:= x`available_tok #+ nth (x`NbR, x`rel), |
14071 | 230 |
NbR:=succ (x`NbR))" |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
231 |
in exI) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
232 |
apply (auto intro!: state_update_type) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
233 |
done |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
234 |
|
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
235 |
lemma alloc_prog_rel_Stable_NbR_lemma: |
14071 | 236 |
"[| G \<in> program; alloc_prog ok G; k\<in>nat |] |
14072
f932be305381
Conversion of UNITY/Distributor to Isar script. General tidy-up.
paulson
parents:
14071
diff
changeset
|
237 |
==> alloc_prog \<squnion> G \<in> Stable({s\<in>state . k \<le> succ(s ` NbR)})" |
16183
052d9aba392d
renamed "constrains" to "safety" to avoid keyword clash
paulson
parents:
15481
diff
changeset
|
238 |
apply (auto intro!: stable_imp_Stable simp add: alloc_prog_ok_iff, safety, auto) |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
239 |
apply (blast intro: le_trans leI) |
14071 | 240 |
apply (drule_tac f = "lift (NbR)" and A = nat in preserves_imp_increasing) |
241 |
apply (drule_tac [2] g = succ in imp_increasing_comp) |
|
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
242 |
apply (rule_tac [2] mono_succ) |
14071 | 243 |
apply (drule_tac [4] x = k in increasing_imp_stable) |
244 |
prefer 5 apply (simp add: Le_def comp_def, auto) |
|
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
245 |
done |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
246 |
|
14071 | 247 |
lemma alloc_prog_NbR_LeadsTo_lemma: |
248 |
"[| G \<in> program; alloc_prog ok G; |
|
14072
f932be305381
Conversion of UNITY/Distributor to Isar script. General tidy-up.
paulson
parents:
14071
diff
changeset
|
249 |
alloc_prog \<squnion> G \<in> Incr(lift(rel)); k\<in>nat |] |
f932be305381
Conversion of UNITY/Distributor to Isar script. General tidy-up.
paulson
parents:
14071
diff
changeset
|
250 |
==> alloc_prog \<squnion> G \<in> |
14071 | 251 |
{s\<in>state. k \<le> length(s`rel)} \<inter> {s\<in>state. succ(s`NbR) = k} |
252 |
LeadsTo {s\<in>state. k \<le> s`NbR}" |
|
14072
f932be305381
Conversion of UNITY/Distributor to Isar script. General tidy-up.
paulson
parents:
14071
diff
changeset
|
253 |
apply (subgoal_tac "alloc_prog \<squnion> G \<in> Stable ({s\<in>state. k \<le> length (s`rel)})") |
14071 | 254 |
apply (drule_tac [2] a = k and g1 = length in imp_Increasing_comp [THEN Increasing_imp_Stable]) |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
255 |
apply (rule_tac [2] mono_length) |
14071 | 256 |
prefer 3 apply simp |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
257 |
apply (simp_all add: refl_prefix Le_def comp_def length_type) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
258 |
apply (rule LeadsTo_weaken) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
259 |
apply (rule PSP_Stable) |
14071 | 260 |
prefer 2 apply assumption |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
261 |
apply (rule PSP_Stable) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
262 |
apply (rule_tac [2] alloc_prog_rel_Stable_NbR_lemma) |
14071 | 263 |
apply (rule alloc_prog_transient_lemma [THEN transient_imp_leadsTo, THEN leadsTo_imp_LeadsTo], assumption+) |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
264 |
apply (auto dest: not_lt_imp_le elim: lt_asym simp add: le_iff) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
265 |
done |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
266 |
|
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
267 |
lemma alloc_prog_NbR_LeadsTo_lemma2 [rule_format]: |
14072
f932be305381
Conversion of UNITY/Distributor to Isar script. General tidy-up.
paulson
parents:
14071
diff
changeset
|
268 |
"[| G \<in> program; alloc_prog ok G; alloc_prog \<squnion> G \<in> Incr(lift(rel)); |
14071 | 269 |
k\<in>nat; n \<in> nat; n < k |] |
14072
f932be305381
Conversion of UNITY/Distributor to Isar script. General tidy-up.
paulson
parents:
14071
diff
changeset
|
270 |
==> alloc_prog \<squnion> G \<in> |
14071 | 271 |
{s\<in>state . k \<le> length(s ` rel)} \<inter> {s\<in>state . s ` NbR = n} |
272 |
LeadsTo {x \<in> state. k \<le> length(x`rel)} \<inter> |
|
273 |
(\<Union>m \<in> greater_than(n). {x \<in> state. x ` NbR=m})" |
|
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
274 |
apply (unfold greater_than_def) |
14071 | 275 |
apply (rule_tac A' = "{x \<in> state. k \<le> length(x`rel)} \<inter> {x \<in> state. n < x`NbR}" |
276 |
in LeadsTo_weaken_R) |
|
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
277 |
apply safe |
14072
f932be305381
Conversion of UNITY/Distributor to Isar script. General tidy-up.
paulson
parents:
14071
diff
changeset
|
278 |
apply (subgoal_tac "alloc_prog \<squnion> G \<in> Stable ({s\<in>state. k \<le> length (s`rel) }) ") |
14071 | 279 |
apply (drule_tac [2] a = k and g1 = length in imp_Increasing_comp [THEN Increasing_imp_Stable]) |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
280 |
apply (rule_tac [2] mono_length) |
14071 | 281 |
prefer 3 apply simp |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
282 |
apply (simp_all add: refl_prefix Le_def comp_def length_type) |
15481 | 283 |
apply (subst Int_commute [of _ "{x \<in> state . n < x ` NbR}"]) |
284 |
apply (rule_tac A = "({s \<in> state . k \<le> length (s ` rel) } \<inter> |
|
285 |
{s\<in>state . s ` NbR = n}) \<inter> {s\<in>state. k \<le> length(s`rel)}" |
|
286 |
in LeadsTo_weaken_L) |
|
14071 | 287 |
apply (rule PSP_Stable, safe) |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
288 |
apply (rule_tac B = "{x \<in> state . n < length (x ` rel) } \<inter> {s\<in>state . s ` NbR = n}" in LeadsTo_Trans) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
289 |
apply (rule_tac [2] LeadsTo_weaken) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
290 |
apply (rule_tac [2] k = "succ (n)" in alloc_prog_NbR_LeadsTo_lemma) |
14071 | 291 |
apply simp_all |
292 |
apply (rule subset_imp_LeadsTo, auto) |
|
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
293 |
apply (blast intro: lt_trans2) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
294 |
done |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
295 |
|
14071 | 296 |
lemma Collect_vimage_eq: "u\<in>nat ==> {<s,f(s)>. s \<in> A} -`` u = {s\<in>A. f(s) < u}" |
297 |
by (force simp add: lt_def) |
|
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
298 |
|
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
299 |
(* Lemma 49, page 28 *) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
300 |
|
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
301 |
lemma alloc_prog_NbR_LeadsTo_lemma3: |
14072
f932be305381
Conversion of UNITY/Distributor to Isar script. General tidy-up.
paulson
parents:
14071
diff
changeset
|
302 |
"[|G \<in> program; alloc_prog ok G; alloc_prog \<squnion> G \<in> Incr(lift(rel)); |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
303 |
k\<in>nat|] |
14072
f932be305381
Conversion of UNITY/Distributor to Isar script. General tidy-up.
paulson
parents:
14071
diff
changeset
|
304 |
==> alloc_prog \<squnion> G \<in> |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
305 |
{s\<in>state. k \<le> length(s`rel)} LeadsTo {s\<in>state. k \<le> s`NbR}" |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
306 |
(* Proof by induction over the difference between k and n *) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
307 |
apply (rule_tac f = "\<lambda>s\<in>state. k #- s`NbR" in LessThan_induct) |
14071 | 308 |
apply (simp_all add: lam_def, auto) |
309 |
apply (rule single_LeadsTo_I, auto) |
|
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
310 |
apply (simp (no_asm_simp) add: Collect_vimage_eq) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
311 |
apply (rename_tac "s0") |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
312 |
apply (case_tac "s0`NbR < k") |
14071 | 313 |
apply (rule_tac [2] subset_imp_LeadsTo, safe) |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
314 |
apply (auto dest!: not_lt_imp_le) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
315 |
apply (rule LeadsTo_weaken) |
14071 | 316 |
apply (rule_tac n = "s0`NbR" in alloc_prog_NbR_LeadsTo_lemma2, safe) |
317 |
prefer 3 apply assumption |
|
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
318 |
apply (auto split add: nat_diff_split simp add: greater_than_def not_lt_imp_le not_le_iff_lt) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
319 |
apply (blast dest: lt_asym) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
320 |
apply (force dest: add_lt_elim2) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
321 |
done |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
322 |
|
14071 | 323 |
subsubsection{*Towards proving lemma 50, page 29*} |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
324 |
|
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
325 |
lemma alloc_prog_giv_Ensures_lemma: |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
326 |
"[| G \<in> program; k\<in>nat; alloc_prog ok G; |
14072
f932be305381
Conversion of UNITY/Distributor to Isar script. General tidy-up.
paulson
parents:
14071
diff
changeset
|
327 |
alloc_prog \<squnion> G \<in> Incr(lift(ask)) |] ==> |
f932be305381
Conversion of UNITY/Distributor to Isar script. General tidy-up.
paulson
parents:
14071
diff
changeset
|
328 |
alloc_prog \<squnion> G \<in> |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
329 |
{s\<in>state. nth(length(s`giv), s`ask) \<le> s`available_tok} \<inter> |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
330 |
{s\<in>state. k < length(s`ask)} \<inter> {s\<in>state. length(s`giv)=k} |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
331 |
Ensures {s\<in>state. ~ k <length(s`ask)} Un {s\<in>state. length(s`giv) \<noteq> k}" |
14071 | 332 |
apply (rule EnsuresI, auto) |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
333 |
apply (erule_tac [2] V = "G\<notin>?u" in thin_rl) |
14071 | 334 |
apply (rule_tac [2] act = alloc_giv_act in transientI) |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
335 |
prefer 2 |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
336 |
apply (simp add: alloc_prog_def [THEN def_prg_Acts]) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
337 |
apply (simp add: alloc_giv_act_def [THEN def_act_eq, THEN act_subset]) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
338 |
apply (auto simp add: alloc_prog_def [THEN def_prg_Acts] domain_def) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
339 |
apply (erule_tac [2] swap) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
340 |
apply (rule_tac [2] ReplaceI) |
14071 | 341 |
apply (rule_tac [2] x = "x (giv := x ` giv @ [nth (length(x`giv), x ` ask) ], available_tok := x ` available_tok #- nth (length(x`giv), x ` ask))" in exI) |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
342 |
apply (auto intro!: state_update_type simp add: app_type) |
14071 | 343 |
apply (rule_tac A = "{s\<in>state . nth (length(s ` giv), s ` ask) \<le> s ` available_tok} \<inter> {s\<in>state . k < length(s ` ask) } \<inter> {s\<in>state. length(s`giv) =k}" and A' = "{s\<in>state . nth (length(s ` giv), s ` ask) \<le> s ` available_tok} Un {s\<in>state. ~ k < length(s`ask) } Un {s\<in>state . length(s ` giv) \<noteq> k}" in Constrains_weaken) |
344 |
apply (auto dest: ActsD simp add: Constrains_def constrains_def alloc_prog_def [THEN def_prg_Acts] alloc_prog_ok_iff) |
|
345 |
apply (subgoal_tac "length(xa ` giv @ [nth (length(xa ` giv), xa ` ask) ]) = length(xa ` giv) #+ 1") |
|
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
346 |
apply (rule_tac [2] trans) |
14071 | 347 |
apply (rule_tac [2] length_app, auto) |
348 |
apply (rule_tac j = "xa ` available_tok" in le_trans, auto) |
|
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
349 |
apply (drule_tac f = "lift (available_tok)" in preserves_imp_eq) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
350 |
apply assumption+ |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
351 |
apply auto |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
352 |
apply (drule_tac a = "xa ` ask" and r = "prefix(tokbag)" and A = "list(tokbag)" |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
353 |
in Increasing_imp_Stable) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
354 |
apply (auto simp add: prefix_iff) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
355 |
apply (drule StableD) |
14071 | 356 |
apply (auto simp add: Constrains_def constrains_def, force) |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
357 |
done |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
358 |
|
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
359 |
lemma alloc_prog_giv_Stable_lemma: |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
360 |
"[| G \<in> program; alloc_prog ok G; k\<in>nat |] |
14072
f932be305381
Conversion of UNITY/Distributor to Isar script. General tidy-up.
paulson
parents:
14071
diff
changeset
|
361 |
==> alloc_prog \<squnion> G \<in> Stable({s\<in>state . k \<le> length(s`giv)})" |
16183
052d9aba392d
renamed "constrains" to "safety" to avoid keyword clash
paulson
parents:
15481
diff
changeset
|
362 |
apply (auto intro!: stable_imp_Stable simp add: alloc_prog_ok_iff, safety) |
14071 | 363 |
apply (auto intro: leI) |
364 |
apply (drule_tac f = "lift (giv)" and g = length in imp_preserves_comp) |
|
365 |
apply (drule_tac f = "length comp lift (giv)" and A = nat and r = Le in preserves_imp_increasing) |
|
366 |
apply (drule_tac [2] x = k in increasing_imp_stable) |
|
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
367 |
prefer 3 apply (simp add: Le_def comp_def) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
368 |
apply (auto simp add: length_type) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
369 |
done |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
370 |
|
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
371 |
(* Lemma 50, page 29 *) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
372 |
|
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
373 |
lemma alloc_prog_giv_LeadsTo_lemma: |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
374 |
"[| G \<in> program; alloc_prog ok G; |
14072
f932be305381
Conversion of UNITY/Distributor to Isar script. General tidy-up.
paulson
parents:
14071
diff
changeset
|
375 |
alloc_prog \<squnion> G \<in> Incr(lift(ask)); k\<in>nat |] |
f932be305381
Conversion of UNITY/Distributor to Isar script. General tidy-up.
paulson
parents:
14071
diff
changeset
|
376 |
==> alloc_prog \<squnion> G \<in> |
14071 | 377 |
{s\<in>state. nth(length(s`giv), s`ask) \<le> s`available_tok} \<inter> |
378 |
{s\<in>state. k < length(s`ask)} \<inter> |
|
379 |
{s\<in>state. length(s`giv) = k} |
|
380 |
LeadsTo {s\<in>state. k < length(s`giv)}" |
|
14072
f932be305381
Conversion of UNITY/Distributor to Isar script. General tidy-up.
paulson
parents:
14071
diff
changeset
|
381 |
apply (subgoal_tac "alloc_prog \<squnion> G \<in> {s\<in>state. nth (length(s`giv), s`ask) \<le> s`available_tok} \<inter> {s\<in>state. k < length(s`ask) } \<inter> {s\<in>state. length(s`giv) = k} LeadsTo {s\<in>state. ~ k <length(s`ask) } Un {s\<in>state. length(s`giv) \<noteq> k}") |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
382 |
prefer 2 apply (blast intro: alloc_prog_giv_Ensures_lemma [THEN LeadsTo_Basis]) |
14072
f932be305381
Conversion of UNITY/Distributor to Isar script. General tidy-up.
paulson
parents:
14071
diff
changeset
|
383 |
apply (subgoal_tac "alloc_prog \<squnion> G \<in> Stable ({s\<in>state. k < length(s`ask) }) ") |
14071 | 384 |
apply (drule PSP_Stable, assumption) |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
385 |
apply (rule LeadsTo_weaken) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
386 |
apply (rule PSP_Stable) |
14071 | 387 |
apply (rule_tac [2] k = k in alloc_prog_giv_Stable_lemma) |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
388 |
apply (auto simp add: le_iff) |
14071 | 389 |
apply (drule_tac a = "succ (k)" and g1 = length in imp_Increasing_comp [THEN Increasing_imp_Stable]) |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
390 |
apply (rule mono_length) |
14071 | 391 |
prefer 2 apply simp |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
392 |
apply (simp_all add: refl_prefix Le_def comp_def length_type) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
393 |
done |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
394 |
|
14076 | 395 |
|
396 |
text{*Lemma 51, page 29. |
|
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
397 |
This theorem states as invariant that if the number of |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
398 |
tokens given does not exceed the number returned, then the upper limit |
14076 | 399 |
(@{term NbT}) does not exceed the number currently available.*} |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
400 |
lemma alloc_prog_Always_lemma: |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
401 |
"[| G \<in> program; alloc_prog ok G; |
14072
f932be305381
Conversion of UNITY/Distributor to Isar script. General tidy-up.
paulson
parents:
14071
diff
changeset
|
402 |
alloc_prog \<squnion> G \<in> Incr(lift(ask)); |
f932be305381
Conversion of UNITY/Distributor to Isar script. General tidy-up.
paulson
parents:
14071
diff
changeset
|
403 |
alloc_prog \<squnion> G \<in> Incr(lift(rel)) |] |
f932be305381
Conversion of UNITY/Distributor to Isar script. General tidy-up.
paulson
parents:
14071
diff
changeset
|
404 |
==> alloc_prog \<squnion> G \<in> |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
405 |
Always({s\<in>state. tokens(s`giv) \<le> tokens(take(s`NbR, s`rel)) --> |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
406 |
NbT \<le> s`available_tok})" |
14076 | 407 |
apply (subgoal_tac |
408 |
"alloc_prog \<squnion> G |
|
409 |
\<in> Always ({s\<in>state. s`NbR \<le> length(s`rel) } \<inter> |
|
410 |
{s\<in>state. s`available_tok #+ tokens(s`giv) = |
|
411 |
NbT #+ tokens(take (s`NbR, s`rel))})") |
|
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
412 |
apply (rule_tac [2] AlwaysI) |
14071 | 413 |
apply (rule_tac [3] giv_Bounded_lemma2, auto) |
414 |
apply (rule Always_weaken, assumption, auto) |
|
415 |
apply (subgoal_tac "0 \<le> tokens(take (x ` NbR, x ` rel)) #- tokens(x`giv) ") |
|
14076 | 416 |
prefer 2 apply (force) |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
417 |
apply (subgoal_tac "x`available_tok = |
14071 | 418 |
NbT #+ (tokens(take(x`NbR,x`rel)) #- tokens(x`giv))") |
14076 | 419 |
apply (simp add: ); |
420 |
apply (auto split add: nat_diff_split dest: lt_trans2) |
|
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
421 |
done |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
422 |
|
14076 | 423 |
|
424 |
||
14071 | 425 |
subsubsection{* Main lemmas towards proving property (31)*} |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
426 |
|
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
427 |
lemma LeadsTo_strength_R: |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
428 |
"[| F \<in> C LeadsTo B'; F \<in> A-C LeadsTo B; B'<=B |] ==> F \<in> A LeadsTo B" |
14071 | 429 |
by (blast intro: LeadsTo_weaken LeadsTo_Un_Un) |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
430 |
|
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
431 |
lemma PSP_StableI: |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
432 |
"[| F \<in> Stable(C); F \<in> A - C LeadsTo B; |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
433 |
F \<in> A \<inter> C LeadsTo B Un (state - C) |] ==> F \<in> A LeadsTo B" |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
434 |
apply (rule_tac A = " (A-C) Un (A \<inter> C)" in LeadsTo_weaken_L) |
14071 | 435 |
prefer 2 apply blast |
436 |
apply (rule LeadsTo_Un, assumption) |
|
437 |
apply (blast intro: LeadsTo_weaken dest: PSP_Stable) |
|
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
438 |
done |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
439 |
|
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
440 |
lemma state_compl_eq [simp]: "state - {s\<in>state. P(s)} = {s\<in>state. ~P(s)}" |
14071 | 441 |
by auto |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
442 |
|
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
443 |
(*needed?*) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
444 |
lemma single_state_Diff_eq [simp]: "{s}-{x \<in> state. P(x)} = (if s\<in>state & P(s) then 0 else {s})" |
14071 | 445 |
by auto |
446 |
||
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
447 |
|
14071 | 448 |
locale alloc_progress = |
449 |
fixes G |
|
450 |
assumes Gprog [intro,simp]: "G \<in> program" |
|
451 |
and okG [iff]: "alloc_prog ok G" |
|
14072
f932be305381
Conversion of UNITY/Distributor to Isar script. General tidy-up.
paulson
parents:
14071
diff
changeset
|
452 |
and Incr_rel [intro]: "alloc_prog \<squnion> G \<in> Incr(lift(rel))" |
f932be305381
Conversion of UNITY/Distributor to Isar script. General tidy-up.
paulson
parents:
14071
diff
changeset
|
453 |
and Incr_ask [intro]: "alloc_prog \<squnion> G \<in> Incr(lift(ask))" |
f932be305381
Conversion of UNITY/Distributor to Isar script. General tidy-up.
paulson
parents:
14071
diff
changeset
|
454 |
and safety: "alloc_prog \<squnion> G |
14071 | 455 |
\<in> Always(\<Inter>k \<in> nat. {s\<in>state. nth(k, s`ask) \<le> NbT})" |
14072
f932be305381
Conversion of UNITY/Distributor to Isar script. General tidy-up.
paulson
parents:
14071
diff
changeset
|
456 |
and progress: "alloc_prog \<squnion> G |
14071 | 457 |
\<in> (\<Inter>k\<in>nat. {s\<in>state. k \<le> tokens(s`giv)} LeadsTo |
458 |
{s\<in>state. k \<le> tokens(s`rel)})" |
|
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
459 |
|
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
460 |
(*First step in proof of (31) -- the corrected version from Charpentier. |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
461 |
This lemma implies that if a client releases some tokens then the Allocator |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
462 |
will eventually recognize that they've been released.*) |
14071 | 463 |
lemma (in alloc_progress) tokens_take_NbR_lemma: |
464 |
"k \<in> tokbag |
|
14072
f932be305381
Conversion of UNITY/Distributor to Isar script. General tidy-up.
paulson
parents:
14071
diff
changeset
|
465 |
==> alloc_prog \<squnion> G \<in> |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
466 |
{s\<in>state. k \<le> tokens(s`rel)} |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
467 |
LeadsTo {s\<in>state. k \<le> tokens(take(s`NbR, s`rel))}" |
14071 | 468 |
apply (rule single_LeadsTo_I, safe) |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
469 |
apply (rule_tac a1 = "s`rel" in Increasing_imp_Stable [THEN PSP_StableI]) |
14071 | 470 |
apply (rule_tac [4] k1 = "length(s`rel)" in alloc_prog_NbR_LeadsTo_lemma3 [THEN LeadsTo_strength_R]) |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
471 |
apply (rule_tac [8] subset_imp_LeadsTo) |
14071 | 472 |
apply (auto intro!: Incr_rel) |
473 |
apply (rule_tac j = "tokens(take (length(s`rel), x`rel))" in le_trans) |
|
474 |
apply (rule_tac j = "tokens(take (length(s`rel), s`rel))" in le_trans) |
|
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
475 |
apply (auto intro!: tokens_mono take_mono simp add: prefix_iff) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
476 |
done |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
477 |
|
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
478 |
(*** Rest of proofs done by lcp ***) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
479 |
|
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
480 |
(*Second step in proof of (31): by LHS of the guarantee and transivity of |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
481 |
LeadsTo *) |
14071 | 482 |
lemma (in alloc_progress) tokens_take_NbR_lemma2: |
483 |
"k \<in> tokbag |
|
14072
f932be305381
Conversion of UNITY/Distributor to Isar script. General tidy-up.
paulson
parents:
14071
diff
changeset
|
484 |
==> alloc_prog \<squnion> G \<in> |
14071 | 485 |
{s\<in>state. tokens(s`giv) = k} |
486 |
LeadsTo {s\<in>state. k \<le> tokens(take(s`NbR, s`rel))}" |
|
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
487 |
apply (rule LeadsTo_Trans) |
14071 | 488 |
apply (rule_tac [2] tokens_take_NbR_lemma) |
489 |
prefer 2 apply assumption |
|
490 |
apply (insert progress) |
|
491 |
apply (blast intro: LeadsTo_weaken_L progress nat_into_Ord) |
|
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
492 |
done |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
493 |
|
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
494 |
(*Third step in proof of (31): by PSP with the fact that giv increases *) |
14071 | 495 |
lemma (in alloc_progress) length_giv_disj: |
496 |
"[| k \<in> tokbag; n \<in> nat |] |
|
14072
f932be305381
Conversion of UNITY/Distributor to Isar script. General tidy-up.
paulson
parents:
14071
diff
changeset
|
497 |
==> alloc_prog \<squnion> G \<in> |
14071 | 498 |
{s\<in>state. length(s`giv) = n & tokens(s`giv) = k} |
499 |
LeadsTo |
|
500 |
{s\<in>state. (length(s`giv) = n & tokens(s`giv) = k & |
|
501 |
k \<le> tokens(take(s`NbR, s`rel))) | n < length(s`giv)}" |
|
502 |
apply (rule single_LeadsTo_I, safe) |
|
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
503 |
apply (rule_tac a1 = "s`giv" in Increasing_imp_Stable [THEN PSP_StableI]) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
504 |
apply (rule alloc_prog_Increasing_giv [THEN guaranteesD]) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
505 |
apply (simp_all add: Int_cons_left) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
506 |
apply (rule LeadsTo_weaken) |
14071 | 507 |
apply (rule_tac k = "tokens(s`giv)" in tokens_take_NbR_lemma2) |
508 |
apply auto |
|
509 |
apply (force dest: prefix_length_le [THEN le_iff [THEN iffD1]]) |
|
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
510 |
apply (simp add: not_lt_iff_le) |
14071 | 511 |
apply (force dest: prefix_length_le_equal) |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
512 |
done |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
513 |
|
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
514 |
(*Fourth step in proof of (31): we apply lemma (51) *) |
14071 | 515 |
lemma (in alloc_progress) length_giv_disj2: |
516 |
"[|k \<in> tokbag; n \<in> nat|] |
|
14072
f932be305381
Conversion of UNITY/Distributor to Isar script. General tidy-up.
paulson
parents:
14071
diff
changeset
|
517 |
==> alloc_prog \<squnion> G \<in> |
14071 | 518 |
{s\<in>state. length(s`giv) = n & tokens(s`giv) = k} |
519 |
LeadsTo |
|
520 |
{s\<in>state. (length(s`giv) = n & NbT \<le> s`available_tok) | |
|
521 |
n < length(s`giv)}" |
|
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
522 |
apply (rule LeadsTo_weaken_R) |
14071 | 523 |
apply (rule Always_LeadsToD [OF alloc_prog_Always_lemma length_giv_disj], auto) |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
524 |
done |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
525 |
|
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
526 |
(*Fifth step in proof of (31): from the fourth step, taking the union over all |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
527 |
k\<in>nat *) |
14071 | 528 |
lemma (in alloc_progress) length_giv_disj3: |
529 |
"n \<in> nat |
|
14072
f932be305381
Conversion of UNITY/Distributor to Isar script. General tidy-up.
paulson
parents:
14071
diff
changeset
|
530 |
==> alloc_prog \<squnion> G \<in> |
14071 | 531 |
{s\<in>state. length(s`giv) = n} |
532 |
LeadsTo |
|
533 |
{s\<in>state. (length(s`giv) = n & NbT \<le> s`available_tok) | |
|
534 |
n < length(s`giv)}" |
|
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
535 |
apply (rule LeadsTo_weaken_L) |
14071 | 536 |
apply (rule_tac I = nat in LeadsTo_UN) |
537 |
apply (rule_tac k = i in length_giv_disj2) |
|
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
538 |
apply (simp_all add: UN_conj_eq) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
539 |
done |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
540 |
|
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
541 |
(*Sixth step in proof of (31): from the fifth step, by PSP with the |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
542 |
assumption that ask increases *) |
14071 | 543 |
lemma (in alloc_progress) length_ask_giv: |
544 |
"[|k \<in> nat; n < k|] |
|
14072
f932be305381
Conversion of UNITY/Distributor to Isar script. General tidy-up.
paulson
parents:
14071
diff
changeset
|
545 |
==> alloc_prog \<squnion> G \<in> |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
546 |
{s\<in>state. length(s`ask) = k & length(s`giv) = n} |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
547 |
LeadsTo |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
548 |
{s\<in>state. (NbT \<le> s`available_tok & length(s`giv) < length(s`ask) & |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
549 |
length(s`giv) = n) | |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
550 |
n < length(s`giv)}" |
14071 | 551 |
apply (rule single_LeadsTo_I, safe) |
552 |
apply (rule_tac a1 = "s`ask" and f1 = "lift(ask)" |
|
553 |
in Increasing_imp_Stable [THEN PSP_StableI]) |
|
554 |
apply (rule Incr_ask, simp_all) |
|
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
555 |
apply (rule LeadsTo_weaken) |
14071 | 556 |
apply (rule_tac n = "length(s ` giv)" in length_giv_disj3) |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
557 |
apply simp_all |
14071 | 558 |
apply blast |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
559 |
apply clarify |
14071 | 560 |
apply simp |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
561 |
apply (blast dest!: prefix_length_le intro: lt_trans2) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
562 |
done |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
563 |
|
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
564 |
|
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
565 |
(*Seventh step in proof of (31): no request (ask[k]) exceeds NbT *) |
14071 | 566 |
lemma (in alloc_progress) length_ask_giv2: |
567 |
"[|k \<in> nat; n < k|] |
|
14072
f932be305381
Conversion of UNITY/Distributor to Isar script. General tidy-up.
paulson
parents:
14071
diff
changeset
|
568 |
==> alloc_prog \<squnion> G \<in> |
14071 | 569 |
{s\<in>state. length(s`ask) = k & length(s`giv) = n} |
570 |
LeadsTo |
|
571 |
{s\<in>state. (nth(length(s`giv), s`ask) \<le> s`available_tok & |
|
572 |
length(s`giv) < length(s`ask) & length(s`giv) = n) | |
|
573 |
n < length(s`giv)}" |
|
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
574 |
apply (rule LeadsTo_weaken_R) |
14071 | 575 |
apply (rule Always_LeadsToD [OF safety length_ask_giv], assumption+, clarify) |
14095
a1ba833d6b61
Changed many Intersection rules from i:I to I~=0 to avoid introducing a new
paulson
parents:
14076
diff
changeset
|
576 |
apply (simp add: INT_iff) |
14071 | 577 |
apply (drule_tac x = "length(x ` giv)" and P = "%x. ?f (x) \<le> NbT" in bspec) |
578 |
apply simp |
|
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
579 |
apply (blast intro: le_trans) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
580 |
done |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
581 |
|
14071 | 582 |
(*Eighth step in proof of (31): by 50, we get |giv| > n. *) |
583 |
lemma (in alloc_progress) extend_giv: |
|
584 |
"[| k \<in> nat; n < k|] |
|
14072
f932be305381
Conversion of UNITY/Distributor to Isar script. General tidy-up.
paulson
parents:
14071
diff
changeset
|
585 |
==> alloc_prog \<squnion> G \<in> |
14071 | 586 |
{s\<in>state. length(s`ask) = k & length(s`giv) = n} |
587 |
LeadsTo {s\<in>state. n < length(s`giv)}" |
|
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
588 |
apply (rule LeadsTo_Un_duplicate) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
589 |
apply (rule LeadsTo_cancel1) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
590 |
apply (rule_tac [2] alloc_prog_giv_LeadsTo_lemma) |
14071 | 591 |
apply (simp_all add: Incr_ask lt_nat_in_nat) |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
592 |
apply (rule LeadsTo_weaken_R) |
14071 | 593 |
apply (rule length_ask_giv2, auto) |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
594 |
done |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
595 |
|
14071 | 596 |
(*Ninth and tenth steps in proof of (31): by 50, we get |giv| > n. |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
597 |
The report has an error: putting |ask|=k for the precondition fails because |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
598 |
we can't expect |ask| to remain fixed until |giv| increases.*) |
14071 | 599 |
lemma (in alloc_progress) alloc_prog_ask_LeadsTo_giv: |
600 |
"k \<in> nat |
|
14072
f932be305381
Conversion of UNITY/Distributor to Isar script. General tidy-up.
paulson
parents:
14071
diff
changeset
|
601 |
==> alloc_prog \<squnion> G \<in> |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
602 |
{s\<in>state. k \<le> length(s`ask)} LeadsTo {s\<in>state. k \<le> length(s`giv)}" |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
603 |
(* Proof by induction over the difference between k and n *) |
14071 | 604 |
apply (rule_tac f = "\<lambda>s\<in>state. k #- length(s`giv)" in LessThan_induct) |
605 |
apply (auto simp add: lam_def Collect_vimage_eq) |
|
606 |
apply (rule single_LeadsTo_I, auto) |
|
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
607 |
apply (rename_tac "s0") |
14071 | 608 |
apply (case_tac "length(s0 ` giv) < length(s0 ` ask) ") |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
609 |
apply (rule_tac [2] subset_imp_LeadsTo) |
14071 | 610 |
apply (auto simp add: not_lt_iff_le) |
611 |
prefer 2 apply (blast dest: le_imp_not_lt intro: lt_trans2) |
|
612 |
apply (rule_tac a1 = "s0`ask" and f1 = "lift (ask)" |
|
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
613 |
in Increasing_imp_Stable [THEN PSP_StableI]) |
14071 | 614 |
apply (rule Incr_ask, simp) |
615 |
apply (force) |
|
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
616 |
apply (rule LeadsTo_weaken) |
14071 | 617 |
apply (rule_tac n = "length(s0 ` giv)" and k = "length(s0 ` ask)" |
618 |
in extend_giv) |
|
619 |
apply (auto dest: not_lt_imp_le simp add: leI diff_lt_iff_lt) |
|
620 |
apply (blast dest!: prefix_length_le intro: lt_trans2) |
|
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
621 |
done |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
622 |
|
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
623 |
(*Final lemma: combine previous result with lemma (30)*) |
14071 | 624 |
lemma (in alloc_progress) final: |
625 |
"h \<in> list(tokbag) |
|
14072
f932be305381
Conversion of UNITY/Distributor to Isar script. General tidy-up.
paulson
parents:
14071
diff
changeset
|
626 |
==> alloc_prog \<squnion> G |
f932be305381
Conversion of UNITY/Distributor to Isar script. General tidy-up.
paulson
parents:
14071
diff
changeset
|
627 |
\<in> {s\<in>state. <h, s`ask> \<in> prefix(tokbag)} LeadsTo |
f932be305381
Conversion of UNITY/Distributor to Isar script. General tidy-up.
paulson
parents:
14071
diff
changeset
|
628 |
{s\<in>state. <h, s`giv> \<in> prefix(tokbag)}" |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
629 |
apply (rule single_LeadsTo_I) |
14071 | 630 |
prefer 2 apply simp |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
631 |
apply (rename_tac s0) |
14071 | 632 |
apply (rule_tac a1 = "s0`ask" and f1 = "lift (ask)" |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
633 |
in Increasing_imp_Stable [THEN PSP_StableI]) |
14071 | 634 |
apply (rule Incr_ask) |
635 |
apply (simp_all add: Int_cons_left) |
|
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
636 |
apply (rule LeadsTo_weaken) |
14071 | 637 |
apply (rule_tac k1 = "length(s0 ` ask)" |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
638 |
in Always_LeadsToD [OF alloc_prog_ask_prefix_giv [THEN guaranteesD] |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
639 |
alloc_prog_ask_LeadsTo_giv]) |
14071 | 640 |
apply (auto simp add: Incr_ask) |
641 |
apply (blast intro: length_le_prefix_imp_prefix prefix_trans prefix_length_le |
|
642 |
lt_trans2) |
|
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
643 |
done |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
644 |
|
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
645 |
(** alloc_prog liveness property (31), page 18 **) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
646 |
|
14071 | 647 |
theorem alloc_prog_progress: |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
648 |
"alloc_prog \<in> |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
649 |
Incr(lift(ask)) \<inter> Incr(lift(rel)) \<inter> |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
650 |
Always(\<Inter>k \<in> nat. {s\<in>state. nth(k, s`ask) \<le> NbT}) \<inter> |
14071 | 651 |
(\<Inter>k\<in>nat. {s\<in>state. k \<le> tokens(s`giv)} LeadsTo |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
652 |
{s\<in>state. k \<le> tokens(s`rel)}) |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
653 |
guarantees (\<Inter>h \<in> list(tokbag). |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
654 |
{s\<in>state. <h, s`ask> \<in> prefix(tokbag)} LeadsTo |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
655 |
{s\<in>state. <h, s`giv> \<in> prefix(tokbag)})" |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
656 |
apply (rule guaranteesI) |
14095
a1ba833d6b61
Changed many Intersection rules from i:I to I~=0 to avoid introducing a new
paulson
parents:
14076
diff
changeset
|
657 |
apply (rule INT_I) |
14071 | 658 |
apply (rule alloc_progress.final) |
14095
a1ba833d6b61
Changed many Intersection rules from i:I to I~=0 to avoid introducing a new
paulson
parents:
14076
diff
changeset
|
659 |
apply (auto simp add: alloc_progress_def) |
14060
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
660 |
done |
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
661 |
|
c0c4af41fa3b
Adding the theory UNITY/AllocImpl.thy, with supporting lemmas
paulson
parents:
diff
changeset
|
662 |
end |