-
Notifications
You must be signed in to change notification settings - Fork 0
/
AnnChange.thy
291 lines (259 loc) · 10.4 KB
/
AnnChange.thy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
(* *********************************************************************
Theory AnnChange.thy is part of a framework for modelling,
verification and transformation of concurrent imperative
programs. Copyright (c) 2021 M. Bortin
The framework is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
For more details see the license agreement (LICENSE) you should have
received along with the framework.
******************************************************************* *)
theory AnnChange
imports ProgCorr
begin
inductive_set Eq_upto_ann :: "('s LA \<times> 's LA) set"
where "(Skip, Skip) \<in> Eq_upto_ann" |
"(Basic f, Basic f) \<in> Eq_upto_ann" |
"(p, p') \<in> Eq_upto_ann \<Longrightarrow> (CJUMP C TO i OTHERWISE p END,
CJUMP C TO i OTHERWISE p' END) \<in> Eq_upto_ann" |
"(p, p') \<in> Eq_upto_ann \<Longrightarrow> (q, q') \<in> Eq_upto_ann \<Longrightarrow>
(IF C THEN p ELSE q FI,
IF C THEN p' ELSE q' FI) \<in> Eq_upto_ann" |
"(p, p') \<in> Eq_upto_ann \<Longrightarrow> (q, q') \<in> Eq_upto_ann \<Longrightarrow>
(WHILE C \<lbrakk>inv: I\<rbrakk> DO p SUBSEQUENTLY q OD,
WHILE C \<lbrakk>inv: I'\<rbrakk> DO p' SUBSEQUENTLY q' OD) \<in> Eq_upto_ann" |
"(p, p') \<in> Eq_upto_ann \<Longrightarrow> (q, q') \<in> Eq_upto_ann \<Longrightarrow>
(p;q, p';q') \<in> Eq_upto_ann" |
"(p, p') \<in> Eq_upto_ann \<Longrightarrow>
(AWAIT C \<lbrakk>ann: a\<rbrakk> THEN p END, AWAIT C \<lbrakk>ann: a'\<rbrakk> THEN p' END) \<in> Eq_upto_ann" |
"(Parallel [], Parallel []) \<in> Eq_upto_ann" |
"(p, p') \<in> Eq_upto_ann \<Longrightarrow> (Parallel ps, Parallel ps') \<in> Eq_upto_ann \<Longrightarrow>
(Parallel ((p, a)#ps), Parallel ((p', a')#ps')) \<in> Eq_upto_ann"
lemma Eq_upto_ann_Parallels :
"(Parallel ps, Parallel ps') \<in> Eq_upto_ann \<Longrightarrow> i < length ps \<Longrightarrow>
(fst (ps ! i), fst (ps' ! i)) \<in> Eq_upto_ann"
apply(induct i arbitrary:ps ps')
apply(erule Eq_upto_ann.cases, simp_all)+
done
lemma Eq_upto_ann_ParallelsI :
"\<forall>i<length ps. (fst (ps ! i), fst (ps' ! i)) \<in> Eq_upto_ann \<Longrightarrow>
length ps = length ps' \<Longrightarrow>
(Parallel ps, Parallel ps') \<in> Eq_upto_ann"
apply(induct ps arbitrary:ps')
apply clarsimp
apply(rule Eq_upto_ann.intros)
apply clarsimp
apply(case_tac ps', clarsimp+)
apply(rule Eq_upto_ann.intros)
apply(drule_tac x=0 in spec, simp)
apply fastforce
done
lemma Eq_upto_ann_scheme[simp] :
"(\<And>i. n\<le>i \<Longrightarrow> i<m \<Longrightarrow> (fst(f i), fst(g i)) \<in> Eq_upto_ann) \<Longrightarrow>
(Parallel (map f [n..<m]), Parallel (map g [n..<m])) \<in> Eq_upto_ann"
by(rule Eq_upto_ann_ParallelsI, simp_all)
lemma Eq_upto_ann_Parallels_len :
"(Parallel ps, Parallel ps') \<in> Eq_upto_ann \<Longrightarrow>
length ps = length ps'"
apply(induct ps arbitrary:ps')
apply(erule Eq_upto_ann.cases, simp_all)+
done
lemma Eq_upto_ann_await_aux :
"(\<lambda>x1 x2. \<rho> \<turnstile> x1 -p\<rightarrow> x2 \<and>
(\<forall>q. (fst x1, q) \<in> Eq_upto_ann \<longrightarrow>
(\<exists>q'. \<rho> \<turnstile> (q, snd x1) -p\<rightarrow> (q', snd x2) \<and> (fst x2, q') \<in> Eq_upto_ann)))\<^sup>*\<^sup>*
cf cf' \<Longrightarrow>
\<forall>q. (fst cf, q) \<in> Eq_upto_ann \<longrightarrow>
(\<exists>q'. \<rho> \<turnstile> (q, snd cf) -p\<rightarrow>\<^sup>* (q', snd cf') \<and> (fst cf', q') \<in> Eq_upto_ann)"
apply(erule converse_rtranclp_induct)
apply clarify
apply(rule_tac x=q in exI, simp)
apply clarsimp
apply(drule spec, drule mp, assumption)
apply clarify
apply(drule spec, drule mp, assumption)
apply clarify
apply(rule exI, rule conjI, rule rtranclp_trans)
apply(erule r_into_rtranclp)
apply assumption+
done
lemma Eq_upto_ann_refl : "(p, p) \<in> Eq_upto_ann"
apply(induct p, (rule Eq_upto_ann.intros)+)
apply simp+
apply(rule Eq_upto_ann.intros)+
apply simp+
apply(rule Eq_upto_ann.intros)+
apply simp+
apply(rule Eq_upto_ann_ParallelsI)
apply (meson fsts.intros in_set_conv_nth)
apply simp
apply(rule Eq_upto_ann.intros)+
apply simp+
apply(rule Eq_upto_ann.intros)+
apply simp+
done
lemma Eq_upto_ann_sym :
"(p, q) \<in> Eq_upto_ann \<Longrightarrow> (q, p) \<in> Eq_upto_ann"
apply(induct rule: Eq_upto_ann.induct)
apply(rule Eq_upto_ann.intros)+
apply assumption+
apply(rule Eq_upto_ann.intros, assumption+)+
apply(rule Eq_upto_ann.intros)+
apply assumption+
done
lemma Eq_upto_ann_trans :
"(p, q) \<in> Eq_upto_ann \<Longrightarrow> (q, r) \<in> Eq_upto_ann \<Longrightarrow> (p, r) \<in> Eq_upto_ann"
apply(induct arbitrary: r rule: Eq_upto_ann.induct, simp_all)
apply(erule_tac ?a2.0=r in Eq_upto_ann.cases, simp_all)
apply(rule Eq_upto_ann.intros, fast)
apply(erule_tac ?a2.0=r in Eq_upto_ann.cases, simp_all)
apply(rule Eq_upto_ann.intros, fast+)
apply(erule_tac ?a2.0=r in Eq_upto_ann.cases, simp_all)
apply(rule Eq_upto_ann.intros, fast+)
apply(erule_tac ?a2.0=r in Eq_upto_ann.cases, simp_all)
apply(rule Eq_upto_ann.intros, fast+)
apply(erule_tac ?a2.0=r in Eq_upto_ann.cases, simp_all)
apply(rule Eq_upto_ann.intros, fast+)
apply(erule_tac ?a2.0=r in Eq_upto_ann.cases, simp_all)
apply(rule Eq_upto_ann.intros, fast+)
done
lemma Eq_upto_ann_corr_aux[rule_format] :
"\<rho> \<turnstile> cf -p\<rightarrow> cf' \<Longrightarrow>
(\<forall>q. (fst cf, q) \<in> Eq_upto_ann \<longrightarrow>
(\<exists>q'. \<rho> \<turnstile> (q, snd cf) -p\<rightarrow> (q', snd cf') \<and> (fst cf', q') \<in> Eq_upto_ann))"
apply(erule pstep.induct)
apply clarsimp
apply(erule Eq_upto_ann.cases, simp_all)
apply(rule exI, rule conjI, rule pstep.Basic)
apply(rule Eq_upto_ann.intros)
apply clarsimp
apply(erule Eq_upto_ann.cases, simp_all)
apply(rule_tac x="\<rho> j" in exI, simp add: Eq_upto_ann_refl)
apply(erule pstep.CJumpT)
apply clarsimp
apply(erule Eq_upto_ann.cases, simp_all)
apply(rule_tac x=p' in exI, simp)
apply(erule pstep.CJumpF)
apply clarsimp
apply(erule Eq_upto_ann.cases, simp_all)
apply clarify
apply(drule spec, drule mp, assumption)
apply clarify
apply(rule exI, rule conjI, erule pstep.Seq)
apply(erule Eq_upto_ann.intros, assumption)
apply clarsimp
apply(erule Eq_upto_ann.cases, simp_all)
apply clarify
apply(erule Eq_upto_ann.cases, simp_all)
apply clarify
apply(rule exI, rule conjI, rule pstep.SeqSkip)
apply assumption
apply clarsimp
apply(erule Eq_upto_ann.cases, simp_all)
apply clarify
apply(rule exI, rule conjI, erule pstep.CondT)
apply assumption
apply clarsimp
apply(erule Eq_upto_ann.cases, simp_all)
apply clarify
apply(rule exI, rule conjI, erule pstep.CondF)
apply assumption
apply clarsimp
apply(erule Eq_upto_ann.cases, simp_all)
apply clarify
apply(rule exI, rule conjI, erule pstep.WhileT)
apply(rule Eq_upto_ann.intros, assumption)
apply(rule Eq_upto_ann.intros)+
apply assumption+
apply clarsimp
apply(erule Eq_upto_ann.cases, simp_all)
apply clarify
apply(rule exI, rule conjI, erule pstep.WhileF)
apply assumption
apply clarsimp
apply(erule Eq_upto_ann.cases, simp_all)
apply clarify
apply(case_tac i, clarsimp)
apply(drule spec, drule mp, assumption)
apply clarify
apply(rule exI, rule conjI, rule_tac i=0 in pstep.Parallel, simp, simp)
apply simp
apply(erule Eq_upto_ann.intros, assumption)
apply clarsimp
apply(rename_tac i)
apply(drule_tac x="fst (ps'!i)" in spec)
apply(drule mp)
apply(erule Eq_upto_ann_Parallels, assumption)
apply clarsimp
apply(rule exI, rule conjI, rule_tac i="Suc i" in pstep.Parallel)
apply simp
apply(drule Eq_upto_ann_Parallels_len, simp)
apply simp
apply(erule Eq_upto_ann.intros)
apply(frule Eq_upto_ann_Parallels_len)
apply(rule Eq_upto_ann_ParallelsI)
apply clarsimp
apply(rename_tac j)
apply(case_tac "i = j", simp)
apply simp
apply(erule Eq_upto_ann_Parallels, simp)
apply simp
apply clarsimp
apply(erule Eq_upto_ann.cases, simp_all)
apply clarify
apply(rule exI, rule conjI, rule pstep.ParallelSkip, simp)
apply(rule Eq_upto_ann.intros)
apply clarsimp
apply(erule Eq_upto_ann.cases, simp_all)
apply(rule exI, rule conjI, rule pstep.ParallelSkip, simp)
apply clarsimp
apply(drule mem_nth)
apply clarify
apply(frule Eq_upto_ann_Parallels_len)
apply(drule Eq_upto_ann_Parallels, simp)
apply(drule bspec, rule_tac n=i in nth_mem, simp)
apply(erule Eq_upto_ann.cases, simp_all)
apply(drule sym, simp)
apply(rule Eq_upto_ann.intros)
apply clarsimp
apply(erule Eq_upto_ann.cases, simp_all)
apply clarify
apply(drule Eq_upto_ann_await_aux)
apply simp
apply(drule spec, drule mp, assumption)
apply clarify
apply(thin_tac "_ \<in> Eq_upto_ann")
apply(erule Eq_upto_ann.cases, simp_all)
apply clarify
apply(rule exI, rule conjI, erule pstep.Await, assumption)
by(rule Eq_upto_ann.intros)
lemma Eq_upto_ann_corr :
"(p, q) \<in> Eq_upto_ann \<Longrightarrow>
\<rho> \<Turnstile> p \<sqsupseteq> q"
apply(simp add: prog_corr_def)
apply(rule_tac x="Eq_upto_ann" in exI, simp)
apply(simp add: prog_sim_def)
apply(rule conjI, clarsimp)
apply(drule Eq_upto_ann_corr_aux)
apply simp
apply(erule Eq_upto_ann_sym)
apply clarsimp
apply(rule exI, erule conjI)
apply(erule Eq_upto_ann_sym)
apply(thin_tac "(p, q) \<in> Eq_upto_ann")
apply(rule conjI, clarify)
apply(erule Eq_upto_ann.cases, simp_all)
apply clarify
apply(erule Eq_upto_ann.cases, simp_all)
done
lemma Eq_upto_ann_eqv :
"(p, q) \<in> Eq_upto_ann \<Longrightarrow>
\<rho> \<Turnstile> p \<approx> q"
apply(simp add: prog_mucorr_def)
apply(rule conjI)
apply(erule Eq_upto_ann_corr)
apply(rule Eq_upto_ann_corr)
apply(erule Eq_upto_ann_sym)
done
lemmas Eq_upto_ann1 = Eq_upto_ann_eqv[THEN prog_corr_RG_eq]
end