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