| author | haftmann |
| Tue, 05 Jul 2005 13:57:23 +0200 | |
| changeset 16688 | e3de7ea24c23 |
| parent 14981 | e73f8140af78 |
| child 17233 | 41eee2e7b465 |
| permissions | -rw-r--r-- |
| 4565 | 1 |
(* Title: HOLCF/IOA/meta_theory/SimCorrectness.ML |
2 |
ID: $Id$ |
|
| 12218 | 3 |
Author: Olaf Müller |
| 4565 | 4 |
|
| 12218 | 5 |
Correctness of Simulations in HOLCF/IOA. |
| 4565 | 6 |
*) |
7 |
||
8 |
||
9 |
||
10 |
(* -------------------------------------------------------------------------------- *) |
|
11 |
||
12 |
section "corresp_ex_sim"; |
|
13 |
||
14 |
||
15 |
(* ---------------------------------------------------------------- *) |
|
16 |
(* corresp_ex_simC *) |
|
17 |
(* ---------------------------------------------------------------- *) |
|
18 |
||
19 |
||
| 5068 | 20 |
Goal "corresp_ex_simC A R = (LAM ex. (%s. case ex of \ |
| 4565 | 21 |
\ nil => nil \ |
22 |
\ | x##xs => (flift1 (%pr. let a = (fst pr); t = (snd pr); \ |
|
23 |
\ T' = @t'. ? ex1. (t,t'):R & move A ex1 s a t' \ |
|
24 |
\ in \ |
|
25 |
\ (@cex. move A cex s a T') \ |
|
| 10835 | 26 |
\ @@ ((corresp_ex_simC A R $xs) T')) \ |
27 |
\ $x) ))"; |
|
| 4565 | 28 |
by (rtac trans 1); |
| 5132 | 29 |
by (rtac fix_eq2 1); |
30 |
by (rtac corresp_ex_simC_def 1); |
|
31 |
by (rtac beta_cfun 1); |
|
| 4565 | 32 |
by (simp_tac (simpset() addsimps [flift1_def]) 1); |
33 |
qed"corresp_ex_simC_unfold"; |
|
34 |
||
| 10835 | 35 |
Goal "(corresp_ex_simC A R$UU) s=UU"; |
| 4565 | 36 |
by (stac corresp_ex_simC_unfold 1); |
37 |
by (Simp_tac 1); |
|
38 |
qed"corresp_ex_simC_UU"; |
|
39 |
||
| 10835 | 40 |
Goal "(corresp_ex_simC A R$nil) s = nil"; |
| 4565 | 41 |
by (stac corresp_ex_simC_unfold 1); |
42 |
by (Simp_tac 1); |
|
43 |
qed"corresp_ex_simC_nil"; |
|
44 |
||
| 10835 | 45 |
Goal "(corresp_ex_simC A R$((a,t)>>xs)) s = \ |
| 4565 | 46 |
\ (let T' = @t'. ? ex1. (t,t'):R & move A ex1 s a t' \ |
47 |
\ in \ |
|
48 |
\ (@cex. move A cex s a T') \ |
|
| 10835 | 49 |
\ @@ ((corresp_ex_simC A R$xs) T'))"; |
| 5132 | 50 |
by (rtac trans 1); |
| 4565 | 51 |
by (stac corresp_ex_simC_unfold 1); |
|
7229
6773ba0c36d5
renamed Cons to Consq in order to avoid clash with List.Cons;
wenzelm
parents:
6161
diff
changeset
|
52 |
by (asm_full_simp_tac (simpset() addsimps [Consq_def,flift1_def]) 1); |
| 4565 | 53 |
by (Simp_tac 1); |
54 |
qed"corresp_ex_simC_cons"; |
|
55 |
||
56 |
||
57 |
Addsimps [corresp_ex_simC_UU,corresp_ex_simC_nil,corresp_ex_simC_cons]; |
|
58 |
||
59 |
||
60 |
||
61 |
(* ------------------------------------------------------------------ *) |
|
62 |
(* The following lemmata describe the definition *) |
|
63 |
(* of move in more detail *) |
|
64 |
(* ------------------------------------------------------------------ *) |
|
65 |
||
66 |
section"properties of move"; |
|
67 |
||
68 |
Delsimps [Let_def]; |
|
69 |
||
| 5068 | 70 |
Goalw [is_simulation_def] |
| 6161 | 71 |
"[|is_simulation R C A; reachable C s; s -a--C-> t; (s,s'):R|] ==>\ |
| 4565 | 72 |
\ let T' = @t'. ? ex1. (t,t'):R & move A ex1 s' a t' in \ |
73 |
\ (t,T'): R & move A (@ex2. move A ex2 s' a T') s' a T'"; |
|
74 |
||
75 |
(* Does not perform conditional rewriting on assumptions automatically as |
|
76 |
usual. Instantiate all variables per hand. Ask Tobias?? *) |
|
77 |
by (subgoal_tac "? t' ex. (t,t'):R & move A ex s' a t'" 1); |
|
78 |
by (Asm_full_simp_tac 2); |
|
79 |
by (etac conjE 2); |
|
80 |
by (eres_inst_tac [("x","s")] allE 2);
|
|
81 |
by (eres_inst_tac [("x","s'")] allE 2);
|
|
82 |
by (eres_inst_tac [("x","t")] allE 2);
|
|
83 |
by (eres_inst_tac [("x","a")] allE 2);
|
|
84 |
by (Asm_full_simp_tac 2); |
|
85 |
(* Go on as usual *) |
|
| 5132 | 86 |
by (etac exE 1); |
| 4565 | 87 |
by (dres_inst_tac [("x","t'"),
|
| 9970 | 88 |
("P","%t'. ? ex.(t,t'):R & move A ex s' a t'")] someI 1);
|
| 5132 | 89 |
by (etac exE 1); |
90 |
by (etac conjE 1); |
|
| 4565 | 91 |
by (asm_full_simp_tac (simpset() addsimps [Let_def]) 1); |
| 9970 | 92 |
by (res_inst_tac [("x","ex")] someI 1);
|
| 5132 | 93 |
by (etac conjE 1); |
94 |
by (assume_tac 1); |
|
| 4565 | 95 |
qed"move_is_move_sim"; |
96 |
||
97 |
||
98 |
Addsimps [Let_def]; |
|
99 |
||
| 5068 | 100 |
Goal |
| 6161 | 101 |
"[|is_simulation R C A; reachable C s; s-a--C-> t; (s,s'):R|] ==>\ |
| 4565 | 102 |
\ let T' = @t'. ? ex1. (t,t'):R & move A ex1 s' a t' in \ |
103 |
\ is_exec_frag A (s',@x. move A x s' a T')"; |
|
104 |
by (cut_inst_tac [] move_is_move_sim 1); |
|
105 |
by (REPEAT (assume_tac 1)); |
|
106 |
by (asm_full_simp_tac (simpset() addsimps [move_def,Let_def]) 1); |
|
107 |
qed"move_subprop1_sim"; |
|
108 |
||
| 5068 | 109 |
Goal |
| 6161 | 110 |
"[|is_simulation R C A; reachable C s; s-a--C-> t; (s,s'):R|] ==>\ |
| 4565 | 111 |
\ let T' = @t'. ? ex1. (t,t'):R & move A ex1 s' a t' in \ |
112 |
\ Finite (@x. move A x s' a T')"; |
|
113 |
by (cut_inst_tac [] move_is_move_sim 1); |
|
114 |
by (REPEAT (assume_tac 1)); |
|
115 |
by (asm_full_simp_tac (simpset() addsimps [move_def,Let_def]) 1); |
|
116 |
qed"move_subprop2_sim"; |
|
117 |
||
| 5068 | 118 |
Goal |
| 6161 | 119 |
"[|is_simulation R C A; reachable C s; s-a--C-> t; (s,s'):R|] ==>\ |
| 4565 | 120 |
\ let T' = @t'. ? ex1. (t,t'):R & move A ex1 s' a t' in \ |
121 |
\ laststate (s',@x. move A x s' a T') = T'"; |
|
122 |
by (cut_inst_tac [] move_is_move_sim 1); |
|
123 |
by (REPEAT (assume_tac 1)); |
|
124 |
by (asm_full_simp_tac (simpset() addsimps [move_def,Let_def]) 1); |
|
125 |
qed"move_subprop3_sim"; |
|
126 |
||
| 5068 | 127 |
Goal |
| 6161 | 128 |
"[|is_simulation R C A; reachable C s; s-a--C-> t; (s,s'):R|] ==>\ |
| 4565 | 129 |
\ let T' = @t'. ? ex1. (t,t'):R & move A ex1 s' a t' in \ |
| 10835 | 130 |
\ mk_trace A$((@x. move A x s' a T')) = \ |
| 4565 | 131 |
\ (if a:ext A then a>>nil else nil)"; |
132 |
by (cut_inst_tac [] move_is_move_sim 1); |
|
133 |
by (REPEAT (assume_tac 1)); |
|
134 |
by (asm_full_simp_tac (simpset() addsimps [move_def,Let_def]) 1); |
|
135 |
qed"move_subprop4_sim"; |
|
136 |
||
| 5068 | 137 |
Goal |
| 6161 | 138 |
"[|is_simulation R C A; reachable C s; s-a--C-> t; (s,s'):R|] ==>\ |
| 4565 | 139 |
\ let T' = @t'. ? ex1. (t,t'):R & move A ex1 s' a t' in \ |
140 |
\ (t,T'):R"; |
|
141 |
by (cut_inst_tac [] move_is_move_sim 1); |
|
142 |
by (REPEAT (assume_tac 1)); |
|
143 |
by (asm_full_simp_tac (simpset() addsimps [move_def,Let_def]) 1); |
|
144 |
qed"move_subprop5_sim"; |
|
145 |
||
146 |
(* ------------------------------------------------------------------ *) |
|
147 |
(* The following lemmata contribute to *) |
|
148 |
(* TRACE INCLUSION Part 1: Traces coincide *) |
|
149 |
(* ------------------------------------------------------------------ *) |
|
150 |
||
151 |
section "Lemmata for <=="; |
|
152 |
||
153 |
||
154 |
(* ------------------------------------------------------ |
|
155 |
Lemma 1 :Traces coincide |
|
156 |
------------------------------------------------------- *) |
|
157 |
||
| 4833 | 158 |
Delsplits[split_if]; |
| 5068 | 159 |
Goal |
| 6161 | 160 |
"[|is_simulation R C A; ext C = ext A|] ==> \ |
| 4565 | 161 |
\ !s s'. reachable C s & is_exec_frag C (s,ex) & (s,s'): R --> \ |
| 10835 | 162 |
\ mk_trace C$ex = mk_trace A$((corresp_ex_simC A R$ex) s')"; |
| 4565 | 163 |
|
164 |
by (pair_induct_tac "ex" [is_exec_frag_def] 1); |
|
165 |
(* cons case *) |
|
166 |
by (safe_tac set_cs); |
|
167 |
ren "ex a t s s'" 1; |
|
168 |
by (asm_full_simp_tac (simpset() addsimps [mk_traceConc]) 1); |
|
169 |
by (forward_tac [reachable.reachable_n] 1); |
|
| 5132 | 170 |
by (assume_tac 1); |
| 4565 | 171 |
by (eres_inst_tac [("x","t")] allE 1);
|
172 |
by (eres_inst_tac [("x",
|
|
173 |
"@t'. ? ex1. (t,t'):R & move A ex1 s' a t'")] |
|
174 |
allE 1); |
|
175 |
by (Asm_full_simp_tac 1); |
|
176 |
by (asm_full_simp_tac (simpset() addsimps |
|
177 |
[rewrite_rule [Let_def] move_subprop5_sim, |
|
178 |
rewrite_rule [Let_def] move_subprop4_sim] |
|
| 4833 | 179 |
addsplits [split_if]) 1); |
| 4565 | 180 |
qed_spec_mp"traces_coincide_sim"; |
| 4833 | 181 |
Addsplits[split_if]; |
| 4565 | 182 |
|
183 |
||
184 |
(* ----------------------------------------------------------- *) |
|
185 |
(* Lemma 2 : corresp_ex_sim is execution *) |
|
186 |
(* ----------------------------------------------------------- *) |
|
187 |
||
188 |
||
| 5068 | 189 |
Goal |
| 6161 | 190 |
"[| is_simulation R C A |] ==>\ |
| 4565 | 191 |
\ !s s'. reachable C s & is_exec_frag C (s,ex) & (s,s'):R \ |
| 10835 | 192 |
\ --> is_exec_frag A (s',(corresp_ex_simC A R$ex) s')"; |
| 4565 | 193 |
|
194 |
by (Asm_full_simp_tac 1); |
|
195 |
by (pair_induct_tac "ex" [is_exec_frag_def] 1); |
|
196 |
(* main case *) |
|
197 |
by (safe_tac set_cs); |
|
198 |
ren "ex a t s s'" 1; |
|
199 |
by (res_inst_tac [("t",
|
|
200 |
"@t'. ? ex1. (t,t'):R & move A ex1 s' a t'")] |
|
201 |
lemma_2_1 1); |
|
202 |
||
203 |
(* Finite *) |
|
| 5132 | 204 |
by (etac (rewrite_rule [Let_def] move_subprop2_sim) 1); |
| 4565 | 205 |
by (REPEAT (atac 1)); |
206 |
by (rtac conjI 1); |
|
207 |
||
208 |
(* is_exec_frag *) |
|
| 5132 | 209 |
by (etac (rewrite_rule [Let_def] move_subprop1_sim) 1); |
| 4565 | 210 |
by (REPEAT (atac 1)); |
211 |
by (rtac conjI 1); |
|
212 |
||
213 |
(* Induction hypothesis *) |
|
214 |
(* reachable_n looping, therefore apply it manually *) |
|
215 |
by (eres_inst_tac [("x","t")] allE 1);
|
|
216 |
by (eres_inst_tac [("x",
|
|
217 |
"@t'. ? ex1. (t,t'):R & move A ex1 s' a t'")] |
|
218 |
allE 1); |
|
219 |
by (Asm_full_simp_tac 1); |
|
220 |
by (forward_tac [reachable.reachable_n] 1); |
|
| 5132 | 221 |
by (assume_tac 1); |
| 4565 | 222 |
by (asm_full_simp_tac (simpset() addsimps |
223 |
[rewrite_rule [Let_def] move_subprop5_sim]) 1); |
|
224 |
(* laststate *) |
|
| 5132 | 225 |
by (etac ((rewrite_rule [Let_def] move_subprop3_sim) RS sym) 1); |
| 4565 | 226 |
by (REPEAT (atac 1)); |
227 |
qed_spec_mp"correspsim_is_execution"; |
|
228 |
||
229 |
||
230 |
(* -------------------------------------------------------------------------------- *) |
|
231 |
||
232 |
section "Main Theorem: T R A C E - I N C L U S I O N"; |
|
233 |
||
234 |
(* -------------------------------------------------------------------------------- *) |
|
235 |
||
236 |
(* generate condition (s,S'):R & S':starts_of A, the first being intereting |
|
237 |
for the induction cases concerning the two lemmas correpsim_is_execution and |
|
238 |
traces_coincide_sim, the second for the start state case. |
|
239 |
S':= @s'. (s,s'):R & s':starts_of A, where s:starts_of C *) |
|
240 |
||
| 5068 | 241 |
Goal |
| 6161 | 242 |
"[| is_simulation R C A; s:starts_of C |] \ |
| 4565 | 243 |
\ ==> let S' = @s'. (s,s'):R & s':starts_of A in \ |
244 |
\ (s,S'):R & S':starts_of A"; |
|
245 |
by (asm_full_simp_tac (simpset() addsimps [is_simulation_def, |
|
246 |
corresp_ex_sim_def, Int_non_empty,Image_def]) 1); |
|
247 |
by (REPEAT (etac conjE 1)); |
|
| 5132 | 248 |
by (etac ballE 1); |
| 4565 | 249 |
by (Blast_tac 2); |
| 5132 | 250 |
by (etac exE 1); |
| 9969 | 251 |
by (rtac someI2 1); |
| 5132 | 252 |
by (assume_tac 1); |
| 4565 | 253 |
by (Blast_tac 1); |
254 |
qed"simulation_starts"; |
|
255 |
||
256 |
bind_thm("sim_starts1",(rewrite_rule [Let_def] simulation_starts) RS conjunct1);
|
|
257 |
bind_thm("sim_starts2",(rewrite_rule [Let_def] simulation_starts) RS conjunct2);
|
|
258 |
||
259 |
||
| 5068 | 260 |
Goalw [traces_def] |
| 6161 | 261 |
"[| ext C = ext A; is_simulation R C A |] \ |
| 4565 | 262 |
\ ==> traces C <= traces A"; |
263 |
||
264 |
by (simp_tac(simpset() addsimps [has_trace_def2])1); |
|
265 |
by (safe_tac set_cs); |
|
266 |
||
267 |
(* give execution of abstract automata *) |
|
268 |
by (res_inst_tac[("x","corresp_ex_sim A R ex")] bexI 1);
|
|
269 |
||
270 |
(* Traces coincide, Lemma 1 *) |
|
271 |
by (pair_tac "ex" 1); |
|
272 |
ren "s ex" 1; |
|
273 |
by (simp_tac (simpset() addsimps [corresp_ex_sim_def]) 1); |
|
274 |
by (res_inst_tac [("s","s")] traces_coincide_sim 1);
|
|
275 |
by (REPEAT (atac 1)); |
|
276 |
by (asm_full_simp_tac (simpset() addsimps [executions_def, |
|
277 |
reachable.reachable_0,sim_starts1]) 1); |
|
278 |
||
279 |
(* corresp_ex_sim is execution, Lemma 2 *) |
|
280 |
by (pair_tac "ex" 1); |
|
281 |
by (asm_full_simp_tac (simpset() addsimps [executions_def]) 1); |
|
282 |
ren "s ex" 1; |
|
283 |
||
284 |
(* start state *) |
|
285 |
by (rtac conjI 1); |
|
286 |
by (asm_full_simp_tac (simpset() addsimps [sim_starts2, |
|
287 |
corresp_ex_sim_def]) 1); |
|
288 |
||
289 |
(* is-execution-fragment *) |
|
290 |
by (asm_full_simp_tac (simpset() addsimps [corresp_ex_sim_def]) 1); |
|
291 |
by (res_inst_tac [("s","s")] correspsim_is_execution 1);
|
|
| 5132 | 292 |
by (assume_tac 1); |
| 4565 | 293 |
by (asm_full_simp_tac (simpset() addsimps [reachable.reachable_0,sim_starts1]) 1); |
294 |
qed"trace_inclusion_for_simulations"; |
|
295 |
||
296 |
||
297 |
||
298 |