src/HOL/Hoare_Parallel/RG_Hoare.thy
changeset 67443 3abf6a722518
parent 62343 24106dc44def
child 68975 5ce4d117cea7
equal deleted inserted replaced
67442:f075640b8868 67443:3abf6a722518
   456  apply(frule_tac j=0 and k=i and p=pre in stability,simp_all)
   456  apply(frule_tac j=0 and k=i and p=pre in stability,simp_all)
   457    apply(erule_tac x=ia in allE,simp)
   457    apply(erule_tac x=ia in allE,simp)
   458   apply(subgoal_tac "x\<in> cp (Some(Await b P)) s")
   458   apply(subgoal_tac "x\<in> cp (Some(Await b P)) s")
   459   apply(erule_tac i=i in unique_ctran_Await,force,simp_all)
   459   apply(erule_tac i=i in unique_ctran_Await,force,simp_all)
   460   apply(simp add:cp_def)
   460   apply(simp add:cp_def)
   461 \<comment>\<open>here starts the different part.\<close>
   461 \<comment> \<open>here starts the different part.\<close>
   462  apply(erule ctran.cases,simp_all)
   462  apply(erule ctran.cases,simp_all)
   463  apply(drule Star_imp_cptn)
   463  apply(drule Star_imp_cptn)
   464  apply clarify
   464  apply clarify
   465  apply(erule_tac x=sa in allE)
   465  apply(erule_tac x=sa in allE)
   466  apply clarify
   466  apply clarify
   738  apply(subgoal_tac "(map (lift Q) ((a, b) # list))\<noteq>[]")
   738  apply(subgoal_tac "(map (lift Q) ((a, b) # list))\<noteq>[]")
   739   apply(drule last_conv_nth)
   739   apply(drule last_conv_nth)
   740   apply (simp del:list.map)
   740   apply (simp del:list.map)
   741   apply(simp only:last_lift_not_None)
   741   apply(simp only:last_lift_not_None)
   742  apply simp
   742  apply simp
   743 \<comment>\<open>\<open>\<exists>i<length x. fst (x ! i) = Some Q\<close>\<close>
   743 \<comment> \<open>\<open>\<exists>i<length x. fst (x ! i) = Some Q\<close>\<close>
   744 apply(erule exE)
   744 apply(erule exE)
   745 apply(drule_tac n=i and P="\<lambda>i. i < length x \<and> fst (x ! i) = Some Q" in Ex_first_occurrence)
   745 apply(drule_tac n=i and P="\<lambda>i. i < length x \<and> fst (x ! i) = Some Q" in Ex_first_occurrence)
   746 apply clarify
   746 apply clarify
   747 apply (simp add:cp_def)
   747 apply (simp add:cp_def)
   748  apply clarify
   748  apply clarify
   880    stable pre rely;  stable post rely; x \<in> cptn_mod \<rbrakk>
   880    stable pre rely;  stable post rely; x \<in> cptn_mod \<rbrakk>
   881   \<Longrightarrow>  \<forall>s xs. x=(Some(While b P),s)#xs \<longrightarrow> x\<in>assum(pre, rely) \<longrightarrow> x \<in> comm (guar, post)"
   881   \<Longrightarrow>  \<forall>s xs. x=(Some(While b P),s)#xs \<longrightarrow> x\<in>assum(pre, rely) \<longrightarrow> x \<in> comm (guar, post)"
   882 apply(erule cptn_mod.induct)
   882 apply(erule cptn_mod.induct)
   883 apply safe
   883 apply safe
   884 apply (simp_all del:last.simps)
   884 apply (simp_all del:last.simps)
   885 \<comment>\<open>5 subgoals left\<close>
   885 \<comment> \<open>5 subgoals left\<close>
   886 apply(simp add:comm_def)
   886 apply(simp add:comm_def)
   887 \<comment>\<open>4 subgoals left\<close>
   887 \<comment> \<open>4 subgoals left\<close>
   888 apply(rule etran_in_comm)
   888 apply(rule etran_in_comm)
   889 apply(erule mp)
   889 apply(erule mp)
   890 apply(erule tl_of_assum_in_assum,simp)
   890 apply(erule tl_of_assum_in_assum,simp)
   891 \<comment>\<open>While-None\<close>
   891 \<comment> \<open>While-None\<close>
   892 apply(ind_cases "((Some (While b P), s), None, t) \<in> ctran" for s t)
   892 apply(ind_cases "((Some (While b P), s), None, t) \<in> ctran" for s t)
   893 apply(simp add:comm_def)
   893 apply(simp add:comm_def)
   894 apply(simp add:cptn_iff_cptn_mod [THEN sym])
   894 apply(simp add:cptn_iff_cptn_mod [THEN sym])
   895 apply(rule conjI,clarify)
   895 apply(rule conjI,clarify)
   896  apply(force simp add:assum_def)
   896  apply(force simp add:assum_def)
   911   apply(erule_tac x="i" in allE,simp)
   911   apply(erule_tac x="i" in allE,simp)
   912   apply(erule_tac x="Suc i" in allE,simp)
   912   apply(erule_tac x="Suc i" in allE,simp)
   913  apply simp
   913  apply simp
   914 apply clarify
   914 apply clarify
   915 apply (simp add:last_length)
   915 apply (simp add:last_length)
   916 \<comment>\<open>WhileOne\<close>
   916 \<comment> \<open>WhileOne\<close>
   917 apply(thin_tac "P = While b P \<longrightarrow> Q" for Q)
   917 apply(thin_tac "P = While b P \<longrightarrow> Q" for Q)
   918 apply(rule ctran_in_comm,simp)
   918 apply(rule ctran_in_comm,simp)
   919 apply(simp add:Cons_lift del:list.map)
   919 apply(simp add:Cons_lift del:list.map)
   920 apply(simp add:comm_def del:list.map)
   920 apply(simp add:comm_def del:list.map)
   921 apply(rule conjI)
   921 apply(rule conjI)
   947  apply(case_tac "xs!i")
   947  apply(case_tac "xs!i")
   948  apply(simp add:lift_def)
   948  apply(simp add:lift_def)
   949  apply(case_tac "fst(xs!i)")
   949  apply(case_tac "fst(xs!i)")
   950   apply force
   950   apply force
   951  apply force
   951  apply force
   952 \<comment>\<open>last=None\<close>
   952 \<comment> \<open>last=None\<close>
   953 apply clarify
   953 apply clarify
   954 apply(subgoal_tac "(map (lift (While b P)) ((Some P, sa) # xs))\<noteq>[]")
   954 apply(subgoal_tac "(map (lift (While b P)) ((Some P, sa) # xs))\<noteq>[]")
   955  apply(drule last_conv_nth)
   955  apply(drule last_conv_nth)
   956  apply (simp del:list.map)
   956  apply (simp del:list.map)
   957  apply(simp only:last_lift_not_None)
   957  apply(simp only:last_lift_not_None)
   958 apply simp
   958 apply simp
   959 \<comment>\<open>WhileMore\<close>
   959 \<comment> \<open>WhileMore\<close>
   960 apply(thin_tac "P = While b P \<longrightarrow> Q" for Q)
   960 apply(thin_tac "P = While b P \<longrightarrow> Q" for Q)
   961 apply(rule ctran_in_comm,simp del:last.simps)
   961 apply(rule ctran_in_comm,simp del:last.simps)
   962 \<comment>\<open>metiendo la hipotesis antes de dividir la conclusion.\<close>
   962 \<comment> \<open>metiendo la hipotesis antes de dividir la conclusion.\<close>
   963 apply(subgoal_tac "(Some (While b P), snd (last ((Some P, sa) # xs))) # ys \<in> assum (pre, rely)")
   963 apply(subgoal_tac "(Some (While b P), snd (last ((Some P, sa) # xs))) # ys \<in> assum (pre, rely)")
   964  apply (simp del:last.simps)
   964  apply (simp del:last.simps)
   965  prefer 2
   965  prefer 2
   966  apply(erule assum_after_body)
   966  apply(erule assum_after_body)
   967   apply (simp del:last.simps)+
   967   apply (simp del:last.simps)+
   968 \<comment>\<open>lo de antes.\<close>
   968 \<comment> \<open>lo de antes.\<close>
   969 apply(simp add:comm_def del:list.map last.simps)
   969 apply(simp add:comm_def del:list.map last.simps)
   970 apply(rule conjI)
   970 apply(rule conjI)
   971  apply clarify
   971  apply clarify
   972  apply(simp only:Cons_lift_append)
   972  apply(simp only:Cons_lift_append)
   973  apply(case_tac "i<length xs")
   973  apply(case_tac "i<length xs")
   999   apply(case_tac "xs!i")
   999   apply(case_tac "xs!i")
  1000   apply(simp add:lift_def)
  1000   apply(simp add:lift_def)
  1001   apply(case_tac "fst(xs!i)")
  1001   apply(case_tac "fst(xs!i)")
  1002    apply force
  1002    apply force
  1003  apply force
  1003  apply force
  1004 \<comment>\<open>\<open>i \<ge> length xs\<close>\<close>
  1004 \<comment> \<open>\<open>i \<ge> length xs\<close>\<close>
  1005 apply(subgoal_tac "i-length xs <length ys")
  1005 apply(subgoal_tac "i-length xs <length ys")
  1006  prefer 2
  1006  prefer 2
  1007  apply arith
  1007  apply arith
  1008 apply(erule_tac x="i-length xs" in allE,clarify)
  1008 apply(erule_tac x="i-length xs" in allE,clarify)
  1009 apply(case_tac "i=length xs")
  1009 apply(case_tac "i=length xs")
  1010  apply (simp add:nth_append snd_lift del:list.map last.simps)
  1010  apply (simp add:nth_append snd_lift del:list.map last.simps)
  1011  apply(simp add:last_length del:last.simps)
  1011  apply(simp add:last_length del:last.simps)
  1012  apply(erule mp)
  1012  apply(erule mp)
  1013  apply(case_tac "last((Some P, sa) # xs)")
  1013  apply(case_tac "last((Some P, sa) # xs)")
  1014  apply(simp add:lift_def del:last.simps)
  1014  apply(simp add:lift_def del:last.simps)
  1015 \<comment>\<open>\<open>i>length xs\<close>\<close>
  1015 \<comment> \<open>\<open>i>length xs\<close>\<close>
  1016 apply(case_tac "i-length xs")
  1016 apply(case_tac "i-length xs")
  1017  apply arith
  1017  apply arith
  1018 apply(simp add:nth_append del:list.map last.simps)
  1018 apply(simp add:nth_append del:list.map last.simps)
  1019 apply(rotate_tac -3)
  1019 apply(rotate_tac -3)
  1020 apply(subgoal_tac "i- Suc (length xs)=nat")
  1020 apply(subgoal_tac "i- Suc (length xs)=nat")
  1021  prefer 2
  1021  prefer 2
  1022  apply arith
  1022  apply arith
  1023 apply simp
  1023 apply simp
  1024 \<comment>\<open>last=None\<close>
  1024 \<comment> \<open>last=None\<close>
  1025 apply clarify
  1025 apply clarify
  1026 apply(case_tac ys)
  1026 apply(case_tac ys)
  1027  apply(simp add:Cons_lift del:list.map last.simps)
  1027  apply(simp add:Cons_lift del:list.map last.simps)
  1028  apply(subgoal_tac "(map (lift (While b P)) ((Some P, sa) # xs))\<noteq>[]")
  1028  apply(subgoal_tac "(map (lift (While b P)) ((Some P, sa) # xs))\<noteq>[]")
  1029   apply(drule last_conv_nth)
  1029   apply(drule last_conv_nth)
  1105   \<forall>i<length clist. clist!i\<in>cp (Some(Com(xs!i))) s; x \<propto> clist \<rbrakk>
  1105   \<forall>i<length clist. clist!i\<in>cp (Some(Com(xs!i))) s; x \<propto> clist \<rbrakk>
  1106   \<Longrightarrow> \<forall>j i. i<length clist \<and> Suc j<length x \<longrightarrow> (clist!i!j) -c\<rightarrow> (clist!i!Suc j)
  1106   \<Longrightarrow> \<forall>j i. i<length clist \<and> Suc j<length x \<longrightarrow> (clist!i!j) -c\<rightarrow> (clist!i!Suc j)
  1107   \<longrightarrow> (snd(clist!i!j), snd(clist!i!Suc j)) \<in> Guar(xs!i)"
  1107   \<longrightarrow> (snd(clist!i!j), snd(clist!i!Suc j)) \<in> Guar(xs!i)"
  1108 apply(unfold par_cp_def)
  1108 apply(unfold par_cp_def)
  1109 apply (rule ccontr)
  1109 apply (rule ccontr)
  1110 \<comment>\<open>By contradiction:\<close>
  1110 \<comment> \<open>By contradiction:\<close>
  1111 apply simp
  1111 apply simp
  1112 apply(erule exE)
  1112 apply(erule exE)
  1113 \<comment>\<open>the first c-tran that does not satisfy the guarantee-condition is from \<open>\<sigma>_i\<close> at step \<open>m\<close>.\<close>
  1113 \<comment> \<open>the first c-tran that does not satisfy the guarantee-condition is from \<open>\<sigma>_i\<close> at step \<open>m\<close>.\<close>
  1114 apply(drule_tac n=j and P="\<lambda>j. \<exists>i. H i j" for H in Ex_first_occurrence)
  1114 apply(drule_tac n=j and P="\<lambda>j. \<exists>i. H i j" for H in Ex_first_occurrence)
  1115 apply(erule exE)
  1115 apply(erule exE)
  1116 apply clarify
  1116 apply clarify
  1117 \<comment>\<open>\<open>\<sigma>_i \<in> A(pre, rely_1)\<close>\<close>
  1117 \<comment> \<open>\<open>\<sigma>_i \<in> A(pre, rely_1)\<close>\<close>
  1118 apply(subgoal_tac "take (Suc (Suc m)) (clist!i) \<in> assum(Pre(xs!i), Rely(xs!i))")
  1118 apply(subgoal_tac "take (Suc (Suc m)) (clist!i) \<in> assum(Pre(xs!i), Rely(xs!i))")
  1119 \<comment>\<open>but this contradicts \<open>\<Turnstile> \<sigma>_i sat [pre_i,rely_i,guar_i,post_i]\<close>\<close>
  1119 \<comment> \<open>but this contradicts \<open>\<Turnstile> \<sigma>_i sat [pre_i,rely_i,guar_i,post_i]\<close>\<close>
  1120  apply(erule_tac x=i and P="\<lambda>i. H i \<longrightarrow> \<Turnstile> (J i) sat [I i,K i,M i,N i]" for H J I K M N in allE,erule impE,assumption)
  1120  apply(erule_tac x=i and P="\<lambda>i. H i \<longrightarrow> \<Turnstile> (J i) sat [I i,K i,M i,N i]" for H J I K M N in allE,erule impE,assumption)
  1121  apply(simp add:com_validity_def)
  1121  apply(simp add:com_validity_def)
  1122  apply(erule_tac x=s in allE)
  1122  apply(erule_tac x=s in allE)
  1123  apply(simp add:cp_def comm_def)
  1123  apply(simp add:cp_def comm_def)
  1124  apply(drule_tac c="take (Suc (Suc m)) (clist ! i)" in subsetD)
  1124  apply(drule_tac c="take (Suc (Suc m)) (clist ! i)" in subsetD)
  1140 apply(erule subsetD)
  1140 apply(erule subsetD)
  1141 apply simp
  1141 apply simp
  1142 apply(simp add:conjoin_def compat_label_def)
  1142 apply(simp add:conjoin_def compat_label_def)
  1143 apply clarify
  1143 apply clarify
  1144 apply(erule_tac x=ia and P="\<lambda>j. H j \<longrightarrow> (P j) \<or> Q j" for H P Q in allE,simp)
  1144 apply(erule_tac x=ia and P="\<lambda>j. H j \<longrightarrow> (P j) \<or> Q j" for H P Q in allE,simp)
  1145 \<comment>\<open>each etran in \<open>\<sigma>_1[0\<dots>m]\<close> corresponds to\<close>
  1145 \<comment> \<open>each etran in \<open>\<sigma>_1[0\<dots>m]\<close> corresponds to\<close>
  1146 apply(erule disjE)
  1146 apply(erule disjE)
  1147 \<comment>\<open>a c-tran in some \<open>\<sigma>_{ib}\<close>\<close>
  1147 \<comment> \<open>a c-tran in some \<open>\<sigma>_{ib}\<close>\<close>
  1148  apply clarify
  1148  apply clarify
  1149  apply(case_tac "i=ib",simp)
  1149  apply(case_tac "i=ib",simp)
  1150   apply(erule etranE,simp)
  1150   apply(erule etranE,simp)
  1151  apply(erule_tac x="ib" and P="\<lambda>i. H i \<longrightarrow> (I i) \<or> (J i)" for H I J in allE)
  1151  apply(erule_tac x="ib" and P="\<lambda>i. H i \<longrightarrow> (I i) \<or> (J i)" for H I J in allE)
  1152  apply (erule etranE)
  1152  apply (erule etranE)
  1158   apply arith
  1158   apply arith
  1159  apply(erule_tac x=ib and P="\<lambda>j. (I j, H j) \<in> ctran \<longrightarrow> P i j" for I H P in allE,simp)
  1159  apply(erule_tac x=ib and P="\<lambda>j. (I j, H j) \<in> ctran \<longrightarrow> P i j" for I H P in allE,simp)
  1160  apply(simp add:same_state_def)
  1160  apply(simp add:same_state_def)
  1161  apply(erule_tac x=i and P="\<lambda>j. (T j) \<longrightarrow> (\<forall>i. (H j i) \<longrightarrow> (snd (d j i))=(snd (e j i)))" for T H d e in all_dupE)
  1161  apply(erule_tac x=i and P="\<lambda>j. (T j) \<longrightarrow> (\<forall>i. (H j i) \<longrightarrow> (snd (d j i))=(snd (e j i)))" for T H d e in all_dupE)
  1162  apply(erule_tac x=ib and P="\<lambda>j. (T j) \<longrightarrow> (\<forall>i. (H j i) \<longrightarrow> (snd (d j i))=(snd (e j i)))" for T H d e in allE,simp)
  1162  apply(erule_tac x=ib and P="\<lambda>j. (T j) \<longrightarrow> (\<forall>i. (H j i) \<longrightarrow> (snd (d j i))=(snd (e j i)))" for T H d e in allE,simp)
  1163 \<comment>\<open>or an e-tran in \<open>\<sigma>\<close>,
  1163 \<comment> \<open>or an e-tran in \<open>\<sigma>\<close>,
  1164 therefore it satisfies \<open>rely \<or> guar_{ib}\<close>\<close>
  1164 therefore it satisfies \<open>rely \<or> guar_{ib}\<close>\<close>
  1165 apply (force simp add:par_assum_def same_state_def)
  1165 apply (force simp add:par_assum_def same_state_def)
  1166 done
  1166 done
  1167 
  1167 
  1168 
  1168