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"
|
13796
|
65 |
apply (unfold Follows_def, blast)
|
|
66 |
done
|
|
67 |
|
13805
|
68 |
lemma Follows_Increasing2: "F \<in> f Fols g ==> F \<in> Increasing g"
|
13796
|
69 |
apply (unfold Follows_def, blast)
|
|
70 |
done
|
|
71 |
|
13805
|
72 |
lemma Follows_Bounded: "F \<in> f Fols g ==> F \<in> Always {s. f s \<subseteq> g s}"
|
13796
|
73 |
apply (unfold Follows_def, blast)
|
|
74 |
done
|
|
75 |
|
|
76 |
lemma Follows_LeadsTo:
|
13805
|
77 |
"F \<in> f Fols g ==> F \<in> {s. k \<le> g s} LeadsTo {s. k \<le> f s}"
|
13798
|
78 |
by (unfold Follows_def, blast)
|
13796
|
79 |
|
|
80 |
lemma Follows_LeadsTo_pfixLe:
|
13805
|
81 |
"F \<in> f Fols g ==> F \<in> {s. k pfixLe g s} LeadsTo {s. k pfixLe f s}"
|
13796
|
82 |
apply (rule single_LeadsTo_I, clarify)
|
|
83 |
apply (drule_tac k="g s" in Follows_LeadsTo)
|
|
84 |
apply (erule LeadsTo_weaken)
|
|
85 |
apply blast
|
|
86 |
apply (blast intro: pfixLe_trans prefix_imp_pfixLe)
|
|
87 |
done
|
|
88 |
|
|
89 |
lemma Follows_LeadsTo_pfixGe:
|
13805
|
90 |
"F \<in> f Fols g ==> F \<in> {s. k pfixGe g s} LeadsTo {s. k pfixGe f s}"
|
13796
|
91 |
apply (rule single_LeadsTo_I, clarify)
|
|
92 |
apply (drule_tac k="g s" in Follows_LeadsTo)
|
|
93 |
apply (erule LeadsTo_weaken)
|
|
94 |
apply blast
|
|
95 |
apply (blast intro: pfixGe_trans prefix_imp_pfixGe)
|
|
96 |
done
|
|
97 |
|
|
98 |
|
|
99 |
lemma Always_Follows1:
|
13805
|
100 |
"[| F \<in> Always {s. f s = f' s}; F \<in> f Fols g |] ==> F \<in> f' Fols g"
|
13796
|
101 |
|
|
102 |
apply (unfold Follows_def Increasing_def Stable_def, auto)
|
|
103 |
apply (erule_tac [3] Always_LeadsTo_weaken)
|
13805
|
104 |
apply (erule_tac A = "{s. z \<le> f s}" and A' = "{s. z \<le> f s}"
|
13798
|
105 |
in Always_Constrains_weaken, auto)
|
13796
|
106 |
apply (drule Always_Int_I, assumption)
|
|
107 |
apply (force intro: Always_weaken)
|
|
108 |
done
|
|
109 |
|
|
110 |
lemma Always_Follows2:
|
13805
|
111 |
"[| F \<in> Always {s. g s = g' s}; F \<in> f Fols g |] ==> F \<in> f Fols g'"
|
13796
|
112 |
apply (unfold Follows_def Increasing_def Stable_def, auto)
|
|
113 |
apply (erule_tac [3] Always_LeadsTo_weaken)
|
13805
|
114 |
apply (erule_tac A = "{s. z \<le> g s}" and A' = "{s. z \<le> g s}"
|
13798
|
115 |
in Always_Constrains_weaken, auto)
|
13796
|
116 |
apply (drule Always_Int_I, assumption)
|
|
117 |
apply (force intro: Always_weaken)
|
|
118 |
done
|
|
119 |
|
|
120 |
|
13798
|
121 |
subsection{*Union properties (with the subset ordering)*}
|
13796
|
122 |
|
|
123 |
(*Can replace "Un" by any sup. But existing max only works for linorders.*)
|
|
124 |
lemma increasing_Un:
|
13805
|
125 |
"[| F \<in> increasing f; F \<in> increasing g |]
|
|
126 |
==> F \<in> increasing (%s. (f s) \<union> (g s))"
|
13796
|
127 |
apply (unfold increasing_def stable_def constrains_def, auto)
|
|
128 |
apply (drule_tac x = "f xa" in spec)
|
|
129 |
apply (drule_tac x = "g xa" in spec)
|
|
130 |
apply (blast dest!: bspec)
|
|
131 |
done
|
|
132 |
|
|
133 |
lemma Increasing_Un:
|
13805
|
134 |
"[| F \<in> Increasing f; F \<in> Increasing g |]
|
|
135 |
==> F \<in> Increasing (%s. (f s) \<union> (g s))"
|
13798
|
136 |
apply (auto simp add: Increasing_def Stable_def Constrains_def
|
|
137 |
stable_def constrains_def)
|
13796
|
138 |
apply (drule_tac x = "f xa" in spec)
|
|
139 |
apply (drule_tac x = "g xa" in spec)
|
|
140 |
apply (blast dest!: bspec)
|
|
141 |
done
|
|
142 |
|
|
143 |
|
|
144 |
lemma Always_Un:
|
13805
|
145 |
"[| F \<in> Always {s. f' s \<le> f s}; F \<in> Always {s. g' s \<le> g s} |]
|
|
146 |
==> F \<in> Always {s. f' s \<union> g' s \<le> f s \<union> g s}"
|
13798
|
147 |
by (simp add: Always_eq_includes_reachable, blast)
|
13796
|
148 |
|
|
149 |
(*Lemma to re-use the argument that one variable increases (progress)
|
|
150 |
while the other variable doesn't decrease (safety)*)
|
|
151 |
lemma Follows_Un_lemma:
|
13805
|
152 |
"[| F \<in> Increasing f; F \<in> Increasing g;
|
|
153 |
F \<in> Increasing g'; F \<in> Always {s. f' s \<le> f s};
|
|
154 |
\<forall>k. F \<in> {s. k \<le> f s} LeadsTo {s. k \<le> f' s} |]
|
|
155 |
==> F \<in> {s. k \<le> f s \<union> g s} LeadsTo {s. k \<le> f' s \<union> g s}"
|
13796
|
156 |
apply (rule single_LeadsTo_I)
|
|
157 |
apply (drule_tac x = "f s" in IncreasingD)
|
|
158 |
apply (drule_tac x = "g s" in IncreasingD)
|
|
159 |
apply (rule LeadsTo_weaken)
|
|
160 |
apply (rule PSP_Stable)
|
|
161 |
apply (erule_tac x = "f s" in spec)
|
|
162 |
apply (erule Stable_Int, assumption)
|
13798
|
163 |
apply blast+
|
13796
|
164 |
done
|
|
165 |
|
|
166 |
lemma Follows_Un:
|
13805
|
167 |
"[| F \<in> f' Fols f; F \<in> g' Fols g |]
|
|
168 |
==> F \<in> (%s. (f' s) \<union> (g' s)) Fols (%s. (f s) \<union> (g s))"
|
13796
|
169 |
apply (unfold Follows_def)
|
|
170 |
apply (simp add: Increasing_Un Always_Un, auto)
|
|
171 |
apply (rule LeadsTo_Trans)
|
|
172 |
apply (blast intro: Follows_Un_lemma)
|
|
173 |
(*Weakening is used to exchange Un's arguments*)
|
|
174 |
apply (blast intro: Follows_Un_lemma [THEN LeadsTo_weaken])
|
|
175 |
done
|
|
176 |
|
|
177 |
|
13798
|
178 |
subsection{*Multiset union properties (with the multiset ordering)*}
|
13796
|
179 |
|
|
180 |
lemma increasing_union:
|
13805
|
181 |
"[| F \<in> increasing f; F \<in> increasing g |]
|
|
182 |
==> F \<in> increasing (%s. (f s) + (g s :: ('a::order) multiset))"
|
13796
|
183 |
apply (unfold increasing_def stable_def constrains_def, auto)
|
|
184 |
apply (drule_tac x = "f xa" in spec)
|
|
185 |
apply (drule_tac x = "g xa" in spec)
|
|
186 |
apply (drule bspec, assumption)
|
|
187 |
apply (blast intro: union_le_mono order_trans)
|
|
188 |
done
|
|
189 |
|
|
190 |
lemma Increasing_union:
|
13805
|
191 |
"[| F \<in> Increasing f; F \<in> Increasing g |]
|
|
192 |
==> F \<in> Increasing (%s. (f s) + (g s :: ('a::order) multiset))"
|
13798
|
193 |
apply (auto simp add: Increasing_def Stable_def Constrains_def
|
|
194 |
stable_def constrains_def)
|
13796
|
195 |
apply (drule_tac x = "f xa" in spec)
|
|
196 |
apply (drule_tac x = "g xa" in spec)
|
|
197 |
apply (drule bspec, assumption)
|
|
198 |
apply (blast intro: union_le_mono order_trans)
|
|
199 |
done
|
|
200 |
|
|
201 |
lemma Always_union:
|
13805
|
202 |
"[| F \<in> Always {s. f' s \<le> f s}; F \<in> Always {s. g' s \<le> g s} |]
|
|
203 |
==> F \<in> Always {s. f' s + g' s \<le> f s + (g s :: ('a::order) multiset)}"
|
13796
|
204 |
apply (simp add: Always_eq_includes_reachable)
|
|
205 |
apply (blast intro: union_le_mono)
|
|
206 |
done
|
|
207 |
|
|
208 |
(*Except the last line, IDENTICAL to the proof script for Follows_Un_lemma*)
|
|
209 |
lemma Follows_union_lemma:
|
13805
|
210 |
"[| F \<in> Increasing f; F \<in> Increasing g;
|
|
211 |
F \<in> Increasing g'; F \<in> Always {s. f' s \<le> f s};
|
|
212 |
\<forall>k::('a::order) multiset.
|
|
213 |
F \<in> {s. k \<le> f s} LeadsTo {s. k \<le> f' s} |]
|
|
214 |
==> F \<in> {s. k \<le> f s + g s} LeadsTo {s. k \<le> f' s + g s}"
|
13796
|
215 |
apply (rule single_LeadsTo_I)
|
|
216 |
apply (drule_tac x = "f s" in IncreasingD)
|
|
217 |
apply (drule_tac x = "g s" in IncreasingD)
|
|
218 |
apply (rule LeadsTo_weaken)
|
|
219 |
apply (rule PSP_Stable)
|
|
220 |
apply (erule_tac x = "f s" in spec)
|
|
221 |
apply (erule Stable_Int, assumption)
|
|
222 |
apply blast
|
|
223 |
apply (blast intro: union_le_mono order_trans)
|
|
224 |
done
|
|
225 |
|
|
226 |
(*The !! is there to influence to effect of permutative rewriting at the end*)
|
|
227 |
lemma Follows_union:
|
|
228 |
"!!g g' ::'b => ('a::order) multiset.
|
13805
|
229 |
[| F \<in> f' Fols f; F \<in> g' Fols g |]
|
|
230 |
==> F \<in> (%s. (f' s) + (g' s)) Fols (%s. (f s) + (g s))"
|
13796
|
231 |
apply (unfold Follows_def)
|
|
232 |
apply (simp add: Increasing_union Always_union, auto)
|
|
233 |
apply (rule LeadsTo_Trans)
|
|
234 |
apply (blast intro: Follows_union_lemma)
|
|
235 |
(*now exchange union's arguments*)
|
|
236 |
apply (simp add: union_commute)
|
|
237 |
apply (blast intro: Follows_union_lemma)
|
|
238 |
done
|
|
239 |
|
|
240 |
lemma Follows_setsum:
|
|
241 |
"!!f ::['c,'b] => ('a::order) multiset.
|
13805
|
242 |
[| \<forall>i \<in> I. F \<in> f' i Fols f i; finite I |]
|
|
243 |
==> F \<in> (%s. \<Sum>i \<in> I. f' i s) Fols (%s. \<Sum>i \<in> I. f i s)"
|
13796
|
244 |
apply (erule rev_mp)
|
|
245 |
apply (erule finite_induct, simp)
|
|
246 |
apply (simp add: Follows_union)
|
|
247 |
done
|
|
248 |
|
|
249 |
|
|
250 |
(*Currently UNUSED, but possibly of interest*)
|
|
251 |
lemma Increasing_imp_Stable_pfixGe:
|
13805
|
252 |
"F \<in> Increasing func ==> F \<in> Stable {s. h pfixGe (func s)}"
|
13796
|
253 |
apply (simp add: Increasing_def Stable_def Constrains_def constrains_def)
|
|
254 |
apply (blast intro: trans_Ge [THEN trans_genPrefix, THEN transD]
|
|
255 |
prefix_imp_pfixGe)
|
|
256 |
done
|
|
257 |
|
|
258 |
(*Currently UNUSED, but possibly of interest*)
|
|
259 |
lemma LeadsTo_le_imp_pfixGe:
|
13805
|
260 |
"\<forall>z. F \<in> {s. z \<le> f s} LeadsTo {s. z \<le> g s}
|
|
261 |
==> F \<in> {s. z pfixGe f s} LeadsTo {s. z pfixGe g s}"
|
13796
|
262 |
apply (rule single_LeadsTo_I)
|
|
263 |
apply (drule_tac x = "f s" in spec)
|
|
264 |
apply (erule LeadsTo_weaken)
|
|
265 |
prefer 2
|
|
266 |
apply (blast intro: trans_Ge [THEN trans_genPrefix, THEN transD]
|
|
267 |
prefix_imp_pfixGe, blast)
|
|
268 |
done
|
|
269 |
|
6706
|
270 |
end
|