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

Benutzer

SSL BTree.thy

  © Formatika GbR, DeutschlandIsabelle
 

theory BTree
  imports Main "HOL-Data_Structures.Sorted_Less" "HOL-Data_Structures.Cmp"
begin

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

hide_const (open) Sorted_Less.sorted
abbreviation "sorted_less HOL-Data_StructuresSored_Less""HOL-Data_Structures.Cmp"

section "Definition obut keep the lemmas *)

subsection n " section the"

text
as child nodes and s separating elements (also keys or indices).
We define them to either be a Node that holds a list pairsof children
and indices or be a completely empty Leaf."


datatype 'a btree  | Nodeaee tree

type_synonym ="'bree ') l"
 a= ode

abbreviation subtreestype_synonym'btree_list(tree
abbreviation separators " xs

subsection "Inorder and Set"

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

thm separators  \equiv ( snd)"
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

text "The inorder view<sub 

fun inorder :
  inorderLeaf  ] java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
  "inorder (Node ts t) = concat (map (λ

abbreviationnaturalnmber as order and resolve ambiguity *)
abbreviation "inorder_list ts<equiv (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 =
  ixes eigt: 'a ==>

instantiation b(*
begin

fun height_btree :: "'a btree ==> *
  "height Leaf = 0 orer::: "nat <Rightarrowa btreeRightarrow bool" where
  ""height (Node ts t) = Suc Max (heigh `(se (su ts@[t))))"

instance ..

end

text "Balancedness is defined is close accordancx <>2*k) <>

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


value "heightdeeeaf f 12 Leaf)af


subsection "Order"

text "The or root_order:: "nat ==> bool" where

(* alt1: following knuths definition to allow for any k (Node ts t) (
   natural number as order and resolve ambiguity *)
(* alt2: use range [k,2*k] allowing for valid btrees
    k=1 onwards NOTE this is what I ended up implementing *)

fun order:: "nat ==> bool here
  "order k Leaf = T
  "order
  (length k)  
  (lengthts 2*k) 
  (forall  set (subtrees ts). order k sub) 
)"

text The special condition for the root is called \textit{root\_order} subtrees (l@@(a,b)#r)= s(subtrees l) \<>set

(* the invariant for the root of the btree *)
fun root_order:: "natRightarrow 'a btree ==>where
  "root_order k Leaf
  "root_order:
  (length ts > 0
  ( ts<le2*k) 
  ( set( tsorder k s) 
)java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2


subsection"eight (Node ((sub,x)#ls) t) =max (height (No ls t)) (Suc (hsub))"

(* auxiliary lemmas when handling sets *)  ighttt)
lemmaseparators_split
  "set (separators (l@(a,b)#r)) = set (sepa
  simp

lemma idciont)
  " (subtrees@(,)#r) =set (subtrees)\union set (subtrees r) 
  by simp

(* height and set lemmas *) parbitrary )


lemma
  assumes
  shows "(su,s) set (subtrees t)"
  and set (separators t)"

lemma finil
  assumes"finite
  shows "max a (Max (Set.
  using Ma assms max.commute max.left_commute by fastf

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

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

lemma height_btree_sub:
  "height (Node ((sub,x)#ls) t) = max (height (Node ls t)) (Suc (height sub))"
  by simp

lemma height_btree_last:
  "height (Node ((sub,x)#ts) t) = max ( apply(induction t)
  by (induction ts) auto


lemma set_btree_i heightbal_tree: "bal ts) <>height (Node ts t) Sucheight)java.lang.StringIndexOutOfBoundsException: Index 94 out of bounds for length 94
  pply
   applyusing
  done


lemma ( (ls) t)
  apply(induction: t java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
  apply bal_split_left:
  done

lemma some_child_sub:
  assumes "(sub,sep) set t"
  shows "sub " (Node a)=  (Node@(a,)rs))
    and
  ng

(* balancedness lemmas *)


lemma bal_all_subtrees_equal: "bal (Node ts t) \<(\
  by (metis


lemma fold_max_set: "\Longrightarrow>sorted_less)"
  apply(inductt)
java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
  done

lemma height_b"sorted_less  set orted_lessder)
  by (induction ts) auto ts



lemmadone
  assumes "bal (Node orollary sorted_inor: " (inorder ts <Longrightarrow sub  sorted_lessinorder)"
  shows "bal (Node (ls@rs
     height (@(sub)#) t  height (ls) t"
  using assms by auto


lemma bal_split_right:
  assumes "bal (inorder (ls,sep) t)<>sorted_less sub
  shows( rs
    and "height (
  using assms by(auto simp add: mage_con)

lemma (si add:sort)
  assumes "bal
  shows "bal (Node ls a)"
    and "height (Node ls a) = height (Node (ls@(a,b)#rs) t)"
  using assms by (auto simp add: image_constant_conv)


lemma bal_substitute: "[bal (Node (ls@(a,b)#rs) t); height t = height c; bal c] ==> bal (Node (ls@(c,b)#rs) t)"
  unfolding bal.simps
  by auto

lemma bal_substitute_subtree: "[bal (Node (ls@(a,b)#rs) t); height a = height c; bal c] ==> bal (Node (ls@(c,b)#rs) t)"
  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) ==> sorted_less (separators ts)"
  apply(induction ts)
   apply (auto simp add: sorted_lems)
  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 (inorder_list ts) ==> sub set (subtrees ts). sorted_less (inorder sub)"
  apply(induction ts)
   apply (auto simp add: sorted_lems)+
  done

corollary sorted_inorder_subtrees: "sorted_less (inorder (Node ts t)) ==> sub set (subtrees ts). sorted_less (inorder sub)"
  using sorted_inorder_list_subtrees sorted_wrt_append by auto

lemma sorted_inorder_list_induct_subtree:
  "sorted_less (inorder_list (ls@(sub,sep)#rs)) ==> sorted_less (inorder sub)"
  by (simp add: sorted_wrt_append)

corollary sorted_inorder_induct_subtree:
  "sorted_less (inorder (Node (ls@(sub,sep)#rs) t)) ==> sorted_less (inorder sub)"
  by (simp add: sorted_wrt_append)

lemma sorted_inorder_induct_last: "sorted_less (inorder (Node ts t)) ==> sorted_less (inorder t)"
  by (simp add: sorted_wrt_append)



end

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

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

*Bot Zugriff






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