|
4565
|
1 |
(* Title: HOLCF/IOA/meta_theory/SimCorrectness.thy
|
|
|
2 |
ID: $Id$
|
|
12218
|
3 |
Author: Olaf Müller
|
|
4565
|
4 |
*)
|
|
|
5 |
|
|
17233
|
6 |
header {* Correctness of Simulations in HOLCF/IOA *}
|
|
4565
|
7 |
|
|
17233
|
8 |
theory SimCorrectness
|
|
|
9 |
imports Simulations
|
|
|
10 |
begin
|
|
|
11 |
|
|
4565
|
12 |
consts
|
|
|
13 |
|
|
17233
|
14 |
corresp_ex_sim ::"('a,'s2)ioa => (('s1 *'s2)set) =>
|
|
4565
|
15 |
('a,'s1)execution => ('a,'s2)execution"
|
|
|
16 |
(* Note: s2 instead of s1 in last argument type !! *)
|
|
|
17 |
corresp_ex_simC ::"('a,'s2)ioa => (('s1 * 's2)set) => ('a,'s1)pairs
|
|
|
18 |
-> ('s2 => ('a,'s2)pairs)"
|
|
|
19 |
|
|
|
20 |
|
|
|
21 |
defs
|
|
17233
|
22 |
|
|
|
23 |
corresp_ex_sim_def:
|
|
4565
|
24 |
"corresp_ex_sim A R ex == let S'= (@s'.(fst ex,s'):R & s': starts_of A)
|
|
17233
|
25 |
in
|
|
10835
|
26 |
(S',(corresp_ex_simC A R$(snd ex)) S')"
|
|
4565
|
27 |
|
|
|
28 |
|
|
17233
|
29 |
corresp_ex_simC_def:
|
|
|
30 |
"corresp_ex_simC A R == (fix$(LAM h ex. (%s. case ex of
|
|
4565
|
31 |
nil => nil
|
|
|
32 |
| x##xs => (flift1 (%pr. let a = (fst pr); t = (snd pr);
|
|
17233
|
33 |
T' = @t'. ? ex1. (t,t'):R & move A ex1 s a t'
|
|
4565
|
34 |
in
|
|
|
35 |
(@cex. move A cex s a T')
|
|
10835
|
36 |
@@ ((h$xs) T'))
|
|
|
37 |
$x) )))"
|
|
17233
|
38 |
|
|
19741
|
39 |
|
|
|
40 |
subsection "corresp_ex_sim"
|
|
|
41 |
|
|
|
42 |
lemma corresp_ex_simC_unfold: "corresp_ex_simC A R = (LAM ex. (%s. case ex of
|
|
|
43 |
nil => nil
|
|
|
44 |
| x##xs => (flift1 (%pr. let a = (fst pr); t = (snd pr);
|
|
|
45 |
T' = @t'. ? ex1. (t,t'):R & move A ex1 s a t'
|
|
|
46 |
in
|
|
|
47 |
(@cex. move A cex s a T')
|
|
|
48 |
@@ ((corresp_ex_simC A R $xs) T'))
|
|
|
49 |
$x) ))"
|
|
|
50 |
apply (rule trans)
|
|
|
51 |
apply (rule fix_eq2)
|
|
|
52 |
apply (rule corresp_ex_simC_def)
|
|
|
53 |
apply (rule beta_cfun)
|
|
|
54 |
apply (simp add: flift1_def)
|
|
|
55 |
done
|
|
|
56 |
|
|
|
57 |
lemma corresp_ex_simC_UU: "(corresp_ex_simC A R$UU) s=UU"
|
|
|
58 |
apply (subst corresp_ex_simC_unfold)
|
|
|
59 |
apply simp
|
|
|
60 |
done
|
|
|
61 |
|
|
|
62 |
lemma corresp_ex_simC_nil: "(corresp_ex_simC A R$nil) s = nil"
|
|
|
63 |
apply (subst corresp_ex_simC_unfold)
|
|
|
64 |
apply simp
|
|
|
65 |
done
|
|
|
66 |
|
|
|
67 |
lemma corresp_ex_simC_cons: "(corresp_ex_simC A R$((a,t)>>xs)) s =
|
|
|
68 |
(let T' = @t'. ? ex1. (t,t'):R & move A ex1 s a t'
|
|
|
69 |
in
|
|
|
70 |
(@cex. move A cex s a T')
|
|
|
71 |
@@ ((corresp_ex_simC A R$xs) T'))"
|
|
|
72 |
apply (rule trans)
|
|
|
73 |
apply (subst corresp_ex_simC_unfold)
|
|
|
74 |
apply (simp add: Consq_def flift1_def)
|
|
|
75 |
apply simp
|
|
|
76 |
done
|
|
|
77 |
|
|
|
78 |
|
|
|
79 |
declare corresp_ex_simC_UU [simp] corresp_ex_simC_nil [simp] corresp_ex_simC_cons [simp]
|
|
|
80 |
|
|
|
81 |
|
|
|
82 |
subsection "properties of move"
|
|
|
83 |
|
|
|
84 |
declare Let_def [simp del]
|
|
|
85 |
|
|
|
86 |
lemma move_is_move_sim:
|
|
|
87 |
"[|is_simulation R C A; reachable C s; s -a--C-> t; (s,s'):R|] ==>
|
|
|
88 |
let T' = @t'. ? ex1. (t,t'):R & move A ex1 s' a t' in
|
|
|
89 |
(t,T'): R & move A (@ex2. move A ex2 s' a T') s' a T'"
|
|
|
90 |
apply (unfold is_simulation_def)
|
|
|
91 |
|
|
|
92 |
(* Does not perform conditional rewriting on assumptions automatically as
|
|
|
93 |
usual. Instantiate all variables per hand. Ask Tobias?? *)
|
|
|
94 |
apply (subgoal_tac "? t' ex. (t,t') :R & move A ex s' a t'")
|
|
|
95 |
prefer 2
|
|
|
96 |
apply simp
|
|
|
97 |
apply (erule conjE)
|
|
|
98 |
apply (erule_tac x = "s" in allE)
|
|
|
99 |
apply (erule_tac x = "s'" in allE)
|
|
|
100 |
apply (erule_tac x = "t" in allE)
|
|
|
101 |
apply (erule_tac x = "a" in allE)
|
|
|
102 |
apply simp
|
|
|
103 |
(* Go on as usual *)
|
|
|
104 |
apply (erule exE)
|
|
|
105 |
apply (drule_tac x = "t'" and P = "%t'. ? ex. (t,t') :R & move A ex s' a t'" in someI)
|
|
|
106 |
apply (erule exE)
|
|
|
107 |
apply (erule conjE)
|
|
|
108 |
apply (simp add: Let_def)
|
|
|
109 |
apply (rule_tac x = "ex" in someI)
|
|
|
110 |
apply (erule conjE)
|
|
|
111 |
apply assumption
|
|
|
112 |
done
|
|
|
113 |
|
|
|
114 |
declare Let_def [simp]
|
|
|
115 |
|
|
|
116 |
lemma move_subprop1_sim:
|
|
|
117 |
"[|is_simulation R C A; reachable C s; s-a--C-> t; (s,s'):R|] ==>
|
|
|
118 |
let T' = @t'. ? ex1. (t,t'):R & move A ex1 s' a t' in
|
|
|
119 |
is_exec_frag A (s',@x. move A x s' a T')"
|
|
|
120 |
apply (cut_tac move_is_move_sim)
|
|
|
121 |
defer
|
|
|
122 |
apply assumption+
|
|
|
123 |
apply (simp add: move_def)
|
|
|
124 |
done
|
|
|
125 |
|
|
|
126 |
lemma move_subprop2_sim:
|
|
|
127 |
"[|is_simulation R C A; reachable C s; s-a--C-> t; (s,s'):R|] ==>
|
|
|
128 |
let T' = @t'. ? ex1. (t,t'):R & move A ex1 s' a t' in
|
|
|
129 |
Finite (@x. move A x s' a T')"
|
|
|
130 |
apply (cut_tac move_is_move_sim)
|
|
|
131 |
defer
|
|
|
132 |
apply assumption+
|
|
|
133 |
apply (simp add: move_def)
|
|
|
134 |
done
|
|
|
135 |
|
|
|
136 |
lemma move_subprop3_sim:
|
|
|
137 |
"[|is_simulation R C A; reachable C s; s-a--C-> t; (s,s'):R|] ==>
|
|
|
138 |
let T' = @t'. ? ex1. (t,t'):R & move A ex1 s' a t' in
|
|
|
139 |
laststate (s',@x. move A x s' a T') = T'"
|
|
|
140 |
apply (cut_tac move_is_move_sim)
|
|
|
141 |
defer
|
|
|
142 |
apply assumption+
|
|
|
143 |
apply (simp add: move_def)
|
|
|
144 |
done
|
|
|
145 |
|
|
|
146 |
lemma move_subprop4_sim:
|
|
|
147 |
"[|is_simulation R C A; reachable C s; s-a--C-> t; (s,s'):R|] ==>
|
|
|
148 |
let T' = @t'. ? ex1. (t,t'):R & move A ex1 s' a t' in
|
|
|
149 |
mk_trace A$((@x. move A x s' a T')) =
|
|
|
150 |
(if a:ext A then a>>nil else nil)"
|
|
|
151 |
apply (cut_tac move_is_move_sim)
|
|
|
152 |
defer
|
|
|
153 |
apply assumption+
|
|
|
154 |
apply (simp add: move_def)
|
|
|
155 |
done
|
|
|
156 |
|
|
|
157 |
lemma move_subprop5_sim:
|
|
|
158 |
"[|is_simulation R C A; reachable C s; s-a--C-> t; (s,s'):R|] ==>
|
|
|
159 |
let T' = @t'. ? ex1. (t,t'):R & move A ex1 s' a t' in
|
|
|
160 |
(t,T'):R"
|
|
|
161 |
apply (cut_tac move_is_move_sim)
|
|
|
162 |
defer
|
|
|
163 |
apply assumption+
|
|
|
164 |
apply (simp add: move_def)
|
|
|
165 |
done
|
|
|
166 |
|
|
|
167 |
|
|
|
168 |
subsection {* TRACE INCLUSION Part 1: Traces coincide *}
|
|
|
169 |
|
|
|
170 |
subsubsection "Lemmata for <=="
|
|
|
171 |
|
|
|
172 |
(* ------------------------------------------------------
|
|
|
173 |
Lemma 1 :Traces coincide
|
|
|
174 |
------------------------------------------------------- *)
|
|
|
175 |
|
|
|
176 |
declare split_if [split del]
|
|
|
177 |
lemma traces_coincide_sim [rule_format (no_asm)]:
|
|
|
178 |
"[|is_simulation R C A; ext C = ext A|] ==>
|
|
|
179 |
!s s'. reachable C s & is_exec_frag C (s,ex) & (s,s'): R -->
|
|
|
180 |
mk_trace C$ex = mk_trace A$((corresp_ex_simC A R$ex) s')"
|
|
|
181 |
|
|
|
182 |
apply (tactic {* pair_induct_tac "ex" [thm "is_exec_frag_def"] 1 *})
|
|
|
183 |
(* cons case *)
|
|
|
184 |
apply (tactic "safe_tac set_cs")
|
|
|
185 |
apply (rename_tac ex a t s s')
|
|
|
186 |
apply (simp add: mk_traceConc)
|
|
|
187 |
apply (frule reachable.reachable_n)
|
|
|
188 |
apply assumption
|
|
|
189 |
apply (erule_tac x = "t" in allE)
|
|
|
190 |
apply (erule_tac x = "@t'. ? ex1. (t,t') :R & move A ex1 s' a t'" in allE)
|
|
|
191 |
apply simp
|
|
|
192 |
apply (simp add: move_subprop5_sim [unfolded Let_def]
|
|
|
193 |
move_subprop4_sim [unfolded Let_def] split add: split_if)
|
|
|
194 |
done
|
|
|
195 |
declare split_if [split]
|
|
|
196 |
|
|
|
197 |
|
|
|
198 |
(* ----------------------------------------------------------- *)
|
|
|
199 |
(* Lemma 2 : corresp_ex_sim is execution *)
|
|
|
200 |
(* ----------------------------------------------------------- *)
|
|
|
201 |
|
|
|
202 |
|
|
|
203 |
lemma correspsim_is_execution [rule_format (no_asm)]:
|
|
|
204 |
"[| is_simulation R C A |] ==>
|
|
|
205 |
!s s'. reachable C s & is_exec_frag C (s,ex) & (s,s'):R
|
|
|
206 |
--> is_exec_frag A (s',(corresp_ex_simC A R$ex) s')"
|
|
|
207 |
|
|
|
208 |
apply (tactic {* pair_induct_tac "ex" [thm "is_exec_frag_def"] 1 *})
|
|
|
209 |
(* main case *)
|
|
|
210 |
apply (tactic "safe_tac set_cs")
|
|
|
211 |
apply (rename_tac ex a t s s')
|
|
|
212 |
apply (rule_tac t = "@t'. ? ex1. (t,t') :R & move A ex1 s' a t'" in lemma_2_1)
|
|
|
213 |
|
|
|
214 |
(* Finite *)
|
|
|
215 |
apply (erule move_subprop2_sim [unfolded Let_def])
|
|
|
216 |
apply assumption+
|
|
|
217 |
apply (rule conjI)
|
|
|
218 |
|
|
|
219 |
(* is_exec_frag *)
|
|
|
220 |
apply (erule move_subprop1_sim [unfolded Let_def])
|
|
|
221 |
apply assumption+
|
|
|
222 |
apply (rule conjI)
|
|
|
223 |
|
|
|
224 |
(* Induction hypothesis *)
|
|
|
225 |
(* reachable_n looping, therefore apply it manually *)
|
|
|
226 |
apply (erule_tac x = "t" in allE)
|
|
|
227 |
apply (erule_tac x = "@t'. ? ex1. (t,t') :R & move A ex1 s' a t'" in allE)
|
|
|
228 |
apply simp
|
|
|
229 |
apply (frule reachable.reachable_n)
|
|
|
230 |
apply assumption
|
|
|
231 |
apply (simp add: move_subprop5_sim [unfolded Let_def])
|
|
|
232 |
(* laststate *)
|
|
|
233 |
apply (erule move_subprop3_sim [unfolded Let_def, symmetric])
|
|
|
234 |
apply assumption+
|
|
|
235 |
done
|
|
|
236 |
|
|
|
237 |
|
|
|
238 |
subsection "Main Theorem: TRACE - INCLUSION"
|
|
|
239 |
|
|
|
240 |
(* -------------------------------------------------------------------------------- *)
|
|
|
241 |
|
|
|
242 |
(* generate condition (s,S'):R & S':starts_of A, the first being intereting
|
|
|
243 |
for the induction cases concerning the two lemmas correpsim_is_execution and
|
|
|
244 |
traces_coincide_sim, the second for the start state case.
|
|
|
245 |
S':= @s'. (s,s'):R & s':starts_of A, where s:starts_of C *)
|
|
|
246 |
|
|
|
247 |
lemma simulation_starts:
|
|
|
248 |
"[| is_simulation R C A; s:starts_of C |]
|
|
|
249 |
==> let S' = @s'. (s,s'):R & s':starts_of A in
|
|
|
250 |
(s,S'):R & S':starts_of A"
|
|
|
251 |
apply (simp add: is_simulation_def corresp_ex_sim_def Int_non_empty Image_def)
|
|
|
252 |
apply (erule conjE)+
|
|
|
253 |
apply (erule ballE)
|
|
|
254 |
prefer 2 apply (blast)
|
|
|
255 |
apply (erule exE)
|
|
|
256 |
apply (rule someI2)
|
|
|
257 |
apply assumption
|
|
|
258 |
apply blast
|
|
|
259 |
done
|
|
|
260 |
|
|
|
261 |
lemmas sim_starts1 = simulation_starts [unfolded Let_def, THEN conjunct1, standard]
|
|
|
262 |
lemmas sim_starts2 = simulation_starts [unfolded Let_def, THEN conjunct2, standard]
|
|
|
263 |
|
|
|
264 |
|
|
|
265 |
lemma trace_inclusion_for_simulations:
|
|
|
266 |
"[| ext C = ext A; is_simulation R C A |]
|
|
|
267 |
==> traces C <= traces A"
|
|
|
268 |
|
|
|
269 |
apply (unfold traces_def)
|
|
|
270 |
|
|
|
271 |
apply (simp (no_asm) add: has_trace_def2)
|
|
|
272 |
apply (tactic "safe_tac set_cs")
|
|
|
273 |
|
|
|
274 |
(* give execution of abstract automata *)
|
|
|
275 |
apply (rule_tac x = "corresp_ex_sim A R ex" in bexI)
|
|
|
276 |
|
|
|
277 |
(* Traces coincide, Lemma 1 *)
|
|
|
278 |
apply (tactic {* pair_tac "ex" 1 *})
|
|
|
279 |
apply (rename_tac s ex)
|
|
|
280 |
apply (simp (no_asm) add: corresp_ex_sim_def)
|
|
|
281 |
apply (rule_tac s = "s" in traces_coincide_sim)
|
|
|
282 |
apply assumption+
|
|
|
283 |
apply (simp add: executions_def reachable.reachable_0 sim_starts1)
|
|
|
284 |
|
|
|
285 |
(* corresp_ex_sim is execution, Lemma 2 *)
|
|
|
286 |
apply (tactic {* pair_tac "ex" 1 *})
|
|
|
287 |
apply (simp add: executions_def)
|
|
|
288 |
apply (rename_tac s ex)
|
|
|
289 |
|
|
|
290 |
(* start state *)
|
|
|
291 |
apply (rule conjI)
|
|
|
292 |
apply (simp add: sim_starts2 corresp_ex_sim_def)
|
|
|
293 |
|
|
|
294 |
(* is-execution-fragment *)
|
|
|
295 |
apply (simp add: corresp_ex_sim_def)
|
|
|
296 |
apply (rule_tac s = s in correspsim_is_execution)
|
|
|
297 |
apply assumption
|
|
|
298 |
apply (simp add: reachable.reachable_0 sim_starts1)
|
|
|
299 |
done
|
|
17233
|
300 |
|
|
|
301 |
end
|