src/HOL/IMPP/Hoare.thy
changeset 42793 88bee9f6eec7
parent 42174 d0be2722ce9f
child 45605 a89b4bc311a5
equal deleted inserted replaced
42792:85fb70b0c5e8 42793:88bee9f6eec7
   207 by (etac hoare_derivs.asm 1);
   207 by (etac hoare_derivs.asm 1);
   208 qed "thin";
   208 qed "thin";
   209 *)
   209 *)
   210 lemma thin [rule_format]: "G'||-ts ==> !G. G' <= G --> G||-ts"
   210 lemma thin [rule_format]: "G'||-ts ==> !G. G' <= G --> G||-ts"
   211 apply (erule hoare_derivs.induct)
   211 apply (erule hoare_derivs.induct)
   212 apply                (tactic {* ALLGOALS (EVERY'[clarify_tac @{claset}, REPEAT o smp_tac 1]) *})
   212 apply                (tactic {* ALLGOALS (EVERY'[clarify_tac @{context}, REPEAT o smp_tac 1]) *})
   213 apply (rule hoare_derivs.empty)
   213 apply (rule hoare_derivs.empty)
   214 apply               (erule (1) hoare_derivs.insert)
   214 apply               (erule (1) hoare_derivs.insert)
   215 apply              (fast intro: hoare_derivs.asm)
   215 apply              (fast intro: hoare_derivs.asm)
   216 apply             (fast intro: hoare_derivs.cut)
   216 apply             (fast intro: hoare_derivs.cut)
   217 apply            (fast intro: hoare_derivs.weaken)
   217 apply            (fast intro: hoare_derivs.weaken)
   218 apply           (rule hoare_derivs.conseq, intro strip, tactic "smp_tac 2 1", clarify, tactic "smp_tac 1 1",rule exI, rule exI, erule (1) conjI)
   218 apply           (rule hoare_derivs.conseq, intro strip, tactic "smp_tac 2 1", clarify, tactic "smp_tac 1 1",rule exI, rule exI, erule (1) conjI)
   219 prefer 7
   219 prefer 7
   220 apply          (rule_tac hoare_derivs.Body, drule_tac spec, erule_tac mp, fast)
   220 apply          (rule_tac hoare_derivs.Body, drule_tac spec, erule_tac mp, fast)
   221 apply         (tactic {* ALLGOALS (resolve_tac ((funpow 5 tl) @{thms hoare_derivs.intros}) THEN_ALL_NEW (fast_tac @{claset})) *})
   221 apply         (tactic {* ALLGOALS (resolve_tac ((funpow 5 tl) @{thms hoare_derivs.intros}) THEN_ALL_NEW (fast_tac @{context})) *})
   222 done
   222 done
   223 
   223 
   224 lemma weak_Body: "G|-{P}. the (body pn) .{Q} ==> G|-{P}. BODY pn .{Q}"
   224 lemma weak_Body: "G|-{P}. the (body pn) .{Q} ==> G|-{P}. BODY pn .{Q}"
   225 apply (rule BodyN)
   225 apply (rule BodyN)
   226 apply (erule thin)
   226 apply (erule thin)
   285 apply          (blast) (* asm *)
   285 apply          (blast) (* asm *)
   286 apply         (blast) (* cut *)
   286 apply         (blast) (* cut *)
   287 apply        (blast) (* weaken *)
   287 apply        (blast) (* weaken *)
   288 apply       (tactic {* ALLGOALS (EVERY'
   288 apply       (tactic {* ALLGOALS (EVERY'
   289   [REPEAT o thin_tac @{context} "hoare_derivs ?x ?y",
   289   [REPEAT o thin_tac @{context} "hoare_derivs ?x ?y",
   290    simp_tac @{simpset}, clarify_tac @{claset}, REPEAT o smp_tac 1]) *})
   290    simp_tac @{simpset}, clarify_tac @{context}, REPEAT o smp_tac 1]) *})
   291 apply       (simp_all (no_asm_use) add: triple_valid_def2)
   291 apply       (simp_all (no_asm_use) add: triple_valid_def2)
   292 apply       (intro strip, tactic "smp_tac 2 1", blast) (* conseq *)
   292 apply       (intro strip, tactic "smp_tac 2 1", blast) (* conseq *)
   293 apply      (tactic {* ALLGOALS (clarsimp_tac @{clasimpset}) *}) (* Skip, Ass, Local *)
   293 apply      (tactic {* ALLGOALS (clarsimp_tac @{context}) *}) (* Skip, Ass, Local *)
   294 prefer 3 apply   (force) (* Call *)
   294 prefer 3 apply   (force) (* Call *)
   295 apply  (erule_tac [2] evaln_elim_cases) (* If *)
   295 apply  (erule_tac [2] evaln_elim_cases) (* If *)
   296 apply   blast+
   296 apply   blast+
   297 done
   297 done
   298 
   298 
   333 declare not_None_eq [iff]
   333 declare not_None_eq [iff]
   334 (* requires com_det, escape (i.e. hoare_derivs.conseq) *)
   334 (* requires com_det, escape (i.e. hoare_derivs.conseq) *)
   335 lemma MGF_lemma1 [rule_format (no_asm)]: "state_not_singleton ==>  
   335 lemma MGF_lemma1 [rule_format (no_asm)]: "state_not_singleton ==>  
   336   !pn:dom body. G|-{=}.BODY pn.{->} ==> WT c --> G|-{=}.c.{->}"
   336   !pn:dom body. G|-{=}.BODY pn.{->} ==> WT c --> G|-{=}.c.{->}"
   337 apply (induct_tac c)
   337 apply (induct_tac c)
   338 apply        (tactic {* ALLGOALS (clarsimp_tac @{clasimpset}) *})
   338 apply        (tactic {* ALLGOALS (clarsimp_tac @{context}) *})
   339 prefer 7 apply        (fast intro: domI)
   339 prefer 7 apply        (fast intro: domI)
   340 apply (erule_tac [6] MGT_alternD)
   340 apply (erule_tac [6] MGT_alternD)
   341 apply       (unfold MGT_def)
   341 apply       (unfold MGT_def)
   342 apply       (drule_tac [7] bspec, erule_tac [7] domI)
   342 apply       (drule_tac [7] bspec, erule_tac [7] domI)
   343 apply       (rule_tac [7] escape, tactic {* clarsimp_tac @{clasimpset} 7 *},
   343 apply       (rule_tac [7] escape, tactic {* clarsimp_tac @{context} 7 *},
   344   rule_tac [7] P1 = "%Z' s. s= (setlocs Z newlocs) [Loc Arg ::= fun Z]" in hoare_derivs.Call [THEN conseq1], erule_tac [7] conseq12)
   344   rule_tac [7] P1 = "%Z' s. s= (setlocs Z newlocs) [Loc Arg ::= fun Z]" in hoare_derivs.Call [THEN conseq1], erule_tac [7] conseq12)
   345 apply        (erule_tac [!] thin_rl)
   345 apply        (erule_tac [!] thin_rl)
   346 apply (rule hoare_derivs.Skip [THEN conseq2])
   346 apply (rule hoare_derivs.Skip [THEN conseq2])
   347 apply (rule_tac [2] hoare_derivs.Ass [THEN conseq1])
   347 apply (rule_tac [2] hoare_derivs.Ass [THEN conseq1])
   348 apply        (rule_tac [3] escape, tactic {* clarsimp_tac @{clasimpset} 3 *},
   348 apply        (rule_tac [3] escape, tactic {* clarsimp_tac @{context} 3 *},
   349   rule_tac [3] P1 = "%Z' s. s= (Z[Loc loc::=fun Z])" in hoare_derivs.Local [THEN conseq1],
   349   rule_tac [3] P1 = "%Z' s. s= (Z[Loc loc::=fun Z])" in hoare_derivs.Local [THEN conseq1],
   350   erule_tac [3] conseq12)
   350   erule_tac [3] conseq12)
   351 apply         (erule_tac [5] hoare_derivs.Comp, erule_tac [5] conseq12)
   351 apply         (erule_tac [5] hoare_derivs.Comp, erule_tac [5] conseq12)
   352 apply         (tactic {* (rtac @{thm hoare_derivs.If} THEN_ALL_NEW etac @{thm conseq12}) 6 *})
   352 apply         (tactic {* (rtac @{thm hoare_derivs.If} THEN_ALL_NEW etac @{thm conseq12}) 6 *})
   353 apply          (rule_tac [8] hoare_derivs.Loop [THEN conseq2], erule_tac [8] conseq12)
   353 apply          (rule_tac [8] hoare_derivs.Loop [THEN conseq2], erule_tac [8] conseq12)
   362     and "!!G c. [| wt c; !pn:U. P G {mgt_call pn} |] ==> P G {mgt c}"
   362     and "!!G c. [| wt c; !pn:U. P G {mgt_call pn} |] ==> P G {mgt c}"
   363     and "!!pn. pn : U ==> wt (the (body pn))"
   363     and "!!pn. pn : U ==> wt (the (body pn))"
   364   shows "finite U ==> uG = mgt_call`U ==>  
   364   shows "finite U ==> uG = mgt_call`U ==>  
   365   !G. G <= uG --> n <= card uG --> card G = card uG - n --> (!c. wt c --> P G {mgt c})"
   365   !G. G <= uG --> n <= card uG --> card G = card uG - n --> (!c. wt c --> P G {mgt c})"
   366 apply (induct_tac n)
   366 apply (induct_tac n)
   367 apply  (tactic {* ALLGOALS (clarsimp_tac @{clasimpset}) *})
   367 apply  (tactic {* ALLGOALS (clarsimp_tac @{context}) *})
   368 apply  (subgoal_tac "G = mgt_call ` U")
   368 apply  (subgoal_tac "G = mgt_call ` U")
   369 prefer 2
   369 prefer 2
   370 apply   (simp add: card_seteq)
   370 apply   (simp add: card_seteq)
   371 apply  simp
   371 apply  simp
   372 apply  (erule assms(3-)) (*MGF_lemma1*)
   372 apply  (erule assms(3-)) (*MGF_lemma1*)