src/HOL/IMP/Abs_Int3.thy
changeset 51245 311fe56541ea
parent 51036 e7b54119c436
child 51359 00b45c7e831f
equal deleted inserted replaced
51244:d8ca566b22b3 51245:311fe56541ea
    85 
    85 
    86 definition "widen_ivl ivl1 ivl2 =
    86 definition "widen_ivl ivl1 ivl2 =
    87   ((*if is_empty ivl1 then ivl2 else
    87   ((*if is_empty ivl1 then ivl2 else
    88    if is_empty ivl2 then ivl1 else*)
    88    if is_empty ivl2 then ivl1 else*)
    89      case (ivl1,ivl2) of (Ivl l1 h1, Ivl l2 h2) \<Rightarrow>
    89      case (ivl1,ivl2) of (Ivl l1 h1, Ivl l2 h2) \<Rightarrow>
    90        Ivl (if le_option False l2 l1 \<and> l2 \<noteq> l1 then None else l1)
    90        Ivl (if l2 \<le> l1 \<and> l2 \<noteq> l1 then Minf else l1)
    91            (if le_option True h1 h2 \<and> h1 \<noteq> h2 then None else h1))"
    91            (if h1 \<le> h2 \<and> h1 \<noteq> h2 then Pinf else h1))"
    92 
    92 
    93 definition "narrow_ivl ivl1 ivl2 =
    93 definition "narrow_ivl ivl1 ivl2 =
    94   ((*if is_empty ivl1 \<or> is_empty ivl2 then empty else*)
    94   ((*if is_empty ivl1 \<or> is_empty ivl2 then empty else*)
    95      case (ivl1,ivl2) of (Ivl l1 h1, Ivl l2 h2) \<Rightarrow>
    95      case (ivl1,ivl2) of (Ivl l1 h1, Ivl l2 h2) \<Rightarrow>
    96        Ivl (if l1 = None then l2 else l1)
    96        Ivl (if l1 = Minf then l2 else l1)
    97            (if h1 = None then h2 else h1))"
    97            (if h1 = Pinf then h2 else h1))"
    98 
    98 
    99 instance
    99 instance
   100 proof qed
   100 proof qed
   101   (auto simp add: widen_ivl_def narrow_ivl_def le_option_def le_ivl_def empty_def split: ivl.split option.split if_splits)
   101   (auto simp add: widen_ivl_def narrow_ivl_def le_lub_defs le_ivl_def empty_def split: ivl.split lub_splits if_splits)
   102 
   102 
   103 end
   103 end
   104 
   104 
   105 
   105 
   106 instantiation st :: (WN)WN_Lc
   106 instantiation st :: (WN)WN_Lc
   380 qed
   380 qed
   381 
   381 
   382 end
   382 end
   383 
   383 
   384 interpretation Abs_Int2
   384 interpretation Abs_Int2
   385 where \<gamma> = \<gamma>_ivl and num' = num_ivl and plus' = plus_ivl
   385 where \<gamma> = \<gamma>_ivl and num' = num_ivl and plus' = "op +"
   386 and test_num' = in_ivl
   386 and test_num' = in_ivl
   387 and filter_plus' = filter_plus_ivl and filter_less' = filter_less_ivl
   387 and filter_plus' = filter_plus_ivl and filter_less' = filter_less_ivl
   388 defines AI_ivl' is AI_wn
   388 defines AI_ivl' is AI_wn
   389 ..
   389 ..
   390 
   390 
   581 
   581 
   582 subsubsection "Termination: Intervals"
   582 subsubsection "Termination: Intervals"
   583 
   583 
   584 definition m_ivl :: "ivl \<Rightarrow> nat" where
   584 definition m_ivl :: "ivl \<Rightarrow> nat" where
   585 "m_ivl ivl = (case ivl of Ivl l h \<Rightarrow>
   585 "m_ivl ivl = (case ivl of Ivl l h \<Rightarrow>
   586      (case l of None \<Rightarrow> 0 | Some _ \<Rightarrow> 1) + (case h of None \<Rightarrow> 0 | Some _ \<Rightarrow> 1))"
   586      (case l of Minf \<Rightarrow> 0 | Lb _ \<Rightarrow> 1) + (case h of Pinf \<Rightarrow> 0 | Ub _ \<Rightarrow> 1))"
   587 
   587 
   588 lemma m_ivl_height: "m_ivl ivl \<le> 2"
   588 lemma m_ivl_height: "m_ivl ivl \<le> 2"
   589 by(simp add: m_ivl_def split: ivl.split option.split)
   589 by(simp add: m_ivl_def split: ivl.split lub_splits)
   590 
   590 
   591 lemma m_ivl_anti_mono: "(y::ivl) \<sqsubseteq> x \<Longrightarrow> m_ivl x \<le> m_ivl y"
   591 lemma m_ivl_anti_mono: "(y::ivl) \<sqsubseteq> x \<Longrightarrow> m_ivl x \<le> m_ivl y"
   592 by(auto simp: m_ivl_def le_option_def le_ivl_def
   592 by(auto simp: m_ivl_def le_lub_defs le_ivl_def
   593         split: ivl.split option.split if_splits)
   593         split: ivl.split lub_splits if_splits)
   594 
   594 
   595 lemma m_ivl_widen:
   595 lemma m_ivl_widen:
   596   "~ y \<sqsubseteq> x \<Longrightarrow> m_ivl(x \<nabla> y) < m_ivl x"
   596   "~ y \<sqsubseteq> x \<Longrightarrow> m_ivl(x \<nabla> y) < m_ivl x"
   597 by(auto simp: m_ivl_def widen_ivl_def le_option_def le_ivl_def
   597 by(auto simp: m_ivl_def widen_ivl_def le_lub_defs le_ivl_def
   598         split: ivl.splits option.splits if_splits)
   598         split: ivl.splits lub_splits if_splits)
   599 
   599 
   600 definition n_ivl :: "ivl \<Rightarrow> nat" where
   600 definition n_ivl :: "ivl \<Rightarrow> nat" where
   601 "n_ivl ivl = 2 - m_ivl ivl"
   601 "n_ivl ivl = 2 - m_ivl ivl"
   602 
   602 
   603 lemma n_ivl_mono: "(x::ivl) \<sqsubseteq> y \<Longrightarrow> n_ivl x \<le> n_ivl y"
   603 lemma n_ivl_mono: "(x::ivl) \<sqsubseteq> y \<Longrightarrow> n_ivl x \<le> n_ivl y"
   604 unfolding n_ivl_def by (metis diff_le_mono2 m_ivl_anti_mono)
   604 unfolding n_ivl_def by (metis diff_le_mono2 m_ivl_anti_mono)
   605 
   605 
   606 lemma n_ivl_narrow:
   606 lemma n_ivl_narrow:
   607   "~ x \<sqsubseteq> x \<triangle> y \<Longrightarrow> n_ivl(x \<triangle> y) < n_ivl x"
   607   "~ x \<sqsubseteq> x \<triangle> y \<Longrightarrow> n_ivl(x \<triangle> y) < n_ivl x"
   608 by(auto simp: n_ivl_def m_ivl_def narrow_ivl_def le_option_def le_ivl_def
   608 by(auto simp: n_ivl_def m_ivl_def narrow_ivl_def le_lub_defs le_ivl_def
   609         split: ivl.splits option.splits if_splits)
   609         split: ivl.splits lub_splits if_splits)
   610 
   610 
   611 
   611 
   612 interpretation Abs_Int2_measure
   612 interpretation Abs_Int2_measure
   613 where \<gamma> = \<gamma>_ivl and num' = num_ivl and plus' = plus_ivl
   613 where \<gamma> = \<gamma>_ivl and num' = num_ivl and plus' = "op +"
   614 and test_num' = in_ivl
   614 and test_num' = in_ivl
   615 and filter_plus' = filter_plus_ivl and filter_less' = filter_less_ivl
   615 and filter_plus' = filter_plus_ivl and filter_less' = filter_less_ivl
   616 and m = m_ivl and n = n_ivl and h = 2
   616 and m = m_ivl and n = n_ivl and h = 2
   617 proof
   617 proof
   618   case goal1 thus ?case by(rule m_ivl_anti_mono)
   618   case goal1 thus ?case by(rule m_ivl_anti_mono)