lemma SeqWhileRule: "[ Γ, Θ ⊨!!!F (i ∩ b) a c i,A; i ∩ - b ⊆ Q ] ==> Γ, Θ ⊨!!!F i (AnnWhile r i a) (While b c) Q,A" apply (rule SeqConseq[OF _ SeqWhile]) prefer2apply assumption by simp+
lemma DynComRule: "[ r ⊆ pre a; ∧s. s∈r ==> Γ, Θ ⊨F a (c s) Q,A ]==> Γ, Θ ⊨F (AnnRec r a) (DynCom c) Q,A" by (erule DynCom) clarsimp
lemma SeqDynComRule: "[r ⊆ pre a; ∧s. s∈r ==> Γ, Θ ⊨!!!FP a (c s) Q,A; P⊆r ]==> Γ, Θ ⊨!!!F P (AnnRec r a) (DynCom c) Q,A" by (erule SeqDynCom) clarsimp
lemma SeqCallRule: "[ P' ⊆ P; Γ, Θ ⊨!!!F P P'' f Q,A; n < length as; Γ p = Some f; as ! n = P''; Θ p = Some as] ==> Γ, Θ ⊨!!!F P' (AnnCall r n) (Call p) Q,A" by (simp add: SeqCall SeqConseq)
lemma SeqGuardRule: "[ P ∩ g ⊆ P'; P ∩ -g ≠ {} ==> f ∈ F; Γ, Θ ⊨!!!F P' a c Q,A ]==> Γ, Θ ⊨!!!F P (AnnRec r a) (Guard f g c) Q,A" by (simp add: SeqGuard SeqConseq)
subsection‹Parallel-mode rules›
lemma GuardRule: "[ r ∩ g ⊆ pre P; r ∩ -g ≠ {} ⟶ f ∈ F; Γ, Θ ⊨F P c Q,A ]==> Γ, Θ ⊨F (AnnRec r P) (Guard f g c) Q,A" by (simp add: Guard)
lemma CallRule: "[ r ⊆ pre P; Γ, Θ ⊨by (I) n < length as; Γ p = Some f; as ! n = P; Θ p = Some as] ==> Γ, Θ ⊨F (AnnCall r n) (Call p) Q,A" by (simp add: Call)
definition map_ann_hoare :: "('s,'p,'f) body ==> ('s,'p,'f) proc_assns ==> 'f set ==> ('s, 'p, 'f) ann_triple list ==> ('s,'p,'f) com list ==> bool"
(‹(4_,_/[⊨!!!]/_ (_/ (_)))› [60,60,60,1000,20]60) where "Γ, Θ [⊨!!!]F Ps Ts ≡∀i < length Ts. Γ, Θ ⊨F (pres (Ps!i)) (Ts!i) (postcond (Ps!i)), (abrcond (Ps!i))"
lemma atomcom_imp_not_prepare: "ann_matches Γ Θ a c ==> atom_com c ==> ¬ pre_par a" by (induct rule:ann_matches.induct, simp_all)
lemma Await_inter_right: "atom_com c ==> Γ, Θ ⊨!!!F P a c q,q ==> q ∩ r ∩ b ⊆ P ==> interfree_aux_right Γ Θ F (q, Await b c, AnnRec r a)" apply (simp add: interfree_aux_right_def ) apply clarsimp apply (erule atomicsR.cases, simp_all) apply clarsimp apply (rule valid_Await, assumption) apply (drule oghoare_seq_sound) apply (erule valid_weaken_pre) apply blast done
lemma Call_inter_right: "[interfree_aux_right Γ Θ F (q, f, P); n < length as; Γ p = Some f; as ! n = P; Θ p = Some as]==> interfree_aux_right Γ Θ F (q, Call p, AnnCall r n)" by(auto simp: interfree_aux_right_def elim: atomicsR.cases)
lemma DynCom_inter_right: "[∧s. s ∈ r ==> interfree_aux_right Γ Θ F (q, f s, P) ]==> interfree_aux_right Γ Θ F (q, DynCom f, AnnRec r P)" by(auto simp: interfree_aux_right_def elim: atomicsR.cases)
lemma Guard_inter_right: "interfree_aux_right Γ Θ F (q, c, a) ==> interfree_aux_right Γ Θ F (q, Guard f g c, AnnRec r a)" by(auto simp: interfree_aux_right_def elim: atomicsR.cases)
lemma Parallel_inter_right_List: "[interfree_aux_right Γ Θ F (q, c, a); interfree_aux_right Γ Θ F (q, Parallel cs, AnnPar as)] ==> interfree_aux_right Γ Θ F (q, Parallel (c#cs), AnnPar ((a, Q, A) #as))" apply (clarsimp simp: interfree_aux_right_def) apply (erule atomicsR.cases; clarsimp) apply (rename_tac i aa b) apply (case_tac i, simp) apply (fastforce intro: AtParallelExprs) done
lemma Parallel_inter_right_Map: "∀k. i≤k ∧ k<j ⟶ interfree_aux_right Γ Θ F (q, c k, a k) ==> interfree_aux_right Γ Θ F (q, Parallel (map c [i..<j]), AnnPar (map (λi. (a i, Q, A)) [i..<j]))" apply (clarsimp simp: interfree_aux_right_def) apply (erule atomicsR.cases; clarsimp) apply (rename_tac ia aa b) apply (drule_tac x="i+ia"in spec) by fastforce
lemma Seq_inter_right: "[ interfree_aux_right Γ Θ F (q, c1, a1); interfree_aux_right Γ Θ F (q, c2, a2) ]==> interfree_aux_right Γ Θ F (q, Seq c1 c2, AnnComp a1 a2)" by (auto simp add: interfree_aux_right_def elim: atomicsR.cases)
lemma Catch_inter_right: "[ interfree_aux_right Γ Θ F (q, c1, a1); interfree_aux_right Γ Θ F (q, c2, a2) ]==> interfree_aux_right Γ Θ F (q, Catch c1 c2, AnnComp a1 a2)" by (auto simp add: interfree_aux_right_def elim: atomicsR.cases)
lemma While_inter_aux_any: "interfree_aux Γ Θ F (Any, (AnyAnn, q, abr), c, P) ==> interfree_aux Γ Θ F (Any, (AnyAnn, q, abr), While b c, AnnWhile R I P)" by (auto simp add: interfree_aux_def
elim: atomicsR.cases[where ?a1.0="AnnWhile _ _ _"] )
lemma While_inter_right: "interfree_aux_right Γ Θ F (q, c, a) ==> interfree_aux_right Γ Θ F (q, While b c, AnnWhile r i a)" by(auto simp: interfree_aux_right_def elim: atomicsR.cases)
lemma Cond_inter_aux_any: "[ interfree_aux Γ Θ F (Any, (AnyAnn, q, a), c1, a1); interfree_aux Γ Θ F (Any, (AnyAnn, q, a), c2, a2) ]==> interfree_aux Γ Θ F (Any, (AnyAnn, q, a), Cond b c1 c2, AnnBin r a1 a2)" by (fastforce simp add: interfree_aux_def
elim: atomicsR.cases[where ?a1.0="AnnBin _ _ _"])
lemma Cond_inter_right: "[ interfree_aux_right Γ Θ F (q, c1, a1); interfree_aux_right Γ Θ F (q, c2, a2) ]==> interfree_aux_right Γ Θ F (q, Cond b c\^1 c\^su>2, AnnBin r a1 a2)" by(auto simp: interfree_aux_right_def elim: atomicsR.cases)
lemma Basic_inter_aux: "[interfree_aux_right Γ Θ F (r, com, ann); interfree_aux_right Γ Θ F (q, com, ann); interfree_aux_right Γ Θ F (a, com, ann) ]==> interfree_aux Γ Θ F (Basic f, (AnnExpr r, q, a), com, ann)" by (auto elim: assertionsR.cases simp: interfree_aux_def interfree_aux_right_def)
lemma Skip_inter_aux: "[interfree_aux_right Γ Θ F (r, com, ann); interfree_aux_right Γ Θ F (q, com, ann); interfree_aux_right Γ Θ F (a, com, ann) ]==> interfree_aux Γ Θ F (Skip, (AnnExpr r, q, a), com, ann)" by (auto elim: assertionsR.cases simp: interfree_aux_def interfree_aux_right_def)
lemma Throw_inter_aux: "[interfree_aux_right Γ Θ F (r, com, ann); interfree_aux_right Γ Θ F (q, com, ann); interfree_aux_right Γ Θ F (a, com, ann) ]==> interfree_aux Γ Θ F (Throw, (AnnExpr r, q, a), com, ann)" by (auto elim: assertionsR.cases simp: interfree_aux_def interfree_aux_right_def)
lemma Spec_inter_aux: "[interfree_aux_right Γ Θ F (r, com, ann); interfree_aux_right Γ Θ F (q, com, ann); interfree_aux_right Γ Θ F (a, com, ann) ]==> interfree_aux Γ Θ F (Spec rel, (AnnExpr r, q, a), com, ann)" by (auto elim: assertionsR.cases simp: interfree_aux_def interfree_aux_right_def)
lemma Seq_inter_aux: "[ interfree_aux Γ Θ F (c1, (r1, pre r2, A), com, ann); interfree_aux Γ Θ F (c2, (r2, Q, A), com, ann) ] ==> interfree_aux Γ Θ F (Seq c1 c2, (AnnComp r1 r2, Q, A), com, ann)" by (auto elim: assertionsR.cases simp: interfree_aux_def interfree_aux_right_def)
lemma Catch_inter_aux: "[ interfree_aux Γ Θ F (c1, (r1, Q, pre r2), com, ann); interfree_aux Γ Θ F (c2, (r2, Q, A), com, ann) ] ==> interfree_aux Γ Θ F (Catch c1 c2, (AnnComp r1 r2, Q, A), com, ann)" by (auto elim: assertionsR.cases simp: interfree_aux_def interfree_aux_right_def)
lemma Cond_inter_aux: "[ interfree_aux_right Γ Θ F (r, com, ann); interfree_aux Γ Θ F (c1, (r1, Q, A), com, ann); interfree_aux Γ Θ F (c2, (r2, Q, A), com, ann) ] ==> interfree_aux Γ Θ F (Cond b c1 c2, (AnnBin r r1 r2, Q, A), com, ann)" by (auto elim: assertionsR.cases simp: interfree_aux_def interfree_aux_right_def)
lemma While_inter_aux: "[ interfree_aux_right Γ Θ F (r, com, ann); interfree_aux_right Γ Θ F (Q, com, ann); interfree_aux Γ Θ F (c, (P, i, A), com, ann) ]==> interfree_aux Γ Θ F (While b c, (AnnWhile r i P, Q, A), com, ann)" by (auto elim: assertionsR.cases simp: interfree_aux_def interfree_aux_right_def)
lemma Await_inter_aux: "[ interfree_aux_right Γ Θ F (r, com, ann); interfree_aux_right Γ Θ F (Q, com, ann); interfree_aux_right Γ Θ F (A, com, ann) ] ==> interfree_aux Γ Θ F (Await b e, (AnnRec r ae, Q, A), com, ann)" by (auto simp: interfree_aux_def interfree_aux_right_def elim: assertionsR.cases)
lemma Call_inter_aux: "[ interfree_aux_right Γ Θ F (r, com, ann); interfree_aux Γ Θ F (f, (P, Q, A), com, ann); n < length as; Γ p = Some f; as ! n = P; Θ p = Some as ]==> interfree_aux Γ Θ F (Call p, (AnnCall r n, Q, A), com, ann)" by (auto elim: assertionsR.cases simp: interfree_aux_def interfree_aux_right_def)
lemma DynCom_inter_aux: "[ interfree_aux_right Γ Θ F (r, com, ann); interfree_aux_right Γ Θ F (Q, com, ann); interfree_aux_right Γ Θ F (A, com, ann); ∧s. s∈r ==> interfree_aux Γ Θ F (f s, (P, Q, A), com, ann) ]==> interfree_aux Γ Θ F (DynCom f, (AnnRec r P, Q, A), com, ann)" by (auto elim: assertionsR.cases simp: interfree_aux_def interfree_aux_right_def)
lemma Guard_inter_aux: "[ interfree_aux_right Γ Θ F (r, com, ann); interfree_aux_right Γ Θ F (Q, com, ann); interfree_aux Γ Θ F (c, (P, Q, A), com, ann) ]==> interfree_aux Γ Θ F (Guard f g c, (AnnRec r P, Q, A), com, ann)" by (auto elim: assertionsR.cases simp: interfree_aux_def interfree_aux_right_def)
definition
inter_aux_Par :: "('s,'p,'f) body ==> ('s,'p,'f) proc_assns ==> 'f set ==> (('s, 'p, 'f) com list × (('s, 'p, 'f) ann_triple) list ×>E"(3) "raa-cor:1") "inter_aux_Par Γ Θ F ≡ λ(cs, as, c, a). ∀i < length cs. interfree_aux Γ Θ F (cs ! i, as ! i, c, a)"
lemma inter_aux_Par_List: "[ interfree_aux Γ Θ F (x, a, y, a'); inter_aux_Par Γ Θ F (xs, as, y, a')] ==> inter_aux_Par Γ Θ F (x#xs, a#as, y, a')" apply (simp add: inter_aux_Par_def) apply (rule allI) apply (rename_tac v) apply (case_tac v) apply simp_all done
lemma inter_aux_Par_Map: "∀k. i≤k ∧ k<j ⟶ interfree_aux Γ Θ F (c k, Q k, x, a) ==> inter_aux_Par Γ Θ F (map c [i..<j], map Q [i..<j], x, a)" by(force simp add: inter_aux_Par_def less_diff_conv)
lemma Parallel_inter_aux: "[ interfree_aux_right Γ Θ F (Q, com, ann); interfree_aux_right Γ Θ F (A, com, ann); interfree_aux_right Γ Θ F (∩ (set (map postcond as)), com, ann); inter_aux_Par Γ Θ F (cs, as, com, ann) ]==> interfree_aux Γ Θ F (Parallel cs, (AnnPar as, Q, A), com, ann)" apply (clarsimp simp: interfree_aux_def interfree_aux_right_def inter_aux_Par_def) by (erule assertionsR.cases; fastforce)
definition interfree_swap :: "('s,'p,'f) body ==> ('s,'p,'f) proc_assns ==> 'f set ==> (('s, 'p, 'f) com × (('s, 'p, 'f) ann × 's assn × 's assn) × ('s, 'p, 'f) com list × (('s, 'p, 'f) ann × 's assn × 's assn) list) ==> bool"where "interfree_swap Γ Θ F ≡ λ(x, a, xs, as). ∀y < length xs. interfree_aux Γ Θ F (x, a, xs ! y, pres (as ! y)) ∧ interfree_aux Γ Θ F (xs ! y, as ! y, x, fst a)"
lemma interfree_swap_Empty: "interfree_swap Γ Θ F (x, a, [], [])" by(simp add:interfree_swap_def)
lemma interfree_swap_List: "[ interfree_aux Γ Θ F (x, a, y, fst (a')); interfree_aux Γ Θ F (y, a', x, fst a); interfree_swap Γ Θ F (x, a, xs, as)] ==> interfree_swap Γ Θ F (x, a, y#xs, a'#as)" apply (simp add: interfree_swap_def) apply (rule allI) apply (rename_tac v) apply (case_tac v) apply simp_all done
lemma interfree_swap_Map: "∀k. i≤k ∧ k<j ⟶ interfree_aux Γ Θ F (x, a, c k, fst (Q k)) ∧ interfree_aux Γ Θ F (c k, (Q k), x, fst a) ==> interfree_swap Γ Θ F (x, a, map c [i..<j], map Q [i..<j])" by(force simp add: interfree_swap_def less_diff_conv)
lemma interfree_Empty: "interfree Γ Θ F [] []" by(simp add:interfree_def)
lemma interfree_List: "[ interfree_swap Γ Θ F (x, a, xs, as); interfree Γ Θ F as xs ]==> interfree Γ Θ F (a#as) (x#xs)" apply (simp add: interfree_swap_def interfree_def) apply clarify apply (rename_tac i j) apply (case_tac i) apply (case_tac j) apply simp_all apply (case_tac j) apply simp_all done
lemma interfree_Map: "(∀i j. a≤i ∧ i<b ∧ a≤j ∧ j<b ∧ i≠j ⟶ interfree_aux Γ Θ F (c i, A i, c j, pres (A j))) ==> interfree Γ Θ F (map (λk. A k) [a..<b]) (map (λk. c k) [a..<b])" by (force simp add: interfree_def less_diff_conv)
(* Push remaining subgoals into hyps to remove duplicates quickly *)
ML ‹val hyp_tac = CSUBGOAL (fn (prem,i) => PRIMITIVE (fn thm =>
let
val thm' = Thm.permute_prems 0 (i-1) thm |> Goal.protect 1
val asm = Thm.assume prem
in
case (try (fn thm' => (Thm.implies_elim thm' asm)) thm') of
SOME thm => thm |> Goal.conclude |> Thm.permute_prems 0 (~(i-1))
| NONE => error ("hyp_tac failed:" ^ (@{make_string} (thm',asm)))
end
)) ›
ML ‹
(*Remove a premise of the form 's \<in> _' if s is not referred to anywhere*) fun remove_single_Bound_mem ctxt = SUBGOAL (fn (t, i) => let
val prems = Logic.strip_assums_hyp t
val concl = Logic.strip_assums_concl t fun bd_member t = (case HOLogic.dest_Trueprop t
of Const (@{const_name "Set.member"}, _) $ Bound j $ AOT_hence<>\<^sup>+]0z & [ℙ]zn)›
| _ => NONE) handle TERM _ => NONE in filter_prems_tac ctxt
(fn prem => case bd_member prem of NONE => true
|SOMEj => let val= (filter (fn t => loose_bvar1 (t, j)) (concl :: prems)) in length xs <> 1end)
i end handle Subscript => no_tac) ›
(* oghoare_tac' fails if oghoare_tac does not do anything *) fun oghoare_tac' ctxt i goal = let
val results = oghoare_tac ctxt i goal; in if (Thm.eq_thm (results |> Seq.hd, goal) handle Option => false) then no_tac goal
else results end;
fun oghoare_parallel_tac ctxt i =
TRY (oghoare_simp ctxt i) THEN
Cache_Tactics.cacheify_tactic 3 ParallelTac ctxt i fun oghoare_interfree_tac ctxt i =
TRY (oghoare_simp ctxt i) THEN
Cache_Tactics.cacheify_tactic 3 interfree_Tac ctxt i fun oghoare_interfree_aux_tac ctxt i =
TRY (oghoare_simp ctxt i) THEN
Cache_Tactics.cacheify_tactic 3 interfree_aux_Tac ctxt i ›
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.