| author | wenzelm | 
| Sun, 22 Mar 2015 12:45:34 +0100 | |
| changeset 59774 | d1b83f7ff6fe | 
| parent 59189 | ad8e0a789af6 | 
| child 59807 | 22bc39064290 | 
| permissions | -rw-r--r-- | 
| 59189 | 1 | section \<open>The Proof System\<close> | 
| 13020 | 2 | |
| 16417 | 3 | theory OG_Hoare imports OG_Tran begin | 
| 13020 | 4 | |
| 39246 | 5 | primrec assertions :: "'a ann_com \<Rightarrow> ('a assn) set" where
 | 
| 13020 | 6 |   "assertions (AnnBasic r f) = {r}"
 | 
| 39246 | 7 | | "assertions (AnnSeq c1 c2) = assertions c1 \<union> assertions c2" | 
| 8 | | "assertions (AnnCond1 r b c1 c2) = {r} \<union> assertions c1 \<union> assertions c2"
 | |
| 9 | | "assertions (AnnCond2 r b c) = {r} \<union> assertions c"
 | |
| 10 | | "assertions (AnnWhile r b i c) = {r, i} \<union> assertions c"
 | |
| 59189 | 11 | | "assertions (AnnAwait r b c) = {r}"
 | 
| 13020 | 12 | |
| 39246 | 13 | primrec atomics :: "'a ann_com \<Rightarrow> ('a assn \<times> 'a com) set" where
 | 
| 13020 | 14 |   "atomics (AnnBasic r f) = {(r, Basic f)}"
 | 
| 39246 | 15 | | "atomics (AnnSeq c1 c2) = atomics c1 \<union> atomics c2" | 
| 16 | | "atomics (AnnCond1 r b c1 c2) = atomics c1 \<union> atomics c2" | |
| 17 | | "atomics (AnnCond2 r b c) = atomics c" | |
| 59189 | 18 | | "atomics (AnnWhile r b i c) = atomics c" | 
| 39246 | 19 | | "atomics (AnnAwait r b c) = {(r \<inter> b, c)}"
 | 
| 13020 | 20 | |
| 39246 | 21 | primrec com :: "'a ann_triple_op \<Rightarrow> 'a ann_com_op" where | 
| 22 | "com (c, q) = c" | |
| 13020 | 23 | |
| 39246 | 24 | primrec post :: "'a ann_triple_op \<Rightarrow> 'a assn" where | 
| 25 | "post (c, q) = q" | |
| 13020 | 26 | |
| 35416 
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
 haftmann parents: 
32960diff
changeset | 27 | definition interfree_aux :: "('a ann_com_op \<times> 'a assn \<times> 'a ann_com_op) \<Rightarrow> bool" where
 | 
| 59189 | 28 | "interfree_aux \<equiv> \<lambda>(co, q, co'). co'= None \<or> | 
| 13020 | 29 | (\<forall>(r,a) \<in> atomics (the co'). \<parallel>= (q \<inter> r) a q \<and> | 
| 30 | (co = None \<or> (\<forall>p \<in> assertions (the co). \<parallel>= (p \<inter> r) a p)))" | |
| 31 | ||
| 59189 | 32 | definition interfree :: "(('a ann_triple_op) list) \<Rightarrow> bool" where
 | 
| 33 | "interfree Ts \<equiv> \<forall>i j. i < length Ts \<and> j < length Ts \<and> i \<noteq> j \<longrightarrow> | |
| 13020 | 34 | interfree_aux (com (Ts!i), post (Ts!i), com (Ts!j)) " | 
| 35 | ||
| 23746 | 36 | inductive | 
| 37 |   oghoare :: "'a assn \<Rightarrow> 'a com \<Rightarrow> 'a assn \<Rightarrow> bool"  ("(3\<parallel>- _//_//_)" [90,55,90] 50)
 | |
| 38 |   and ann_hoare :: "'a ann_com \<Rightarrow> 'a assn \<Rightarrow> bool"  ("(2\<turnstile> _// _)" [60,90] 45)
 | |
| 39 | where | |
| 13020 | 40 |   AnnBasic: "r \<subseteq> {s. f s \<in> q} \<Longrightarrow> \<turnstile> (AnnBasic r f) q"
 | 
| 41 | ||
| 23746 | 42 | | AnnSeq: "\<lbrakk> \<turnstile> c0 pre c1; \<turnstile> c1 q \<rbrakk> \<Longrightarrow> \<turnstile> (AnnSeq c0 c1) q" | 
| 59189 | 43 | |
| 44 | | AnnCond1: "\<lbrakk> r \<inter> b \<subseteq> pre c1; \<turnstile> c1 q; r \<inter> -b \<subseteq> pre c2; \<turnstile> c2 q\<rbrakk> | |
| 13020 | 45 | \<Longrightarrow> \<turnstile> (AnnCond1 r b c1 c2) q" | 
| 23746 | 46 | | AnnCond2: "\<lbrakk> r \<inter> b \<subseteq> pre c; \<turnstile> c q; r \<inter> -b \<subseteq> q \<rbrakk> \<Longrightarrow> \<turnstile> (AnnCond2 r b c) q" | 
| 59189 | 47 | |
| 48 | | AnnWhile: "\<lbrakk> r \<subseteq> i; i \<inter> b \<subseteq> pre c; \<turnstile> c i; i \<inter> -b \<subseteq> q \<rbrakk> | |
| 13020 | 49 | \<Longrightarrow> \<turnstile> (AnnWhile r b i c) q" | 
| 59189 | 50 | |
| 23746 | 51 | | AnnAwait: "\<lbrakk> atom_com c; \<parallel>- (r \<inter> b) c q \<rbrakk> \<Longrightarrow> \<turnstile> (AnnAwait r b c) q" | 
| 59189 | 52 | |
| 23746 | 53 | | AnnConseq: "\<lbrakk>\<turnstile> c q; q \<subseteq> q' \<rbrakk> \<Longrightarrow> \<turnstile> c q'" | 
| 13020 | 54 | |
| 55 | ||
| 23746 | 56 | | Parallel: "\<lbrakk> \<forall>i<length Ts. \<exists>c q. Ts!i = (Some c, q) \<and> \<turnstile> c q; interfree Ts \<rbrakk> | 
| 59189 | 57 |            \<Longrightarrow> \<parallel>- (\<Inter>i\<in>{i. i<length Ts}. pre(the(com(Ts!i))))
 | 
| 58 | Parallel Ts | |
| 13020 | 59 |                   (\<Inter>i\<in>{i. i<length Ts}. post(Ts!i))"
 | 
| 60 | ||
| 23746 | 61 | | Basic:   "\<parallel>- {s. f s \<in>q} (Basic f) q"
 | 
| 59189 | 62 | |
| 23746 | 63 | | Seq: "\<lbrakk> \<parallel>- p c1 r; \<parallel>- r c2 q \<rbrakk> \<Longrightarrow> \<parallel>- p (Seq c1 c2) q " | 
| 13020 | 64 | |
| 23746 | 65 | | Cond: "\<lbrakk> \<parallel>- (p \<inter> b) c1 q; \<parallel>- (p \<inter> -b) c2 q \<rbrakk> \<Longrightarrow> \<parallel>- p (Cond b c1 c2) q" | 
| 13020 | 66 | |
| 23746 | 67 | | While: "\<lbrakk> \<parallel>- (p \<inter> b) c p \<rbrakk> \<Longrightarrow> \<parallel>- p (While b i c) (p \<inter> -b)" | 
| 13020 | 68 | |
| 23746 | 69 | | Conseq: "\<lbrakk> p' \<subseteq> p; \<parallel>- p c q ; q \<subseteq> q' \<rbrakk> \<Longrightarrow> \<parallel>- p' c q'" | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32621diff
changeset | 70 | |
| 59189 | 71 | section \<open>Soundness\<close> | 
| 13020 | 72 | (* In the version Isabelle-10-Sep-1999: HOL: The THEN and ELSE | 
| 73 | parts of conditional expressions (if P then x else y) are no longer | |
| 74 | simplified. (This allows the simplifier to unfold recursive | |
| 75 | functional programs.) To restore the old behaviour, we declare | |
| 76 | @{text "lemmas [cong del] = if_weak_cong"}. *)
 | |
| 77 | ||
| 78 | lemmas [cong del] = if_weak_cong | |
| 79 | ||
| 80 | lemmas ann_hoare_induct = oghoare_ann_hoare.induct [THEN conjunct2] | |
| 81 | lemmas oghoare_induct = oghoare_ann_hoare.induct [THEN conjunct1] | |
| 82 | ||
| 83 | lemmas AnnBasic = oghoare_ann_hoare.AnnBasic | |
| 84 | lemmas AnnSeq = oghoare_ann_hoare.AnnSeq | |
| 85 | lemmas AnnCond1 = oghoare_ann_hoare.AnnCond1 | |
| 86 | lemmas AnnCond2 = oghoare_ann_hoare.AnnCond2 | |
| 87 | lemmas AnnWhile = oghoare_ann_hoare.AnnWhile | |
| 88 | lemmas AnnAwait = oghoare_ann_hoare.AnnAwait | |
| 89 | lemmas AnnConseq = oghoare_ann_hoare.AnnConseq | |
| 90 | ||
| 91 | lemmas Parallel = oghoare_ann_hoare.Parallel | |
| 92 | lemmas Basic = oghoare_ann_hoare.Basic | |
| 93 | lemmas Seq = oghoare_ann_hoare.Seq | |
| 94 | lemmas Cond = oghoare_ann_hoare.Cond | |
| 95 | lemmas While = oghoare_ann_hoare.While | |
| 96 | lemmas Conseq = oghoare_ann_hoare.Conseq | |
| 97 | ||
| 59189 | 98 | subsection \<open>Soundness of the System for Atomic Programs\<close> | 
| 13020 | 99 | |
| 59189 | 100 | lemma Basic_ntran [rule_format]: | 
| 13020 | 101 | "(Basic f, s) -Pn\<rightarrow> (Parallel Ts, t) \<longrightarrow> All_None Ts \<longrightarrow> t = f s" | 
| 102 | apply(induct "n") | |
| 103 | apply(simp (no_asm)) | |
| 46362 | 104 | apply(fast dest: relpow_Suc_D2 Parallel_empty_lemma elim: transition_cases) | 
| 13020 | 105 | done | 
| 106 | ||
| 107 | lemma SEM_fwhile: "SEM S (p \<inter> b) \<subseteq> p \<Longrightarrow> SEM (fwhile b S k) p \<subseteq> (p \<inter> -b)" | |
| 108 | apply (induct "k") | |
| 109 | apply(simp (no_asm) add: L3_5v_lemma3) | |
| 110 | apply(simp (no_asm) add: L3_5iv L3_5ii Parallel_empty) | |
| 15102 | 111 | apply(rule conjI) | 
| 59189 | 112 | apply (blast dest: L3_5i) | 
| 13020 | 113 | apply(simp add: SEM_def sem_def id_def) | 
| 59189 | 114 | apply (blast dest: Basic_ntran rtrancl_imp_UN_relpow) | 
| 13020 | 115 | done | 
| 116 | ||
| 59189 | 117 | lemma atom_hoare_sound [rule_format]: | 
| 13020 | 118 | " \<parallel>- p c q \<longrightarrow> atom_com(c) \<longrightarrow> \<parallel>= p c q" | 
| 119 | apply (unfold com_validity_def) | |
| 120 | apply(rule oghoare_induct) | |
| 121 | apply simp_all | |
| 59189 | 122 | --\<open>Basic\<close> | 
| 13020 | 123 | apply(simp add: SEM_def sem_def) | 
| 46362 | 124 | apply(fast dest: rtrancl_imp_UN_relpow Basic_ntran) | 
| 59189 | 125 | --\<open>Seq\<close> | 
| 13020 | 126 | apply(rule impI) | 
| 127 | apply(rule subset_trans) | |
| 128 | prefer 2 apply simp | |
| 129 | apply(simp add: L3_5ii L3_5i) | |
| 59189 | 130 | --\<open>Cond\<close> | 
| 13020 | 131 | apply(simp add: L3_5iv) | 
| 59189 | 132 | --\<open>While\<close> | 
| 133 | apply (force simp add: L3_5v dest: SEM_fwhile) | |
| 134 | --\<open>Conseq\<close> | |
| 15102 | 135 | apply(force simp add: SEM_def sem_def) | 
| 13020 | 136 | done | 
| 59189 | 137 | |
| 138 | subsection \<open>Soundness of the System for Component Programs\<close> | |
| 13020 | 139 | |
| 140 | inductive_cases ann_transition_cases: | |
| 23746 | 141 | "(None,s) -1\<rightarrow> (c', s')" | 
| 142 | "(Some (AnnBasic r f),s) -1\<rightarrow> (c', s')" | |
| 143 | "(Some (AnnSeq c1 c2), s) -1\<rightarrow> (c', s')" | |
| 144 | "(Some (AnnCond1 r b c1 c2), s) -1\<rightarrow> (c', s')" | |
| 145 | "(Some (AnnCond2 r b c), s) -1\<rightarrow> (c', s')" | |
| 146 | "(Some (AnnWhile r b I c), s) -1\<rightarrow> (c', s')" | |
| 147 | "(Some (AnnAwait r b c),s) -1\<rightarrow> (c', s')" | |
| 13020 | 148 | |
| 59189 | 149 | text \<open>Strong Soundness for Component Programs:\<close> | 
| 13020 | 150 | |
| 46008 
c296c75f4cf4
reverted some changes for set->predicate transition, according to "hg log -u berghofe -r Isabelle2007:Isabelle2008";
 wenzelm parents: 
44535diff
changeset | 151 | lemma ann_hoare_case_analysis [rule_format]: "\<turnstile> C q' \<longrightarrow> | 
| 59189 | 152 |   ((\<forall>r f. C = AnnBasic r f \<longrightarrow> (\<exists>q. r \<subseteq> {s. f s \<in> q} \<and> q \<subseteq> q')) \<and>
 | 
| 153 | (\<forall>c0 c1. C = AnnSeq c0 c1 \<longrightarrow> (\<exists>q. q \<subseteq> q' \<and> \<turnstile> c0 pre c1 \<and> \<turnstile> c1 q)) \<and> | |
| 154 | (\<forall>r b c1 c2. C = AnnCond1 r b c1 c2 \<longrightarrow> (\<exists>q. q \<subseteq> q' \<and> | |
| 155 | r \<inter> b \<subseteq> pre c1 \<and> \<turnstile> c1 q \<and> r \<inter> -b \<subseteq> pre c2 \<and> \<turnstile> c2 q)) \<and> | |
| 156 | (\<forall>r b c. C = AnnCond2 r b c \<longrightarrow> | |
| 157 | (\<exists>q. q \<subseteq> q' \<and> r \<inter> b \<subseteq> pre c \<and> \<turnstile> c q \<and> r \<inter> -b \<subseteq> q)) \<and> | |
| 158 | (\<forall>r i b c. C = AnnWhile r b i c \<longrightarrow> | |
| 159 | (\<exists>q. q \<subseteq> q' \<and> r \<subseteq> i \<and> i \<inter> b \<subseteq> pre c \<and> \<turnstile> c i \<and> i \<inter> -b \<subseteq> q)) \<and> | |
| 13020 | 160 | (\<forall>r b c. C = AnnAwait r b c \<longrightarrow> (\<exists>q. q \<subseteq> q' \<and> \<parallel>- (r \<inter> b) c q)))" | 
| 161 | apply(rule ann_hoare_induct) | |
| 46008 
c296c75f4cf4
reverted some changes for set->predicate transition, according to "hg log -u berghofe -r Isabelle2007:Isabelle2008";
 wenzelm parents: 
44535diff
changeset | 162 | apply simp_all | 
| 13020 | 163 | apply(rule_tac x=q in exI,simp)+ | 
| 164 | apply(rule conjI,clarify,simp,clarify,rule_tac x=qa in exI,fast)+ | |
| 165 | apply(clarify,simp,clarify,rule_tac x=qa in exI,fast) | |
| 166 | done | |
| 167 | ||
| 23746 | 168 | lemma Help: "(transition \<inter> {(x,y). True}) = (transition)"
 | 
| 13020 | 169 | apply force | 
| 170 | done | |
| 171 | ||
| 59189 | 172 | lemma Strong_Soundness_aux_aux [rule_format]: | 
| 173 | "(co, s) -1\<rightarrow> (co', t) \<longrightarrow> (\<forall>c. co = Some c \<longrightarrow> s\<in> pre c \<longrightarrow> | |
| 13020 | 174 | (\<forall>q. \<turnstile> c q \<longrightarrow> (if co' = None then t\<in>q else t \<in> pre(the co') \<and> \<turnstile> (the co') q )))" | 
| 175 | apply(rule ann_transition_transition.induct [THEN conjunct1]) | |
| 59189 | 176 | apply simp_all | 
| 177 | --\<open>Basic\<close> | |
| 13020 | 178 | apply clarify | 
| 179 | apply(frule ann_hoare_case_analysis) | |
| 180 | apply force | |
| 59189 | 181 | --\<open>Seq\<close> | 
| 13020 | 182 | apply clarify | 
| 183 | apply(frule ann_hoare_case_analysis,simp) | |
| 184 | apply(fast intro: AnnConseq) | |
| 185 | apply clarify | |
| 186 | apply(frule ann_hoare_case_analysis,simp) | |
| 187 | apply clarify | |
| 188 | apply(rule conjI) | |
| 189 | apply force | |
| 190 | apply(rule AnnSeq,simp) | |
| 191 | apply(fast intro: AnnConseq) | |
| 59189 | 192 | --\<open>Cond1\<close> | 
| 13020 | 193 | apply clarify | 
| 194 | apply(frule ann_hoare_case_analysis,simp) | |
| 195 | apply(fast intro: AnnConseq) | |
| 196 | apply clarify | |
| 197 | apply(frule ann_hoare_case_analysis,simp) | |
| 198 | apply(fast intro: AnnConseq) | |
| 59189 | 199 | --\<open>Cond2\<close> | 
| 13020 | 200 | apply clarify | 
| 201 | apply(frule ann_hoare_case_analysis,simp) | |
| 202 | apply(fast intro: AnnConseq) | |
| 203 | apply clarify | |
| 204 | apply(frule ann_hoare_case_analysis,simp) | |
| 205 | apply(fast intro: AnnConseq) | |
| 59189 | 206 | --\<open>While\<close> | 
| 13020 | 207 | apply clarify | 
| 208 | apply(frule ann_hoare_case_analysis,simp) | |
| 209 | apply force | |
| 210 | apply clarify | |
| 211 | apply(frule ann_hoare_case_analysis,simp) | |
| 212 | apply auto | |
| 213 | apply(rule AnnSeq) | |
| 214 | apply simp | |
| 215 | apply(rule AnnWhile) | |
| 216 | apply simp_all | |
| 59189 | 217 | --\<open>Await\<close> | 
| 13020 | 218 | apply(frule ann_hoare_case_analysis,simp) | 
| 219 | apply clarify | |
| 220 | apply(drule atom_hoare_sound) | |
| 59189 | 221 | apply simp | 
| 13020 | 222 | apply(simp add: com_validity_def SEM_def sem_def) | 
| 223 | apply(simp add: Help All_None_def) | |
| 224 | apply force | |
| 225 | done | |
| 226 | ||
| 59189 | 227 | lemma Strong_Soundness_aux: "\<lbrakk> (Some c, s) -*\<rightarrow> (co, t); s \<in> pre c; \<turnstile> c q \<rbrakk> | 
| 13020 | 228 | \<Longrightarrow> if co = None then t \<in> q else t \<in> pre (the co) \<and> \<turnstile> (the co) q" | 
| 229 | apply(erule rtrancl_induct2) | |
| 230 | apply simp | |
| 231 | apply(case_tac "a") | |
| 232 | apply(fast elim: ann_transition_cases) | |
| 233 | apply(erule Strong_Soundness_aux_aux) | |
| 234 | apply simp | |
| 235 | apply simp_all | |
| 236 | done | |
| 237 | ||
| 59189 | 238 | lemma Strong_Soundness: "\<lbrakk> (Some c, s)-*\<rightarrow>(co, t); s \<in> pre c; \<turnstile> c q \<rbrakk> | 
| 13020 | 239 | \<Longrightarrow> if co = None then t\<in>q else t \<in> pre (the co)" | 
| 240 | apply(force dest:Strong_Soundness_aux) | |
| 241 | done | |
| 242 | ||
| 243 | lemma ann_hoare_sound: "\<turnstile> c q \<Longrightarrow> \<Turnstile> c q" | |
| 244 | apply (unfold ann_com_validity_def ann_SEM_def ann_sem_def) | |
| 245 | apply clarify | |
| 246 | apply(drule Strong_Soundness) | |
| 247 | apply simp_all | |
| 248 | done | |
| 249 | ||
| 59189 | 250 | subsection \<open>Soundness of the System for Parallel Programs\<close> | 
| 13020 | 251 | |
| 59189 | 252 | lemma Parallel_length_post_P1: "(Parallel Ts,s) -P1\<rightarrow> (R', t) \<Longrightarrow> | 
| 13020 | 253 | (\<exists>Rs. R' = (Parallel Rs) \<and> (length Rs) = (length Ts) \<and> | 
| 254 | (\<forall>i. i<length Ts \<longrightarrow> post(Rs ! i) = post(Ts ! i)))" | |
| 255 | apply(erule transition_cases) | |
| 256 | apply simp | |
| 257 | apply clarify | |
| 258 | apply(case_tac "i=ia") | |
| 259 | apply simp+ | |
| 260 | done | |
| 261 | ||
| 59189 | 262 | lemma Parallel_length_post_PStar: "(Parallel Ts,s) -P*\<rightarrow> (R',t) \<Longrightarrow> | 
| 263 | (\<exists>Rs. R' = (Parallel Rs) \<and> (length Rs) = (length Ts) \<and> | |
| 13020 | 264 | (\<forall>i. i<length Ts \<longrightarrow> post(Ts ! i) = post(Rs ! i)))" | 
| 265 | apply(erule rtrancl_induct2) | |
| 266 | apply(simp_all) | |
| 267 | apply clarify | |
| 268 | apply simp | |
| 269 | apply(drule Parallel_length_post_P1) | |
| 270 | apply auto | |
| 271 | done | |
| 272 | ||
| 273 | lemma assertions_lemma: "pre c \<in> assertions c" | |
| 274 | apply(rule ann_com_com.induct [THEN conjunct1]) | |
| 275 | apply auto | |
| 276 | done | |
| 277 | ||
| 59189 | 278 | lemma interfree_aux1 [rule_format]: | 
| 13020 | 279 | "(c,s) -1\<rightarrow> (r,t) \<longrightarrow> (interfree_aux(c1, q1, c) \<longrightarrow> interfree_aux(c1, q1, r))" | 
| 280 | apply (rule ann_transition_transition.induct [THEN conjunct1]) | |
| 281 | apply(safe) | |
| 282 | prefer 13 | |
| 283 | apply (rule TrueI) | |
| 284 | apply (simp_all add:interfree_aux_def) | |
| 285 | apply force+ | |
| 286 | done | |
| 287 | ||
| 59189 | 288 | lemma interfree_aux2 [rule_format]: | 
| 13020 | 289 | "(c,s) -1\<rightarrow> (r,t) \<longrightarrow> (interfree_aux(c, q, a) \<longrightarrow> interfree_aux(r, q, a) )" | 
| 290 | apply (rule ann_transition_transition.induct [THEN conjunct1]) | |
| 291 | apply(force simp add:interfree_aux_def)+ | |
| 292 | done | |
| 293 | ||
| 59189 | 294 | lemma interfree_lemma: "\<lbrakk> (Some c, s) -1\<rightarrow> (r, t);interfree Ts ; i<length Ts; | 
| 13020 | 295 | Ts!i = (Some c, q) \<rbrakk> \<Longrightarrow> interfree (Ts[i:= (r, q)])" | 
| 296 | apply(simp add: interfree_def) | |
| 297 | apply clarify | |
| 298 | apply(case_tac "i=j") | |
| 299 | apply(drule_tac t = "ia" in not_sym) | |
| 300 | apply simp_all | |
| 301 | apply(force elim: interfree_aux1) | |
| 302 | apply(force elim: interfree_aux2 simp add:nth_list_update) | |
| 303 | done | |
| 304 | ||
| 59189 | 305 | text \<open>Strong Soundness Theorem for Parallel Programs:\<close> | 
| 13020 | 306 | |
| 59189 | 307 | lemma Parallel_Strong_Soundness_Seq_aux: | 
| 308 | "\<lbrakk>interfree Ts; i<length Ts; com(Ts ! i) = Some(AnnSeq c0 c1) \<rbrakk> | |
| 13020 | 309 | \<Longrightarrow> interfree (Ts[i:=(Some c0, pre c1)])" | 
| 310 | apply(simp add: interfree_def) | |
| 311 | apply clarify | |
| 312 | apply(case_tac "i=j") | |
| 313 | apply(force simp add: nth_list_update interfree_aux_def) | |
| 314 | apply(case_tac "i=ia") | |
| 315 | apply(erule_tac x=ia in allE) | |
| 316 | apply(force simp add:interfree_aux_def assertions_lemma) | |
| 317 | apply simp | |
| 318 | done | |
| 319 | ||
| 59189 | 320 | lemma Parallel_Strong_Soundness_Seq [rule_format (no_asm)]: | 
| 321 | "\<lbrakk> \<forall>i<length Ts. (if com(Ts!i) = None then b \<in> post(Ts!i) | |
| 322 | else b \<in> pre(the(com(Ts!i))) \<and> \<turnstile> the(com(Ts!i)) post(Ts!i)); | |
| 323 | com(Ts ! i) = Some(AnnSeq c0 c1); i<length Ts; interfree Ts \<rbrakk> \<Longrightarrow> | |
| 324 | (\<forall>ia<length Ts. (if com(Ts[i:=(Some c0, pre c1)]! ia) = None | |
| 325 | then b \<in> post(Ts[i:=(Some c0, pre c1)]! ia) | |
| 326 | else b \<in> pre(the(com(Ts[i:=(Some c0, pre c1)]! ia))) \<and> | |
| 327 | \<turnstile> the(com(Ts[i:=(Some c0, pre c1)]! ia)) post(Ts[i:=(Some c0, pre c1)]! ia))) | |
| 13020 | 328 | \<and> interfree (Ts[i:= (Some c0, pre c1)])" | 
| 329 | apply(rule conjI) | |
| 330 | apply safe | |
| 331 | apply(case_tac "i=ia") | |
| 332 | apply simp | |
| 333 | apply(force dest: ann_hoare_case_analysis) | |
| 334 | apply simp | |
| 335 | apply(fast elim: Parallel_Strong_Soundness_Seq_aux) | |
| 336 | done | |
| 337 | ||
| 59189 | 338 | lemma Parallel_Strong_Soundness_aux_aux [rule_format]: | 
| 339 | "(Some c, b) -1\<rightarrow> (co, t) \<longrightarrow> | |
| 340 | (\<forall>Ts. i<length Ts \<longrightarrow> com(Ts ! i) = Some c \<longrightarrow> | |
| 341 | (\<forall>i<length Ts. (if com(Ts ! i) = None then b\<in>post(Ts!i) | |
| 342 | else b\<in>pre(the(com(Ts!i))) \<and> \<turnstile> the(com(Ts!i)) post(Ts!i))) \<longrightarrow> | |
| 343 | interfree Ts \<longrightarrow> | |
| 344 | (\<forall>j. j<length Ts \<and> i\<noteq>j \<longrightarrow> (if com(Ts!j) = None then t\<in>post(Ts!j) | |
| 13020 | 345 | else t\<in>pre(the(com(Ts!j))) \<and> \<turnstile> the(com(Ts!j)) post(Ts!j))) )" | 
| 346 | apply(rule ann_transition_transition.induct [THEN conjunct1]) | |
| 347 | apply safe | |
| 348 | prefer 11 | |
| 349 | apply(rule TrueI) | |
| 350 | apply simp_all | |
| 59189 | 351 | --\<open>Basic\<close> | 
| 13020 | 352 | apply(erule_tac x = "i" in all_dupE, erule (1) notE impE) | 
| 353 | apply(erule_tac x = "j" in allE , erule (1) notE impE) | |
| 354 | apply(simp add: interfree_def) | |
| 355 | apply(erule_tac x = "j" in allE,simp) | |
| 356 | apply(erule_tac x = "i" in allE,simp) | |
| 357 | apply(drule_tac t = "i" in not_sym) | |
| 358 | apply(case_tac "com(Ts ! j)=None") | |
| 359 | apply(force intro: converse_rtrancl_into_rtrancl | |
| 360 | simp add: interfree_aux_def com_validity_def SEM_def sem_def All_None_def) | |
| 361 | apply(simp add:interfree_aux_def) | |
| 362 | apply clarify | |
| 363 | apply simp | |
| 364 | apply(erule_tac x="pre y" in ballE) | |
| 59189 | 365 | apply(force intro: converse_rtrancl_into_rtrancl | 
| 13020 | 366 | simp add: com_validity_def SEM_def sem_def All_None_def) | 
| 367 | apply(simp add:assertions_lemma) | |
| 59189 | 368 | --\<open>Seqs\<close> | 
| 13020 | 369 | apply(erule_tac x = "Ts[i:=(Some c0, pre c1)]" in allE) | 
| 370 | apply(drule Parallel_Strong_Soundness_Seq,simp+) | |
| 371 | apply(erule_tac x = "Ts[i:=(Some c0, pre c1)]" in allE) | |
| 372 | apply(drule Parallel_Strong_Soundness_Seq,simp+) | |
| 59189 | 373 | --\<open>Await\<close> | 
| 13020 | 374 | apply(rule_tac x = "i" in allE , assumption , erule (1) notE impE) | 
| 375 | apply(erule_tac x = "j" in allE , erule (1) notE impE) | |
| 376 | apply(simp add: interfree_def) | |
| 377 | apply(erule_tac x = "j" in allE,simp) | |
| 378 | apply(erule_tac x = "i" in allE,simp) | |
| 379 | apply(drule_tac t = "i" in not_sym) | |
| 380 | apply(case_tac "com(Ts ! j)=None") | |
| 59189 | 381 | apply(force intro: converse_rtrancl_into_rtrancl simp add: interfree_aux_def | 
| 13020 | 382 | com_validity_def SEM_def sem_def All_None_def Help) | 
| 383 | apply(simp add:interfree_aux_def) | |
| 384 | apply clarify | |
| 385 | apply simp | |
| 386 | apply(erule_tac x="pre y" in ballE) | |
| 59189 | 387 | apply(force intro: converse_rtrancl_into_rtrancl | 
| 13020 | 388 | simp add: com_validity_def SEM_def sem_def All_None_def Help) | 
| 389 | apply(simp add:assertions_lemma) | |
| 390 | done | |
| 391 | ||
| 59189 | 392 | lemma Parallel_Strong_Soundness_aux [rule_format]: | 
| 13020 | 393 | "\<lbrakk>(Ts',s) -P*\<rightarrow> (Rs',t); Ts' = (Parallel Ts); interfree Ts; | 
| 59189 | 394 | \<forall>i. i<length Ts \<longrightarrow> (\<exists>c q. (Ts ! i) = (Some c, q) \<and> s\<in>(pre c) \<and> \<turnstile> c q ) \<rbrakk> \<Longrightarrow> | 
| 395 | \<forall>Rs. Rs' = (Parallel Rs) \<longrightarrow> (\<forall>j. j<length Rs \<longrightarrow> | |
| 396 | (if com(Rs ! j) = None then t\<in>post(Ts ! j) | |
| 13020 | 397 | else t\<in>pre(the(com(Rs ! j))) \<and> \<turnstile> the(com(Rs ! j)) post(Ts ! j))) \<and> interfree Rs" | 
| 398 | apply(erule rtrancl_induct2) | |
| 399 | apply clarify | |
| 59189 | 400 | --\<open>Base\<close> | 
| 13020 | 401 | apply force | 
| 59189 | 402 | --\<open>Induction step\<close> | 
| 13020 | 403 | apply clarify | 
| 404 | apply(drule Parallel_length_post_PStar) | |
| 405 | apply clarify | |
| 23746 | 406 | apply (ind_cases "(Parallel Ts, s) -P1\<rightarrow> (Parallel Rs, t)" for Ts s Rs t) | 
| 13020 | 407 | apply(rule conjI) | 
| 408 | apply clarify | |
| 409 | apply(case_tac "i=j") | |
| 410 | apply(simp split del:split_if) | |
| 411 | apply(erule Strong_Soundness_aux_aux,simp+) | |
| 412 | apply force | |
| 413 | apply force | |
| 414 | apply(simp split del: split_if) | |
| 415 | apply(erule Parallel_Strong_Soundness_aux_aux) | |
| 416 | apply(simp_all add: split del:split_if) | |
| 417 | apply force | |
| 418 | apply(rule interfree_lemma) | |
| 419 | apply simp_all | |
| 420 | done | |
| 421 | ||
| 59189 | 422 | lemma Parallel_Strong_Soundness: | 
| 423 | "\<lbrakk>(Parallel Ts, s) -P*\<rightarrow> (Parallel Rs, t); interfree Ts; j<length Rs; | |
| 424 | \<forall>i. i<length Ts \<longrightarrow> (\<exists>c q. Ts ! i = (Some c, q) \<and> s\<in>pre c \<and> \<turnstile> c q) \<rbrakk> \<Longrightarrow> | |
| 13020 | 425 | if com(Rs ! j) = None then t\<in>post(Ts ! j) else t\<in>pre (the(com(Rs ! j)))" | 
| 426 | apply(drule Parallel_Strong_Soundness_aux) | |
| 427 | apply simp+ | |
| 428 | done | |
| 429 | ||
| 15102 | 430 | lemma oghoare_sound [rule_format]: "\<parallel>- p c q \<longrightarrow> \<parallel>= p c q" | 
| 13020 | 431 | apply (unfold com_validity_def) | 
| 432 | apply(rule oghoare_induct) | |
| 433 | apply(rule TrueI)+ | |
| 59189 | 434 | --\<open>Parallel\<close> | 
| 13020 | 435 | apply(simp add: SEM_def sem_def) | 
| 44535 
5e681762d538
use rename_tac to make proof script more robust (with separate set type, 'clarify' yields different variable names)
 huffman parents: 
39246diff
changeset | 436 | apply(clarify, rename_tac x y i Ts') | 
| 13020 | 437 | apply(frule Parallel_length_post_PStar) | 
| 438 | apply clarify | |
| 44535 
5e681762d538
use rename_tac to make proof script more robust (with separate set type, 'clarify' yields different variable names)
 huffman parents: 
39246diff
changeset | 439 | apply(drule_tac j=i in Parallel_Strong_Soundness) | 
| 13020 | 440 | apply clarify | 
| 441 | apply simp | |
| 442 | apply force | |
| 443 | apply simp | |
| 444 | apply(erule_tac V = "\<forall>i. ?P i" in thin_rl) | |
| 445 | apply(drule_tac s = "length Rs" in sym) | |
| 446 | apply(erule allE, erule impE, assumption) | |
| 447 | apply(force dest: nth_mem simp add: All_None_def) | |
| 59189 | 448 | --\<open>Basic\<close> | 
| 13020 | 449 | apply(simp add: SEM_def sem_def) | 
| 46362 | 450 | apply(force dest: rtrancl_imp_UN_relpow Basic_ntran) | 
| 59189 | 451 | --\<open>Seq\<close> | 
| 13020 | 452 | apply(rule subset_trans) | 
| 453 | prefer 2 apply assumption | |
| 454 | apply(simp add: L3_5ii L3_5i) | |
| 59189 | 455 | --\<open>Cond\<close> | 
| 13020 | 456 | apply(simp add: L3_5iv) | 
| 59189 | 457 | --\<open>While\<close> | 
| 13020 | 458 | apply(simp add: L3_5v) | 
| 59189 | 459 | apply (blast dest: SEM_fwhile) | 
| 460 | --\<open>Conseq\<close> | |
| 15102 | 461 | apply(auto simp add: SEM_def sem_def) | 
| 13020 | 462 | done | 
| 463 | ||
| 39246 | 464 | end |