author | paulson |
Sat, 08 Feb 2003 16:05:33 +0100 | |
changeset 13812 | 91713a1915ee |
parent 13805 | 3786b2fd6808 |
child 15102 | 04b0e943fcc9 |
permissions | -rw-r--r-- |
6706 | 1 |
(* Title: HOL/UNITY/Follows |
2 |
ID: $Id$ |
|
3 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory |
|
4 |
Copyright 1998 University of Cambridge |
|
13798 | 5 |
*) |
6706 | 6 |
|
13798 | 7 |
header{*The Follows Relation of Charpentier and Sivilotte*} |
6706 | 8 |
|
13796 | 9 |
theory Follows = SubstAx + ListOrder + Multiset: |
6706 | 10 |
|
11 |
constdefs |
|
12 |
||
13 |
Follows :: "['a => 'b::{order}, 'a => 'b::{order}] => 'a program set" |
|
6809 | 14 |
(infixl "Fols" 65) |
13805 | 15 |
"f Fols g == Increasing g \<inter> Increasing f Int |
16 |
Always {s. f s \<le> g s} Int |
|
17 |
(\<Inter>k. {s. k \<le> g s} LeadsTo {s. k \<le> f s})" |
|
6706 | 18 |
|
19 |
||
13796 | 20 |
(*Does this hold for "invariant"?*) |
21 |
lemma mono_Always_o: |
|
13805 | 22 |
"mono h ==> Always {s. f s \<le> g s} \<subseteq> Always {s. h (f s) \<le> h (g s)}" |
13796 | 23 |
apply (simp add: Always_eq_includes_reachable) |
24 |
apply (blast intro: monoD) |
|
25 |
done |
|
26 |
||
27 |
lemma mono_LeadsTo_o: |
|
28 |
"mono (h::'a::order => 'b::order) |
|
13805 | 29 |
==> (\<Inter>j. {s. j \<le> g s} LeadsTo {s. j \<le> f s}) \<subseteq> |
30 |
(\<Inter>k. {s. k \<le> h (g s)} LeadsTo {s. k \<le> h (f s)})" |
|
13796 | 31 |
apply auto |
32 |
apply (rule single_LeadsTo_I) |
|
33 |
apply (drule_tac x = "g s" in spec) |
|
34 |
apply (erule LeadsTo_weaken) |
|
35 |
apply (blast intro: monoD order_trans)+ |
|
36 |
done |
|
37 |
||
13805 | 38 |
lemma Follows_constant [iff]: "F \<in> (%s. c) Fols (%s. c)" |
13796 | 39 |
by (unfold Follows_def, auto) |
40 |
||
13805 | 41 |
lemma mono_Follows_o: "mono h ==> f Fols g \<subseteq> (h o f) Fols (h o g)" |
13796 | 42 |
apply (unfold Follows_def, clarify) |
43 |
apply (simp add: mono_Increasing_o [THEN [2] rev_subsetD] |
|
44 |
mono_Always_o [THEN [2] rev_subsetD] |
|
45 |
mono_LeadsTo_o [THEN [2] rev_subsetD, THEN INT_D]) |
|
46 |
done |
|
47 |
||
48 |
lemma mono_Follows_apply: |
|
13805 | 49 |
"mono h ==> f Fols g \<subseteq> (%x. h (f x)) Fols (%x. h (g x))" |
13796 | 50 |
apply (drule mono_Follows_o) |
51 |
apply (force simp add: o_def) |
|
52 |
done |
|
53 |
||
54 |
lemma Follows_trans: |
|
13805 | 55 |
"[| F \<in> f Fols g; F \<in> g Fols h |] ==> F \<in> f Fols h" |
13796 | 56 |
apply (unfold Follows_def) |
57 |
apply (simp add: Always_eq_includes_reachable) |
|
58 |
apply (blast intro: order_trans LeadsTo_Trans) |
|
59 |
done |
|
60 |
||
61 |
||
13798 | 62 |
subsection{*Destruction rules*} |
13796 | 63 |
|
13805 | 64 |
lemma Follows_Increasing1: "F \<in> f Fols g ==> F \<in> Increasing f" |
13812
91713a1915ee
converting HOL/UNITY to use unconditional fairness
paulson
parents:
13805
diff
changeset
|
65 |
by (unfold Follows_def, blast) |
13796 | 66 |
|
13805 | 67 |
lemma Follows_Increasing2: "F \<in> f Fols g ==> F \<in> Increasing g" |
13812
91713a1915ee
converting HOL/UNITY to use unconditional fairness
paulson
parents:
13805
diff
changeset
|
68 |
by (unfold Follows_def, blast) |
13796 | 69 |
|
13805 | 70 |
lemma Follows_Bounded: "F \<in> f Fols g ==> F \<in> Always {s. f s \<subseteq> g s}" |
13812
91713a1915ee
converting HOL/UNITY to use unconditional fairness
paulson
parents:
13805
diff
changeset
|
71 |
by (unfold Follows_def, blast) |
13796 | 72 |
|
73 |
lemma Follows_LeadsTo: |
|
13805 | 74 |
"F \<in> f Fols g ==> F \<in> {s. k \<le> g s} LeadsTo {s. k \<le> f s}" |
13798 | 75 |
by (unfold Follows_def, blast) |
13796 | 76 |
|
77 |
lemma Follows_LeadsTo_pfixLe: |
|
13805 | 78 |
"F \<in> f Fols g ==> F \<in> {s. k pfixLe g s} LeadsTo {s. k pfixLe f s}" |
13796 | 79 |
apply (rule single_LeadsTo_I, clarify) |
80 |
apply (drule_tac k="g s" in Follows_LeadsTo) |
|
81 |
apply (erule LeadsTo_weaken) |
|
82 |
apply blast |
|
83 |
apply (blast intro: pfixLe_trans prefix_imp_pfixLe) |
|
84 |
done |
|
85 |
||
86 |
lemma Follows_LeadsTo_pfixGe: |
|
13805 | 87 |
"F \<in> f Fols g ==> F \<in> {s. k pfixGe g s} LeadsTo {s. k pfixGe f s}" |
13796 | 88 |
apply (rule single_LeadsTo_I, clarify) |
89 |
apply (drule_tac k="g s" in Follows_LeadsTo) |
|
90 |
apply (erule LeadsTo_weaken) |
|
91 |
apply blast |
|
92 |
apply (blast intro: pfixGe_trans prefix_imp_pfixGe) |
|
93 |
done |
|
94 |
||
95 |
||
96 |
lemma Always_Follows1: |
|
13805 | 97 |
"[| F \<in> Always {s. f s = f' s}; F \<in> f Fols g |] ==> F \<in> f' Fols g" |
13796 | 98 |
|
99 |
apply (unfold Follows_def Increasing_def Stable_def, auto) |
|
100 |
apply (erule_tac [3] Always_LeadsTo_weaken) |
|
13805 | 101 |
apply (erule_tac A = "{s. z \<le> f s}" and A' = "{s. z \<le> f s}" |
13798 | 102 |
in Always_Constrains_weaken, auto) |
13796 | 103 |
apply (drule Always_Int_I, assumption) |
104 |
apply (force intro: Always_weaken) |
|
105 |
done |
|
106 |
||
107 |
lemma Always_Follows2: |
|
13805 | 108 |
"[| F \<in> Always {s. g s = g' s}; F \<in> f Fols g |] ==> F \<in> f Fols g'" |
13796 | 109 |
apply (unfold Follows_def Increasing_def Stable_def, auto) |
110 |
apply (erule_tac [3] Always_LeadsTo_weaken) |
|
13805 | 111 |
apply (erule_tac A = "{s. z \<le> g s}" and A' = "{s. z \<le> g s}" |
13798 | 112 |
in Always_Constrains_weaken, auto) |
13796 | 113 |
apply (drule Always_Int_I, assumption) |
114 |
apply (force intro: Always_weaken) |
|
115 |
done |
|
116 |
||
117 |
||
13798 | 118 |
subsection{*Union properties (with the subset ordering)*} |
13796 | 119 |
|
120 |
(*Can replace "Un" by any sup. But existing max only works for linorders.*) |
|
121 |
lemma increasing_Un: |
|
13805 | 122 |
"[| F \<in> increasing f; F \<in> increasing g |] |
123 |
==> F \<in> increasing (%s. (f s) \<union> (g s))" |
|
13796 | 124 |
apply (unfold increasing_def stable_def constrains_def, auto) |
125 |
apply (drule_tac x = "f xa" in spec) |
|
126 |
apply (drule_tac x = "g xa" in spec) |
|
127 |
apply (blast dest!: bspec) |
|
128 |
done |
|
129 |
||
130 |
lemma Increasing_Un: |
|
13805 | 131 |
"[| F \<in> Increasing f; F \<in> Increasing g |] |
132 |
==> F \<in> Increasing (%s. (f s) \<union> (g s))" |
|
13798 | 133 |
apply (auto simp add: Increasing_def Stable_def Constrains_def |
134 |
stable_def constrains_def) |
|
13796 | 135 |
apply (drule_tac x = "f xa" in spec) |
136 |
apply (drule_tac x = "g xa" in spec) |
|
137 |
apply (blast dest!: bspec) |
|
138 |
done |
|
139 |
||
140 |
||
141 |
lemma Always_Un: |
|
13805 | 142 |
"[| F \<in> Always {s. f' s \<le> f s}; F \<in> Always {s. g' s \<le> g s} |] |
143 |
==> F \<in> Always {s. f' s \<union> g' s \<le> f s \<union> g s}" |
|
13798 | 144 |
by (simp add: Always_eq_includes_reachable, blast) |
13796 | 145 |
|
146 |
(*Lemma to re-use the argument that one variable increases (progress) |
|
147 |
while the other variable doesn't decrease (safety)*) |
|
148 |
lemma Follows_Un_lemma: |
|
13805 | 149 |
"[| F \<in> Increasing f; F \<in> Increasing g; |
150 |
F \<in> Increasing g'; F \<in> Always {s. f' s \<le> f s}; |
|
151 |
\<forall>k. F \<in> {s. k \<le> f s} LeadsTo {s. k \<le> f' s} |] |
|
152 |
==> F \<in> {s. k \<le> f s \<union> g s} LeadsTo {s. k \<le> f' s \<union> g s}" |
|
13796 | 153 |
apply (rule single_LeadsTo_I) |
154 |
apply (drule_tac x = "f s" in IncreasingD) |
|
155 |
apply (drule_tac x = "g s" in IncreasingD) |
|
156 |
apply (rule LeadsTo_weaken) |
|
157 |
apply (rule PSP_Stable) |
|
158 |
apply (erule_tac x = "f s" in spec) |
|
13812
91713a1915ee
converting HOL/UNITY to use unconditional fairness
paulson
parents:
13805
diff
changeset
|
159 |
apply (erule Stable_Int, assumption, blast+) |
13796 | 160 |
done |
161 |
||
162 |
lemma Follows_Un: |
|
13805 | 163 |
"[| F \<in> f' Fols f; F \<in> g' Fols g |] |
164 |
==> F \<in> (%s. (f' s) \<union> (g' s)) Fols (%s. (f s) \<union> (g s))" |
|
13796 | 165 |
apply (unfold Follows_def) |
166 |
apply (simp add: Increasing_Un Always_Un, auto) |
|
167 |
apply (rule LeadsTo_Trans) |
|
168 |
apply (blast intro: Follows_Un_lemma) |
|
169 |
(*Weakening is used to exchange Un's arguments*) |
|
170 |
apply (blast intro: Follows_Un_lemma [THEN LeadsTo_weaken]) |
|
171 |
done |
|
172 |
||
173 |
||
13798 | 174 |
subsection{*Multiset union properties (with the multiset ordering)*} |
13796 | 175 |
|
176 |
lemma increasing_union: |
|
13805 | 177 |
"[| F \<in> increasing f; F \<in> increasing g |] |
178 |
==> F \<in> increasing (%s. (f s) + (g s :: ('a::order) multiset))" |
|
13796 | 179 |
apply (unfold increasing_def stable_def constrains_def, auto) |
180 |
apply (drule_tac x = "f xa" in spec) |
|
181 |
apply (drule_tac x = "g xa" in spec) |
|
182 |
apply (drule bspec, assumption) |
|
183 |
apply (blast intro: union_le_mono order_trans) |
|
184 |
done |
|
185 |
||
186 |
lemma Increasing_union: |
|
13805 | 187 |
"[| F \<in> Increasing f; F \<in> Increasing g |] |
188 |
==> F \<in> Increasing (%s. (f s) + (g s :: ('a::order) multiset))" |
|
13798 | 189 |
apply (auto simp add: Increasing_def Stable_def Constrains_def |
190 |
stable_def constrains_def) |
|
13796 | 191 |
apply (drule_tac x = "f xa" in spec) |
192 |
apply (drule_tac x = "g xa" in spec) |
|
193 |
apply (drule bspec, assumption) |
|
194 |
apply (blast intro: union_le_mono order_trans) |
|
195 |
done |
|
196 |
||
197 |
lemma Always_union: |
|
13805 | 198 |
"[| F \<in> Always {s. f' s \<le> f s}; F \<in> Always {s. g' s \<le> g s} |] |
199 |
==> F \<in> Always {s. f' s + g' s \<le> f s + (g s :: ('a::order) multiset)}" |
|
13796 | 200 |
apply (simp add: Always_eq_includes_reachable) |
201 |
apply (blast intro: union_le_mono) |
|
202 |
done |
|
203 |
||
204 |
(*Except the last line, IDENTICAL to the proof script for Follows_Un_lemma*) |
|
205 |
lemma Follows_union_lemma: |
|
13805 | 206 |
"[| F \<in> Increasing f; F \<in> Increasing g; |
207 |
F \<in> Increasing g'; F \<in> Always {s. f' s \<le> f s}; |
|
208 |
\<forall>k::('a::order) multiset. |
|
209 |
F \<in> {s. k \<le> f s} LeadsTo {s. k \<le> f' s} |] |
|
210 |
==> F \<in> {s. k \<le> f s + g s} LeadsTo {s. k \<le> f' s + g s}" |
|
13796 | 211 |
apply (rule single_LeadsTo_I) |
212 |
apply (drule_tac x = "f s" in IncreasingD) |
|
213 |
apply (drule_tac x = "g s" in IncreasingD) |
|
214 |
apply (rule LeadsTo_weaken) |
|
215 |
apply (rule PSP_Stable) |
|
216 |
apply (erule_tac x = "f s" in spec) |
|
13812
91713a1915ee
converting HOL/UNITY to use unconditional fairness
paulson
parents:
13805
diff
changeset
|
217 |
apply (erule Stable_Int, assumption, blast) |
13796 | 218 |
apply (blast intro: union_le_mono order_trans) |
219 |
done |
|
220 |
||
221 |
(*The !! is there to influence to effect of permutative rewriting at the end*) |
|
222 |
lemma Follows_union: |
|
223 |
"!!g g' ::'b => ('a::order) multiset. |
|
13805 | 224 |
[| F \<in> f' Fols f; F \<in> g' Fols g |] |
225 |
==> F \<in> (%s. (f' s) + (g' s)) Fols (%s. (f s) + (g s))" |
|
13796 | 226 |
apply (unfold Follows_def) |
227 |
apply (simp add: Increasing_union Always_union, auto) |
|
228 |
apply (rule LeadsTo_Trans) |
|
229 |
apply (blast intro: Follows_union_lemma) |
|
230 |
(*now exchange union's arguments*) |
|
231 |
apply (simp add: union_commute) |
|
232 |
apply (blast intro: Follows_union_lemma) |
|
233 |
done |
|
234 |
||
235 |
lemma Follows_setsum: |
|
236 |
"!!f ::['c,'b] => ('a::order) multiset. |
|
13805 | 237 |
[| \<forall>i \<in> I. F \<in> f' i Fols f i; finite I |] |
238 |
==> F \<in> (%s. \<Sum>i \<in> I. f' i s) Fols (%s. \<Sum>i \<in> I. f i s)" |
|
13796 | 239 |
apply (erule rev_mp) |
240 |
apply (erule finite_induct, simp) |
|
241 |
apply (simp add: Follows_union) |
|
242 |
done |
|
243 |
||
244 |
||
245 |
(*Currently UNUSED, but possibly of interest*) |
|
246 |
lemma Increasing_imp_Stable_pfixGe: |
|
13805 | 247 |
"F \<in> Increasing func ==> F \<in> Stable {s. h pfixGe (func s)}" |
13796 | 248 |
apply (simp add: Increasing_def Stable_def Constrains_def constrains_def) |
249 |
apply (blast intro: trans_Ge [THEN trans_genPrefix, THEN transD] |
|
250 |
prefix_imp_pfixGe) |
|
251 |
done |
|
252 |
||
253 |
(*Currently UNUSED, but possibly of interest*) |
|
254 |
lemma LeadsTo_le_imp_pfixGe: |
|
13805 | 255 |
"\<forall>z. F \<in> {s. z \<le> f s} LeadsTo {s. z \<le> g s} |
256 |
==> F \<in> {s. z pfixGe f s} LeadsTo {s. z pfixGe g s}" |
|
13796 | 257 |
apply (rule single_LeadsTo_I) |
258 |
apply (drule_tac x = "f s" in spec) |
|
259 |
apply (erule LeadsTo_weaken) |
|
260 |
prefer 2 |
|
261 |
apply (blast intro: trans_Ge [THEN trans_genPrefix, THEN transD] |
|
262 |
prefix_imp_pfixGe, blast) |
|
263 |
done |
|
264 |
||
6706 | 265 |
end |