| author | wenzelm | 
| Mon, 04 Dec 2023 12:10:39 +0100 | |
| changeset 79120 | 45b2171e9e03 | 
| parent 69597 | ff784d5a5bfb | 
| child 80914 | d97fdabd9e2b | 
| permissions | -rw-r--r-- | 
| 11376 | 1 | (* Title: HOL/NanoJava/Equivalence.thy | 
| 2 | Author: David von Oheimb | |
| 3 | Copyright 2001 Technische Universitaet Muenchen | |
| 4 | *) | |
| 5 | ||
| 58889 | 6 | section "Equivalence of Operational and Axiomatic Semantics" | 
| 11376 | 7 | |
| 16417 | 8 | theory Equivalence imports OpSem AxSem begin | 
| 11376 | 9 | |
| 10 | subsection "Validity" | |
| 11 | ||
| 61990 | 12 | definition valid :: "[assn,stmt, assn] => bool" ("\<Turnstile> {(1_)}/ (_)/ {(1_)}" [3,90,3] 60) where
 | 
| 13 |  "\<Turnstile>  {P} c {Q} \<equiv> \<forall>s   t. P s --> (\<exists>n. s -c  -n\<rightarrow> t) --> Q   t"
 | |
| 11476 | 14 | |
| 61990 | 15 | definition evalid   :: "[assn,expr,vassn] => bool" ("\<Turnstile>\<^sub>e {(1_)}/ (_)/ {(1_)}" [3,90,3] 60) where
 | 
| 16 |  "\<Turnstile>\<^sub>e {P} e {Q} \<equiv> \<forall>s v t. P s --> (\<exists>n. s -e\<succ>v-n\<rightarrow> t) --> Q v t"
 | |
| 11376 | 17 | |
| 61990 | 18 | definition nvalid   :: "[nat, triple    ] => bool" ("\<Turnstile>_: _" [61,61] 60) where
 | 
| 19 | "\<Turnstile>n: t \<equiv> let (P,c,Q) = t in \<forall>s t. s -c -n\<rightarrow> t --> P s --> Q t" | |
| 11376 | 20 | |
| 61990 | 21 | definition envalid   :: "[nat,etriple    ] => bool" ("\<Turnstile>_:\<^sub>e _" [61,61] 60) where
 | 
| 22 | "\<Turnstile>n:\<^sub>e t \<equiv> let (P,e,Q) = t in \<forall>s v t. s -e\<succ>v-n\<rightarrow> t --> P s --> Q v t" | |
| 11476 | 23 | |
| 61990 | 24 | definition nvalids :: "[nat,       triple set] => bool" ("|\<Turnstile>_: _" [61,61] 60) where
 | 
| 25 | "|\<Turnstile>n: T \<equiv> \<forall>t\<in>T. \<Turnstile>n: t" | |
| 11376 | 26 | |
| 61990 | 27 | definition cnvalids :: "[triple set,triple set] => bool" ("_ |\<Turnstile>/ _" [61,61] 60) where
 | 
| 28 | "A |\<Turnstile> C \<equiv> \<forall>n. |\<Turnstile>n: A --> |\<Turnstile>n: C" | |
| 11376 | 29 | |
| 61990 | 30 | definition cenvalid  :: "[triple set,etriple   ] => bool" ("_ |\<Turnstile>\<^sub>e/ _"[61,61] 60) where
 | 
| 31 | "A |\<Turnstile>\<^sub>e t \<equiv> \<forall>n. |\<Turnstile>n: A --> \<Turnstile>n:\<^sub>e t" | |
| 11376 | 32 | |
| 11476 | 33 | lemma nvalid_def2: "\<Turnstile>n: (P,c,Q) \<equiv> \<forall>s t. s -c-n\<rightarrow> t \<longrightarrow> P s \<longrightarrow> Q t" | 
| 11376 | 34 | by (simp add: nvalid_def Let_def) | 
| 35 | ||
| 11476 | 36 | lemma valid_def2: "\<Turnstile> {P} c {Q} = (\<forall>n. \<Turnstile>n: (P,c,Q))"
 | 
| 37 | apply (simp add: valid_def nvalid_def2) | |
| 11376 | 38 | apply blast | 
| 39 | done | |
| 40 | ||
| 11486 | 41 | lemma envalid_def2: "\<Turnstile>n:\<^sub>e (P,e,Q) \<equiv> \<forall>s v t. s -e\<succ>v-n\<rightarrow> t \<longrightarrow> P s \<longrightarrow> Q v t" | 
| 11476 | 42 | by (simp add: envalid_def Let_def) | 
| 43 | ||
| 11486 | 44 | lemma evalid_def2: "\<Turnstile>\<^sub>e {P} e {Q} = (\<forall>n. \<Turnstile>n:\<^sub>e (P,e,Q))"
 | 
| 11476 | 45 | apply (simp add: evalid_def envalid_def2) | 
| 46 | apply blast | |
| 47 | done | |
| 48 | ||
| 49 | lemma cenvalid_def2: | |
| 11486 | 50 | "A|\<Turnstile>\<^sub>e (P,e,Q) = (\<forall>n. |\<Turnstile>n: A \<longrightarrow> (\<forall>s v t. s -e\<succ>v-n\<rightarrow> t \<longrightarrow> P s \<longrightarrow> Q v t))" | 
| 11476 | 51 | by(simp add: cenvalid_def envalid_def2) | 
| 52 | ||
| 11376 | 53 | |
| 54 | subsection "Soundness" | |
| 55 | ||
| 11476 | 56 | declare exec_elim_cases [elim!] eval_elim_cases [elim!] | 
| 11376 | 57 | |
| 11497 
0e66e0114d9a
corrected initialization of locals, streamlined Impl
 oheimb parents: 
11486diff
changeset | 58 | lemma Impl_nvalid_0: "\<Turnstile>0: (P,Impl M,Q)" | 
| 11476 | 59 | by (clarsimp simp add: nvalid_def2) | 
| 11376 | 60 | |
| 11497 
0e66e0114d9a
corrected initialization of locals, streamlined Impl
 oheimb parents: 
11486diff
changeset | 61 | lemma Impl_nvalid_Suc: "\<Turnstile>n: (P,body M,Q) \<Longrightarrow> \<Turnstile>Suc n: (P,Impl M,Q)" | 
| 11476 | 62 | by (clarsimp simp add: nvalid_def2) | 
| 11376 | 63 | |
| 64 | lemma nvalid_SucD: "\<And>t. \<Turnstile>Suc n:t \<Longrightarrow> \<Turnstile>n:t" | |
| 11476 | 65 | by (force simp add: split_paired_all nvalid_def2 intro: exec_mono) | 
| 11376 | 66 | |
| 67 | lemma nvalids_SucD: "Ball A (nvalid (Suc n)) \<Longrightarrow> Ball A (nvalid n)" | |
| 68 | by (fast intro: nvalid_SucD) | |
| 69 | ||
| 70 | lemma Loop_sound_lemma [rule_format (no_asm)]: | |
| 11476 | 71 | "\<forall>s t. s -c-n\<rightarrow> t \<longrightarrow> P s \<and> s<x> \<noteq> Null \<longrightarrow> P t \<Longrightarrow> | 
| 72 | (s -c0-n0\<rightarrow> t \<longrightarrow> P s \<longrightarrow> c0 = While (x) c \<longrightarrow> n0 = n \<longrightarrow> P t \<and> t<x> = Null)" | |
| 14174 
f3cafd2929d5
Methods rule_tac etc support static (Isar) contexts.
 ballarin parents: 
12934diff
changeset | 73 | apply (rule_tac ?P2.1="%s e v n t. True" in exec_eval.induct [THEN conjunct1]) | 
| 11376 | 74 | apply clarsimp+ | 
| 75 | done | |
| 76 | ||
| 77 | lemma Impl_sound_lemma: | |
| 11497 
0e66e0114d9a
corrected initialization of locals, streamlined Impl
 oheimb parents: 
11486diff
changeset | 78 | "\<lbrakk>\<forall>z n. Ball (A \<union> B) (nvalid n) \<longrightarrow> Ball (f z ` Ms) (nvalid n); | 
| 12742 | 79 | Cm\<in>Ms; Ball A (nvalid na); Ball B (nvalid na)\<rbrakk> \<Longrightarrow> nvalid na (f z Cm)" | 
| 11376 | 80 | by blast | 
| 81 | ||
| 11476 | 82 | lemma all_conjunct2: "\<forall>l. P' l \<and> P l \<Longrightarrow> \<forall>l. P l" | 
| 83 | by fast | |
| 84 | ||
| 85 | lemma all3_conjunct2: | |
| 86 | "\<forall>a p l. (P' a p l \<and> P a p l) \<Longrightarrow> \<forall>a p l. P a p l" | |
| 87 | by fast | |
| 88 | ||
| 89 | lemma cnvalid1_eq: | |
| 90 |   "A |\<Turnstile> {(P,c,Q)} \<equiv> \<forall>n. |\<Turnstile>n: A \<longrightarrow> (\<forall>s t. s -c-n\<rightarrow> t \<longrightarrow> P s \<longrightarrow> Q t)"
 | |
| 91 | by(simp add: cnvalids_def nvalids_def nvalid_def2) | |
| 92 | ||
| 11486 | 93 | lemma hoare_sound_main:"\<And>t. (A |\<turnstile> C \<longrightarrow> A |\<Turnstile> C) \<and> (A |\<turnstile>\<^sub>e t \<longrightarrow> A |\<Turnstile>\<^sub>e t)" | 
| 69597 | 94 | apply (tactic "split_all_tac \<^context> 1", rename_tac P e Q) | 
| 11476 | 95 | apply (rule hoare_ehoare.induct) | 
| 12524 
66eb843b1d35
mods due to mor powerful simprocs for 1-point rules (quantifier1).
 nipkow parents: 
11565diff
changeset | 96 | (*18*) | 
| 69597 | 97 | apply (tactic \<open>ALLGOALS (REPEAT o dresolve_tac \<^context> [@{thm all_conjunct2}, @{thm all3_conjunct2}])\<close>)
 | 
| 98 | apply (tactic \<open>ALLGOALS (REPEAT o Rule_Insts.thin_tac \<^context> "hoare _ _" [])\<close>) | |
| 99 | apply (tactic \<open>ALLGOALS (REPEAT o Rule_Insts.thin_tac \<^context> "ehoare _ _" [])\<close>) | |
| 11476 | 100 | apply (simp_all only: cnvalid1_eq cenvalid_def2) | 
| 12524 
66eb843b1d35
mods due to mor powerful simprocs for 1-point rules (quantifier1).
 nipkow parents: 
11565diff
changeset | 101 | apply fast | 
| 
66eb843b1d35
mods due to mor powerful simprocs for 1-point rules (quantifier1).
 nipkow parents: 
11565diff
changeset | 102 | apply fast | 
| 
66eb843b1d35
mods due to mor powerful simprocs for 1-point rules (quantifier1).
 nipkow parents: 
11565diff
changeset | 103 | apply fast | 
| 69597 | 104 | apply (clarify,tactic "smp_tac \<^context> 1 1",erule(2) Loop_sound_lemma,(rule HOL.refl)+) | 
| 12524 
66eb843b1d35
mods due to mor powerful simprocs for 1-point rules (quantifier1).
 nipkow parents: 
11565diff
changeset | 105 | apply fast | 
| 
66eb843b1d35
mods due to mor powerful simprocs for 1-point rules (quantifier1).
 nipkow parents: 
11565diff
changeset | 106 | apply fast | 
| 
66eb843b1d35
mods due to mor powerful simprocs for 1-point rules (quantifier1).
 nipkow parents: 
11565diff
changeset | 107 | apply fast | 
| 
66eb843b1d35
mods due to mor powerful simprocs for 1-point rules (quantifier1).
 nipkow parents: 
11565diff
changeset | 108 | apply fast | 
| 
66eb843b1d35
mods due to mor powerful simprocs for 1-point rules (quantifier1).
 nipkow parents: 
11565diff
changeset | 109 | apply fast | 
| 
66eb843b1d35
mods due to mor powerful simprocs for 1-point rules (quantifier1).
 nipkow parents: 
11565diff
changeset | 110 | apply fast | 
| 
66eb843b1d35
mods due to mor powerful simprocs for 1-point rules (quantifier1).
 nipkow parents: 
11565diff
changeset | 111 | apply (clarsimp del: Meth_elim_cases) (* Call *) | 
| 
66eb843b1d35
mods due to mor powerful simprocs for 1-point rules (quantifier1).
 nipkow parents: 
11565diff
changeset | 112 | apply (force del: Impl_elim_cases) | 
| 
66eb843b1d35
mods due to mor powerful simprocs for 1-point rules (quantifier1).
 nipkow parents: 
11565diff
changeset | 113 | defer | 
| 
66eb843b1d35
mods due to mor powerful simprocs for 1-point rules (quantifier1).
 nipkow parents: 
11565diff
changeset | 114 | prefer 4 apply blast (* Conseq *) | 
| 
66eb843b1d35
mods due to mor powerful simprocs for 1-point rules (quantifier1).
 nipkow parents: 
11565diff
changeset | 115 | prefer 4 apply blast (* eConseq *) | 
| 
66eb843b1d35
mods due to mor powerful simprocs for 1-point rules (quantifier1).
 nipkow parents: 
11565diff
changeset | 116 | apply (simp_all (no_asm_use) only: cnvalids_def nvalids_def) | 
| 
66eb843b1d35
mods due to mor powerful simprocs for 1-point rules (quantifier1).
 nipkow parents: 
11565diff
changeset | 117 | apply blast | 
| 
66eb843b1d35
mods due to mor powerful simprocs for 1-point rules (quantifier1).
 nipkow parents: 
11565diff
changeset | 118 | apply blast | 
| 
66eb843b1d35
mods due to mor powerful simprocs for 1-point rules (quantifier1).
 nipkow parents: 
11565diff
changeset | 119 | apply blast | 
| 11376 | 120 | apply (rule allI) | 
| 11565 | 121 | apply (rule_tac x=Z in spec) | 
| 11376 | 122 | apply (induct_tac "n") | 
| 12524 
66eb843b1d35
mods due to mor powerful simprocs for 1-point rules (quantifier1).
 nipkow parents: 
11565diff
changeset | 123 | apply (clarify intro!: Impl_nvalid_0) | 
| 11376 | 124 | apply (clarify intro!: Impl_nvalid_Suc) | 
| 125 | apply (drule nvalids_SucD) | |
| 37604 | 126 | apply (simp only: HOL.all_simps) | 
| 11376 | 127 | apply (erule (1) impE) | 
| 11497 
0e66e0114d9a
corrected initialization of locals, streamlined Impl
 oheimb parents: 
11486diff
changeset | 128 | apply (drule (2) Impl_sound_lemma) | 
| 12524 
66eb843b1d35
mods due to mor powerful simprocs for 1-point rules (quantifier1).
 nipkow parents: 
11565diff
changeset | 129 | apply blast | 
| 11497 
0e66e0114d9a
corrected initialization of locals, streamlined Impl
 oheimb parents: 
11486diff
changeset | 130 | apply assumption | 
| 11376 | 131 | done | 
| 132 | ||
| 133 | theorem hoare_sound: "{} \<turnstile> {P} c {Q} \<Longrightarrow> \<Turnstile> {P} c {Q}"
 | |
| 134 | apply (simp only: valid_def2) | |
| 11476 | 135 | apply (drule hoare_sound_main [THEN conjunct1, rule_format]) | 
| 11376 | 136 | apply (unfold cnvalids_def nvalids_def) | 
| 137 | apply fast | |
| 138 | done | |
| 139 | ||
| 11486 | 140 | theorem ehoare_sound: "{} \<turnstile>\<^sub>e {P} e {Q} \<Longrightarrow> \<Turnstile>\<^sub>e {P} e {Q}"
 | 
| 11476 | 141 | apply (simp only: evalid_def2) | 
| 142 | apply (drule hoare_sound_main [THEN conjunct2, rule_format]) | |
| 143 | apply (unfold cenvalid_def nvalids_def) | |
| 144 | apply fast | |
| 145 | done | |
| 146 | ||
| 11376 | 147 | |
| 148 | subsection "(Relative) Completeness" | |
| 149 | ||
| 35416 
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
 haftmann parents: 
27239diff
changeset | 150 | definition MGT :: "stmt => state => triple" where | 
| 23755 | 151 | "MGT c Z \<equiv> (\<lambda>s. Z = s, c, \<lambda> t. \<exists>n. Z -c- n\<rightarrow> t)" | 
| 35416 
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
 haftmann parents: 
27239diff
changeset | 152 | |
| 61990 | 153 | definition MGT\<^sub>e :: "expr => state => etriple" where | 
| 154 | "MGT\<^sub>e e Z \<equiv> (\<lambda>s. Z = s, e, \<lambda>v t. \<exists>n. Z -e\<succ>v-n\<rightarrow> t)" | |
| 11376 | 155 | |
| 156 | lemma MGF_implies_complete: | |
| 11565 | 157 |  "\<forall>Z. {} |\<turnstile> { MGT c Z} \<Longrightarrow> \<Turnstile>  {P} c {Q} \<Longrightarrow> {} \<turnstile>  {P} c {Q}"
 | 
| 11376 | 158 | apply (simp only: valid_def2) | 
| 159 | apply (unfold MGT_def) | |
| 11476 | 160 | apply (erule hoare_ehoare.Conseq) | 
| 161 | apply (clarsimp simp add: nvalid_def2) | |
| 11376 | 162 | done | 
| 163 | ||
| 11476 | 164 | lemma eMGF_implies_complete: | 
| 11565 | 165 |  "\<forall>Z. {} |\<turnstile>\<^sub>e MGT\<^sub>e e Z \<Longrightarrow> \<Turnstile>\<^sub>e {P} e {Q} \<Longrightarrow> {} \<turnstile>\<^sub>e {P} e {Q}"
 | 
| 11476 | 166 | apply (simp only: evalid_def2) | 
| 61990 | 167 | apply (unfold MGT\<^sub>e_def) | 
| 11476 | 168 | apply (erule hoare_ehoare.eConseq) | 
| 169 | apply (clarsimp simp add: envalid_def2) | |
| 170 | done | |
| 11376 | 171 | |
| 11476 | 172 | declare exec_eval.intros[intro!] | 
| 11376 | 173 | |
| 67399 | 174 | lemma MGF_Loop: "\<forall>Z. A \<turnstile> {(=) Z} c {\<lambda>t. \<exists>n. Z -c-n\<rightarrow> t} \<Longrightarrow> 
 | 
| 175 |   A \<turnstile> {(=) Z} While (x) c {\<lambda>t. \<exists>n. Z -While (x) c-n\<rightarrow> t}"
 | |
| 67613 | 176 | apply (rule_tac P' = "\<lambda>Z s. (Z,s) \<in> ({(s,t). \<exists>n. s<x> \<noteq> Null \<and> s -c-n\<rightarrow> t})\<^sup>*"
 | 
| 11476 | 177 | in hoare_ehoare.Conseq) | 
| 11376 | 178 | apply (rule allI) | 
| 11476 | 179 | apply (rule hoare_ehoare.Loop) | 
| 180 | apply (erule hoare_ehoare.Conseq) | |
| 11376 | 181 | apply clarsimp | 
| 182 | apply (blast intro:rtrancl_into_rtrancl) | |
| 183 | apply (erule thin_rl) | |
| 184 | apply clarsimp | |
| 11565 | 185 | apply (erule_tac x = Z in allE) | 
| 11376 | 186 | apply clarsimp | 
| 187 | apply (erule converse_rtrancl_induct) | |
| 188 | apply blast | |
| 189 | apply clarsimp | |
| 11476 | 190 | apply (drule (1) exec_exec_max) | 
| 11376 | 191 | apply (blast del: exec_elim_cases) | 
| 192 | done | |
| 193 | ||
| 11565 | 194 | lemma MGF_lemma: "\<forall>M Z. A |\<turnstile> {MGT (Impl M) Z} \<Longrightarrow> 
 | 
| 195 |  (\<forall>Z. A |\<turnstile> {MGT c Z}) \<and> (\<forall>Z. A |\<turnstile>\<^sub>e MGT\<^sub>e e Z)"
 | |
| 61990 | 196 | apply (simp add: MGT_def MGT\<^sub>e_def) | 
| 11476 | 197 | apply (rule stmt_expr.induct) | 
| 198 | apply (rule_tac [!] allI) | |
| 11376 | 199 | |
| 11476 | 200 | apply (rule Conseq1 [OF hoare_ehoare.Skip]) | 
| 11376 | 201 | apply blast | 
| 202 | ||
| 11476 | 203 | apply (rule hoare_ehoare.Comp) | 
| 11376 | 204 | apply (erule spec) | 
| 11476 | 205 | apply (erule hoare_ehoare.Conseq) | 
| 11376 | 206 | apply clarsimp | 
| 11476 | 207 | apply (drule (1) exec_exec_max) | 
| 11376 | 208 | apply blast | 
| 209 | ||
| 11476 | 210 | apply (erule thin_rl) | 
| 211 | apply (rule hoare_ehoare.Cond) | |
| 212 | apply (erule spec) | |
| 213 | apply (rule allI) | |
| 214 | apply (simp) | |
| 215 | apply (rule conjI) | |
| 216 | apply (rule impI, erule hoare_ehoare.Conseq, clarsimp, drule (1) eval_exec_max, | |
| 217 | erule thin_rl, erule thin_rl, force)+ | |
| 11376 | 218 | |
| 219 | apply (erule MGF_Loop) | |
| 220 | ||
| 11476 | 221 | apply (erule hoare_ehoare.eConseq [THEN hoare_ehoare.LAss]) | 
| 222 | apply fast | |
| 11376 | 223 | |
| 11476 | 224 | apply (erule thin_rl) | 
| 58262 | 225 | apply (rename_tac expr1 u v Z, rule_tac Q = "\<lambda>a s. \<exists>n. Z -expr1\<succ>Addr a-n\<rightarrow> s" in hoare_ehoare.FAss) | 
| 11476 | 226 | apply (drule spec) | 
| 227 | apply (erule eConseq2) | |
| 228 | apply fast | |
| 229 | apply (rule allI) | |
| 230 | apply (erule hoare_ehoare.eConseq) | |
| 231 | apply clarsimp | |
| 232 | apply (drule (1) eval_eval_max) | |
| 11376 | 233 | apply blast | 
| 234 | ||
| 11507 | 235 | apply (simp only: split_paired_all) | 
| 11476 | 236 | apply (rule hoare_ehoare.Meth) | 
| 11376 | 237 | apply (rule allI) | 
| 11476 | 238 | apply (drule spec, drule spec, erule hoare_ehoare.Conseq) | 
| 11376 | 239 | apply blast | 
| 240 | ||
| 11497 
0e66e0114d9a
corrected initialization of locals, streamlined Impl
 oheimb parents: 
11486diff
changeset | 241 | apply (simp add: split_paired_all) | 
| 11476 | 242 | |
| 243 | apply (rule eConseq1 [OF hoare_ehoare.NewC]) | |
| 244 | apply blast | |
| 245 | ||
| 246 | apply (erule hoare_ehoare.eConseq [THEN hoare_ehoare.Cast]) | |
| 247 | apply fast | |
| 248 | ||
| 249 | apply (rule eConseq1 [OF hoare_ehoare.LAcc]) | |
| 250 | apply blast | |
| 251 | ||
| 252 | apply (erule hoare_ehoare.eConseq [THEN hoare_ehoare.FAcc]) | |
| 253 | apply fast | |
| 254 | ||
| 58262 | 255 | apply (rename_tac expr1 u expr2 Z) | 
| 11565 | 256 | apply (rule_tac R = "\<lambda>a v s. \<exists>n1 n2 t. Z -expr1\<succ>a-n1\<rightarrow> t \<and> t -expr2\<succ>v-n2\<rightarrow> s" in | 
| 11476 | 257 | hoare_ehoare.Call) | 
| 258 | apply (erule spec) | |
| 259 | apply (rule allI) | |
| 260 | apply (erule hoare_ehoare.eConseq) | |
| 261 | apply clarsimp | |
| 262 | apply blast | |
| 263 | apply (rule allI)+ | |
| 264 | apply (rule hoare_ehoare.Meth) | |
| 265 | apply (rule allI) | |
| 266 | apply (drule spec, drule spec, erule hoare_ehoare.Conseq) | |
| 267 | apply (erule thin_rl, erule thin_rl) | |
| 268 | apply (clarsimp del: Impl_elim_cases) | |
| 269 | apply (drule (2) eval_eval_exec_max) | |
| 11565 | 270 | apply (force del: Impl_elim_cases) | 
| 11376 | 271 | done | 
| 272 | ||
| 11565 | 273 | lemma MGF_Impl: "{} |\<turnstile> {MGT (Impl M) Z}"
 | 
| 11376 | 274 | apply (unfold MGT_def) | 
| 12934 
6003b4f916c0
Clarification wrt. use of polymorphic variants of Hoare logic rules
 oheimb parents: 
12742diff
changeset | 275 | apply (rule Impl1') | 
| 11376 | 276 | apply (rule_tac [2] UNIV_I) | 
| 277 | apply clarsimp | |
| 11476 | 278 | apply (rule hoare_ehoare.ConjI) | 
| 11376 | 279 | apply clarsimp | 
| 280 | apply (rule ssubst [OF Impl_body_eq]) | |
| 281 | apply (fold MGT_def) | |
| 11476 | 282 | apply (rule MGF_lemma [THEN conjunct1, rule_format]) | 
| 283 | apply (rule hoare_ehoare.Asm) | |
| 11376 | 284 | apply force | 
| 285 | done | |
| 286 | ||
| 287 | theorem hoare_relative_complete: "\<Turnstile> {P} c {Q} \<Longrightarrow> {} \<turnstile> {P} c {Q}"
 | |
| 288 | apply (rule MGF_implies_complete) | |
| 289 | apply (erule_tac [2] asm_rl) | |
| 290 | apply (rule allI) | |
| 11476 | 291 | apply (rule MGF_lemma [THEN conjunct1, rule_format]) | 
| 292 | apply (rule MGF_Impl) | |
| 293 | done | |
| 294 | ||
| 11486 | 295 | theorem ehoare_relative_complete: "\<Turnstile>\<^sub>e {P} e {Q} \<Longrightarrow> {} \<turnstile>\<^sub>e {P} e {Q}"
 | 
| 11476 | 296 | apply (rule eMGF_implies_complete) | 
| 297 | apply (erule_tac [2] asm_rl) | |
| 298 | apply (rule allI) | |
| 299 | apply (rule MGF_lemma [THEN conjunct2, rule_format]) | |
| 11376 | 300 | apply (rule MGF_Impl) | 
| 301 | done | |
| 302 | ||
| 11565 | 303 | lemma cFalse: "A \<turnstile> {\<lambda>s. False} c {Q}"
 | 
| 304 | apply (rule cThin) | |
| 305 | apply (rule hoare_relative_complete) | |
| 306 | apply (auto simp add: valid_def) | |
| 307 | done | |
| 308 | ||
| 309 | lemma eFalse: "A \<turnstile>\<^sub>e {\<lambda>s. False} e {Q}"
 | |
| 310 | apply (rule eThin) | |
| 311 | apply (rule ehoare_relative_complete) | |
| 312 | apply (auto simp add: evalid_def) | |
| 313 | done | |
| 314 | ||
| 11376 | 315 | end |