src/HOL/Library/RBT_Set.thy
 changeset 53745 788730ab7da4 parent 51540 eea5c4ca4a0e child 53955 436649a2ed62
```     1.1 --- a/src/HOL/Library/RBT_Set.thy	Fri Sep 20 00:08:42 2013 +0200
1.2 +++ b/src/HOL/Library/RBT_Set.thy	Fri Sep 20 10:09:16 2013 +0200
1.3 @@ -628,20 +628,16 @@
1.4    "A \<le> Coset t \<longleftrightarrow> (\<forall>y\<in>Set t. y \<notin> A)"
1.5  by auto
1.6
1.7 -definition non_empty_trees where [code del]: "non_empty_trees t1 t2 \<longleftrightarrow> Coset t1 \<le> Set t2"
1.8 -
1.9 -code_abort non_empty_trees
1.10 -
1.11  lemma subset_Coset_empty_Set_empty [code]:
1.12    "Coset t1 \<le> Set t2 \<longleftrightarrow> (case (impl_of t1, impl_of t2) of
1.13      (rbt.Empty, rbt.Empty) => False |
1.14 -    (_, _) => non_empty_trees t1 t2)"
1.15 +    (_, _) => Code.abort (STR ''non_empty_trees'') (\<lambda>_. Coset t1 \<le> Set t2))"
1.16  proof -
1.17    have *: "\<And>t. impl_of t = rbt.Empty \<Longrightarrow> t = RBT rbt.Empty"
1.18      by (subst(asm) RBT_inverse[symmetric]) (auto simp: impl_of_inject)
1.19    have **: "Lifting.invariant is_rbt rbt.Empty rbt.Empty" unfolding Lifting.invariant_def by simp
1.20    show ?thesis
1.21 -    by (auto simp: Set_def lookup.abs_eq[OF **] dest!: * split: rbt.split simp: non_empty_trees_def)
1.22 +    by (auto simp: Set_def lookup.abs_eq[OF **] dest!: * split: rbt.split)
1.23  qed
1.24
1.25  text {* A frequent case – avoid intermediate sets *}
1.26 @@ -661,15 +657,11 @@
1.27      by (auto simp add: setsum.eq_fold finite_fold_fold_keys o_def)
1.28  qed
1.29
1.30 -definition not_a_singleton_tree  where [code del]: "not_a_singleton_tree x y = x y"
1.31 -
1.32 -code_abort not_a_singleton_tree
1.33 -
1.34  lemma the_elem_set [code]:
1.35    fixes t :: "('a :: linorder, unit) rbt"
1.36    shows "the_elem (Set t) = (case impl_of t of
1.37      (Branch RBT_Impl.B RBT_Impl.Empty x () RBT_Impl.Empty) \<Rightarrow> x
1.38 -    | _ \<Rightarrow> not_a_singleton_tree the_elem (Set t))"
1.39 +    | _ \<Rightarrow> Code.abort (STR ''not_a_singleton_tree'') (\<lambda>_. the_elem (Set t)))"
1.40  proof -
1.41    {
1.42      fix x :: "'a :: linorder"
1.43 @@ -681,7 +673,7 @@
1.44        by (subst(asm) RBT_inverse[symmetric, OF *])
1.45          (auto simp: Set_def the_elem_def lookup.abs_eq[OF **] impl_of_inject)
1.46    }
1.47 -  then show ?thesis unfolding not_a_singleton_tree_def
1.48 +  then show ?thesis
1.49      by(auto split: rbt.split unit.split color.split)
1.50  qed
1.51
1.52 @@ -729,17 +721,16 @@
1.53    "wf (Set t) = acyclic (Set t)"
1.55
1.56 -definition not_non_empty_tree  where [code del]: "not_non_empty_tree x y = x y"
1.57 -
1.58 -code_abort not_non_empty_tree
1.59 -
1.60  lemma Min_fin_set_fold [code]:
1.61 -  "Min (Set t) = (if is_empty t then not_non_empty_tree Min (Set t) else r_min_opt t)"
1.62 +  "Min (Set t) =
1.63 +  (if is_empty t
1.64 +   then Code.abort (STR ''not_non_empty_tree'') (\<lambda>_. Min (Set t))
1.65 +   else r_min_opt t)"
1.66  proof -
1.67    have *: "semilattice (min :: 'a \<Rightarrow> 'a \<Rightarrow> 'a)" ..
1.68    with finite_fold1_fold1_keys [OF *, folded Min_def]
1.69    show ?thesis
1.70 -    by (simp add: not_non_empty_tree_def r_min_alt_def r_min_eq_r_min_opt [symmetric])
1.71 +    by (simp add: r_min_alt_def r_min_eq_r_min_opt [symmetric])
1.72  qed
1.73
1.74  lemma Inf_fin_set_fold [code]:
1.75 @@ -771,12 +762,15 @@
1.76  qed
1.77
1.78  lemma Max_fin_set_fold [code]:
1.79 -  "Max (Set t) = (if is_empty t then not_non_empty_tree Max (Set t) else r_max_opt t)"
1.80 +  "Max (Set t) =
1.81 +  (if is_empty t
1.82 +   then Code.abort (STR ''not_non_empty_tree'') (\<lambda>_. Max (Set t))
1.83 +   else r_max_opt t)"
1.84  proof -
1.85    have *: "semilattice (max :: 'a \<Rightarrow> 'a \<Rightarrow> 'a)" ..
1.86    with finite_fold1_fold1_keys [OF *, folded Max_def]
1.87    show ?thesis
1.88 -    by (simp add: not_non_empty_tree_def r_max_alt_def r_max_eq_r_max_opt [symmetric])
1.89 +    by (simp add: r_max_alt_def r_max_eq_r_max_opt [symmetric])
1.90  qed
1.91
1.92  lemma Sup_fin_set_fold [code]:
```