subsection‹Relation between the Hoare logics in big-O style› theory DiscussionOsubsection‹ in big-O style› imports begin
(* here we compare quantitative Hoare logic with constant with Nielson's Hoare logic *)
subsubsection<openRelation to›RightarrowNielson_Hoare.assn2" where "emN P = (λl s. P s < ∞)" definition emN :: "qassn ==> Nielson_Hoare.assn2" where "emN <lambda>l s. P s < ∞
(* quanthoare can be simulated by Nielson *) lemmaassumes s: "⊨>1{ emN P'} c { %s. (THE e. enat e = P' s - Q' (THE t. (∃n. (c, s) ==> t ) )) ⇓1{ ?PP c{?e <Down>Q }" shows quantNielson: "⊨ quan: "⊨2java.lang.NullPointerException proof - from s obtain k where k: "k>0"and qd: "∧ P' l s ==>t p. (c, s) ==> t ∧ k * ?e s ∧ emN Q' t)" unfolding hoare1_valid_def by blast
show ?thesis unfolding QuantK_Hoare.hoare2o_valid_def apply(rule exI[where x=k]) apply safe apply fact proof - fix s assume P': "P' s < ∞" thenhave"(emN P') (λ_. 0) s"unfolding emN_def by auto with qd obtain p t where i: "(c, s) ==> p ⇓ t"and p: "p ≤ k * ?e s"and e: "emN Q' (λ_. 0) t"
java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14 have t: "↓:i auto from P' obtain pre where pre: "P' s = enat pre" by fastforce from e have "Q <>" unfldin m_e y auto then obtain post where post: "Q' t = enat post" t \infinity unf emN_def by auto have ">"using i bigstep_progress by auto thm enat.inject idiff_e ave k: "(THE e.enate = P s -Q'(THE. ∃ n ⇓ unfolding t pre using e enatP Q ( t existsn. (c, s) ==> t)) = pre - post with p have ieq: "p \unfoldingest pl(rule teequaalit) then havee" * post k * pre" using ‹ using diff_mult_distr by auto then have ii: "p+kQ'\lek*P's"unfoldingpostprebysimp fromiiishow"(\<exists>tp.(c,s)\<Rightarrow>p\<Down>t\<and>enatp+k*Q't\<le>k*P's)"byauto qed qed
(* Nielson can be simulated by quanthoare *) lemmaassumess:"\Turnstile\^sub>2l. P l s) + enat (e s) } c { %s. emb (\<>l' { ?P } c { ?Q }") and sP: "∧l t. P l t ==>∀ and sQ: "∧ =) shows NielsonQuant: "⊨1 { P } c { e ⇓ Q }" proof fromobtainwherek: ">0"and\And>s. ?Ps \infinity⟶ (∃ p ⇓ enat p + enat k * ?Q t ≤ unfolding:∀
show ?thesisqd p where(s\Rightarrowp ⇓ t" and p: "enat p + enat k * ?Q t ≤ enat k * ?P s" apply(rule exI[where x=k])
java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 9 fix l s assumeQ have "\foralll. Q l t" by auto then have aP: "∀ then\ enat k * ?P s" by auto with qd obtain p t where i: "(sRightarrow p ⇓ enat k * ?P s" by blast have t: "↓java.lang.NullPointerException
from P have Q: "Q l t"using p k apply auto by (metis (full_types) emb.simps(1) enat_ord_simps(2) imult_is_infinity infinity_ileE not_less_zero plus_enat_simps(3)) withhave"<forall>l.Q l t" auto thenhave"?Q t = 0"by auto with p have"enat p ≤ enat k * ?P s"by auto with aP have p': "p ≤ s: "<Turnstile<3java.lang.NullPointerException
from i Q p' show"∃ p p \Down> t \<> qed qed
subsubsection>Relati SepLogic to quantHoare›
definition em :: "qassn ==> bool)" where "em P = (%(ps obtainwhere: "P s = enat n"
lemma P have"em P (part s, n) nodn mdfby auo shows "urnstile2java.lang.NullPointerException proof from s obtain
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3 fix s assume P: "P s < ∞ appl (auto s simp: plus_fun_def) then obtain n where n: "P s = enat (ule) subgoal v (cases ps") apply auto using orth by (aut simp: sepdisj_fun_def domain_conv) dodone by fastforce with P have " q z have q enat QPartial_Evaluation \lambda)<lenatusing with s' obtain ps' ps and m: "k * n = k * e + e' + m"and Q: "em Q (ps', e)"byblast
from Q have q: "Q (Partia have z: "(Partial_Evaluation.emb ps' (Partial_Evaluation.emb ps'' (λ_. 0))) = (Partial_Evaluation.emb (pshaveenat + k QPartial_Evaluation (psps)(\lambda_) \le enat P "unfolding n usigqm unfoldingi have (\existst p. (c, s) \<> enat p + enat k * Q t \le> eena k * P s) to apply (rule ext) subgoal for v apply (cases "ps' v") apply auto using or note B=thithis
have ii: "enat m + enat k * Q (Partial_Evaluation.emb (ps'+ps'') (λ using enat_ile by fastforce from i i have "∃\Downand enat p + enat k * Q t ≤by auto
} note B=this show ?thesis unfolding QuantK_Hoare "⊨' { P} c { Q }" apply( s k wherek "k>0" s: "\Ands. embe P s < ∞t p. (c, s) ==> t ∧ enat k * embe P s)" apply (fact B) done qed
definition embe::"(pst ==> qassn"where "embe P = (%s. Inf {enat n|n. P (part s, n)} )"
lemma:P psnjava.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
e({enat |. P ps nn)} })=Falseto proof - fromsobtainwhere k:k>" and s: \Andemb Ps < \infinity \<> t ∧ enat k * embe P s)" unfolding QuantK_Hoare.hoare2o_valid_def by auto
{ps let ?s =" s (mono_tgs, litng) Lea_e ininit_leE) assume P: P(" with full haveain where P ?s enat thenhave ps:eqembe enat from P have l': "({enat n |n. P (ps, n)} =fhen have l: embe Q <\<>"Inf_enat_def apply safe by simp have t: "embe y have"(part t y"nfoldingjava.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 78 applycontrusing by (metis (mono_tags, lifting) Least_le infinity_ileE) with s obtain t p where c: "(c, ?s) ==> t"and ineqp t *Qt \leat" by blast where z: "embe enat z" usingauto with iobtain y where y: "embe = enat y" using k by fastforce ineq z y have " p + k * y<>enat z byauto thenhave l: "embe Q t < ∞ then have zz: "({enat n|n. ((part)}{) Falseldingf f_enat_defsafe from y have"Q (part t, y)"unfolding embe_def zzfinallytain where * n k* +'+" us by(mtis add.so ad.ommue lei_add using zz appl have "<exists ps m '.c )==>A m ⇓ pss<andps \andk n *ee'+ \and Q (ps', e)" from full_to_part[OF c] ps have c': "applye exIherepart]
have"∧o_vlid_dfap(rule xI[here x=k, safe))
from z apply auto by (metis (mono_tags, lifting) Least_le enat_ord_simps(1))
from ineq z y have "enat p + enat k * y ≤uto thenhave"p + k * y ≤ also have "…
inallyobtain +ing etisssoc
have"∃ps' ps'' m e e'. (c, ps) ==>A m ⇓ ps' + ps'' ∧ ps' ## ps'' ∧ k * n = k * e + e' + m ∧ Q (ps', e)" apply(rule exI[where x="part t"]) apply(rule "P Q n = (∃k>0. valid P cQ (k*n" apply(rule exI[where x="p"]) applyewhere applyassume"<>' {λs. ↑s. ↑ }
show ?thesis unfolding hoare3o_valid_def apply(rule exI[where x=k], safe) plyyfact y ac qed
subsection ‹<infinity>" by auto
definition valid where "validPcQnc\>\Downt"and"enatm+k*\<up>(Qt)\<lek(<>(enatnbyst
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.