| author | webertj | 
| Fri, 02 Apr 2004 17:28:16 +0200 | |
| changeset 14514 | 15abb7d42e2e | 
| parent 13601 | fd3e3d6b37b2 | 
| child 15236 | f289e8ba2bb3 | 
| permissions | -rw-r--r-- | 
| 13020 | 1 | header {* \section{Operational Semantics} *}
 | 
| 2 | ||
| 3 | theory RG_Tran = RG_Com: | |
| 4 | ||
| 5 | subsection {* Semantics of Component Programs *}
 | |
| 6 | ||
| 7 | subsubsection {* Environment transitions *}
 | |
| 8 | ||
| 9 | types 'a conf = "(('a com) option) \<times> 'a"
 | |
| 10 | ||
| 11 | consts etran    :: "('a conf \<times> 'a conf) set" 
 | |
| 12 | syntax  "_etran"  :: "'a conf \<Rightarrow> 'a conf \<Rightarrow> bool"  ("_ -e\<rightarrow> _" [81,81] 80)
 | |
| 13 | translations "P -e\<rightarrow> Q" \<rightleftharpoons> "(P,Q) \<in> etran" | |
| 14 | inductive etran | |
| 15 | intros | |
| 16 | Env: "(P, s) -e\<rightarrow> (P, t)" | |
| 17 | ||
| 18 | subsubsection {* Component transitions *}
 | |
| 19 | ||
| 20 | consts ctran    :: "('a conf \<times> 'a conf) set"
 | |
| 21 | syntax | |
| 22 |   "_ctran"  :: "'a conf \<Rightarrow> 'a conf \<Rightarrow> bool"   ("_ -c\<rightarrow> _" [81,81] 80)
 | |
| 23 |   "_ctran_*":: "'a conf \<Rightarrow> 'a conf \<Rightarrow> bool"   ("_ -c*\<rightarrow> _" [81,81] 80)
 | |
| 24 | translations | |
| 25 | "P -c\<rightarrow> Q" \<rightleftharpoons> "(P,Q) \<in> ctran" | |
| 26 | "P -c*\<rightarrow> Q" \<rightleftharpoons> "(P,Q) \<in> ctran^*" | |
| 27 | ||
| 28 | inductive ctran | |
| 29 | intros | |
| 30 | Basic: "(Some(Basic f), s) -c\<rightarrow> (None, f s)" | |
| 31 | ||
| 32 | Seq1: "(Some P0, s) -c\<rightarrow> (None, t) \<Longrightarrow> (Some(Seq P0 P1), s) -c\<rightarrow> (Some P1, t)" | |
| 33 | ||
| 34 | Seq2: "(Some P0, s) -c\<rightarrow> (Some P2, t) \<Longrightarrow> (Some(Seq P0 P1), s) -c\<rightarrow> (Some(Seq P2 P1), t)" | |
| 35 | ||
| 36 | CondT: "s\<in>b \<Longrightarrow> (Some(Cond b P1 P2), s) -c\<rightarrow> (Some P1, s)" | |
| 37 | CondF: "s\<notin>b \<Longrightarrow> (Some(Cond b P1 P2), s) -c\<rightarrow> (Some P2, s)" | |
| 38 | ||
| 39 | WhileF: "s\<notin>b \<Longrightarrow> (Some(While b P), s) -c\<rightarrow> (None, s)" | |
| 40 | WhileT: "s\<in>b \<Longrightarrow> (Some(While b P), s) -c\<rightarrow> (Some(Seq P (While b P)), s)" | |
| 41 | ||
| 42 | Await: "\<lbrakk>s\<in>b; (Some P, s) -c*\<rightarrow> (None, t)\<rbrakk> \<Longrightarrow> (Some(Await b P), s) -c\<rightarrow> (None, t)" | |
| 43 | ||
| 44 | monos "rtrancl_mono" | |
| 45 | ||
| 46 | subsection {* Semantics of Parallel Programs *}
 | |
| 47 | ||
| 48 | types 'a par_conf = "('a par_com) \<times> 'a"
 | |
| 49 | consts | |
| 50 |   par_etran :: "('a par_conf \<times> 'a par_conf) set"
 | |
| 51 |   par_ctran :: "('a par_conf \<times> 'a par_conf) set"
 | |
| 52 | syntax | |
| 53 |   "_par_etran":: "['a par_conf,'a par_conf] \<Rightarrow> bool" ("_ -pe\<rightarrow> _" [81,81] 80)
 | |
| 54 |   "_par_ctran":: "['a par_conf,'a par_conf] \<Rightarrow> bool" ("_ -pc\<rightarrow> _" [81,81] 80)
 | |
| 55 | translations | |
| 56 | "P -pe\<rightarrow> Q" \<rightleftharpoons> "(P,Q) \<in> par_etran" | |
| 57 | "P -pc\<rightarrow> Q" \<rightleftharpoons> "(P,Q) \<in> par_ctran" | |
| 58 | ||
| 59 | inductive par_etran | |
| 60 | intros | |
| 61 | ParEnv: "(Ps, s) -pe\<rightarrow> (Ps, t)" | |
| 62 | ||
| 63 | inductive par_ctran | |
| 64 | intros | |
| 65 | ParComp: "\<lbrakk>i<length Ps; (Ps!i, s) -c\<rightarrow> (r, t)\<rbrakk> \<Longrightarrow> (Ps, s) -pc\<rightarrow> (Ps[i:=r], t)" | |
| 66 | ||
| 67 | subsection {* Computations *}
 | |
| 68 | ||
| 69 | subsubsection {* Sequential computations *}
 | |
| 70 | ||
| 71 | types 'a confs = "('a conf) list"
 | |
| 72 | consts cptn :: "('a confs) set"
 | |
| 73 | inductive "cptn" | |
| 74 | intros | |
| 75 | CptnOne: "[(P,s)] \<in> cptn" | |
| 76 | CptnEnv: "(P, t)#xs \<in> cptn \<Longrightarrow> (P,s)#(P,t)#xs \<in> cptn" | |
| 77 | CptnComp: "\<lbrakk>(P,s) -c\<rightarrow> (Q,t); (Q, t)#xs \<in> cptn \<rbrakk> \<Longrightarrow> (P,s)#(Q,t)#xs \<in> cptn" | |
| 78 | ||
| 79 | constdefs | |
| 80 |   cp :: "('a com) option \<Rightarrow> 'a \<Rightarrow> ('a confs) set"
 | |
| 81 |   "cp P s \<equiv> {l. l!0=(P,s) \<and> l \<in> cptn}"  
 | |
| 82 | ||
| 83 | subsubsection {* Parallel computations *}
 | |
| 84 | ||
| 85 | types  'a par_confs = "('a par_conf) list"
 | |
| 86 | consts par_cptn :: "('a par_confs) set"
 | |
| 87 | inductive "par_cptn" | |
| 88 | intros | |
| 89 | ParCptnOne: "[(P,s)] \<in> par_cptn" | |
| 90 | ParCptnEnv: "(P,t)#xs \<in> par_cptn \<Longrightarrow> (P,s)#(P,t)#xs \<in> par_cptn" | |
| 91 | ParCptnComp: "\<lbrakk> (P,s) -pc\<rightarrow> (Q,t); (Q,t)#xs \<in> par_cptn \<rbrakk> \<Longrightarrow> (P,s)#(Q,t)#xs \<in> par_cptn" | |
| 92 | ||
| 93 | constdefs | |
| 94 |   par_cp :: "'a par_com \<Rightarrow> 'a \<Rightarrow> ('a par_confs) set"
 | |
| 95 |   "par_cp P s \<equiv> {l. l!0=(P,s) \<and> l \<in> par_cptn}"  
 | |
| 96 | ||
| 97 | subsection{* Modular Definition of Computation *}
 | |
| 98 | ||
| 99 | constdefs | |
| 100 | lift :: "'a com \<Rightarrow> 'a conf \<Rightarrow> 'a conf" | |
| 101 | "lift Q \<equiv> \<lambda>(P, s). (if P=None then (Some Q,s) else (Some(Seq (the P) Q), s))" | |
| 102 | ||
| 103 | consts  cptn_mod :: "('a confs) set"
 | |
| 104 | inductive "cptn_mod" | |
| 105 | intros | |
| 106 | CptnModOne: "[(P, s)] \<in> cptn_mod" | |
| 107 | CptnModEnv: "(P, t)#xs \<in> cptn_mod \<Longrightarrow> (P, s)#(P, t)#xs \<in> cptn_mod" | |
| 108 | CptnModNone: "\<lbrakk>(Some P, s) -c\<rightarrow> (None, t); (None, t)#xs \<in> cptn_mod \<rbrakk> \<Longrightarrow> (Some P,s)#(None, t)#xs \<in>cptn_mod" | |
| 109 | CptnModCondT: "\<lbrakk>(Some P0, s)#ys \<in> cptn_mod; s \<in> b \<rbrakk> \<Longrightarrow> (Some(Cond b P0 P1), s)#(Some P0, s)#ys \<in> cptn_mod" | |
| 110 | CptnModCondF: "\<lbrakk>(Some P1, s)#ys \<in> cptn_mod; s \<notin> b \<rbrakk> \<Longrightarrow> (Some(Cond b P0 P1), s)#(Some P1, s)#ys \<in> cptn_mod" | |
| 111 | CptnModSeq1: "\<lbrakk>(Some P0, s)#xs \<in> cptn_mod; zs=map (lift P1) xs \<rbrakk> | |
| 112 | \<Longrightarrow> (Some(Seq P0 P1), s)#zs \<in> cptn_mod" | |
| 113 | CptnModSeq2: | |
| 114 | "\<lbrakk>(Some P0, s)#xs \<in> cptn_mod; fst(last ((Some P0, s)#xs)) = None; | |
| 115 | (Some P1, snd(last ((Some P0, s)#xs)))#ys \<in> cptn_mod; | |
| 116 | zs=(map (lift P1) xs)@ys \<rbrakk> \<Longrightarrow> (Some(Seq P0 P1), s)#zs \<in> cptn_mod" | |
| 117 | ||
| 118 | CptnModWhile1: | |
| 119 | "\<lbrakk> (Some P, s)#xs \<in> cptn_mod; s \<in> b; zs=map (lift (While b P)) xs \<rbrakk> | |
| 120 | \<Longrightarrow> (Some(While b P), s)#(Some(Seq P (While b P)), s)#zs \<in> cptn_mod" | |
| 121 | CptnModWhile2: | |
| 122 | "\<lbrakk> (Some P, s)#xs \<in> cptn_mod; fst(last ((Some P, s)#xs))=None; s \<in> b; | |
| 123 | zs=(map (lift (While b P)) xs)@ys; | |
| 124 | (Some(While b P), snd(last ((Some P, s)#xs)))#ys \<in> cptn_mod\<rbrakk> | |
| 125 | \<Longrightarrow> (Some(While b P), s)#(Some(Seq P (While b P)), s)#zs \<in> cptn_mod" | |
| 126 | ||
| 127 | subsection {* Equivalence of Both Definitions.*}
 | |
| 128 | ||
| 129 | lemma last_length: "((a#xs)!(length xs))=last (a#xs)" | |
| 130 | apply simp | |
| 131 | apply(induct xs,simp+) | |
| 132 | apply(case_tac list) | |
| 133 | apply simp_all | |
| 134 | done | |
| 135 | ||
| 136 | lemma div_seq [rule_format]: "list \<in> cptn_mod \<Longrightarrow> | |
| 137 | (\<forall>s P Q zs. list=(Some (Seq P Q), s)#zs \<longrightarrow> | |
| 138 | (\<exists>xs. (Some P, s)#xs \<in> cptn_mod \<and> (zs=(map (lift Q) xs) \<or> | |
| 139 | ( fst(((Some P, s)#xs)!length xs)=None \<and> | |
| 140 | (\<exists>ys. (Some Q, snd(((Some P, s)#xs)!length xs))#ys \<in> cptn_mod | |
| 141 | \<and> zs=(map (lift (Q)) xs)@ys)))))" | |
| 142 | apply(erule cptn_mod.induct) | |
| 143 | apply simp_all | |
| 144 | apply clarify | |
| 145 | apply(force intro:CptnModOne) | |
| 146 | apply clarify | |
| 147 | apply(erule_tac x=Pa in allE) | |
| 148 | apply(erule_tac x=Q in allE) | |
| 149 | apply simp | |
| 150 | apply clarify | |
| 151 | apply(erule disjE) | |
| 152 | apply(rule_tac x="(Some Pa,t)#xsa" in exI) | |
| 153 | apply(rule conjI) | |
| 154 | apply clarify | |
| 155 | apply(erule CptnModEnv) | |
| 156 | apply(rule disjI1) | |
| 157 | apply(simp add:lift_def) | |
| 158 | apply clarify | |
| 159 | apply(rule_tac x="(Some Pa,t)#xsa" in exI) | |
| 160 | apply(rule conjI) | |
| 161 | apply(erule CptnModEnv) | |
| 162 | apply(rule disjI2) | |
| 163 | apply(rule conjI) | |
| 164 | apply(case_tac xsa,simp,simp) | |
| 165 | apply(rule_tac x="ys" in exI) | |
| 166 | apply(rule conjI) | |
| 167 | apply simp | |
| 168 | apply(simp add:lift_def) | |
| 169 | apply clarify | |
| 170 | apply(erule ctran.elims,simp_all) | |
| 171 | apply clarify | |
| 172 | apply(rule_tac x="xs" in exI) | |
| 173 | apply simp | |
| 174 | apply clarify | |
| 175 | apply(rule_tac x="xs" in exI) | |
| 176 | apply(simp add: last_length) | |
| 177 | done | |
| 178 | ||
| 179 | lemma cptn_onlyif_cptn_mod_aux [rule_format]: | |
| 180 | "\<forall>s Q t xs.((Some a, s), Q, t) \<in> ctran \<longrightarrow> (Q, t) # xs \<in> cptn_mod | |
| 181 | \<longrightarrow> (Some a, s) # (Q, t) # xs \<in> cptn_mod" | |
| 182 | apply(induct a) | |
| 183 | apply simp_all | |
| 184 | --{* basic *}
 | |
| 185 | apply clarify | |
| 186 | apply(erule ctran.elims,simp_all) | |
| 187 | apply(rule CptnModNone,rule Basic,simp) | |
| 188 | apply clarify | |
| 189 | apply(erule ctran.elims,simp_all) | |
| 190 | --{* Seq1 *}
 | |
| 191 | apply(rule_tac xs="[(None,ta)]" in CptnModSeq2) | |
| 192 | apply(erule CptnModNone) | |
| 193 | apply(rule CptnModOne) | |
| 194 | apply simp | |
| 195 | apply simp | |
| 196 | apply(simp add:lift_def) | |
| 197 | --{* Seq2 *}
 | |
| 198 | apply(erule_tac x=sa in allE) | |
| 199 | apply(erule_tac x="Some P2" in allE) | |
| 200 | apply(erule allE,erule impE, assumption) | |
| 201 | apply(drule div_seq,simp) | |
| 202 | apply force | |
| 203 | apply clarify | |
| 204 | apply(erule disjE) | |
| 205 | apply clarify | |
| 206 | apply(erule allE,erule impE, assumption) | |
| 207 | apply(erule_tac CptnModSeq1) | |
| 208 | apply(simp add:lift_def) | |
| 209 | apply clarify | |
| 210 | apply(erule allE,erule impE, assumption) | |
| 211 | apply(erule_tac CptnModSeq2) | |
| 212 | apply (simp add:last_length) | |
| 213 | apply (simp add:last_length) | |
| 214 | apply(simp add:lift_def) | |
| 215 | --{* Cond *}
 | |
| 216 | apply clarify | |
| 217 | apply(erule ctran.elims,simp_all) | |
| 218 | apply(force elim: CptnModCondT) | |
| 219 | apply(force elim: CptnModCondF) | |
| 220 | --{* While *}
 | |
| 221 | apply clarify | |
| 222 | apply(erule ctran.elims,simp_all) | |
| 223 | apply(rule CptnModNone,erule WhileF,simp) | |
| 224 | apply(drule div_seq,force) | |
| 225 | apply clarify | |
| 226 | apply (erule disjE) | |
| 227 | apply(force elim:CptnModWhile1) | |
| 228 | apply clarify | |
| 229 | apply(force simp add:last_length elim:CptnModWhile2) | |
| 230 | --{* await *}
 | |
| 231 | apply clarify | |
| 232 | apply(erule ctran.elims,simp_all) | |
| 233 | apply(rule CptnModNone,erule Await,simp+) | |
| 234 | done | |
| 235 | ||
| 236 | lemma cptn_onlyif_cptn_mod [rule_format]: "c \<in> cptn \<Longrightarrow> c \<in> cptn_mod" | |
| 237 | apply(erule cptn.induct) | |
| 238 | apply(rule CptnModOne) | |
| 239 | apply(erule CptnModEnv) | |
| 240 | apply(case_tac P) | |
| 241 | apply simp | |
| 242 | apply(erule ctran.elims,simp_all) | |
| 243 | apply(force elim:cptn_onlyif_cptn_mod_aux) | |
| 244 | done | |
| 245 | ||
| 246 | lemma lift_is_cptn: "c\<in>cptn \<Longrightarrow> map (lift P) c \<in> cptn" | |
| 247 | apply(erule cptn.induct) | |
| 248 | apply(force simp add:lift_def CptnOne) | |
| 249 | apply(force intro:CptnEnv simp add:lift_def) | |
| 250 | apply(force simp add:lift_def intro:CptnComp Seq2 Seq1 elim:ctran.elims) | |
| 251 | done | |
| 252 | ||
| 253 | lemma cptn_append_is_cptn [rule_format]: | |
| 254 | "\<forall>b a. b#c1\<in>cptn \<longrightarrow> a#c2\<in>cptn \<longrightarrow> (b#c1)!length c1=a \<longrightarrow> b#c1@c2\<in>cptn" | |
| 255 | apply(induct c1) | |
| 256 | apply simp | |
| 257 | apply clarify | |
| 258 | apply(erule cptn.elims,simp_all) | |
| 259 | apply(force intro:CptnEnv) | |
| 260 | apply(force elim:CptnComp) | |
| 261 | done | |
| 262 | ||
| 263 | lemma last_lift: "\<lbrakk>xs\<noteq>[]; fst(xs!(length xs - (Suc 0)))=None\<rbrakk> | |
| 264 | \<Longrightarrow> fst((map (lift P) xs)!(length (map (lift P) xs)- (Suc 0)))=(Some P)" | |
| 265 | apply(case_tac "(xs ! (length xs - (Suc 0)))") | |
| 266 | apply (simp add:lift_def) | |
| 267 | done | |
| 268 | ||
| 269 | lemma last_fst [rule_format]: "P((a#x)!length x) \<longrightarrow> \<not>P a \<longrightarrow> P (x!(length x - (Suc 0)))" | |
| 270 | apply(induct x,simp+) | |
| 271 | done | |
| 272 | ||
| 273 | lemma last_fst_esp: | |
| 274 | "fst(((Some a,s)#xs)!(length xs))=None \<Longrightarrow> fst(xs!(length xs - (Suc 0)))=None" | |
| 275 | apply(erule last_fst) | |
| 276 | apply simp | |
| 277 | done | |
| 278 | ||
| 279 | lemma last_snd: "xs\<noteq>[] \<Longrightarrow> | |
| 280 | snd(((map (lift P) xs))!(length (map (lift P) xs) - (Suc 0)))=snd(xs!(length xs - (Suc 0)))" | |
| 281 | apply(case_tac "(xs ! (length xs - (Suc 0)))",simp) | |
| 282 | apply (simp add:lift_def) | |
| 283 | done | |
| 284 | ||
| 285 | lemma Cons_lift: "(Some (Seq P Q), s) # (map (lift Q) xs) = map (lift Q) ((Some P, s) # xs)" | |
| 286 | by(simp add:lift_def) | |
| 287 | ||
| 288 | lemma Cons_lift_append: | |
| 289 | "(Some (Seq P Q), s) # (map (lift Q) xs) @ ys = map (lift Q) ((Some P, s) # xs)@ ys " | |
| 290 | by(simp add:lift_def) | |
| 291 | ||
| 292 | lemma lift_nth: "i<length xs \<Longrightarrow> map (lift Q) xs ! i = lift Q (xs! i)" | |
| 293 | by (simp add:lift_def) | |
| 294 | ||
| 295 | lemma snd_lift: "i< length xs \<Longrightarrow> snd(lift Q (xs ! i))= snd (xs ! i)" | |
| 296 | apply(case_tac "xs!i") | |
| 297 | apply(simp add:lift_def) | |
| 298 | done | |
| 299 | ||
| 300 | lemma cptn_if_cptn_mod: "c \<in> cptn_mod \<Longrightarrow> c \<in> cptn" | |
| 301 | apply(erule cptn_mod.induct) | |
| 302 | apply(rule CptnOne) | |
| 303 | apply(erule CptnEnv) | |
| 304 | apply(erule CptnComp,simp) | |
| 305 | apply(rule CptnComp) | |
| 306 | apply(erule CondT,simp) | |
| 307 | apply(rule CptnComp) | |
| 308 | apply(erule CondF,simp) | |
| 309 | --{* Seq1 *}   
 | |
| 310 | apply(erule cptn.elims,simp_all) | |
| 311 | apply(rule CptnOne) | |
| 312 | apply clarify | |
| 313 | apply(drule_tac P=P1 in lift_is_cptn) | |
| 314 | apply(simp add:lift_def) | |
| 315 | apply(rule CptnEnv,simp) | |
| 316 | apply clarify | |
| 317 | apply(simp add:lift_def) | |
| 318 | apply(rule conjI) | |
| 319 | apply clarify | |
| 320 | apply(rule CptnComp) | |
| 321 | apply(rule Seq1,simp) | |
| 322 | apply(drule_tac P=P1 in lift_is_cptn) | |
| 323 | apply(simp add:lift_def) | |
| 324 | apply clarify | |
| 325 | apply(rule CptnComp) | |
| 326 | apply(rule Seq2,simp) | |
| 327 | apply(drule_tac P=P1 in lift_is_cptn) | |
| 328 | apply(simp add:lift_def) | |
| 329 | --{* Seq2 *}
 | |
| 330 | apply(rule cptn_append_is_cptn) | |
| 331 | apply(drule_tac P=P1 in lift_is_cptn) | |
| 332 | apply(simp add:lift_def) | |
| 333 | apply simp | |
| 334 | apply(case_tac "xs\<noteq>[]") | |
| 335 | apply(drule_tac P=P1 in last_lift) | |
| 336 | apply(rule last_fst_esp) | |
| 337 | apply (simp add:last_length) | |
| 338 | apply(simp add:Cons_lift del:map.simps) | |
| 339 | apply(rule conjI, clarify, simp) | |
| 340 | apply(case_tac "(((Some P0, s) # xs) ! length xs)") | |
| 341 | apply clarify | |
| 342 | apply (simp add:lift_def last_length) | |
| 343 | apply (simp add:last_length) | |
| 344 | --{* While1 *}
 | |
| 345 | apply(rule CptnComp) | |
| 346 | apply(rule WhileT,simp) | |
| 347 | apply(drule_tac P="While b P" in lift_is_cptn) | |
| 348 | apply(simp add:lift_def) | |
| 349 | --{* While2 *}
 | |
| 350 | apply(rule CptnComp) | |
| 351 | apply(rule WhileT,simp) | |
| 352 | apply(rule cptn_append_is_cptn) | |
| 353 | apply(drule_tac P="While b P" in lift_is_cptn) | |
| 354 | apply(simp add:lift_def) | |
| 355 | apply simp | |
| 356 | apply(case_tac "xs\<noteq>[]") | |
| 357 | apply(drule_tac P="While b P" in last_lift) | |
| 358 | apply(rule last_fst_esp,simp add:last_length) | |
| 359 | apply(simp add:Cons_lift del:map.simps) | |
| 360 | apply(rule conjI, clarify, simp) | |
| 361 | apply(case_tac "(((Some P, s) # xs) ! length xs)") | |
| 362 | apply clarify | |
| 363 | apply (simp add:last_length lift_def) | |
| 364 | apply simp | |
| 365 | done | |
| 366 | ||
| 367 | theorem cptn_iff_cptn_mod: "(c \<in> cptn) = (c \<in> cptn_mod)" | |
| 368 | apply(rule iffI) | |
| 369 | apply(erule cptn_onlyif_cptn_mod) | |
| 370 | apply(erule cptn_if_cptn_mod) | |
| 371 | done | |
| 372 | ||
| 373 | section {* Validity  of Correctness Formulas*}
 | |
| 374 | ||
| 375 | subsection {* Validity for Component Programs. *}
 | |
| 376 | ||
| 377 | types 'a rgformula = "'a com \<times> 'a set \<times> ('a \<times> 'a) set \<times> ('a \<times> 'a) set \<times> 'a set"
 | |
| 378 | ||
| 379 | constdefs | |
| 380 |   assum :: "('a set \<times> ('a \<times> 'a) set) \<Rightarrow> ('a confs) set"
 | |
| 381 |   "assum \<equiv> \<lambda>(pre, rely). {c. snd(c!0) \<in> pre \<and> (\<forall>i. Suc i<length c \<longrightarrow> 
 | |
| 382 | c!i -e\<rightarrow> c!(Suc i) \<longrightarrow> (snd(c!i), snd(c!Suc i)) \<in> rely)}" | |
| 383 | ||
| 384 |   comm :: "(('a \<times> 'a) set \<times> 'a set) \<Rightarrow> ('a confs) set"
 | |
| 385 |   "comm \<equiv> \<lambda>(guar, post). {c. (\<forall>i. Suc i<length c \<longrightarrow> 
 | |
| 386 | c!i -c\<rightarrow> c!(Suc i) \<longrightarrow> (snd(c!i), snd(c!Suc i)) \<in> guar) \<and> | |
| 387 | (fst (last c) = None \<longrightarrow> snd (last c) \<in> post)}" | |
| 388 | ||
| 389 |   com_validity :: "'a com \<Rightarrow> 'a set \<Rightarrow> ('a \<times> 'a) set \<Rightarrow> ('a \<times> 'a) set \<Rightarrow> 'a set \<Rightarrow> bool" 
 | |
| 390 |                  ("\<Turnstile> _ sat [_, _, _, _]" [60,0,0,0,0] 45)
 | |
| 391 | "\<Turnstile> P sat [pre, rely, guar, post] \<equiv> | |
| 392 | \<forall>s. cp (Some P) s \<inter> assum(pre, rely) \<subseteq> comm(guar, post)" | |
| 393 | ||
| 394 | subsection {* Validity for Parallel Programs. *}
 | |
| 395 | ||
| 396 | constdefs | |
| 397 |   All_None :: "(('a com) option) list \<Rightarrow> bool"
 | |
| 398 | "All_None xs \<equiv> \<forall>c\<in>set xs. c=None" | |
| 399 | ||
| 400 |   par_assum :: "('a set \<times> ('a \<times> 'a) set) \<Rightarrow> ('a par_confs) set"
 | |
| 401 |   "par_assum \<equiv> \<lambda>(pre, rely). {c. snd(c!0) \<in> pre \<and> (\<forall>i. Suc i<length c \<longrightarrow> 
 | |
| 402 | c!i -pe\<rightarrow> c!Suc i \<longrightarrow> (snd(c!i), snd(c!Suc i)) \<in> rely)}" | |
| 403 | ||
| 404 |   par_comm :: "(('a \<times> 'a) set \<times> 'a set) \<Rightarrow> ('a par_confs) set"
 | |
| 405 |   "par_comm \<equiv> \<lambda>(guar, post). {c. (\<forall>i. Suc i<length c \<longrightarrow>   
 | |
| 406 | c!i -pc\<rightarrow> c!Suc i \<longrightarrow> (snd(c!i), snd(c!Suc i)) \<in> guar) \<and> | |
| 407 | (All_None (fst (last c)) \<longrightarrow> snd( last c) \<in> post)}" | |
| 408 | ||
| 13022 
b115b305612f
New order in the loading of theories (Quote-antiquote right before the OG_Syntax and RG_Syntax respectively)
 prensani parents: 
13020diff
changeset | 409 |   par_com_validity :: "'a  par_com \<Rightarrow> 'a set \<Rightarrow> ('a \<times> 'a) set \<Rightarrow> ('a \<times> 'a) set 
 | 
| 
b115b305612f
New order in the loading of theories (Quote-antiquote right before the OG_Syntax and RG_Syntax respectively)
 prensani parents: 
13020diff
changeset | 410 | \<Rightarrow> 'a set \<Rightarrow> bool"  ("\<Turnstile> _ SAT [_, _, _, _]" [60,0,0,0,0] 45)
 | 
| 13020 | 411 | "\<Turnstile> Ps SAT [pre, rely, guar, post] \<equiv> | 
| 412 | \<forall>s. par_cp Ps s \<inter> par_assum(pre, rely) \<subseteq> par_comm(guar, post)" | |
| 413 | ||
| 414 | subsection {* Compositionality of the Semantics *}
 | |
| 415 | ||
| 416 | subsubsection {* Definition of the conjoin operator *}
 | |
| 417 | ||
| 418 | constdefs | |
| 419 |   same_length :: "'a par_confs \<Rightarrow> ('a confs) list \<Rightarrow> bool"
 | |
| 420 | "same_length c clist \<equiv> (\<forall>i<length clist. length(clist!i)=length c)" | |
| 421 | ||
| 422 |   same_state :: "'a par_confs \<Rightarrow> ('a confs) list \<Rightarrow> bool"
 | |
| 423 | "same_state c clist \<equiv> (\<forall>i <length clist. \<forall>j<length c. snd(c!j) = snd((clist!i)!j))" | |
| 424 | ||
| 425 |   same_program :: "'a par_confs \<Rightarrow> ('a confs) list \<Rightarrow> bool"
 | |
| 426 | "same_program c clist \<equiv> (\<forall>j<length c. fst(c!j) = map (\<lambda>x. fst(nth x j)) clist)" | |
| 427 | ||
| 428 |   compat_label :: "'a par_confs \<Rightarrow> ('a confs) list \<Rightarrow> bool"
 | |
| 429 | "compat_label c clist \<equiv> (\<forall>j. Suc j<length c \<longrightarrow> | |
| 430 | (c!j -pc\<rightarrow> c!Suc j \<and> (\<exists>i<length clist. (clist!i)!j -c\<rightarrow> (clist!i)! Suc j \<and> | |
| 13022 
b115b305612f
New order in the loading of theories (Quote-antiquote right before the OG_Syntax and RG_Syntax respectively)
 prensani parents: 
13020diff
changeset | 431 | (\<forall>l<length clist. l\<noteq>i \<longrightarrow> (clist!l)!j -e\<rightarrow> (clist!l)! Suc j))) \<or> | 
| 13020 | 432 | (c!j -pe\<rightarrow> c!Suc j \<and> (\<forall>i<length clist. (clist!i)!j -e\<rightarrow> (clist!i)! Suc j)))" | 
| 433 | ||
| 434 |   conjoin :: "'a par_confs \<Rightarrow> ('a confs) list \<Rightarrow> bool"  ("_ \<propto> _" [65,65] 64)
 | |
| 435 | "c \<propto> clist \<equiv> (same_length c clist) \<and> (same_state c clist) \<and> (same_program c clist) \<and> (compat_label c clist)" | |
| 436 | ||
| 437 | subsubsection {* Some previous lemmas *}
 | |
| 438 | ||
| 13022 
b115b305612f
New order in the loading of theories (Quote-antiquote right before the OG_Syntax and RG_Syntax respectively)
 prensani parents: 
13020diff
changeset | 439 | lemma list_eq_if [rule_format]: | 
| 
b115b305612f
New order in the loading of theories (Quote-antiquote right before the OG_Syntax and RG_Syntax respectively)
 prensani parents: 
13020diff
changeset | 440 | "\<forall>ys. xs=ys \<longrightarrow> (length xs = length ys) \<longrightarrow> (\<forall>i<length xs. xs!i=ys!i)" | 
| 13020 | 441 | apply (induct xs) | 
| 442 | apply simp | |
| 443 | apply clarify | |
| 444 | done | |
| 445 | ||
| 446 | lemma list_eq: "(length xs = length ys \<and> (\<forall>i<length xs. xs!i=ys!i)) = (xs=ys)" | |
| 447 | apply(rule iffI) | |
| 448 | apply clarify | |
| 449 | apply(erule nth_equalityI) | |
| 450 | apply simp+ | |
| 451 | done | |
| 452 | ||
| 453 | lemma nth_tl: "\<lbrakk> ys!0=a; ys\<noteq>[] \<rbrakk> \<Longrightarrow> ys=(a#(tl ys))" | |
| 454 | apply(case_tac ys) | |
| 455 | apply simp+ | |
| 456 | done | |
| 457 | ||
| 458 | lemma nth_tl_if [rule_format]: "ys\<noteq>[] \<longrightarrow> ys!0=a \<longrightarrow> P ys \<longrightarrow> P (a#(tl ys))" | |
| 459 | apply(induct ys) | |
| 460 | apply simp+ | |
| 461 | done | |
| 462 | ||
| 463 | lemma nth_tl_onlyif [rule_format]: "ys\<noteq>[] \<longrightarrow> ys!0=a \<longrightarrow> P (a#(tl ys)) \<longrightarrow> P ys" | |
| 464 | apply(induct ys) | |
| 465 | apply simp+ | |
| 466 | done | |
| 467 | ||
| 468 | lemma seq_not_eq1: "Seq c1 c2\<noteq>c1" | |
| 469 | apply(rule com.induct) | |
| 470 | apply simp_all | |
| 471 | apply clarify | |
| 472 | done | |
| 473 | ||
| 474 | lemma seq_not_eq2: "Seq c1 c2\<noteq>c2" | |
| 475 | apply(rule com.induct) | |
| 476 | apply simp_all | |
| 477 | apply clarify | |
| 478 | done | |
| 479 | ||
| 480 | lemma if_not_eq1: "Cond b c1 c2 \<noteq>c1" | |
| 481 | apply(rule com.induct) | |
| 482 | apply simp_all | |
| 483 | apply clarify | |
| 484 | done | |
| 485 | ||
| 486 | lemma if_not_eq2: "Cond b c1 c2\<noteq>c2" | |
| 487 | apply(rule com.induct) | |
| 488 | apply simp_all | |
| 489 | apply clarify | |
| 490 | done | |
| 491 | ||
| 492 | lemmas seq_and_if_not_eq [simp] = seq_not_eq1 seq_not_eq2 | |
| 493 | seq_not_eq1 [THEN not_sym] seq_not_eq2 [THEN not_sym] | |
| 494 | if_not_eq1 if_not_eq2 if_not_eq1 [THEN not_sym] if_not_eq2 [THEN not_sym] | |
| 495 | ||
| 496 | lemma prog_not_eq_in_ctran_aux [rule_format]: "(P,s) -c\<rightarrow> (Q,t) \<Longrightarrow> (P\<noteq>Q)" | |
| 497 | apply(erule ctran.induct) | |
| 498 | apply simp_all | |
| 499 | done | |
| 500 | ||
| 501 | lemma prog_not_eq_in_ctran [simp]: "\<not> (P,s) -c\<rightarrow> (P,t)" | |
| 502 | apply clarify | |
| 503 | apply(drule prog_not_eq_in_ctran_aux) | |
| 504 | apply simp | |
| 505 | done | |
| 506 | ||
| 507 | lemma prog_not_eq_in_par_ctran_aux [rule_format]: "(P,s) -pc\<rightarrow> (Q,t) \<Longrightarrow> (P\<noteq>Q)" | |
| 508 | apply(erule par_ctran.induct) | |
| 509 | apply(drule prog_not_eq_in_ctran_aux) | |
| 510 | apply clarify | |
| 511 | apply(drule list_eq_if) | |
| 512 | apply simp_all | |
| 513 | apply force | |
| 514 | done | |
| 515 | ||
| 516 | lemma prog_not_eq_in_par_ctran [simp]: "\<not> (P,s) -pc\<rightarrow> (P,t)" | |
| 517 | apply clarify | |
| 518 | apply(drule prog_not_eq_in_par_ctran_aux) | |
| 519 | apply simp | |
| 520 | done | |
| 521 | ||
| 522 | lemma tl_in_cptn: "\<lbrakk> a#xs \<in>cptn; xs\<noteq>[] \<rbrakk> \<Longrightarrow> xs\<in>cptn" | |
| 523 | apply(force elim:cptn.elims) | |
| 524 | done | |
| 525 | ||
| 13022 
b115b305612f
New order in the loading of theories (Quote-antiquote right before the OG_Syntax and RG_Syntax respectively)
 prensani parents: 
13020diff
changeset | 526 | lemma tl_zero[rule_format]: | 
| 
b115b305612f
New order in the loading of theories (Quote-antiquote right before the OG_Syntax and RG_Syntax respectively)
 prensani parents: 
13020diff
changeset | 527 | "P (ys!Suc j) \<longrightarrow> Suc j<length ys \<longrightarrow> ys\<noteq>[] \<longrightarrow> P (tl(ys)!j)" | 
| 13020 | 528 | apply(induct ys) | 
| 529 | apply simp_all | |
| 530 | done | |
| 531 | ||
| 532 | subsection {* The Semantics is Compositional *}
 | |
| 533 | ||
| 534 | lemma aux_if [rule_format]: | |
| 535 | "\<forall>xs s clist. (length clist = length xs \<and> (\<forall>i<length xs. (xs!i,s)#clist!i \<in> cptn) | |
| 536 | \<and> ((xs, s)#ys \<propto> map (\<lambda>i. (fst i,s)#snd i) (zip xs clist)) | |
| 537 | \<longrightarrow> (xs, s)#ys \<in> par_cptn)" | |
| 538 | apply(induct ys) | |
| 539 | apply(clarify) | |
| 540 | apply(rule ParCptnOne) | |
| 541 | apply(clarify) | |
| 542 | apply(simp add:conjoin_def compat_label_def) | |
| 543 | apply clarify | |
| 544 | apply(erule_tac x="0" and P="\<lambda>j. ?H j \<longrightarrow> (?P j \<or> ?Q j)" in all_dupE,simp) | |
| 545 | apply(erule disjE) | |
| 546 | --{* first step is a Component step *}
 | |
| 547 | apply clarify | |
| 548 | apply simp | |
| 549 | apply(subgoal_tac "a=(xs[i:=(fst(clist!i!0))])") | |
| 550 | apply(subgoal_tac "b=snd(clist!i!0)",simp) | |
| 551 | prefer 2 | |
| 552 | apply(simp add: same_state_def) | |
| 553 | apply(erule_tac x=i in allE,erule impE,assumption, | |
| 554 | erule_tac x=1 and P="\<lambda>j. (?H j) \<longrightarrow> (snd (?d j))=(snd (?e j))" in allE,simp) | |
| 555 | prefer 2 | |
| 556 | apply(simp add:same_program_def) | |
| 557 | apply(erule_tac x=1 and P="\<lambda>j. ?H j \<longrightarrow> (fst (?s j))=(?t j)" in allE,simp) | |
| 558 | apply(rule nth_equalityI,simp) | |
| 559 | apply clarify | |
| 560 | apply(case_tac "i=ia",simp,simp) | |
| 561 | apply(erule_tac x=ia and P="\<lambda>j. ?H j \<longrightarrow> ?I j \<longrightarrow> ?J j" in allE) | |
| 562 | apply(drule_tac t=i in not_sym,simp) | |
| 563 | apply(erule etran.elims,simp) | |
| 564 | apply(rule ParCptnComp) | |
| 565 | apply(erule ParComp,simp) | |
| 566 | --{* applying the induction hypothesis *}
 | |
| 567 | apply(erule_tac x="xs[i := fst (clist ! i ! 0)]" in allE) | |
| 568 | apply(erule_tac x="snd (clist ! i ! 0)" in allE) | |
| 569 | apply(erule mp) | |
| 570 | apply(rule_tac x="map tl clist" in exI,simp) | |
| 571 | apply(rule conjI,clarify) | |
| 572 | apply(case_tac "i=ia",simp) | |
| 573 | apply(rule nth_tl_if) | |
| 574 | apply(force simp add:same_length_def length_Suc_conv) | |
| 575 | apply simp | |
| 576 | apply(erule allE,erule impE,assumption,erule tl_in_cptn) | |
| 577 | apply(force simp add:same_length_def length_Suc_conv) | |
| 578 | apply(rule nth_tl_if) | |
| 579 | apply(force simp add:same_length_def length_Suc_conv) | |
| 580 | apply(simp add:same_state_def) | |
| 581 | apply(erule_tac x=ia in allE, erule impE, assumption, | |
| 582 | erule_tac x=1 and P="\<lambda>j. ?H j \<longrightarrow> (snd (?d j))=(snd (?e j))" in allE) | |
| 583 | apply(erule_tac x=ia and P="\<lambda>j. ?H j \<longrightarrow> ?I j \<longrightarrow> ?J j" in allE) | |
| 584 | apply(drule_tac t=i in not_sym,simp) | |
| 585 | apply(erule etran.elims,simp) | |
| 586 | apply(erule allE,erule impE,assumption,erule tl_in_cptn) | |
| 587 | apply(force simp add:same_length_def length_Suc_conv) | |
| 588 | apply(simp add:same_length_def same_state_def) | |
| 589 | apply(rule conjI) | |
| 590 | apply clarify | |
| 591 | apply(case_tac j,simp,simp) | |
| 592 | apply(erule_tac x=ia in allE, erule impE, assumption, | |
| 593 | erule_tac x="Suc(Suc nat)" and P="\<lambda>j. ?H j \<longrightarrow> (snd (?d j))=(snd (?e j))" in allE,simp) | |
| 594 | apply(force simp add:same_length_def length_Suc_conv) | |
| 595 | apply(rule conjI) | |
| 596 | apply(simp add:same_program_def) | |
| 597 | apply clarify | |
| 598 | apply(case_tac j,simp) | |
| 599 | apply(rule nth_equalityI,simp) | |
| 600 | apply clarify | |
| 601 | apply(case_tac "i=ia",simp,simp) | |
| 602 | apply(erule_tac x="Suc(Suc nat)" and P="\<lambda>j. ?H j \<longrightarrow> (fst (?s j))=(?t j)" in allE,simp) | |
| 603 | apply(rule nth_equalityI,simp,simp) | |
| 604 | apply(force simp add:length_Suc_conv) | |
| 605 | apply(rule allI,rule impI) | |
| 606 | apply(erule_tac x="Suc j" and P="\<lambda>j. ?H j \<longrightarrow> (?I j \<or> ?J j)" in allE,simp) | |
| 607 | apply(erule disjE) | |
| 608 | apply clarify | |
| 609 | apply(rule_tac x=ia in exI,simp) | |
| 610 | apply(case_tac "i=ia",simp) | |
| 611 | apply(rule conjI) | |
| 612 | apply(force simp add: length_Suc_conv) | |
| 613 | apply clarify | |
| 614 | apply(erule_tac x=l and P="\<lambda>j. ?H j \<longrightarrow> ?I j \<longrightarrow> ?J j" in allE,erule impE,assumption) | |
| 615 | apply(erule_tac x=l and P="\<lambda>j. ?H j \<longrightarrow> ?I j \<longrightarrow> ?J j" in allE,erule impE,assumption) | |
| 616 | apply simp | |
| 617 | apply(case_tac j,simp) | |
| 618 | apply(rule tl_zero) | |
| 619 | apply(erule_tac x=l in allE, erule impE, assumption, | |
| 620 | erule_tac x=1 and P="\<lambda>j. (?H j) \<longrightarrow> (snd (?d j))=(snd (?e j))" in allE,simp) | |
| 621 | apply(force elim:etran.elims intro:Env) | |
| 622 | apply force | |
| 623 | apply force | |
| 624 | apply simp | |
| 625 | apply(rule tl_zero) | |
| 626 | apply(erule tl_zero) | |
| 627 | apply force | |
| 628 | apply force | |
| 629 | apply force | |
| 630 | apply force | |
| 631 | apply(rule conjI,simp) | |
| 632 | apply(rule nth_tl_if) | |
| 633 | apply force | |
| 634 | apply(erule_tac x=ia in allE, erule impE, assumption, | |
| 635 | erule_tac x=1 and P="\<lambda>j. ?H j \<longrightarrow> (snd (?d j))=(snd (?e j))" in allE) | |
| 636 | apply(erule_tac x=ia and P="\<lambda>j. ?H j \<longrightarrow> ?I j \<longrightarrow> ?J j" in allE) | |
| 637 | apply(drule_tac t=i in not_sym,simp) | |
| 638 | apply(erule etran.elims,simp) | |
| 639 | apply(erule tl_zero) | |
| 640 | apply force | |
| 641 | apply force | |
| 642 | apply clarify | |
| 643 | apply(case_tac "i=l",simp) | |
| 644 | apply(rule nth_tl_if) | |
| 645 | apply(erule_tac x=l and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE,force) | |
| 646 | apply simp | |
| 647 | apply(erule_tac P="\<lambda>j. ?H j \<longrightarrow> ?I j \<longrightarrow> ?J j" in allE,erule impE,assumption,erule impE,assumption) | |
| 648 | apply(erule tl_zero,force) | |
| 649 | apply(erule_tac x=l and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE,force) | |
| 650 | apply(rule nth_tl_if) | |
| 651 | apply(erule_tac x=l and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE,force) | |
| 652 | apply(erule_tac x=l in allE, erule impE, assumption, | |
| 653 | erule_tac x=1 and P="\<lambda>j. ?H j \<longrightarrow> (snd (?d j))=(snd (?e j))" in allE) | |
| 654 | apply(erule_tac x=l and P="\<lambda>j. ?H j \<longrightarrow> ?I j \<longrightarrow> ?J j" in allE,erule impE, assumption,simp) | |
| 655 | apply(erule etran.elims,simp) | |
| 656 | apply(rule tl_zero) | |
| 657 | apply force | |
| 658 | apply force | |
| 659 | apply(erule_tac x=l and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE,force) | |
| 660 | apply(rule disjI2) | |
| 661 | apply(case_tac j,simp) | |
| 662 | apply clarify | |
| 663 | apply(rule tl_zero) | |
| 664 | apply(erule_tac x=ia and P="\<lambda>j. ?H j \<longrightarrow> ?I j\<in>etran" in allE,erule impE, assumption) | |
| 665 | apply(case_tac "i=ia",simp,simp) | |
| 666 | apply(erule_tac x=ia in allE, erule impE, assumption, | |
| 667 | erule_tac x=1 and P="\<lambda>j. ?H j \<longrightarrow> (snd (?d j))=(snd (?e j))" in allE) | |
| 668 | apply(erule_tac x=ia and P="\<lambda>j. ?H j \<longrightarrow> ?I j \<longrightarrow> ?J j" in allE,erule impE, assumption,simp) | |
| 669 | apply(force elim:etran.elims intro:Env) | |
| 670 | apply force | |
| 671 | apply(erule_tac x=ia and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE,force) | |
| 672 | apply simp | |
| 673 | apply clarify | |
| 674 | apply(rule tl_zero) | |
| 675 | apply(rule tl_zero,force) | |
| 676 | apply force | |
| 677 | apply(erule_tac x=ia and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE,force) | |
| 678 | apply force | |
| 679 | apply(erule_tac x=ia and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE,force) | |
| 680 | --{* first step is an environmental step *}
 | |
| 681 | apply clarify | |
| 682 | apply(erule par_etran.elims) | |
| 683 | apply simp | |
| 684 | apply(rule ParCptnEnv) | |
| 685 | apply(erule_tac x="Ps" in allE) | |
| 686 | apply(erule_tac x="t" in allE) | |
| 687 | apply(erule mp) | |
| 688 | apply(rule_tac x="map tl clist" in exI,simp) | |
| 689 | apply(rule conjI) | |
| 690 | apply clarify | |
| 691 | apply(erule_tac x=i and P="\<lambda>j. ?H j \<longrightarrow> (?I ?s j) \<in> cptn" in allE,simp) | |
| 692 | apply(erule cptn.elims) | |
| 693 | apply(simp add:same_length_def) | |
| 694 | apply(erule_tac x=i and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE,force) | |
| 695 | apply(simp add:same_state_def) | |
| 696 | apply(erule_tac x=i in allE, erule impE, assumption, | |
| 697 | erule_tac x=1 and P="\<lambda>j. ?H j \<longrightarrow> (snd (?d j))=(snd (?e j))" in allE,simp) | |
| 698 | apply(erule_tac x=i and P="\<lambda>j. ?H j \<longrightarrow> ?J j \<in>etran" in allE,simp) | |
| 699 | apply(erule etran.elims,simp) | |
| 700 | apply(simp add:same_state_def same_length_def) | |
| 701 | apply(rule conjI,clarify) | |
| 702 | apply(case_tac j,simp,simp) | |
| 703 | apply(erule_tac x=i in allE, erule impE, assumption, | |
| 704 | erule_tac x="Suc(Suc nat)" and P="\<lambda>j. ?H j \<longrightarrow> (snd (?d j))=(snd (?e j))" in allE,simp) | |
| 705 | apply(rule tl_zero) | |
| 706 | apply(simp) | |
| 707 | apply force | |
| 708 | apply(erule_tac x=i and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE,force) | |
| 709 | apply(rule conjI) | |
| 710 | apply(simp add:same_program_def) | |
| 711 | apply clarify | |
| 712 | apply(case_tac j,simp) | |
| 713 | apply(rule nth_equalityI,simp) | |
| 714 | apply clarify | |
| 715 | apply simp | |
| 716 | apply(erule_tac x="Suc(Suc nat)" and P="\<lambda>j. ?H j \<longrightarrow> (fst (?s j))=(?t j)" in allE,simp) | |
| 717 | apply(rule nth_equalityI,simp,simp) | |
| 718 | apply(force simp add:length_Suc_conv) | |
| 719 | apply(rule allI,rule impI) | |
| 720 | apply(erule_tac x="Suc j" and P="\<lambda>j. ?H j \<longrightarrow> (?I j \<or> ?J j)" in allE,simp) | |
| 721 | apply(erule disjE) | |
| 722 | apply clarify | |
| 723 | apply(rule_tac x=i in exI,simp) | |
| 724 | apply(rule conjI) | |
| 725 | apply(erule_tac x=i and P="\<lambda>i. ?H i \<longrightarrow> ?J i \<in>etran" in allE, erule impE, assumption) | |
| 726 | apply(erule etran.elims,simp) | |
| 727 | apply(erule_tac x=i in allE, erule impE, assumption, | |
| 728 | erule_tac x=1 and P="\<lambda>j. (?H j) \<longrightarrow> (snd (?d j))=(snd (?e j))" in allE,simp) | |
| 729 | apply(rule nth_tl_if) | |
| 730 | apply(erule_tac x=i and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE,force) | |
| 731 | apply simp | |
| 732 | apply(erule tl_zero,force) | |
| 733 | apply(erule_tac x=i and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE,force) | |
| 734 | apply clarify | |
| 735 | apply(erule_tac x=l and P="\<lambda>i. ?H i \<longrightarrow> ?J i \<in>etran" in allE, erule impE, assumption) | |
| 736 | apply(erule etran.elims,simp) | |
| 737 | apply(erule_tac x=l in allE, erule impE, assumption, | |
| 738 | erule_tac x=1 and P="\<lambda>j. (?H j) \<longrightarrow> (snd (?d j))=(snd (?e j))" in allE,simp) | |
| 739 | apply(rule nth_tl_if) | |
| 740 | apply(erule_tac x=l and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE,force) | |
| 741 | apply simp | |
| 742 | apply(rule tl_zero,force) | |
| 743 | apply force | |
| 744 | apply(erule_tac x=l and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE,force) | |
| 745 | apply(rule disjI2) | |
| 746 | apply simp | |
| 747 | apply clarify | |
| 748 | apply(case_tac j,simp) | |
| 749 | apply(rule tl_zero) | |
| 750 | apply(erule_tac x=i and P="\<lambda>i. ?H i \<longrightarrow> ?J i \<in>etran" in allE, erule impE, assumption) | |
| 751 | apply(erule_tac x=i and P="\<lambda>i. ?H i \<longrightarrow> ?J i \<in>etran" in allE, erule impE, assumption) | |
| 752 | apply(force elim:etran.elims intro:Env) | |
| 753 | apply force | |
| 754 | apply(erule_tac x=i and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE,force) | |
| 755 | apply simp | |
| 756 | apply(rule tl_zero) | |
| 757 | apply(rule tl_zero,force) | |
| 758 | apply force | |
| 759 | apply(erule_tac x=i and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE,force) | |
| 760 | apply force | |
| 761 | apply(erule_tac x=i and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE,force) | |
| 762 | done | |
| 763 | ||
| 764 | lemma less_Suc_0 [iff]: "(n < Suc 0) = (n = 0)" | |
| 765 | by auto | |
| 766 | ||
| 767 | lemma aux_onlyif [rule_format]: "\<forall>xs s. (xs, s)#ys \<in> par_cptn \<longrightarrow> | |
| 768 | (\<exists>clist. (length clist = length xs) \<and> | |
| 769 | (xs, s)#ys \<propto> map (\<lambda>i. (fst i,s)#(snd i)) (zip xs clist) \<and> | |
| 770 | (\<forall>i<length xs. (xs!i,s)#(clist!i) \<in> cptn))" | |
| 771 | apply(induct ys) | |
| 772 | apply(clarify) | |
| 773 | apply(rule_tac x="map (\<lambda>i. []) [0..length xs(]" in exI) | |
| 774 | apply(simp add: conjoin_def same_length_def same_state_def same_program_def compat_label_def) | |
| 775 | apply(rule conjI) | |
| 776 | apply(rule nth_equalityI,simp,simp) | |
| 777 | apply(force intro: cptn.intros) | |
| 778 | apply(clarify) | |
| 779 | apply(erule par_cptn.elims,simp) | |
| 780 | apply simp | |
| 781 | apply(erule_tac x="xs" in allE) | |
| 782 | apply(erule_tac x="t" in allE,simp) | |
| 783 | apply clarify | |
| 784 | apply(rule_tac x="(map (\<lambda>j. (P!j, t)#(clist!j)) [0..length P(])" in exI,simp) | |
| 785 | apply(rule conjI) | |
| 786 | prefer 2 | |
| 787 | apply clarify | |
| 788 | apply(rule CptnEnv,simp) | |
| 789 | apply(simp add:conjoin_def same_length_def same_state_def) | |
| 790 | apply (rule conjI) | |
| 791 | apply clarify | |
| 792 | apply(case_tac j,simp,simp) | |
| 793 | apply(rule conjI) | |
| 794 | apply(simp add:same_program_def) | |
| 795 | apply clarify | |
| 796 | apply(case_tac j,simp) | |
| 797 | apply(rule nth_equalityI,simp,simp) | |
| 798 | apply simp | |
| 799 | apply(rule nth_equalityI,simp,simp) | |
| 800 | apply(simp add:compat_label_def) | |
| 801 | apply clarify | |
| 802 | apply(case_tac j,simp) | |
| 803 | apply(simp add:ParEnv) | |
| 804 | apply clarify | |
| 805 | apply(simp add:Env) | |
| 806 | apply simp | |
| 807 | apply(erule_tac x=nat in allE,erule impE, assumption) | |
| 808 | apply(erule disjE,simp) | |
| 809 | apply clarify | |
| 810 | apply(rule_tac x=i in exI,simp) | |
| 811 | apply force | |
| 812 | apply(erule par_ctran.elims,simp) | |
| 813 | apply(erule_tac x="Ps[i:=r]" in allE) | |
| 814 | apply(erule_tac x="ta" in allE,simp) | |
| 815 | apply clarify | |
| 816 | apply(rule_tac x="(map (\<lambda>j. (Ps!j, ta)#(clist!j)) [0..length Ps(]) [i:=((r, ta)#(clist!i))]" in exI,simp) | |
| 817 | apply(rule conjI) | |
| 818 | prefer 2 | |
| 819 | apply clarify | |
| 820 | apply(case_tac "i=ia",simp) | |
| 821 | apply(erule CptnComp) | |
| 822 | apply(erule_tac x=ia and P="\<lambda>j. ?H j \<longrightarrow> (?I j \<in> cptn)" in allE,simp) | |
| 823 | apply simp | |
| 824 | apply(erule_tac x=ia in allE) | |
| 825 | apply(rule CptnEnv,simp) | |
| 826 | apply(simp add:conjoin_def) | |
| 827 | apply (rule conjI) | |
| 828 | apply(simp add:same_length_def) | |
| 829 | apply clarify | |
| 830 | apply(case_tac "i=ia",simp,simp) | |
| 831 | apply(rule conjI) | |
| 832 | apply(simp add:same_state_def) | |
| 833 | apply clarify | |
| 13601 | 834 | apply(case_tac j, simp, simp (no_asm_simp)) | 
| 13020 | 835 | apply(case_tac "i=ia",simp,simp) | 
| 836 | apply(rule conjI) | |
| 837 | apply(simp add:same_program_def) | |
| 838 | apply clarify | |
| 839 | apply(case_tac j,simp) | |
| 840 | apply(rule nth_equalityI,simp,simp) | |
| 841 | apply simp | |
| 842 | apply(rule nth_equalityI,simp,simp) | |
| 843 | apply(erule_tac x=nat and P="\<lambda>j. ?H j \<longrightarrow> (fst (?a j))=((?b j))" in allE) | |
| 844 | apply(case_tac nat) | |
| 845 | apply clarify | |
| 846 | apply(case_tac "i=ia",simp,simp) | |
| 847 | apply clarify | |
| 848 | apply(case_tac "i=ia",simp,simp) | |
| 849 | apply(simp add:compat_label_def) | |
| 850 | apply clarify | |
| 851 | apply(case_tac j) | |
| 852 | apply(rule conjI,simp) | |
| 853 | apply(erule ParComp,assumption) | |
| 854 | apply clarify | |
| 855 | apply(rule_tac x=i in exI,simp) | |
| 856 | apply clarify | |
| 857 | apply(rule Env) | |
| 858 | apply simp | |
| 859 | apply(erule_tac x=nat and P="\<lambda>j. ?H j \<longrightarrow> (?P j \<or> ?Q j)" in allE,simp) | |
| 860 | apply(erule disjE) | |
| 861 | apply clarify | |
| 862 | apply(rule_tac x=ia in exI,simp) | |
| 863 | apply(rule conjI) | |
| 864 | apply(case_tac "i=ia",simp,simp) | |
| 865 | apply clarify | |
| 866 | apply(case_tac "i=l",simp) | |
| 867 | apply(case_tac "l=ia",simp,simp) | |
| 868 | apply(erule_tac x=l in allE,erule impE,assumption,erule impE, assumption,simp) | |
| 869 | apply simp | |
| 870 | apply(erule_tac x=l in allE,erule impE,assumption,erule impE, assumption,simp) | |
| 871 | apply clarify | |
| 872 | apply(erule_tac x=ia and P="\<lambda>j. ?H j \<longrightarrow> (?P j)\<in>etran" in allE, erule impE, assumption) | |
| 13601 | 873 | apply(case_tac "i=ia",simp,simp) | 
| 13020 | 874 | done | 
| 875 | ||
| 876 | lemma one_iff_aux: "xs\<noteq>[] \<Longrightarrow> (\<forall>ys. ((xs, s)#ys \<in> par_cptn) = | |
| 877 | (\<exists>clist. length clist= length xs \<and> | |
| 878 | ((xs, s)#ys \<propto> map (\<lambda>i. (fst i,s)#(snd i)) (zip xs clist)) \<and> | |
| 879 | (\<forall>i<length xs. (xs!i,s)#(clist!i) \<in> cptn))) = | |
| 880 |  (par_cp (xs) s = {c. \<exists>clist. (length clist)=(length xs) \<and>
 | |
| 881 | (\<forall>i<length clist. (clist!i) \<in> cp(xs!i) s) \<and> c \<propto> clist})" | |
| 882 | apply (rule iffI) | |
| 883 | apply(rule subset_antisym) | |
| 884 | apply(rule subsetI) | |
| 885 | apply(clarify) | |
| 886 | apply(simp add:par_cp_def cp_def) | |
| 887 | apply(case_tac x) | |
| 888 | apply(force elim:par_cptn.elims) | |
| 889 | apply simp | |
| 890 | apply(erule_tac x="list" in allE) | |
| 891 | apply clarify | |
| 892 | apply simp | |
| 893 | apply(rule_tac x="map (\<lambda>i. (fst i, s) # snd i) (zip xs clist)" in exI,simp) | |
| 894 | apply(rule subsetI) | |
| 895 | apply(clarify) | |
| 896 | apply(case_tac x) | |
| 897 | apply(erule_tac x=0 in allE) | |
| 898 | apply(simp add:cp_def conjoin_def same_length_def same_program_def same_state_def compat_label_def) | |
| 899 | apply clarify | |
| 900 | apply(erule cptn.elims,force,force,force) | |
| 901 | apply(simp add:par_cp_def conjoin_def same_length_def same_program_def same_state_def compat_label_def) | |
| 902 | apply clarify | |
| 903 | apply(erule_tac x=0 and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in all_dupE) | |
| 904 | apply(subgoal_tac "a = xs") | |
| 905 | apply(subgoal_tac "b = s",simp) | |
| 906 | prefer 3 | |
| 907 | apply(erule_tac x=0 and P="\<lambda>j. ?H j \<longrightarrow> (fst (?s j))=((?t j))" in allE) | |
| 908 | apply (simp add:cp_def) | |
| 909 | apply(rule nth_equalityI,simp,simp) | |
| 910 | prefer 2 | |
| 911 | apply(erule_tac x=0 in allE) | |
| 912 | apply (simp add:cp_def) | |
| 913 | apply(erule_tac x=0 and P="\<lambda>j. ?H j \<longrightarrow> (\<forall>i. ?T i \<longrightarrow> (snd (?d j i))=(snd (?e j i)))" in allE,simp) | |
| 914 | apply(erule_tac x=0 and P="\<lambda>j. ?H j \<longrightarrow> (snd (?d j))=(snd (?e j))" in allE,simp) | |
| 915 | apply(erule_tac x=list in allE) | |
| 916 | apply(rule_tac x="map tl clist" in exI,simp) | |
| 917 | apply(rule conjI) | |
| 918 | apply clarify | |
| 919 | apply(case_tac j,simp) | |
| 920 | apply(erule_tac x=i in allE, erule impE, assumption, | |
| 921 | erule_tac x="0" and P="\<lambda>j. ?H j \<longrightarrow> (snd (?d j))=(snd (?e j))" in allE,simp) | |
| 922 | apply(erule_tac x=i in allE, erule impE, assumption, | |
| 923 | erule_tac x="Suc nat" and P="\<lambda>j. ?H j \<longrightarrow> (snd (?d j))=(snd (?e j))" in allE) | |
| 924 | apply(erule_tac x=i and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE) | |
| 925 | apply(case_tac "clist!i",simp,simp) | |
| 926 | apply(rule conjI) | |
| 927 | apply clarify | |
| 928 | apply(rule nth_equalityI,simp,simp) | |
| 929 | apply(case_tac j) | |
| 930 | apply clarify | |
| 931 | apply(erule_tac x=i in allE) | |
| 932 | apply(simp add:cp_def) | |
| 933 | apply clarify | |
| 934 | apply simp | |
| 935 | apply(erule_tac x=i and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE) | |
| 936 | apply(case_tac "clist!i",simp,simp) | |
| 937 | apply(thin_tac "?H = (\<exists>i. ?J i)") | |
| 938 | apply(rule conjI) | |
| 939 | apply clarify | |
| 940 | apply(erule_tac x=j in allE,erule impE, assumption,erule disjE) | |
| 941 | apply clarify | |
| 942 | apply(rule_tac x=i in exI,simp) | |
| 943 | apply(case_tac j,simp) | |
| 944 | apply(rule conjI) | |
| 945 | apply(erule_tac x=i in allE) | |
| 946 | apply(simp add:cp_def) | |
| 947 | apply(erule_tac x=i and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE) | |
| 948 | apply(case_tac "clist!i",simp,simp) | |
| 949 | apply clarify | |
| 950 | apply(erule_tac x=l in allE) | |
| 951 | apply(erule_tac x=l and P="\<lambda>j. ?H j \<longrightarrow> ?I j \<longrightarrow> ?J j" in allE) | |
| 952 | apply clarify | |
| 953 | apply(simp add:cp_def) | |
| 954 | apply(erule_tac x=l and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE) | |
| 955 | apply(case_tac "clist!l",simp,simp) | |
| 956 | apply simp | |
| 957 | apply(rule conjI) | |
| 958 | apply(erule_tac x=i and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE) | |
| 959 | apply(case_tac "clist!i",simp,simp) | |
| 960 | apply clarify | |
| 961 | apply(erule_tac x=l and P="\<lambda>j. ?H j \<longrightarrow> ?I j \<longrightarrow> ?J j" in allE) | |
| 962 | apply(erule_tac x=l and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE) | |
| 963 | apply(case_tac "clist!l",simp,simp) | |
| 964 | apply clarify | |
| 965 | apply(erule_tac x=i in allE) | |
| 966 | apply(simp add:cp_def) | |
| 967 | apply(erule_tac x=i and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE) | |
| 968 | apply(case_tac "clist!i",simp) | |
| 969 | apply(rule nth_tl_if,simp,simp) | |
| 970 | apply(erule_tac x=i and P="\<lambda>j. ?H j \<longrightarrow> (?P j)\<in>etran" in allE, erule impE, assumption,simp) | |
| 971 | apply(simp add:cp_def) | |
| 972 | apply clarify | |
| 973 | apply(rule nth_tl_if) | |
| 974 | apply(erule_tac x=i and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE) | |
| 975 | apply(case_tac "clist!i",simp,simp) | |
| 976 | apply force | |
| 977 | apply force | |
| 978 | apply clarify | |
| 979 | apply(rule iffI) | |
| 980 | apply(simp add:par_cp_def) | |
| 981 | apply(erule_tac c="(xs, s) # ys" in equalityCE) | |
| 982 | apply simp | |
| 983 | apply clarify | |
| 984 | apply(rule_tac x="map tl clist" in exI) | |
| 985 | apply simp | |
| 986 | apply (rule conjI) | |
| 987 | apply(simp add:conjoin_def cp_def) | |
| 988 | apply(rule conjI) | |
| 989 | apply clarify | |
| 990 | apply(unfold same_length_def) | |
| 991 | apply clarify | |
| 992 | apply(erule_tac x=i and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE,simp) | |
| 993 | apply(rule conjI) | |
| 994 | apply(simp add:same_state_def) | |
| 995 | apply clarify | |
| 996 | apply(erule_tac x=i in allE, erule impE, assumption, | |
| 997 | erule_tac x=j and P="\<lambda>j. ?H j \<longrightarrow> (snd (?d j))=(snd (?e j))" in allE) | |
| 998 | apply(case_tac j,simp) | |
| 999 | apply(erule_tac x=i and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE) | |
| 1000 | apply(case_tac "clist!i",simp,simp) | |
| 1001 | apply(rule conjI) | |
| 1002 | apply(simp add:same_program_def) | |
| 1003 | apply clarify | |
| 1004 | apply(rule nth_equalityI,simp,simp) | |
| 1005 | apply(case_tac j,simp) | |
| 1006 | apply clarify | |
| 1007 | apply(erule_tac x=i and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE) | |
| 1008 | apply(case_tac "clist!i",simp,simp) | |
| 1009 | apply clarify | |
| 1010 | apply(simp add:compat_label_def) | |
| 1011 | apply(rule allI,rule impI) | |
| 1012 | apply(erule_tac x=j in allE,erule impE, assumption) | |
| 1013 | apply(erule disjE) | |
| 1014 | apply clarify | |
| 1015 | apply(rule_tac x=i in exI,simp) | |
| 1016 | apply(rule conjI) | |
| 1017 | apply(erule_tac x=i in allE) | |
| 1018 | apply(case_tac j,simp) | |
| 1019 | apply(erule_tac x=i and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE) | |
| 1020 | apply(case_tac "clist!i",simp,simp) | |
| 1021 | apply(erule_tac x=i and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE) | |
| 1022 | apply(case_tac "clist!i",simp,simp) | |
| 1023 | apply clarify | |
| 1024 | apply(erule_tac x=l and P="\<lambda>j. ?H j \<longrightarrow> ?I j \<longrightarrow> ?J j" in allE) | |
| 1025 | apply(erule_tac x=l and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE) | |
| 1026 | apply(case_tac "clist!l",simp,simp) | |
| 1027 | apply(erule_tac x=l in allE,simp) | |
| 1028 | apply(rule disjI2) | |
| 1029 | apply clarify | |
| 1030 | apply(rule tl_zero) | |
| 1031 | apply(case_tac j,simp,simp) | |
| 1032 | apply(rule tl_zero,force) | |
| 1033 | apply force | |
| 1034 | apply(erule_tac x=i and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE,force) | |
| 1035 | apply force | |
| 1036 | apply(erule_tac x=i and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE,force) | |
| 1037 | apply clarify | |
| 1038 | apply(erule_tac x=i in allE) | |
| 1039 | apply(simp add:cp_def) | |
| 1040 | apply(rule nth_tl_if) | |
| 1041 | apply(simp add:conjoin_def) | |
| 1042 | apply clarify | |
| 1043 | apply(simp add:same_length_def) | |
| 1044 | apply(erule_tac x=i in allE,simp) | |
| 1045 | apply simp | |
| 1046 | apply simp | |
| 1047 | apply simp | |
| 1048 | apply clarify | |
| 1049 | apply(erule_tac c="(xs, s) # ys" in equalityCE) | |
| 1050 | apply(simp add:par_cp_def) | |
| 1051 | apply simp | |
| 1052 | apply(erule_tac x="map (\<lambda>i. (fst i, s) # snd i) (zip xs clist)" in allE) | |
| 1053 | apply simp | |
| 1054 | apply clarify | |
| 1055 | apply(simp add:cp_def) | |
| 1056 | done | |
| 1057 | ||
| 1058 | theorem one: "xs\<noteq>[] \<Longrightarrow> | |
| 1059 |  par_cp xs s = {c. \<exists>clist. (length clist)=(length xs) \<and> 
 | |
| 1060 | (\<forall>i<length clist. (clist!i) \<in> cp(xs!i) s) \<and> c \<propto> clist}" | |
| 1061 | apply(frule one_iff_aux) | |
| 1062 | apply(drule sym) | |
| 1063 | apply(erule iffD2) | |
| 1064 | apply clarify | |
| 1065 | apply(rule iffI) | |
| 1066 | apply(erule aux_onlyif) | |
| 1067 | apply clarify | |
| 1068 | apply(force intro:aux_if) | |
| 1069 | done | |
| 1070 | ||
| 13187 | 1071 | end |