Cookies disclaimer

I agree Our site saves small pieces of text information (cookies) on your device in order to deliver better content and for statistical purposes. You can disable the usage of cookies by changing the settings of your browser. By browsing our website without changing the browser settings you grant us permission to store that information on your device.

FDS Week 9 Homework

Week 9 homework.

Resources

Download Files

Definitions File

theory Defs
  imports Main "HOL-Data_Structures.Tree23" "HOL-Data_Structures.RBT_Set"
begin

fun bhs :: "'a rbt \<Rightarrow> nat set" where
  "bhs Tree.Leaf = {0}" |
  "bhs (Tree.Node l (_,c) r) = (let H = bhs l \<union> bhs r in if c=Black then Suc ` H else H)"

end

Template File

theory Template
  imports Defs
begin

fun mk_rbt :: "'a tree23 \<Rightarrow> 'a rbt" where
  "mk_rbt _ = undefined"

lemma mk_rbt_inorder_btree: "Tree2.inorder (mk_rbt t) = Tree23.inorder t"
  sorry

lemma mk_rbt_color_btree: "color (mk_rbt t) = Black"
  sorry

lemma mk_rbt_invh_btree: "Tree23.complete t \<Longrightarrow> invh (mk_rbt t)"
  sorry

lemma mk_rbt_invc_btree: "invc (mk_rbt t)"
  sorry

corollary invh_iff_bhs: "invh t \<longleftrightarrow> bhs t = {bheight t}"
  sorry
end

Check File

theory Check
  imports Template
begin

lemma mk_rbt_inorder_btree: "Tree2.inorder (mk_rbt t) = Tree23.inorder t"
  by(rule mk_rbt_inorder_btree)

lemma mk_rbt_color_btree: "color (mk_rbt t) = Black"
  by(rule mk_rbt_color_btree)

lemma mk_rbt_invh_btree: "Tree23.complete t \<Longrightarrow> invh (mk_rbt t)"
  by(rule mk_rbt_invh_btree)

lemma mk_rbt_invc_btree: "invc (mk_rbt t)"
  by(rule mk_rbt_invc_btree)

corollary invh_iff_bhs: "invh t \<longleftrightarrow> bhs t = {bheight t}"
  by(rule invh_iff_bhs)

end

Terms and Conditions