instance proof (standard, goal_cases) case 1 show ?caseby (rule less_ivl_def) next case 2 show ?caseby transfer (simp add: le_rep_def split: prod.splits) next case 3 thus ?caseby transfer (auto simp: le_rep_def split: if_splits) next case 4 thus ?caseby transfer (auto simp: le_rep_def eq_ivl_iff split: if_splits) next case 5 thus ?caseby transfer (auto simp add: le_rep_def sup_rep_def is_empty_min_max) next case 6 thus ?caseby transfer (auto simp add: le_rep_def sup_rep_def is_empty_min_max) next case 7 thus ?caseby transfer (auto simp add: le_rep_def sup_rep_def) next case 8 show ?caseby transfer (simp add: le_rep_def is_empty_rep_def) qed
end
text\<open>Implement (naive) executable equality:\<close> instantiation ivl :: equal begin
lemma\<gamma>_inf: "\<gamma>_ivl (iv1 \<sqinter> iv2) = \<gamma>_ivl iv1 \<inter> \<gamma>_ivl iv2" by transfer (rule \<gamma>_inf_rep)
definition"\ = empty_ivl"
instance proof (standard, goal_cases) case 1 thus ?caseby (simp add: \<gamma>_inf le_ivl_iff_subset) next case 2 thus ?caseby (simp add: \<gamma>_inf le_ivl_iff_subset) next case 3 thus ?caseby (simp add: \<gamma>_inf le_ivl_iff_subset) next case 4 show ?case unfolding bot_ivl_def by transfer (auto simp: le_iff_subset) qed
end
lemma eq_ivl_empty: "eq_ivl p empty_rep = is_empty_rep p" by (metis eq_ivl_iff is_empty_empty_rep)
lemma le_ivl_nice: "[l1,h1] \ [l2,h2] \
(if [l1,h1] = \<bottom> then True else if [l2,h2] = \<bottom> then False else l1 \<ge> l2 & h1 \<le> h2)" unfolding bot_ivl_def by transfer (simp add: le_rep_def eq_ivl_empty)
lemma sup_ivl_nice: "[l1,h1] \ [l2,h2] =
(if [l1,h1] = \<bottom> then [l2,h2] else if [l2,h2] = \<bottom> then [l1,h1] else [min l1 l2,max h1 h2])" unfolding bot_ivl_def by transfer (simp add: sup_rep_def eq_ivl_empty)
lemma inf_ivl_nice: "[l1,h1] \ [l2,h2] = [max l1 l2,min h1 h2]" by transfer (simp add: inf_rep_def)
lemma top_ivl_nice: "\ = [-\,\]" by (simp add: top_ivl_def)
instantiation ivl :: plus begin
definition plus_rep :: "eint2 \ eint2 \ eint2" where "plus_rep p1 p2 =
(if is_empty_rep p1 \<or> is_empty_rep p2 then empty_rep else let (l1,h1) = p1; (l2,h2) = p2 in (l1+l2, h1+h2))"
lemma plus_ivl_nice: "[l1,h1] + [l2,h2] =
(if [l1,h1] = \<bottom> \<or> [l2,h2] = \<bottom> then \<bottom> else [l1+l2 , h1+h2])" unfolding bot_ivl_def by transfer (auto simp: plus_rep_def eq_ivl_empty)
lemma uminus_eq_Minf[simp]: "-x = Minf \ x = Pinf" by(cases x) auto lemma uminus_eq_Pinf[simp]: "-x = Pinf \ x = Minf" by(cases x) auto
lemma uminus_le_Fin_iff: "- x \ Fin(-y) \ Fin y \ (x::'a::ordered_ab_group_add extended)" by(cases x) auto lemma Fin_uminus_le_iff: "Fin(-y) \ -x \ x \ ((Fin y)::'a::ordered_ab_group_add extended)" by(cases x) auto
instantiation ivl :: uminus begin
definition uminus_rep :: "eint2 \ eint2" where "uminus_rep p = (let (l,h) = p in (-h, -l))"
lemma\<gamma>_uminus_rep: "i \<in> \<gamma>_rep p \<Longrightarrow> -i \<in> \<gamma>_rep(uminus_rep p)" by(auto simp: uminus_rep_def \<gamma>_rep_def image_def uminus_le_Fin_iff Fin_uminus_le_iff
split: prod.split)
lift_definition uminus_ivl :: "ivl \ ivl" is uminus_rep by (auto simp: uminus_rep_def eq_ivl_def \<gamma>_rep_cases)
(auto simp: Icc_eq_Icc split: extended.splits)
instance .. end
lemma\<gamma>_uminus: "i \<in> \<gamma>_ivl iv \<Longrightarrow> -i \<in> \<gamma>_ivl(- iv)" by transfer (rule \<gamma>_uminus_rep)
lemma uminus_nice: "-[l,h] = [-h,-l]" by transfer (simp add: uminus_rep_def)
lemma\<gamma>_aboveI: "i \<in> \<gamma>_ivl iv \<Longrightarrow> i \<le> j \<Longrightarrow> j \<in> \<gamma>_ivl(above iv)" by transfer
(auto simp add: above_rep_def \<gamma>_rep_cases is_empty_rep_def
split: extended.splits)
lemma\<gamma>_belowI: "i \<in> \<gamma>_ivl iv \<Longrightarrow> j \<le> i \<Longrightarrow> j \<in> \<gamma>_ivl(below iv)" by transfer
(auto simp add: below_rep_def \<gamma>_rep_cases is_empty_rep_def
split: extended.splits)
global_interpretation Val_semilattice where\<gamma> = \<gamma>_ivl and num' = num_ivl and plus' = "(+)" proof (standard, goal_cases) case 1 thus ?caseby transfer (simp add: le_iff_subset) next case 2 show ?caseby transfer (simp add: \<gamma>_rep_def) next case 3 show ?caseby transfer (simp add: \<gamma>_rep_def) next case 4 thus ?case apply transfer apply(auto simp: \<gamma>_rep_def plus_rep_def add_mono_le_Fin add_mono_Fin_le) by(auto simp: empty_rep_def is_empty_rep_def) qed
global_interpretation Val_lattice_gamma where\<gamma> = \<gamma>_ivl and num' = num_ivl and plus' = "(+)" defines aval_ivl = aval' proof (standard, goal_cases) case 1 show ?caseby(simp add: \<gamma>_inf) next case 2 show ?caseunfolding bot_ivl_def by transfer simp qed
global_interpretation Val_inv where\<gamma> = \<gamma>_ivl and num' = num_ivl and plus' = "(+)" and test_num' = in_ivl and inv_plus' = inv_plus_ivl and inv_less' = inv_less_ivl proof (standard, goal_cases) case 1 thus ?caseby transfer (auto simp: \<gamma>_rep_def) next case (2 _ _ _ _ _ i1 i2) thus ?case unfolding inv_plus_ivl_def minus_ivl_def apply(clarsimp simp add: \<gamma>_inf) using gamma_plus'[of "i1+i2" _ "-i1"] gamma_plus'[of "i1+i2" _ "-i2"] by(simp add: \<gamma>_uminus) next case (3 i1 i2) thus ?case unfolding inv_less_ivl_def minus_ivl_def one_extended_def apply(clarsimp simp add: \<gamma>_inf split: if_splits) using gamma_plus'[of "i1+1" _ "-1"] gamma_plus'[of "i2 - 1" _ "1"] apply(simp add: \<gamma>_belowI[of i2] \<gamma>_aboveI[of i1]
uminus_ivl.abs_eq uminus_rep_def \<gamma>_ivl_nice) apply(simp add: \<gamma>_aboveI[of i2] \<gamma>_belowI[of i1]) done qed
global_interpretation Abs_Int_inv where\<gamma> = \<gamma>_ivl and num' = num_ivl and plus' = "(+)" and test_num' = in_ivl and inv_plus' = inv_plus_ivl and inv_less' = inv_less_ivl defines inv_aval_ivl = inv_aval' and inv_bval_ivl = inv_bval' and step_ivl = step' and AI_ivl = AI and aval_ivl' = aval''
..
text\<open>Takes as many iterations as the actual execution. Would diverge if
loop did not terminate. Worse still, as the following example shows: even if
the actual execution terminates, the analysis may not. The value of y keeps
increasing as the analysis is iterated, no matter how long:\<close>
value"show_acom (steps test4_ivl 50)"
text\<open>Relationships between variables are NOT captured:\<close> value"show_acom_opt (AI_ivl test5_ivl)"
text\<open>Again, the analysis would not terminate:\<close> value"show_acom (steps test6_ivl 50)"
end
¤ Dauer der Verarbeitung: 0.2 Sekunden
(vorverarbeitet)
¤
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.