# HG changeset patch # User nipkow # Date 1348227570 -7200 # Node ID 2694d1615eefe43d314f9fb690a46bc354f51527 # Parent 675b9df572dfe6d7f5eaedc936baf24697693a48 more termination proofs diff -r 675b9df572df -r 2694d1615eef src/HOL/IMP/Abs_Int3.thy --- a/src/HOL/IMP/Abs_Int3.thy Fri Sep 21 12:27:56 2012 +0200 +++ b/src/HOL/IMP/Abs_Int3.thy Fri Sep 21 13:39:30 2012 +0200 @@ -435,19 +435,10 @@ definition "m_st S = (SUM x:dom S. m(fun S x))" -lemma h_st: assumes "finite X" and "dom S \ X" -shows "m_st S \ h * card X" -proof(auto simp: m_st_def) - have "(\x\dom S. m (fun S x)) \ (\x\dom S. h)" (is "?L \ _") - by(rule setsum_mono)(simp add: m_height) - also have "\ \ (\x\X. h)" - by(rule setsum_mono3[OF assms]) simp - also have "\ = h * card X" by simp - finally show "?L \ \" . -qed +lemma m_st_h: "x \ L X \ finite X \ m_st x \ h * card X" +by(simp add: L_st_def m_st_def) + (metis nat_mult_commute of_nat_id setsum_bounded[OF m_height]) - -(* FIXME identical *) lemma m_st_anti_mono: "S1 \ S2 \ m_st S1 \ m_st S2" proof(auto simp add: le_st_def m_st_def) assume "\x\dom S2. fun S1 x \ fun S2 x" @@ -496,19 +487,22 @@ ultimately show ?thesis by(simp add: n_st_def) qed +definition m_o :: "nat \ 'av st option \ nat" where +"m_o d opt = (case opt of None \ h*d+1 | Some S \ m_st S)" -definition "m_o k opt = (case opt of None \ k+1 | Some x \ m_st x)" +lemma m_o_h: "ost \ L X \ finite X \ m_o (card X) ost \ (h*card X + 1)" +by(auto simp add: m_o_def m_st_h split: option.split dest!:m_st_h) lemma m_o_anti_mono: "S1 \ L X \ S2 \ L X \ finite X \ - S1 \ S2 \ m_o (h * card X) S2 \ m_o (h * card X) S1" + S1 \ S2 \ m_o (card X) S2 \ m_o (card X) S1" apply(induction S1 S2 rule: le_option.induct) -apply(auto simp: m_o_def m_st_anti_mono le_SucI h_st L_st_def +apply(auto simp: m_o_def m_st_anti_mono le_SucI m_st_h L_st_def split: option.splits) done lemma m_o_widen: "\ S1 \ L X; S2 \ L X; finite X; \ S2 \ S1 \ \ - m_o (h * card X) (S1 \ S2) < m_o (h * card X) S1" -by(auto simp: m_o_def L_st_def h_st less_Suc_eq_le m_st_widen + m_o (card X) (S1 \ S2) < m_o (card X) S1" +by(auto simp: m_o_def L_st_def m_st_h less_Suc_eq_le m_st_widen split: option.split) definition "n_o opt = (case opt of None \ 0 | Some x \ n_st x + 1)" @@ -531,7 +525,22 @@ definition "m_c C = (let as = annos C in - \i=0..i L(vars(strip C))" +shows "m_c C \ size(annos C) * (h * card(vars(strip C)) + 1)" +proof- + let ?X = "vars(strip C)" let ?n = "card ?X" let ?a = "size(annos C)" + { fix i assume "i < ?a" + hence "annos C ! i \ L ?X" using assms by(simp add: L_acom_def) + note m_o_h[OF this finite_cvars] + } note 1 = this + have "m_c C = (\i \ (\i = ?a * (h * ?n + 1)" by simp + finally show ?thesis . +qed lemma m_c_widen: "C1 \ Lc c \ C2 \ Lc c \ \ C2 \ C1 \ m_c (C1 \ C2) < m_c C1" @@ -564,7 +573,7 @@ apply(rule n_o_mono) apply(rule narrow2) apply(fastforce simp: le_iff_le_annos listrel_iff_nth) -apply(auto simp: le_iff_le_annos listrel_iff_nth strip_narrow_acom) +apply(auto simp: le_iff_le_annos listrel_iff_nth) apply(rule_tac x=i in bexI) prefer 2 apply simp apply(rule n_o_narrow[where X = "vars(strip C1)"]) @@ -588,7 +597,7 @@ next fix C assume "P C" thus "P (C \ f C)" by(simp add: P_f P_widen) qed -thm mono_step'(*FIXME does not need wt assms*) + lemma iter_narrow_termination: fixes n :: "'a::WN_Lc \ nat" assumes P_f: "\C. P C \ P(f C)"