# HG changeset patch # User nipkow # Date 1366791827 -7200 # Node ID c27bb7994bd396882b0012896977132d147093ea # Parent 789507cd689ded3f63e662abd20f136a42a75428 moved defs into locale to reduce unnecessary polymorphism; tuned diff -r 789507cd689d -r c27bb7994bd3 src/HOL/IMP/Abs_Int0.thy --- a/src/HOL/IMP/Abs_Int0.thy Tue Apr 23 19:40:33 2013 +0200 +++ b/src/HOL/IMP/Abs_Int0.thy Wed Apr 24 10:23:47 2013 +0200 @@ -304,7 +304,7 @@ locale Measure1_fun = -fixes m :: "'av::{order,top} \ nat" +fixes m :: "'av::top \ nat" fixes h :: "nat" assumes h: "m x \ h" begin @@ -315,11 +315,12 @@ lemma m_s_h: "finite X \ m_s X S \ h * card X" by(simp add: m_s_def) (metis nat_mult_commute of_nat_id setsum_bounded[OF h]) -definition m_o :: "vname set \ 'av st option \ nat" ("m\<^isub>o") where -"m_o X opt = (case opt of None \ h * card X + 1 | Some S \ m_s X S)" +fun m_o :: "vname set \ 'av st option \ nat" ("m\<^isub>o") where +"m_o X (Some S) = m_s X S" | +"m_o X None = h * card X + 1" lemma m_o_h: "finite X \ m_o X opt \ (h*card X + 1)" -by(auto simp add: m_o_def m_s_h le_SucI split: option.split dest:m_s_h) +by(cases opt)(auto simp add: m_s_h le_SucI dest: m_s_h) definition m_c :: "'av st option acom \ nat" ("m\<^isub>c") where "m_c C = (\i}. +locale Measure_fun = Measure1_fun where m=m for m :: "'av::semilattice \ nat" + +assumes m2: "x < y \ m x > m y" +begin + +text{* The predicates @{text "top_on_ty X a"} that follow describe that any abstract +state in @{text a} maps all variables in @{text X} to @{term \}. This is an important invariant for the termination proof where we argue that only the finitely many variables in the program change. That the others do not change follows because they remain @{term \}. *} -fun top_on_st :: "vname set \ 'a::top st \ bool" where -"top_on_st X f = (\x\X. f x = \)" +fun top_on_st :: "vname set \ 'av st \ bool" ("top'_on\<^isub>s") where +"top_on_st X S = (\x\X. S x = \)" -fun top_on_opt :: "vname set \ 'a::top st option \ bool" where -"top_on_opt X (Some F) = top_on_st X F" | +fun top_on_opt :: "vname set \ 'av st option \ bool" ("top'_on\<^isub>o") where +"top_on_opt X (Some S) = top_on_st X S" | "top_on_opt X None = True" -definition top_on_acom :: "vname set \ 'a::top st option acom \ bool" where +definition top_on_acom :: "vname set \ 'av st option acom \ bool" ("top'_on\<^isub>c") where "top_on_acom X C = (\a \ set(annos C). top_on_opt X a)" -lemma top_on_top: "top_on_opt X (\::_ st option)" +lemma top_on_top: "top_on_opt X \" by(auto simp: top_option_def) lemma top_on_bot: "top_on_acom X (bot c)" @@ -383,23 +388,18 @@ by(auto simp add: top_on_acom_def) lemma top_on_sup: - "top_on_opt X o1 \ top_on_opt X o2 \ top_on_opt X (o1 \ o2 :: _ st option)" + "top_on_opt X o1 \ top_on_opt X o2 \ top_on_opt X (o1 \ o2)" apply(induction o1 o2 rule: sup_option.induct) apply(auto) done -lemma top_on_Step: fixes C :: "('a::semilattice)st option acom" +lemma top_on_Step: fixes C :: "'av st option acom" assumes "!!x e S. \top_on_opt X S; x \ X; vars e \ -X\ \ top_on_opt X (f x e S)" "!!b S. top_on_opt X S \ vars b \ -X \ top_on_opt X (g b S)" shows "\ vars C \ -X; top_on_opt X S; top_on_acom X C \ \ top_on_acom X (Step f g S C)" proof(induction C arbitrary: S) qed (auto simp: top_on_acom_simps vars_acom_def top_on_post top_on_sup assms) - -locale Measure_fun = Measure1_fun + -assumes m2: "x < y \ m x > m y" -begin - lemma m1: "x \ y \ m x \ m y" by(auto simp: le_less m2) @@ -422,9 +422,9 @@ lemma m_o2: "finite X \ top_on_opt (-X) o1 \ top_on_opt (-X) o2 \ o1 < o2 \ m_o X o1 > m_o X o2" proof(induction o1 o2 rule: less_eq_option.induct) - case 1 thus ?case by (auto simp: m_o_def m_s2 less_option_def) + case 1 thus ?case by (auto simp: m_s2 less_option_def) next - case 2 thus ?case by(auto simp: m_o_def less_option_def le_imp_less_Suc m_s_h) + case 2 thus ?case by(auto simp: less_option_def le_imp_less_Suc m_s_h) next case 3 thus ?case by (auto simp: less_option_def) qed @@ -465,7 +465,7 @@ for \ :: "'av::semilattice \ val set" and m :: "'av \ nat" begin -lemma top_on_step': "\ vars C \ -X; top_on_acom X C \ \ top_on_acom X (step' \ C)" +lemma top_on_step': "\ vars C \ X; top_on_acom (-X) C \ \ top_on_acom (-X) (step' \ C)" unfolding step'_def by(rule top_on_Step) (auto simp add: top_option_def fa_def split: option.splits)