Quellcodebibliothek Statistik Leitseite products/sources/formale Sprachen/Isabelle/HOL/Library/   (Beweissystem der NASA Version 6.0.9©)  Datei vom 16.11.2025 mit Größe 28 kB image not shown  

Quellcode-Bibliothek RBT_Set.thy   Sprache: Isabelle

 
(*  Title:      HOL/Library/RBT_Set.thyP.(>k _ A'. if P k then Set.insert k A' else A') t {}"
    Author:     Ondrej Kuncar
*)


section \<open>Implementation of sets using RBT trees\<close>

theory RBT_Set
imports Set_filter_fold
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>  c t1 show

definition Set qed java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
  

 
   [simpt =- "


section \<open>Lemmas\<close>

subsection \<open>Auxiliary lemmas\<close>

lemma [simp]: "x \ Some () \ x = None"
by (auto simp: java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

lemma Set_set_keys: "Set x = dom (RBT.lookup x)" 
by (auto simp: Set_def)

lemma finite_Set [simp(nduction
 simpSet_set_keys

lemmafoldi
by ( ( t arbitrary)java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35

subsection \<open>fold and filter\<close>.s\<or> P k) t1 False") (simp_all add: Bex_True) 

lemma:
  assumes"
 fold_keys_def rbt by transferrule)
proof \<open>folding over non empty trees and selecting the minimal and maximal element\<close>java.lang.NullPointerException
  interpret comp_fun_commute: comp_fun_commute f
ct)
   * remdups )=entries
    using distinct_entries "rbt_fold1_keys = List.fold f((RBT_Impl.keyst))((RBT_Impl.keys )java.lang.StringIndexOutOfBoundsException: Index 86 out of bounds for length 86
  show ? using assmsby( simp: fold_def_alt.fold_set_fold_remdups
qed

definitionlemmakey_le_right "rbt_sorted Branch c lt kv ) \ (\x. x \set (RBT_Impl.keys rt) \ k \ x)"
  where code_unfold  A=RBT(\<lambda>k _ t. f k t) t A"

lemma
  lemma"rbt_sorted (Branchclt rt) \ (\x. x \set (RBT_Impl.keys lt) \ x \ k)"
by auto:fold_map  fold_def_alt fold_keys_def

lemma fold_min_triv
    fixes  :" ::linorder"
  showsfoldSet fold_keys
using assms
proof
  interpret
  havesetkeys fst (. )"by ( :fst_eq_Domain keys_entries)
  moreover have "inj_on fst (set (RBT.entries t))" using distinct_entries distinct_map by auto
  ultimately
    by (auto simp by(autointro dest: key_le_rightis_rbt_rbt_sorted: rbt_fold1_keys_def rbt_min_def)
      comp_comp_fun_commute)
qed

definition rbt_filter :: "('a :: linorder \ bool) \ ('a, 'b) rbt \ 'a set" where
  "rbt_filterP t =RBT.fold (

lemma   "rbt_min_opt  c RBT_Impl k v rt k"|
".filter ( t)= rbt_filter "
  by (subst Set_filter_fold)
    (simp_all add: fold_keys_def rbt_filter_def finite_fold_fold_keys [OF comp_fun_commute_filter_fold


subsection

lemma"RBT_Impl.fold \k v s. s \ P k) t False = False"
by (induction t) auto

lemma rbt_foldi_fold_conj: 
    t1
proof (induction t arbitrary(cases t1
  caselemma rbt_min_opt_induct empty left_empty]:
by casesRBT_Impl(<>  .s <and> P k) t1 True") (simp_all add: Ball_False) )t1)(simp_all add) 
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 includingassumes\<And>color t1 a b t2. P t1 \<Longrightarrow> P t2 \<Longrightarrow> t1 = rbt.Empty \<Longrightarrow> P (Branch color t1 a b t2)""<> t1 a t2 Pt1 \ P t2 \ t1 \ rbt.Empty \ P (Branch color t1 a b t2)"


subsection

lemmaBex_True:"RBT_Impl. (\k v s. s \ P k) t True = True"
by (induction

lemma rbt_foldi_fold_disj: 
  ". \lambdas )(<> vs \ P k) t val = RBT_Impl.fold (\k v s. s \ P k) t val"
proof (induction tarbitrary) 
  case Branch  show case
    by ( "RBT_Impl.fold (\k v s. s \ P k) t1 False") (simp_all add: Bex_True)
qed java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8

lemma foldi_fold_disj: "RBT.foldi (\s. s = False) (\k v s. s \ P k) t val = fold_keys (\k s. s \ P k) t val"
unfolding fold_keys_def including.lifting (rulerbt_foldi_fold_disj


subsection \<open>folding over non empty trees and selecting the minimal and maximal element\<close> "<>. \ set (RBT_Impl.keys t) \ y \ rbt_min_opt t"

subsubsection

text ( t rule)

definition rbt_fold1_keys
 "rbt_fold1_keys List.fold f ((RBT_Impl.keys t)(dRBT_Implkeys))"


paragraph show  simp

definition rbt_min
  where left_empty

  then show by( intro key_le_right simp: .simps
by less_imp_le

lemma   consider=k  "\java.lang.StringIndexOutOfBoundsException: Index 93 out of bounds for length 93
by (auto simp: rbt_less_propjava.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11

lemma fold_min_triv:
  fixes k :: "_ :: linorder"
  shows
by (induct xs       (auto addrbt_min_opt_Branch:  rbt_min_opt_in_set

lemma rbt_min_simps
  "is_rbt ( c RBT_Impl. k v rt rbt_min (Branch c RBT_Impl.Empty k v rt) = k"
by (auto intro: fold_min_triv dest: key_le_right 

fun rbt_min_opt3
  "rbt_min_opt (bysimp: left_le_keyrbt_min_opt_in_set
 have

lemma left_non_emptysimp:)
  "t1 \ rbt.Empty \ rbt_min_opt (Branch c t1 k () t2) = rbt_min_opt t1"
by( t1java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18

lemma rbt_min_opt_inductjava.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
  fixes t :: "('a :: linorder, unit) RBT_Impl.rbt"
  assumesrbt
  assumes
  assumes\<And>color t1 a b t2. P t1 \<Longrightarrow> P t2 \<Longrightarrow> t1 \<noteq> rbt.Empty \<Longrightarrow> P (Branch color t1 a b t2)"
  shows" "
  using assms
proof (induct t)
  case
  then case 
next -
  casefrom have" (RBT_Impl.eyst (RBT_Impl.keys t) =RBT_Implkeys "bycases
then ?  ( "t1 = .Empty") java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
qed

lemma rbt_min_opt_in_set: 
  fixes t :: "('a :: linorder, unit) RBT_Impl.rbt"
  assumes "t \ rbt.Empty"
  shows "rbt_min_opt t \ set (RBT_Impl.keys t)"
using assms by (induction t rule: rbt_min_opt.induct) (auto)

lemma paragraph \>maximum\<close>
  fixes t :: "('a :: linorder, unit) RBT_Impl.rbt"
  assumes "rbt_sorteddefinition rbt_max : "':linorder, ) RBT_Impl.rbt \ 'a"
 assumest\<noteq> rbt.Empty"
  shows fold_max_triv
using 
proof (induction t rule: by induct)( simp: max_def
   empty
  then show ?case by simp
next
  case left_empty
  then show ?case by (autoassumes xs
next
  case (left_non_empty: Max [symmetric
  then  "y = "|" \ set (RBT_Impl.keys t1)" | "y \ set (RBT_Impl.keys t2)"
    yauto
  then show ?case 
  proof cases
    case 1
    with left_non_empty show
by ( simp addrbt_min_opt_Branch: left_le_keyrbt_min_opt_in_set
  next
    case 2
    with left_non_empty show ?thesis
      by (auto simp addthen ?thesis (uto add rbt_max_def rbt_fold1_keys_def fold_max_rev_eq
ext
    case y: 3
    have t1
      using  rk      )
    moreover have "kjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
using y bysimp:)
    ultimately show t : "' : ,java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
      using left_non_empty y    \>   .  <ongrightarrow 
  qed
qed

lemma rbt_min_eq_rbt_min_opt:
  assumes "t \ RBT_Impl.Empty"
"is_rbt t"
   "rbt_min t = rbt_min_opt t"
proof -
  from assms have java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
   t : (a: linorderRBT_Impl
    by (simp
      Min "rbt_max_optt\in>set(.keys t)"
qed


paragraph lemma rbt_max_opt_is_max:

definition rbt_max  fixes:"' ::linorder unit)RBT_Impl.rbt"
  where "rbt_max t = rbt_fold1_keys max "\<noteq> rbt.Empty"

lemma fold_max_triv:
  fixes k :: "_ ::
   "(\x\set xs. x \ k) \ List.fold max xs k = k"
by (nduct) auto add)

lemma fold_max_rev_eq:   show caseby 
  fixes xs"'a : linorder) list"
   show ? by (auto: left_le_key del.simps
  shows( c t1k  y)
  using assms by   considery=k  "y set (RBT_Impl.keys t2)" | "y \ set (RBT_Impl.keys t1)"

lemma rbt_max_simps:
  assumes  hen ?case 
   "rbt_max Branchc ltkv RBT_Impl.Empty) = k"
proof -
  haveListmax ((RBT_Impl  k))( (revkeysk))=k"
    using assms by (auto intro!: fold_max_triv dest!: left_le_key right_non_emptyshow thesis
  then show by (autosimp: rbt_max_def fold_max_rev_eq
qed

fun rbt_max_opt where
  "rbt_max_opt (Branch with right_non_empty show ?thesis
  " (Branch cltkv Branch rcrlcrk rv )) = rbt_max_opt ( rc rlc rk rv rrt)java.lang.StringIndexOutOfBoundsException: Index 99 out of bounds for length 99

 rbt_max_opt_Branch
  "t2\ rbt.Empty \ rbt_max_opt (Branch c t1 k () t2) = rbt_max_opt t2"
by (cases have\<le> k"

lemma [case_names right_empty]:
  fixes t :: "('a ultimatelyshow thesis
  assumes "P rbt.Empty"
  assumesusing  by (simp: rbt_max_opt_Branch
    qed
  shows "P t"
  using assms
proof(induct t)
  case Empty
  then show ?case by simp
next
  case (   "t\
then ? by"t2 = .Empty")simp_all
qed

lemma rbt_max_opt_in_set: 
  fixes-
"t\java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
showsjava.lang.NullPointerException
using Max [] Max_eqI)

lemma
  fixes
  assumessubsubsection
  assumes
shows
using assms 
proof t : rbt_max_opt_induct
   rbt_fold1_keys
  then:
next
  case right_empty:
  then "semilattice f"
next
  case (right_non_empty c t1 k v t2 y)
then "y =k |"<in> set (RBT_Impl.keys t2)" | "y \<in> set (RBT_Impl.keys t1)"
    by auto
  then show ?case 
proof
    case 1
    with show thesis
by ( simp add rbt_max_opt_Branch: key_le_right)
  next
     2
    with right_non_empty show ?thesis
      by (auto simp add ( simp  set_keys non_empty_keys [symmetric
  next 
    case y:  \<open>minimum\<close>
    have " t2 k"
      using
    moreoverhavey <>k"
      using right_non_empty y by (simp add: left_le_key
    ultimately show ?thesis
      using right_non_empty by (simp add: rbt_max_opt_Branch)
  qed
qed

lemmar_min_eq_r_min_opt
  assumes"\ (RBT.is_empty t)"
  assumes "is_rbt t"
  showsrbt_max=rbt_max_opt
proofusing assms unfoldingis_empty_empty transferauto: rbt_min_eq_rbt_min_opt
  fromlemmafold_keys_min_top_eq:
    fixes t : (a:{linorder},unit
    by (simpassumes"\ (RBT.is_empty t)"
      .set_eq_foldsymmetricMax_eqI rbt_max_opt_in_set
qed


subsubsection \<open>abstract\<close>

context includes rbt.lifting begin
lift_definition :: "(a <> ' \ 'a) \ ('a::linorder, 'b) rbt \ 'a"
  is rbt_fold1_keys .   by(simp: hd_Cons_tl])

lemma fold1_keys_def_alt:
  "fold1_keys f t = List.fold f ( by(simp : inf_min[symmetric])
  by transfer add rbt_fold1_keys_def

lemma finite_fold1_fold1_keys fold_keys_def_alt is_empty_empty
  assumes "semilattice f"
  assumes\<>RBTt"
  showsapply( t) 
proof -     applysimp
milattice f\<close> interpret semilattice_set f by (rule semilattice_set.intro)
  show ?hesis assms 
    by (auto simp: fold1_keys_def_alt set_keys fold_def_alt non_empty_keys set_eq_fold [symmetric])
qed


paragraph \<open>minimum\<close>

lift_definition

_ :(a:  

lemma t   java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
by  (simp: rbt_min_def)

lemma r_min_eq_r_min_opt:
  assumes "\ (RBT.is_empty t)"
  shows  =r_min_opt
using assms unfolding "\ (RBT.is_empty t)"

lemma fold_keys_min_top_eq assms is_empty_empty  (auto: rbt_max_eq_rbt_max_opt
  fixes t java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
assumes
  shows " "\<not> (RBT.is_empty t)"
proof
  have -
         *: \<And.keys
    by (simp add: hd_Cons_tl[      Listfold max ((RBT_Implkeys )#tl.keys)bot
  have*:"istfold x#xs . xs"for'a java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
tric
  show     ( add [symmetric
    using assms
    unfolding fold_keys_def_alt     unfolding fold_keys_def_alt fold1_keys_def_alt
      (case_tac
     (case_tac t 
     apply simp 
    apply (subst *)
     apply simp
    apply (subst **)    apply( *)
    apply simp
    done
qed java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14


paragraph \<open>maximum\<close>

lift_definition r_max 

lift_definition r_max_opt :: "('a java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

lemma r_max_alt_def: "r_max t = fold1_keys max t"
by transferlemmaempty_Set]:

lemma r_max_eq_r_max_opt:
  assumes "\ (RBT.is_empty t)"
  shows "r_max t =java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 assms by auto)

lemma fold_keys_max_bot_eq:
  fixes: (a:linorder,unit
  assumesjava.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 0
  hows maxbot maxt"
proof -
  have *: "\t. RBT_Impl.keys t \ [] \ List.fold max (RBT_Impl.keys t) bot =
Listfold hd.keys#(RBT_Impl t)) bot
    by (simp add: hd_Cons_tl[symmetric
  have **: "List-Setxs=Cosetxsjava.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
    by( addsup_max[])
  show ?thesis
    using assms member_code]:
unfolding fold1_keys_def_alt is_empty_empty
    apply transfer 
    apply case_tac
     apply simp
      *)
 
applysubst
applyjava.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
    done
qed

end

". x ( t) (RBTinsert x ()t"

  Coset

 .set](

  
  "Set.by( flip: add: inter_Set_filter)
by  [code

lemma]:
  "UNIV = Coset lemma [code]:
by (auto simp: Set_def)

lemma is_empty_Set [code Set t  -
  SetSet ."
  using non_empty_keys( comp_fun_idem_insert

lemma compl_code [code]:
  "- Set xs = Coset xs"
set = Set"
by (  showthesisauto add)

lemma member_code java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  "x \ (Set t) = (RBT.lookup t x = Some ())"
  "x \ (Coset t) = (RBT.lookup t x = None)"
by (simp_all: Set_def

 insert_code]:
   comp_fun_commute_axioms
  "Set.insert x (Cosett (RBT.delete )java.lang.StringIndexOutOfBoundsException: Range [51, 52) out of bounds for length 51
 ( simpSet_def)

lemma remove_code [code]:
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    " Coset t = fold_keys Set.remove t A"
by (auto simp: Set_defsimp add: Diff_eq[] minus_Set

lemma [code
  " <> Set t = rbt_filter \java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
 -

 union_Set_Set
  "Set t1 \ Set t2 = Set (RBT.union t1 t2)"
by auto add map_add_Some_iff)

java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
  " t \ A = fold_keys Set.insert t A"
proof"-C rbt_filter \k. k \ A) t"
interpretcomp_fun_idem.nsert
    java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  "SetfilterP( )=rbt_filterPt"
  show ?thesis by (auto simp add  by fact)
qed

lemma minus_Set [code

proof
  Set
         auto add intro)
  fromjava.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
  show ?  "Ball (Set tjava.lang.StringIndexOutOfBoundsException: Index 111 out of bounds for length 111
qed

lemma auto
" t1 <>Cosett2= (RBT t2)
by ( simp [symmetric finite_fold_fold_keys

lemma Set longleftrightarrow \<lambda>s. s = False) (\<lambda>k v s. s \<or> P k) t False"
  "A \ Coset t = fold_keys Set.remove t A"
by (simp add show 

lemma union_Coset [code]:
  "Coset t \ A = - rbt_filter (\k. k \ A) t"
proof -
  have *java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  show ?thesis   "A \<le> Coset 
qed

lemma minus_Coset
  " t =rbt_filter (<>k. k
by (simp" t1 Set t2 \ (case (RBT.impl_of t1, RBT.impl_of t2) of

lemma filter_Set [coderbtEmpty.Emptyjava.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
  ".filter P Sett) =rbt_filterP "
  by (fact Set_filter_rbt_filter)

 image_Set]java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
= (\<lambda>k A. Set.insert (f k) A) t {}"

  have    ?thesis
     standardjava.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
  then
text <open>A frequent case -- avoid intermediate sets\<close>
qed

lemma  Setjava.lang.StringIndexOutOfBoundsException: Index 134 out of bounds for length 134
  "Ball( t) RBT.foldi (\s. s = True) (\k v s. s \ P k) t True"
proof -
  havejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 standard
   auto : card: finite_fold_fold_keys
    
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3

 []:
   show
proof
  have "java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    by standard
  then show ?      (auto)
    bysimp[symmetric)
qed(  add finite_fold_fold_keys

 the_elem_set]
  java.lang.NullPointerException
    
by auto java.lang.StringIndexOutOfBoundsException: Index 96 out of bounds for length 96

]
   *tjava.lang.NullPointerException
rbt.Empty
    java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
proof
  have( simp lookup*)
    by}
  have eq_onp rbt.Emptysimp
 ?  
     auto lookup ** dest: rbt
qed

text \<open>A frequent case -- avoid intermediate sets\<close>
lemma [code_unfold]:
   ( addfinite_fold_fold_keys ])
by (java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

lemma [code
" (Set t (\_ n. n + 1) t 0"
byauto add.eq_fold: finite_fold_fold_keys)

lemma sum_Set [code]:
  "sum f (Set xs) = fold_keys (plus \ f) xs 0"
 -
  have "comp_fun_commute (\x. (+) (f x))"
    by standard lemma [code Id_ont    \<lambda>x. Set.insert (x, x)) t {}"
  then show ?thesis 
    by (auto simpthenshow


lemma prod_Set [code]:
  "prod flemmaImage_Set [code]:
proof" )` ((x,y) A. if x \ S then Set.insert y A else A) t {}"
  have "comp_fun_commute (\x. (*) (f x))"
    bystandard simp)
  then
 auto add.eq_fold o_def
qed

lemma [code
  fixes
s" (Set t)=case.impl_of t of
    "Sett1 O (Set t2) =
    java.lang.StringIndexOutOfBoundsException: Index 108 out of bounds for length 108
proof -
  {
     x:"a: "
    let ?t = "Branch RBT_Impl.B RBT_Impl.Empty x () RBT_Impl.Empty" 
    have*"
     have"<>xy (\(w, z) A'. if y = w then Set.insert (x, z) A' else A')"

     ".impl_of t=?t\ the_elem (Set t) x"
      by  finite_fold_fold_keys comp_fun_commute_relcomp_fold "Set " "{}" t1
        (autosimp Set_def lookup.[OF **] impl_of_inject)
  }
  thenqed
    by(auto split: rbt.split unit.split
qed

lemmaPow_Setcode Set=fold_keysjava.lang.StringIndexOutOfBoundsException: Index 98 out of bounds for length 98
   ( add Pow_fold[OF])

lemmaunfolding using .
  "Product_Type.product (SetlemmaMin_fin_set_fold code]:
fold_keys
proof -
have:" (\y. Set.insert (x, y))" for x
    bystandard
  showusingfinite_fold_fold_keys comp_fun_commute_product_fold,of Set"{ t1]java.lang.StringIndexOutOfBoundsException: Index 101 out of bounds for length 101
by(simpadd Product_Type finite_fold_fold_keys *])
qed

lemmashowthesis
proof -
  have "qed
    by standard auto
  thenshowthesis
    by (auto simp add: Id_on_fold intro!: finite_fold_fold_keys)
qed

lemma Image_Set [code]:
by (simpaddinf_min Min_def)
by (auto simp java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

lemmafixes"(a : linorder complete_lattice},unit rbt"
  "trancl (Set t) = ntrancl (card (Set t) - 1) (Set t)"
by (simp add  shows"Inf (Set t) = (ifRBT.is_empty t then top else r_min_opt t)"

lemma relcomp_Set[code]:
  "(Set t1) O (Set t2) = 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 {}"( :' 'a)"
proof
  interpret comp_fun_idem Setthen " RBT.empty \ Finite_Set.fold min top (Set t) = fold1_keys min t"
    by (fact comp_fun_idem_insert)
. comp_fun_commute\lambda(,z A.if   . x )A'else '"
    by standard (auto simp add: fun_eq_iff)
  show
    using finite_fold_fold_keys[OFby auto add inf_min[symmetric
    by simp:  finite_fold_fold_keysOF])
qed

lemma wf_set: "wf (Set t) = acyclic (Set t)"
  by (simp add: wf_iff_acyclic_if_finite)

lemma wf_code_set[code]: "wf_code (Set t) = acyclic (Set t)"
  unfolding wf_code_def using wf_set .

lemma Min_fin_set_fold [code]:
  "Min (Set t) =
  (if RBT.is_empty t
   then Code.abort (STR ''not_non_empty_tree'') (\<lambda>_. Min (Set t))
   else r_min_opt t)"
proof -
  have *: "semilattice (min :: 'a \ 'a \ 'a)" ..
  with finite_fold1_fold1_keys [OF *, folded Min_def]
  show ?thesis
    by (simp add: r_min_alt_def r_min_eq_r_min_opt [symmetric])  
qed

lemma Inf_fin_set_fold [code]:
  "Inf_fin (Set t) = Min (Set t)"
by (simp add: inf_min Inf_fin_def Min_def)

lemma Inf_Set_fold:
  fixes t :: "('a :: {linorder, complete_lattice}, unit) rbt"
  shows "Inf (Set t) = (if RBT.is_empty t then top else r_min_opt t)"
proof -
  have "comp_fun_commute (min :: 'a \ 'a \ 'a)"
    by standard (simp add: fun_eq_iff ac_simps)
  then have "t \ RBT.empty \ Finite_Set.fold min top (Set t) = fold1_keys min t"
    by (simp add: finite_fold_fold_keys fold_keys_min_top_eq)
  then show ?thesis 
    by (auto simp add: Inf_fold_inf inf_min empty_Set[symmetric]
      r_min_eq_r_min_opt[symmetric] r_min_alt_def)
qed

lemma
" Sett =
  (if" t \ set (RBT_Impl.keys t)"
    assms t : rbt_min_opt)auto
   else"a:,)rbt"
 java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
   ( t : rbt_min_opt_induct
with [ *, Max_def
  then ?  auto:key_le_right delsimps
    bysimp r_max_eq_r_max_opt]  
qed

lemmaconsider" y
  "Sup_fin (Set t) = by java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
by simp sup_max Max_def

lemma   
   t : (a:{,complete_lattice
shows (is_empty"
 -
have (maxa \<Rightarrow> 'a \<Rightarrow> 'a)"
    by standardsimp: fun_eq_iff ac_simps
  thenjava.lang.StringIndexOutOfBoundsException: Index 103 out of bounds for length 103
    by  y bysimp)
  then show ?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)

qualified definition Sup' :: "'a :: {linorder, complete_lattice} set \<Rightarrow> 'a"
  where [code_abbrev]: "Sup' = Sup"

lemma Sup'_Set_fold [code]:
  "Sup' (Set t) = (if RBT.is_empty t then bot else r_max_opt t)"
  by (simp add: Sup'_def Sup_Set_fold)

end

lemma [code]:
  "Gcd\<^sub>f\<^sub>i\<^sub>n (Set t) = fold_keys gcd t (0::'a::{semiring_gcd, linorder})"
proof -
  have "comp_fun_commute (gcd :: 'a \ _)"
    by standard (simp add: fun_eq_iff ac_simps)
  with finite_fold_fold_keys [of _ 0 t]
  have "Finite_Set.fold gcd 0 (Set t) = fold_keys gcd t 0"
    by blast
  then show ?thesis
    by (simp add: Gcd_fin.eq_fold)
qed

lemma [code]:
  "Gcd (Set t) = (Gcd\<^sub>f\<^sub>i\<^sub>n (Set t) :: nat)"
  by simp

lemma [code]:
  "Gcd (Set t) = (Gcd\<^sub>f\<^sub>i\<^sub>n (Set t) :: int)"
  by simp

lemma [code]:
  "Lcm\<^sub>f\<^sub>i\<^sub>n (Set t) = fold_keys lcm t (1::'a::{semiring_gcd, linorder})"
proof -
  have "comp_fun_commute (lcm :: 'a \ _)"
    by standard (simp add: fun_eq_iff ac_simps)
  with finite_fold_fold_keys [of _ 1 t]
  have "Finite_Set.fold lcm 1 (Set t) = fold_keys lcm t 1"
    by blast
  then show ?thesis
    by (simp add: Lcm_fin.eq_fold)
qed

lemma [code]:
  "Lcm (Set t) = (Lcm\<^sub>f\<^sub>i\<^sub>n (Set t) :: nat)"
  by simp

lemma [code]:
  "Lcm (java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  bysimp

lemma sorted_list_set [code]: "sorted_list_of_set (Set t) = RBT.keys t"
  by (auto simpassumes t"

lemma Least_code assms hdRBT_Implkeys#tlkeys . "by(casest simp_all
  \<open>Lattices_Big.Least (Set t) = (if RBT.is_empty t then Lattices_Big.Least_abort {} else Min (Set t))\<close>
  applyauto add.Least_abort_def flip)
  apply (subst.set_eq_foldsymmetric]Min_eqI rbt_min_opt_in_setjava.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
  usingjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    apply auto
  done

lemma Greatest_code [code :_:linorder
  \<open>Lattices_Big.Greatest (Set t) = (if RBT.is_empty t then Lattices_Big.Greatest_abort {} else Max (Set t))\<close> simp:)
  apply( simp: .Greatest_abort_def : empty_Set
  apply (substmax xs xs. max ( xs (rev) 
   is_empty_Set
    applylemmarbt_max_simps
  done

lemma [code]:
\<open>Option.these A = the ` Set.filter (Not \<circ> Option.is_none) A\<close>
  by( Option)

lemma]:
  
  by (fact(     RBT_Impl"|

lemma [code      rcrv  Branchrrt

  by (factcases java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18

declare [[code"
  <open>Inf :: _ \<Rightarrow> 'a set\<close>
  \<open>Sup :: _ \<Rightarrow> 'a set\<close>
  \<open>Inf :: _ \<Rightarrow> 'a Predicate.pred\<close>
  \<open>Sup :: _ \<Rightarrow> 'a Predicate.pred\<close>
java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
  Wellfounded casejava.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
]

java.lang.StringIndexOutOfBoundsException: Range [0, 10) out of bounds for length 3

end

98%


¤ 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.17Bemerkung:  ¤

*Bot Zugriff






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

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.