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