locale Val_inv = Val_lattice_gamma where γ = γ for γ :: "'av::bounded_lattice ==> val set" + fixes test_num' :: "val ==> 'av ==> bool" and inv_plus' :: "'av ==> 'av ==> 'av ==> 'av * 'av" and inv_less' :: "bool ==> 'av ==> 'av ==> 'av * 'av" assumes test_num': "test_num' i a = (i ∈ γ a)" and inv_plus': "inv_plus' a a1 a2 = (a1',a2') ==> i1 ∈ γ a1 ==> i2 ∈ γ a2 ==> i1+i2 ∈ γ a ==> i1 ∈ γ a1' ∧ i2 ∈ γ a2'" and inv_less': "inv_less' (i1<i2) a1 a2 = (a1',a2') ==> i1 ∈ γ a1 ==> i2 ∈ γ a2 ==> i1 ∈ γ a1' ∧ i2 ∈ γ a2'"
locale Abs_Int_inv = Val_inv where γ = γ for γ :: "'av::bounded_lattice ==> val set" begin
lemma in_gamma_sup_UpI: "s ∈ γo S1 ∨ s ∈ γo S2 ==> s ∈ γo(S1 ⊔ S2)" by (metis (opaque_lifting, no_types) sup_ge1 sup_ge2 mono_gamma_o subsetD)
fun aval'' :: "aexp ==> 'av st option ==> 'av"where "aval'' e None = ⊥" | "aval'' e (Some S) = aval' e S"
lemma aval''_correct: "s ∈ γo S ==> aval a s ∈ γ(aval'' a S)" by(cases S)(auto simp add: aval'_correct split: option.splits)
subsubsection"Backward analysis"
fun inv_aval' :: "aexp ==> 'av ==> 'av st option ==> 'av st option"where "inv_aval' (N n) a S = (if test_num' n a then S else None)" | "inv_aval' (V x) a S = (case S of None ==> None | Some S ==> let a' = fun S x ⊓ a in if a' = ⊥ then None else Some(update S x a'))" | "inv_aval' (Plus e1 e2) a S = (let (a1,a2) = inv_plus' a (aval'' e1 S) (aval'' e2 S) in inv_aval' e1 a1 (inv_aval' e2 a2 S))"
text‹The test for const‹bot› in the const‹V›-case is important: const‹bot› indicates that a variable has no possible values, i.e.\ that the current
point is unreachable. But then the abstract state should collapse to const‹None›. Put differently, we maintain the invariant that in an abstract
of the form term‹Some s›, all variables are mapped to non-const‹bot› values. Otherwise the (pointwise) sup of two abstract states, one of
contains const‹bot› values, may produce too large a result, thus
the analysis less precise.›
fun inv_bval' :: "bexp ==> bool ==> 'av st option ==> 'av st option"where "inv_bval' (Bc v) res S = (if v=res then S else None)" | "inv_bval' (Not b) res S = inv_bval' b (¬ res) S" | "inv_bval' (And b1 b2) res S = (if res then inv_bval' b1 True (inv_bval' b2 True S) else inv_bval' b1 False S ⊔ inv_bval' b2 False S)" | "inv_bval' (Less e1 e2) res S = (let (a1,a2) = inv_less' res (aval'' e1 S) (aval'' e2 S) in inv_aval' e1 a1 (inv_aval' e2 a2 S))"
lemma inv_aval'_correct: "s ∈ γo S ==> aval e s ∈ γ a ==> s ∈ γo (inv_aval' e a S)" proof(induction e arbitrary: a S) case N thus ?caseby simp (metis test_num') next case (V x) obtain S' where"S = Some S'"and"s ∈ γs S'"using‹s ∈ γo S› by(auto simp: in_gamma_option_iff) moreoverhence"s x ∈ γ (fun S' x)" by(simp add: γ_st_def) moreoverhave"s x ∈ γ a"using V(2) by simp ultimatelyshow ?case by(simp add: Let_def γ_st_def)
(metis mono_gamma emptyE in_gamma_inf gamma_bot subset_empty) next case (Plus e1 e2) thus ?case using inv_plus'[OF _ aval''_correct aval''_correct] by (auto split: prod.split) qed
lemma inv_bval'_correct: "s ∈ γo S ==> bv = bval b s ==> s ∈ γo(inv_bval' b bv S)" proof(induction b arbitrary: S bv) case Bc thus ?caseby simp next case (Not b) thus ?caseby simp next case (And b1 b2) thus ?case by simp (metis And(1) And(2) in_gamma_sup_UpI) next case (Less e1 e2) thus ?case apply hypsubst_thin apply (auto split: prod.split) apply (metis (lifting) inv_aval'_correct aval''_correct inv_less') done qed
definition"step' = Step (λx e S. case S of None ==> None | Some S ==> Some(update S x (aval' e S))) (λb S. inv_bval' b True S)"
definition AI :: "com ==> 'av st option acom option"where "AI c = pfp (step' ⊤) (bot c)"
lemma strip_step'[simp]: "strip(step' S c) = strip c" by(simp add: step'_def)
lemma top_on_inv_aval': "[ top_on_opt S X; vars e ⊆ -X ]==> top_on_opt (inv_aval' e a S) X" by(induction e arbitrary: a S) (auto simp: Let_def split: option.splits prod.split)
lemma top_on_inv_bval': "[top_on_opt S X; vars b ⊆ -X]==> top_on_opt (inv_bval' b r S) X" by(induction b arbitrary: r S) (auto simp: top_on_inv_aval' top_on_sup split: prod.split)
lemma top_on_step': "top_on_acom C (- vars C) ==> top_on_acom (step' ⊤ C) (- vars C)" unfolding step'_def by(rule top_on_Step)
(auto simp add: top_on_top top_on_inv_bval' split: option.split)
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.