lemma WhileRule: "\ p \ i; \- (i \ b) c i ; (i \ (-b)) \ q \ \<Longrightarrow> \<parallel>- p (While b i c) q" apply(rule Conseq) prefer 2 apply(rule While) apply assumption+ done
text\<open>Three new proof rules for special instances of the \<open>AnnBasic\<close> and the \<open>AnnAwait\<close> commands when the transformation
performed on the state is the identity, andfor an \<open>AnnAwait\<close>
command where the boolean condition is\<open>{s. True}\<close>:\<close>
lemma AnnatomRule: "\ atom_com(c); \- r c q \ \ \ (AnnAwait r {s. True} c) q" apply(rule AnnAwait) apply simp_all done
lemma AnnwaitRule: "\ (r \ b) \ q \ \ \ (AnnAwait r b (Basic id)) q" apply(rule AnnAwait) apply simp apply(rule BasicRule) apply simp done
text\<open>Lemmata to avoid using the definition of \<open>map_ann_hoare\<close>, \<open>interfree_aux\<close>, \<open>interfree_swap\<close> and \<open>interfree\<close> by splitting it into different cases:\<close>
lemma interfree_aux_rule1: "interfree_aux(co, q, None)" by(simp add:interfree_aux_def)
lemma interfree_aux_rule2: "\(R,r)\(atomics a). \- (q \ R) r q \ interfree_aux(None, q, Some a)" apply(simp add:interfree_aux_def) apply(force elim:oghoare_sound) done
lemma interfree_aux_rule3: "(\(R, r)\(atomics a). \- (q \ R) r q \ (\p\(assertions c). \- (p \ R) r p)) \<Longrightarrow> interfree_aux(Some c, q, Some a)" apply(simp add:interfree_aux_def) apply(force elim:oghoare_sound) done
lemma AnnBasic_assertions: "\interfree_aux(None, r, Some a); interfree_aux(None, q, Some a)\ \
interfree_aux(Some (AnnBasic r f), q, Some a)" apply(simp add: interfree_aux_def) by force
lemma AnnSeq_assertions: "\ interfree_aux(Some c1, q, Some a); interfree_aux(Some c2, q, Some a)\\
interfree_aux(Some (AnnSeq c1 c2), q, Some a)" apply(simp add: interfree_aux_def) by force
lemma AnnCond1_assertions: "\ interfree_aux(None, r, Some a); interfree_aux(Some c1, q, Some a);
interfree_aux(Some c2, q, Some a)\<rbrakk>\<Longrightarrow>
interfree_aux(Some(AnnCond1 r b c1 c2), q, Some a)" apply(simp add: interfree_aux_def) by force
lemma AnnCond2_assertions: "\ interfree_aux(None, r, Some a); interfree_aux(Some c, q, Some a)\\
interfree_aux(Some (AnnCond2 r b c), q, Some a)" apply(simp add: interfree_aux_def) by force
lemma AnnWhile_assertions: "\ interfree_aux(None, r, Some a); interfree_aux(None, i, Some a);
interfree_aux(Some c, q, Some a)\<rbrakk>\<Longrightarrow>
interfree_aux(Some (AnnWhile r b i c), q, Some a)" apply(simp add: interfree_aux_def) by force
lemma AnnAwait_assertions: "\ interfree_aux(None, r, Some a); interfree_aux(None, q, Some a)\\
interfree_aux(Some (AnnAwait r b c), q, Some a)" apply(simp add: interfree_aux_def) by force
lemma AnnBasic_atomics: "\- (q \ r) (Basic f) q \ interfree_aux(None, q, Some (AnnBasic r f))" by(simp add: interfree_aux_def oghoare_sound)
lemma AnnSeq_atomics: "\ interfree_aux(Any, q, Some a1); interfree_aux(Any, q, Some a2)\\
interfree_aux(Any, q, Some (AnnSeq a1 a2))" apply(simp add: interfree_aux_def) by force
lemma AnnCond1_atomics: "\ interfree_aux(Any, q, Some a1); interfree_aux(Any, q, Some a2)\\
interfree_aux(Any, q, Some (AnnCond1 r b a1 a2))" apply(simp add: interfree_aux_def) by force
lemma AnnCond2_atomics: "interfree_aux (Any, q, Some a)\ interfree_aux(Any, q, Some (AnnCond2 r b a))" by(simp add: interfree_aux_def)
lemma AnnWhile_atomics: "interfree_aux (Any, q, Some a) \<Longrightarrow> interfree_aux(Any, q, Some (AnnWhile r b i a))" by(simp add: interfree_aux_def)
lemma Annatom_atomics: "\- (q \ r) a q \ interfree_aux (None, q, Some (AnnAwait r {x. True} a))" by(simp add: interfree_aux_def oghoare_sound)
lemma AnnAwait_atomics: "\- (q \ (r \ b)) a q \ interfree_aux (None, q, Some (AnnAwait r b a))" by(simp add: interfree_aux_def oghoare_sound)
definition interfree_swap :: "('a ann_triple_op * ('a ann_triple_op) list) \ bool" where "interfree_swap == \(x, xs). \y\set xs. interfree_aux (com x, post x, com y) \<and> interfree_aux(com y, post y, com x)"
text\<open>The following are some useful lemmas and simplification
tactics to control which theorems are used to simplify at each moment,
so that the original input does not suffer any unexpected
transformation.\<close>
lemma Compl_Collect: "-(Collect b) = {x. \(b x)}" by fast
text\<open>The following tactic applies \<open>tac\<close> to each conjunct in a
subgoal of the form \<open>A \<Longrightarrow> a1 \<and> a2 \<and> .. \<and> an\<close> returning \<open>n\<close> subgoals, one for each conjunct:\<close>
ML \<open> fun conjI_Tac ctxt tac i st = st |>
( (EVERY [resolve_tac ctxt [conjI] i,
conjI_Tac ctxt tac (i+1),
tac i]) ORELSE (tac i) ) \<close>
subsubsection \<open>Tactic for the generation of the verification conditions\<close>
text\<open>The tactic basically uses two subtactics:
\begin{description}
\item[HoareRuleTac] is called at the level of parallel programs, it uses the ParallelTac to solve parallel composition of programs.
This verification has two parts, namely, (1) all component programs are
correct and (2) they are interference free. \<open>HoareRuleTac\<close> is also called at the level of atomic regions, i.e. \<open>\<langle> \<rangle>\<close> and \<open>AWAIT b THEN _ END\<close>, and at each interference freedom test.
\item[AnnHoareRuleTac] is for component programs which
are annotated programs and so, there are not unknown assertions
(no need touse the parameter precond, see NOTE).
NOTE: precond(::bool) informs if the subgoal has the form \<open>\<parallel>- ?p c q\<close>, in this case we have precond=False and the generated verification
condition would have the form \<open>?p \<subseteq> \<dots>\<close> which can be solved by \<open>rtac subset_refl\<close>, if True we proceed to simplify it using
the simplification tactics above.
\end{description} \<close>
ML \<open>
fun WlpTac ctxt i = resolve_tac ctxt @{thms SeqRule} i THEN HoareRuleTac ctxt false (i + 1) and HoareRuleTac ctxt precond i st = st |>
( (WlpTac ctxt i THEN HoareRuleTac ctxt precond i)
ORELSE
(FIRST[resolve_tac ctxt @{thms SkipRule} i,
resolve_tac ctxt @{thms BasicRule} i,
EVERY[resolve_tac ctxt @{thms ParallelConseqRule} i,
ParallelConseq ctxt (i+2),
ParallelTac ctxt (i+1),
ParallelConseq ctxt i],
EVERY[resolve_tac ctxt @{thms CondRule} i,
HoareRuleTac ctxt false (i+2),
HoareRuleTac ctxt false (i+1)],
EVERY[resolve_tac ctxt @{thms WhileRule} i,
HoareRuleTac ctxt true (i+1)],
K all_tac i ] THEN (if precond then (K all_tac i) else resolve_tac ctxt @{thms subset_refl} i)))
and AnnWlpTac ctxt i = resolve_tac ctxt @{thms AnnSeq} i THEN AnnHoareRuleTac ctxt (i + 1) and AnnHoareRuleTac ctxt i st = st |>
( (AnnWlpTac ctxt i THEN AnnHoareRuleTac ctxt i )
ORELSE
(FIRST[(resolve_tac ctxt @{thms AnnskipRule} i),
EVERY[resolve_tac ctxt @{thms AnnatomRule} i,
HoareRuleTac ctxt true (i+1)],
(resolve_tac ctxt @{thms AnnwaitRule} i),
resolve_tac ctxt @{thms AnnBasic} i,
EVERY[resolve_tac ctxt @{thms AnnCond1} i,
AnnHoareRuleTac ctxt (i+3),
AnnHoareRuleTac ctxt (i+1)],
EVERY[resolve_tac ctxt @{thms AnnCond2} i,
AnnHoareRuleTac ctxt (i+1)],
EVERY[resolve_tac ctxt @{thms AnnWhile} i,
AnnHoareRuleTac ctxt (i+2)],
EVERY[resolve_tac ctxt @{thms AnnAwait} i,
HoareRuleTac ctxt true (i+1)],
K all_tac i]))
and ParallelTac ctxt i = EVERY[resolve_tac ctxt @{thms ParallelRule} i,
interfree_Tac ctxt (i+1),
MapAnn_Tac ctxt i]
and MapAnn_Tac ctxt i st = st |>
(FIRST[resolve_tac ctxt @{thms MapAnnEmpty} i,
EVERY[resolve_tac ctxt @{thms MapAnnList} i,
MapAnn_Tac ctxt (i+1),
AnnHoareRuleTac ctxt i],
EVERY[resolve_tac ctxt @{thms MapAnnMap} i,
resolve_tac ctxt @{thms allI} i,
resolve_tac ctxt @{thms impI} i,
AnnHoareRuleTac ctxt i]])
and interfree_swap_Tac ctxt i st = st |>
(FIRST[resolve_tac ctxt @{thms interfree_swap_Empty} i,
EVERY[resolve_tac ctxt @{thms interfree_swap_List} i,
interfree_swap_Tac ctxt (i+2),
interfree_aux_Tac ctxt (i+1),
interfree_aux_Tac ctxt i ],
EVERY[resolve_tac ctxt @{thms interfree_swap_Map} i,
resolve_tac ctxt @{thms allI} i,
resolve_tac ctxt @{thms impI} i,
conjI_Tac ctxt (interfree_aux_Tac ctxt) i]])
and interfree_Tac ctxt i st = st |>
(FIRST[resolve_tac ctxt @{thms interfree_Empty} i,
EVERY[resolve_tac ctxt @{thms interfree_List} i,
interfree_Tac ctxt (i+1),
interfree_swap_Tac ctxt i],
EVERY[resolve_tac ctxt @{thms interfree_Map} i,
resolve_tac ctxt @{thms allI} i,
resolve_tac ctxt @{thms allI} i,
resolve_tac ctxt @{thms impI} i,
interfree_aux_Tac ctxt i ]])
and interfree_aux_Tac ctxt i = (before_interfree_simp_tac ctxt i ) THEN
(FIRST[resolve_tac ctxt @{thms interfree_aux_rule1} i,
dest_assertions_Tac ctxt i])
and dest_assertions_Tac ctxt i st = st |>
(FIRST[EVERY[resolve_tac ctxt @{thms AnnBasic_assertions} i,
dest_atomics_Tac ctxt (i+1),
dest_atomics_Tac ctxt i],
EVERY[resolve_tac ctxt @{thms AnnSeq_assertions} i,
dest_assertions_Tac ctxt (i+1),
dest_assertions_Tac ctxt i],
EVERY[resolve_tac ctxt @{thms AnnCond1_assertions} i,
dest_assertions_Tac ctxt (i+2),
dest_assertions_Tac ctxt (i+1),
dest_atomics_Tac ctxt i],
EVERY[resolve_tac ctxt @{thms AnnCond2_assertions} i,
dest_assertions_Tac ctxt (i+1),
dest_atomics_Tac ctxt i],
EVERY[resolve_tac ctxt @{thms AnnWhile_assertions} i,
dest_assertions_Tac ctxt (i+2),
dest_atomics_Tac ctxt (i+1),
dest_atomics_Tac ctxt i],
EVERY[resolve_tac ctxt @{thms AnnAwait_assertions} i,
dest_atomics_Tac ctxt (i+1),
dest_atomics_Tac ctxt i],
dest_atomics_Tac ctxt i])
and dest_atomics_Tac ctxt i st = st |>
(FIRST[EVERY[resolve_tac ctxt @{thms AnnBasic_atomics} i,
HoareRuleTac ctxt true i],
EVERY[resolve_tac ctxt @{thms AnnSeq_atomics} i,
dest_atomics_Tac ctxt (i+1),
dest_atomics_Tac ctxt i],
EVERY[resolve_tac ctxt @{thms AnnCond1_atomics} i,
dest_atomics_Tac ctxt (i+1),
dest_atomics_Tac ctxt i],
EVERY[resolve_tac ctxt @{thms AnnCond2_atomics} i,
dest_atomics_Tac ctxt i],
EVERY[resolve_tac ctxt @{thms AnnWhile_atomics} i,
dest_atomics_Tac ctxt i],
EVERY[resolve_tac ctxt @{thms Annatom_atomics} i,
HoareRuleTac ctxt true i],
EVERY[resolve_tac ctxt @{thms AnnAwait_atomics} i,
HoareRuleTac ctxt true i],
K all_tac i]) \<close>
text\<open>The final tactic is given the name \<open>oghoare\<close>:\<close>
ML \<open> fun oghoare_tac ctxt = SUBGOAL (fn (_, i) => HoareRuleTac ctxt true i) \<close>
text\<open>Notice that the tactic for parallel programs \<open>oghoare_tac\<close> is initially invoked with the value \<open>true\<close> for
the parameter \<open>precond\<close>.
Parts of the tactic can be also individually used to generate the
verification conditions for annotated sequential programs andto
generate verification conditions out of interference freedom tests:\<close>
ML \<open> fun annhoare_tac ctxt = SUBGOAL (fn (_, i) => AnnHoareRuleTac 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.0.13Bemerkung:
Wie Sie bei der Firma Beratungs- und Dienstleistungen beauftragen können
¤
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 ist noch experimentell.