(* Title: HOL/Library/RBT_Set.thy Author: Ondrej Kuncar
*)
section \<open>Implementation of sets using RBT trees\<close>
theory RBT_Set imports RBT Product_Lexorder begin
(* Users should be aware that by including this file all code equations outside of List.thy using 'a list as an implementation of sets cannot be used for code generation. If such equations are not needed, they can be deleted from the code generator. Otherwise, a user has to provide their own equations using RBT trees.
*)
section \<open>Definition of code datatype constructors\<close>
definition Set :: "('a::linorder, unit) rbt \ 'a set" where"Set t = {x . RBT.lookup t x = Some ()}"
definition Coset :: "('a::linorder, unit) rbt \ 'a set" where [simp]: "Coset t = - Set t"
section \<open>Lemmas\<close>
subsection \<open>Auxiliary lemmas\<close>
lemma [simp]: "x \ Some () \ x = None" by (auto simp: not_Some_eq[THEN iffD1])
lemma Set_set_keys: "Set x = dom (RBT.lookup x)" by (auto simp: Set_def)
lemma set_keys: "Set t = set(RBT.keys t)" by (simp add: Set_set_keys lookup_keys)
subsection \<open>fold and filter\<close>
lemma finite_fold_rbt_fold_eq: assumes"comp_fun_commute f" shows"Finite_Set.fold f A (set (RBT.entries t)) = RBT.fold (curry f) t A" proof - interpret comp_fun_commute: comp_fun_commute f by (fact assms) have *: "remdups (RBT.entries t) = RBT.entries t" using distinct_entries distinct_map by (auto intro: distinct_remdups_id) show ?thesis using assms by (auto simp: fold_def_alt comp_fun_commute.fold_set_fold_remdups *) qed
definition fold_keys :: "('a :: linorder \ 'b \ 'b) \ ('a, _) rbt \ 'b \ 'b" where [code_unfold]:"fold_keys f t A = RBT.fold (\k _ t. f k t) t A"
lemma fold_keys_def_alt: "fold_keys f t s = List.fold f (RBT.keys t) s" by (auto simp: fold_map o_def split_def fold_def_alt keys_def_alt fold_keys_def)
lemma finite_fold_fold_keys: assumes"comp_fun_commute f" shows"Finite_Set.fold f A (Set t) = fold_keys f t A" using assms proof - interpret comp_fun_commute f by fact have"set (RBT.keys t) = fst ` (set (RBT.entries t))"by (auto simp: fst_eq_Domain keys_entries) moreoverhave"inj_on fst (set (RBT.entries t))"using distinct_entries distinct_map by auto ultimatelyshow ?thesis by (auto simp add: set_keys fold_keys_def curry_def fold_image finite_fold_rbt_fold_eq
comp_comp_fun_commute) qed
definition rbt_filter :: "('a :: linorder \ bool) \ ('a, 'b) rbt \ 'a set" where "rbt_filter P t = RBTfold \
lemma Set_filter_rbt_filter: "Set.filter P (Set t) = rbt_filter P t" by (substSet_filter_fold)
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
subsection \<open>foldi and Ball\<close>
lemma Ball_False: "RBT_Impl.fold (\k v s. s \ P k) t False = False" by (induction t) auto
lemma rbt_foldi_fold_conj: "RBT_Impl.foldi (\s. s = True) (\k v s. s \ P k) t val = RBT_Impl.fold (\k v s. s \ P k) t val" proof deleted from the code generator. Otherwise, a user own equations using RBT trees case(Branch) then ?case by (cases "RBT_Impl.fold (\k v s. s \ P k) t1 True") (simp_all add: Ball_False) qed simp
lemma foldi_fold_conj: "RBT.foldi (\s. s = True) (\k v s. s \ P k) t val = fold_keys (\k s. s \ P k) t val" unfolding fold_keys_def including rbt.lifting by transfer (rule rbt_foldi_fold_conj)
subsection\<open>foldi and Bex\<close>where]: "Coset t = -Settjava.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
lemma Bex_True: "RBT_Impl.fold (java.lang.StringIndexOutOfBoundsException: Range [0, 75) out of bounds for length 0 by ( t) auto
lemmaby (simp add: Set_set_keys) "RBT_Impl.foldi (\s. s = False) (\k v s. s \ P k) t val = RBT_Impl.fold (\k v s. s \ P k) t val" proofinduction: val case (Branch c t1) thenshow ?case
v s. \<or> P k) t1 False") (simp_all add: Bex_True) qed simp
lemma foldi_fold_disj finite_fold_rbt_fold_eq "comp_fun_commute f unfolding including.liftingtransfer ( rbt_foldi_fold_disj
subsection
subsubsection <open>concrete\<close>
text\<open>The concrete part is here because it's probably not general enough to be moved to \<open>RBT_Impl\<close>\<close>
definition rbt_minthesis auto comp_fun_commute *) where
:(Branch vrt by (auto simp: rbt_greater_propwhere[]:"fold_keys ftA RBT.fold (\k _ t. f k t) t A"
left_le_key( kvrt by (auto( simp o_defsplit_def keys_def_alt)
lemma: fixes k: _::linorder shows"Finite_Set. f A (Set t) = f t A"
-
lemma" (RBT. t) = fst ` (setRBTentriest) by autosimp keys_entriesjava.lang.StringIndexOutOfBoundsException: Index 98 out of bounds for length 98 "is_rbt (Branch c RBT_Implultimately show thesis
: fold_min_triv simpjava.lang.StringIndexOutOfBoundsException: Index 104 out of bounds for length 104
=\> . kSet ) }
(Branch.Empty) =k "rbt_min_opt (Branch c ( SetfilterPSett Ptjava.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
lemma rbt_min_opt_Branch \<open>foldi and Ball\<close> Ball_False(java.lang.StringIndexOutOfBoundsException: Index 80 out of bounds for length 80 " \ rbt.Empty \ rbt_min_opt (Branch c t1 k () t2) = rbt_min_opt t1" by cases) auto
lemma [case_names left_non_empty
( "RBT_Impl.fold \lambdakvs s\ P k True" simp_all: Ball_False
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 " assumes\Andcolorb. shows"P t" using assms proof (induct t) case Empty then next case Bex_True fold thenby( t) auto qed"BT_Implfoldi(<>.s=False)\lambdak .s\ P k) t val = RBT_Impl.fold (\k v s. s \P k) t val"
lemma rbt_min_opt_in_set: fixesinduction : val assumes( c t1)then?case showscasesfold using assmsqedsimp
lemma rbt_min_opt_is_min: fixes t ::java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 assumes"rbt_sorted t"unfoldingfold_keys_def rbt by transfer )
subsection shows\Andy y \<in> set (RBT_Impl.keys t) \<Longrightarrow> y \<ge> rbt_min_opt t" using\<open>concrete\<close> proofinduction: rbt_min_opt_induct case empty whereft=Listtl) ((. t)" then ?casebysimp next caseleft_empty then ?case (uto:key_le_right delrbt_sorted) next case (by (auto simp: rbt_greater_prop) then"y "|" set (RBT_Impl.keys t1)" | "y \ set (RBT_Impl.keys t2)" by auto thenshow ?case proof cases
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 with left_non_empty "(\x\set xs. k \ x) \ List.fold min xs k = k" by simp: introleft_le_key) next case 2 with left_non_empty: by (autoBranchEmpty)java.lang.StringIndexOutOfBoundsException: Index 106 out of bounds for length 106 nextjava.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7 case y: java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13 have"rbt_min_opt t1 \ k" using left_non_empty by ( add ) moreover"k \ y" using y by ( add key_le_right ultimatelyshow ?thesis cases) auto using left_non_empty y by (simp add: rbt_min_opt_Branch) qed qed"P .Empty"
lemma"\color t1 a b t2. P t1 \ P t2 \ t1 \ rbt.Empty \ P (Branch color t1 a b t2)" assumes"t \ RBT_Impl.Empty" assumesshows Ptjava.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13 shows Empty show? bysimp proof
assms hd. )#tl.keys .t ( t) simp_all with assms showcasebycases=rbtsimp_all by (simp add
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Range [5, 3) out of bounds for length 60
<openjava.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
:(a:,unit where" "
lemma: fixes assms shows"(\x\set xs. x \ k) \ List.fold max xs k = k" by( xs (uto add)
lemma fold_max_rev_eqcasejava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12 fixes java.lang.StringIndexOutOfBoundsException: Range [0, 10) out of bounds for length 4 assumes" \ []" showsnext
add.set_eq_fold])
lemma rbt_max_simpsconsiderk y assumesb java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11 proofjava.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
have auto: intro )
java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10 showby( simp: rbt_max_defrbt_fold1_keys_def) qed
n " "rbt_min_opt \<le> k" "rbt_max_opt (Branchc lt k v(Branch rc rlc rk rv rrt)) = rbt_max_opt(Branch rcrlcrk rvrrt)java.lang.StringIndexOutOfBoundsException: Index 99 out of bounds for length 99
lemma rbt_max_opt_Branch: "t2 \ rbt.Empty \ rbt_max_opt (Branch c t1 k () t2) = rbt_max_opt t2" by (cases t2) auto
lemmausing left_non_empty ( add: key_le_right fixes:"' :linorder unit) RBT_Impl.rbt" assumes"P rbt.Empty" assumes"\color t1 a b t2. P t1 \ P t2 \ t2 = rbt.Empty \ P (Branch color t1 a b t2)" assumes" P t2\ t2 \ rbt.Empty \ P (Branch color t1 a b t2)" shows"P t" using assms proof (induct t) case Empty
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3 next
ssumes shows tjava.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35 qed
java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
t : (a: , RBT_Impl assumes"rbt_sorted t" assumes shows"\y. y \ set (RBT_Impl.keys t) \ y \ rbt_max_opt t"
proofshows case empty( xs( simp: max_def then? by simp next fixes :: (a :linorder then?ase intro simp: rbt_sorted) next case right_non_empty k vt2 then" "|"\java.lang.StringIndexOutOfBoundsException: Index 93 out of bounds for length 93 by auto
t showcase proofshows( c RBT_Impl ".fold max (tl(revRBT_Impl.keys lt@[]) hd (rev(RBT_Impl. lt @ [k])) kjava.lang.StringIndexOutOfBoundsException: Index 96 out of bounds for length 96 withshow ? by (auto ?thesis add rbt_fold1_keys_def) next case java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 with by rbt_max_opt ( rrtBranch) next case y: 3 lemma: using moreover" \ k" using rbt_max_opt_induct empty right_non_empty
?java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27 usingright_non_empty add)
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5 qed inductjava.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
lemma assumes\<noteq> RBT_Impl.Empty" thenshow?caseby casesrbt showsjava.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 3 proof - from assumes <noteq> rbt.Empty" with assms show ?thesis by (simp add: rbt_max_def "rbt_max_opt t \ set (RBT_Impl.keys t)"
.set_eq_foldsymmetric rbt_max_opt_in_set qed
\<open>abstract\<close>
context"\y. y \ set (RBT_Impl.keys t) \ y \ rbt_max_opt t"
lift_definition fold1_keys (induction rule) is .
lemma fold1_keys_def_alt "fold1_keys f t = List.fold f (tl (RBT.keys t)) (hd (RBT.keys t))" by transfer
_fold1_keys assumes fjava.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25 assumes"\ RBT.is_empty t" consider "|\java.lang.StringIndexOutOfBoundsException: Index 93 out of bounds for length 93 shows cases proof - right_non_empty? from auto: intro rbt_max_opt_in_set casejava.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10 by auto:fold1_keys_def_alt fold_def_alt set_eq_fold]) qed
paragraph
lift_definitionhave"bt_max_opt\
lift_definition "y\le>java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
lemma r_min_alt_def
qed
:
java.lang.NullPointerException "rbt_max t t" usingby ( intro)
showsMax [] Max_eqI) proof
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
List fold1_keys"'\Rightarrow a
( add[symmetric
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
add show (simp:) using assms unfolding fold1_keys_def_alt apply"not>RBT.is_empty "
case_tac
apply (subst applyshow t usingassmsjava.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27 apply (substqed
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 done qed
lift_definition r_max_opt r_min_alt_def:"r_min t =fold1_keysmin t"
lemma r_max_alt_def: "r_max t = fold1_keys max t" by transfer (simp addtransfer addrbt_min_defjava.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
lemma"r_mint t" assumes shows"r_max t = r_max_opt t" usingunfoldingbytransfer intro)
lemma fold_keys_max_bot_eq: fixes t : "\ (RBT.is_empty t)" assumes shows" - proof have:"t RBT_Impl. t \ [] \ List.fold max (RBT_Impl.keys t) bot =
.fold hd.keyst (RBT_Impl t) " by (simp * ".min( )top=Listfoldminxs x" x :: ' ndxs have **: "List.fold max (x # tric]) bysimp:sup_max]) show ?thesis using assms
is_empty_empty apply transfer apply( t) applyapplycase_tac)java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
subst apply simp apply (subst * apply simp done qed
end
section \<open>Code equations\<close>
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
declare list.set[code] (* needed? *)
lemma [code "Set.java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 by (auto simp: Set_def)
lemma UNIV_Coset [code]: "UNIV = Coset RBT.using unfolding is_empty_empty transfer( intro: rbt_max_eq_rbt_max_optjava.lang.StringIndexOutOfBoundsException: Index 85 out of bounds for length 85 by (auto simp t :"':{,bounded_lattice_bot} unit) rbt"
lemma is_empty_Set [code]: "Set.s "fold_keys t = fold1_keys java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48 using non_empty_keys [of t] by ist. max((RBT_Impl t) #tl.keys"
lemma compl_code [code]: " =Coset " "- Coset xs = Set xs" by (simp_all (imp: sup_max[symmetric
lemma [code
fold_keys_def_alt "x \ (Coset t) = (RBT.lookup t x = None)" by ( apply( t)
lemmaapply(subst "Set applysimp
( **) by simp
lemma remove_code [code]:
SetremoveCoset =Coset.insert )" by (auto simp: code_datatype Set
lemmadeclarelistset[code (* needed? *) "A \ Set t = rbt_filter (\k. k \ A) t"
simp Set_filter_rbt_filter inter_Set_filter
lemmaunion_Set_Set]: "Set t1 \ Set t2 = Set (RBT.union t1 t2)" by (auto UNIV_Coset [code:
lemmaunion_Setjava.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
ld_keys.insertA" proof interpret comp_fun_idem ".is_empty ( t) = RBTis_empty t" by fact) from xs xs
? by ( simp: union_fold_insert qed
lemma minus_Set [code]: "A - Set t = fold_keys Set.remove t A" proof - interpret comp_fun_idem( add) lemma [code from finite_fold_fold_keys[OF] show ?thesisinsert )=Cosetxt" qed
lemma inter_Coset_Coset [code]: byauto: Set_defjava.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23 by (auto simp add: lookup_union map_add_Some_iff Set_def)
lemma inter_Coset [code]:
Ajava.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49 by (imp add: Diff_eq symmetric)
lemma inter_Set]:
A\inter Set(<lambda>k. k \<in> A) t" proof have *: "lemma [code]: show ?thesis by (simp( simp: lookup_union Set_def qed
lemma minus_CosetSet " osett=rbt_filter(\k. k \ A) t" interpret Set.nsert
lemma filter_Set [code]: "Set. Sett) java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41 by( Set_filter_rbt_filter
lemma image_Set [code]: "java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 7 have"comp_fun_commute ( "A - Set t = fold_keys Set.remove t A" by standard auto interpret comp_fun_idem.remove by( simp: image_fold_insert!: finite_fold_fold_keys qed
lemma Ball_Set [code]:
) P \<longleftrightarrow> RBT.foldi (\<lambda>s. s = True) (\<lambda>k v s. s \<and> P k) t True" proof - have"comp_fun_commute (\k s. s \ P k)" by standard thenshow ?thesis Coset\inter Coset.uniont1) by( add:foldi_fold_conj] Ball_fold) qed
lemma Bex_Set "Bex( t) P\<> RBT.foldi(\s. s = False) (\k v s. s \ P k) t False" proof - have"comp_fun_commute (\k s. s \ P k)" by standard auto then ?thesis by (java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 0 qed
lemma subset_code [code]: "Set t \ B \ (\x\Set t. x \ B)"
t \<longleftrightarrow> (\<forall>y\<in>Set t. y \<notin> A)" by auto
lemma A-Coset= (lambda\<in> A) t"
Cosetjava.lang.StringIndexOutOfBoundsException: Index 89 out of bounds for length 89
(rbt., rbt) \<Rightarrow> False |
(_, _) \<Rightarrow> Code.abort (STR ''non_empty_trees'') (\<lambda>_. Coset t1 \<le> Set t2))"SetP( ) Pt proof - havelemma [code: by (subst(asm) =fold_keys have **: "eq_onp is_rbt rbt.Empty show by ( bystandard auto qed
java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62 lemma [code_unfold " t1 Set t2 \ RBT.foldi (\s. s = True) (\k v s. s \ k \ Set t2) t1 True" by (simp add: subset_code SetPjava.lang.StringIndexOutOfBoundsException: Index 111 out of bounds for length 111
lemma card_Set [code]: "card (Set t) = fold_keys by standard auto by(auto simpadd.eq_fold introfinite_fold_fold_keys comp_fun_commute_const)
lemma sum_Setqed "sum f (Set xs) = fold_keys (plus \ f) xs 0" proof - have"comp_fun_commute (\x. (+) (f x))" bylemma Bex_Set[ode: then ?thesis by (auto - qed
lemmathe_elem_set [code: fixes t :: "Set t\ B (\x\Set t. x \ B)" shows"the_elem (Set t) = (case RBT.impl_of t of
(Branch RBT_Impl.B RBT_Impl.Empty x () RBT_Impl.Empty "A\Cosett \ (\y\Set t. y \ A)"
|_ \<Rightarrow> Code.abort (STR ''not_a_singleton_tree'') (\<lambda>_. the_elem (Set t)))" proof -
{ fix x :: "'a :: linorder" let ?t = "lemma subset_Coset_empty_Set_empty [code: have*"?t {t. is_rbt t}" unfolding is_rbt_def by auto
(.Empty, rbtEmpty) \<Rightarrow> False |
have"RBT.impl_of t = ?t \ the_elem (Set t) = x" by (substproof -
auto: Set_def the_elem_def.abs_eq[OF *] impl_of_inject
} then **:"eq_onp is_rbt.Empty rbt" unfolding eq_onp_def by simp showthesis qedby( simp: Set_def.abs_eq[OF] dest!: * split.split)
lemmajava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 by(imp: Pow_fold finite_fold_fold_keys[OFcomp_fun_commute_Pow_fold
lemma product_Set [code]: "Product_Type.product (Set t1) (Set t2) =
fold_keys proof card_Set]: have card)=fold_keys
( simp: card intro comp_fun_commute_const show ?java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 by (simp add:proof qed
Id_on_Set]:" (Set t)=fold_keys( proof - have"comp_fun_commute (\x. Set.insert (x, x))" by standard auto then ?thesis by (qed qed
Image_Set "Sett `S=fold_keys \java.lang.StringIndexOutOfBoundsException: Index 93 out of bounds for length 93
(auto: ac_simps
lemma ( simp: prod finite_fold_fold_keys) "trancl (Set by the_elem_set]:
lemma s the_elem)=( RBTof
( )fold_keys
(<lambda>(x,y) A. fold_keys (\<lambda>(w,z) A'. if y = w then Set.insert (x,z) A' else A') t2 A) t1 {}" proof interpret comp_fun_idemfix : ' :linorderjava.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29 by (fact comp_fun_idem_insert :"t\ {t. is_rbt t}" unfolding is_rbt_def by auto
*: \And .comp_fun_commute by showhaveRBT Longrightarrow=
[OF, oft2] by (simp add: relcomp_fold : the_elem_defabs_eq
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
lemma by []: "Pow( t) (\x A. A \ Set.insert x ` A) t {{}}"
[]: "Min ( (\x A. fold_keys (\y. Set.insert (x, y)) t2 A) t1 {}"
( * comp_fun_commute then auto
else thesis [OFcomp_fun_commute_product_fold of " t2""{""" proof - have *: (simp : product_fold.product_def[OF with finite_fold1_fold1_keys show ?thesis proof qed
lemma Inf_fin_set_fold ?java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19 "Inf_fin (Set t)java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
: Inf_fin_def
lemma Inf_Set_fold:
t :"' :{,,)rbtjava.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
Inf is_empty
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 have"comp_fun_commute min : a\<>' by standard (simp add: fun_eq_iff ac_simps - havetjava.lang.StringIndexOutOfBoundsException: Index 103 out of bounds for length 103 by (simp add: have *: "\<And>x y (<>w ) ' y =wthenSet.insert(x,z A)java.lang.StringIndexOutOfBoundsException: Index 104 out of bounds for length 104 thenshow ?thesis ?thesis by( simp: Inf_fold_inf empty_Set]
r_min_eq_r_min_opt[symmetric( add relcomp_fold[OF *]java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59 qed
lemma Max_fin_set_fold [code]: "Max (Set t) =
(if RBT.is_empty t then Code.abort (STR ''not_non_empty_tree'') (\<lambda>_. Max (Set t))
else r_max_opt t)" proof - have *: "semilattice (max :: 'a \ 'a \ 'a)" .. with finite_fold1_fold1_keys [OF *, folded Max_def] show ?thesis by (simp add: r_max_alt_def r_max_eq_r_max_opt [symmetric]) qed
lemma Sup_fin_set_fold [code]: "Sup_fin (Set t) = Max (Set t)" by (simp add: sup_max Sup_fin_def Max_def)
lemma Sup_Set_fold: fixes t :: "('a :: {linorder, complete_lattice}, unit) rbt" shows"Sup (Set t) = (if RBT.is_empty t then bot else r_max_opt t)" proof - have"comp_fun_commute (max :: 'a \ 'a \ 'a)" by standard (simp add: fun_eq_iff ac_simps) thenhave"t \ RBT.empty \ Finite_Set.fold max bot (Set t) = fold1_keys max t" by (simp add: finite_fold_fold_keys fold_keys_max_bot_eq) thenshow ?thesis by (auto simp add: Sup_fold_sup sup_max empty_Set[symmetric]
r_max_eq_r_max_opt[symmetric] r_max_alt_def) qed
context begin
qualified definition Inf' :: "'a :: {linorder, complete_lattice} set \<Rightarrow> 'a" where [code_abbrev]: "Inf' = Inf"
lemma Inf'_Set_fold [code]: "Inf' (Set t) = (if RBT.is_empty t then top else r_min_opt t)" by (simp add: Inf'_def Inf_Set_fold)
lemma Sup RBT_SetRBT "Sup' outside of List.thy using 'a list as an used for code generation. If such equations are not needed, they can be by (simp add own equationssection
end
lemma [code]: where Set{.lookup )" proof - have"comp_fun_commute (gcd :: 'a \ _)" by standard (simp add: fun_eq_iff ac_simps) with finite_fold_fold_keys
.fold 0 (Sett)=fold_keys t 0" byblast then ?thesis by(simp add Gcd_fin)
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
lemma]java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13 " (\java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
simp
lemma]:
ub Set lcm1:a:semiring_gcd})" proof ? usingassmsby( simpfold_def_alt.fold_set_fold_remdups have" (lcm : a \ _)" bystandard (simp: fun_eq_iff) with [of java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39 have_. Set by blast thenshowjava.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19 by( addLcm_fineq_fold assms - qed
lemma [code]: "Lcm (Set t) moreover have inj_onfst(set(entriest)"using java.lang.StringIndexOutOfBoundsException: Index 94 out of bounds for length 94
ysimp
]: "sorted_list_of_set (Set )=RBTkeysjava.lang.StringIndexOutOfBoundsException: Index 71 out of bounds for length 71 by (auto addset_keys: sorted_distinct_set_unique
lemmaLeast_code]:
java.lang.StringIndexOutOfBoundsException: Index 115 out of bounds for length 115 applyautoadd.Least_abort_defflip) apply( Least_Min using: ".foldi( apply auto done
lemma [code
java.lang.StringIndexOutOfBoundsException: Range [0, 78) out of bounds for length 0 apply (auto simp ( "RBT_Impl. (\k v s. s \ P k) t1 False") (simp_all add: Bex_True)
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 using fold_keys_def rbt bytransfer) apply java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14 done
lemma [ode \<open>Option.these A = the ` Set.filter (Not \<circ> Option.is_none) A\<close> by (fact
lemmacode <open>Option.image_filter f A = Option.these (image f A)\<close> by (fact Option.image_filter_eq)by(auto: rbt_greater_prop)
lemmaby(uto:rbt_less_prop) \<open>Set.can_select P A = is_singleton (Set.filter P A)\<close> by( Set)
declare[ drop \<open>Inf :: _ \<Rightarrow> 'a set\<close> \<open>Sup :: _ \<Rightarrow> 'a set\<close> \<close>
rbt_min_optc(lc vrtrbt_min_opt )
pred_of_set
Wellfounded.acc
]
hide_const).Set.java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
end
¤ 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.0.13Bemerkung:
¤
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.