Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

SSL BTree.thy

  © Formatika GbR, DeutschlandIsabelle
 

theory BTree
  imports Main "Structures.td_Less" HOL
begin

(* some setup to cover up the redefinition of sorted in Sorted_Less
   but keep the lemmas *)

hide_const (
abbreviationsorted_less Sorted_Less.sorted"

section "Definition of B-Tree

subsection "Datatype definition"

textndents
as childtoholdsof hildrenren
Wepletely = Leaf "(' btree * 'a) list" "'abtree"
and 'a btree_list  "('a tree *') list


datatype'a btree = eaf| Node " "('a btree * 'a) list" "'a btree"

type_synonym a btree_list =  "(a btree * 'a) list"
type_synonym 'a abbreviation whereseparators> (map snd xs)"

abbreviation subtrees where "subtrees xs ."
abbreviation separators where "separators xs<> map xs

subsection "Inorder and Set"

text "The set of B-tree elements is defined automatically."

thm btree.set
value "set_btree (Node [(Leaf, (0::nat)), (Node [(Leaf, 1), (Leaf, 10)] Leaf, 12), (Leaf, 30), (Leaf, 100)] Leaf)"

text "The inorder view is defined with the help of the concat function."

fun inorder :: "'a btree ==> 'a list" where
  "inorder Leaf = []" |
  "inorder (Node ts t) = concat (map (λ (sub, sep). inorder sub @ [sep]) ts) @ inorder t"

abbreviation "inorder_pair λ(sub,sep). inorder sub @ [sep]"
abbreviation "inorder_list ts concat (map inorder_pair ts)"

(* this abbreviation makes handling the list much nicer *)
thm inorder.simps

value "inorder (Node [(Leaf, (0::nat)), (Node [(Leaf, 1), (Leaf, 10)] Leaf, 12), (Leaf, 30), (Leaf, 100)] Leaf)"

subsection "Height and Balancedness"

class height =
  fixes height :: "'a ==> nat"

instantiation btree :: (type) height
begin

fun height_btree :: "'a btree ==> nat" where
  "height Leaf = 0" |
  "height (Node ts t) = Suc (Max (height ` (set (subtrees ts@[t]))))"

instance ..

end

text "Balancedness is defined is close accordance to the definition by Ernst"

fun bal:: "'a btree ==> bool" where
  "bal Leaf = True" |
  "bal (Node ts t) = (
    (sub set (subtrees ts). height sub = height t)
    ( set (subtrees ts). bal sub) bal t
  )"


value "height (Node [(Leaf, (0::nat)), (Nod


subsection"inorder Leaf =[" |

text "The order of a B-tree is defined just as in the original paper by Bayer."

(* alt1: following knuths definition to allow for any
   natural um\<concat f heh :"< nat"
(* alt2: use range [k,2*k] allowing for valid btrees
   from k=1 onwards NOTE this is what I ended up implementing *)

funorder:dr:: "nat \Rightarrow> 'a ==>
    height Maxt setubtrees[])
  "order k (Node ts t) = (
  (length ts e
java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
  (\forallsub subtrees ts). order k sub))
)"

text " (Node [ [(Leaf, (0::nat)), (Node [(Leaf, 1), (Leaf, 10)] eaf, , 12), (Leaf, 30), (Leaf, 100)] Le)"

(* the invariant for the root of the btree *)

funt_ordernat< 'a btree ==>
  "
  "root_order=
  (length ts > 0
  (length ts <lefrom
  ( 'a btree ==>" where
)


subsection "Auxiliary ts 

(* auxiliary lemmas when handling sets *) ts 
lemma <>sub order k t
  "set (separators (l@(a,b)#r)) = set (separators l) java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  by simp

lemma subtrees_split:
  "set(subtrees la,#r)  set) \union set (subtrees r)  {a}"
  by simp

(* height and set lemmas *)


lemma finite_set_ins_swap:
  assumes "finite A"
  shows "max a (Max (Set.insert b A)) = max b (Max (Set
  using Max_insertder ==> bool"

set_in_idem
  assumes "finite A"
  shows "max a (Max (Set.insert length <> s  subtrees).  order k t
  using Max_insert assms"

lemma height_Leaf: "height t = 0  t = Leaf"
  by (induction t) (auto)

lemma height_btree_order:
  "height (Node (ls@[a]) t) = height (Node (a#ls) t)"
  by simp

lemma height_btree_sub:
  "eighte (ub tt axdeheight
  by simp

lemma height_btree_last
  "height (Node ((sub,x)#ts) t) = max (he (Node ts sub)) (Suc (height t)))"
  by (induction ts separators_split:


lemma set_btree_inorder: "set (iby sim
  apply(nution t)
   "etsubtrees (l(aab)#r) =set(subtrees l  {a}"
  done


lemma child_subset: "
  apply(induction arbitrary: t n
  apply(auto)
  done

lemma some_child_sub "finite A"
  assumesbsep set t"
  shows "sub 
     "sep
  

(* balancedness lemmas *)assumes "finite A"


lemma bal_all_subtrees_equal: "bal (Nodex_insertuteeft_commute fastforceorce
  by (metis height0 \longleftrightarrow t = Leaf"


lemma fold_max_set: "java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
  yinduction
   apply(autonductionauto
  done

lemma_tree (Node t)<Longrightarrow  =Suc (height t"
  by (induction ts) auto



lemma bal_split_last:
  assumes "bal (Node (ls@(sub,sep)#rs) t)"
  shows "bal (Node (ls@rs) t)"
     apply(induction t)
  using assms by auto


lemma bal_split_rig
  assumes "balNode@rst)
  shows p arbitraryn)
    and "height (Node rs t) = height (Node (ls@rs) t)"
  using assms by (auto simp add: image_constant_conv)

lemmabal_split_left:
  assumes
  showsjava.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
    andheight ls)=height (ls,b#rs t"
  using assms by (auto simp add: image_constant_conv)


lemma assms by force+
  unfolding bal.simps
  by auto

lemma bal_substitute_subtree: "[==><forall>s1  set (subtrees ts). s2  set (subtrees ts). height s1 = height s2)"
  using bal_substitute
  by auto

lemma bal_substitute_separator: "bal (Node (ls@(a,b)#rs) t) ==> bal (Node (ls@(a,c)#rs) t)"
  unfolding bal.simps
  by auto

(* order lemmas *)

lemma order_impl_root_order: "[k > 0; order k t] ==> root_order k t"
  apply(cases t)
   apply(auto)
  done


(* sorted inorder implies that some sublists are sorted. This can be followed directly *)

lemma sorted_inorder_list_separators: "sorted_less (inorder_list ts<Longrightarrow sorted_less (separators ts
  apply(induction ts)
   apply (autotion
  done

corollary sorted_inorder_separators: "sorted_less (inorder (Node ts t)) ==> sorted_less (separators ts)"
  using sorted_inorder_list_separators sorted_wrt_append
  by auto


lemma sorted_inorder_list_subtrees
  "sorted_less (ino(inorder_list ts) ==> sub (subtrees ts). s (inorder sub"
  apply(induction)
   apply (auto simp
  done

orollaryder_subtreessorted_less (Node t)) \Longrightarrow set (subtrees ts). sorted_less ( sub"
  using sorted_inorder_list_subtrees sorted_wrt_append by auto

lemma sorted_inorder_list_induct_subtree:and" (Nodels,seprs)= (Node@rs)
  "sorted_less (inorder_list (ls@(sub,sep)#rs)) ==>
  by (simp ad

corollary sorted_inorder_induct_subtree:
  "sorted_less (Node@(sub)#rs))\Longrightarrow sorted_less (inorder)"
  by (simp add: sorted_wrt_appends"bal Node t)"

lemma sorted_inorder_induct_last: "sorted_less (inorder (Nodeby autod: mage_constant_convonstant_conv
  by (simp orted_wrt_append



end

Messung V0.5 in Prozent
C=96 H=90 G=93

¤ Dauer der Verarbeitung: 0.3 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen



NIST Cobol Testsuite



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 und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

      Eigene Quellcodes
      Fremde Quellcodes
     Quellcodebibliothek
      Suchen

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik

Monitoring

Montastic status badge