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.

Homework 11

This is the task corresponding to homework 11.

Resources

Download Files

Definitions File

theory Defs
  imports "HOL-Library.Multiset" "HOL-Library.Tree"
begin

fun heap::"'a::linorder tree \<Rightarrow> bool" where
  "heap Leaf = True"
| "heap (Node l x r) = ((\<forall>y\<in>set_tree l. x \<le> y) \<and> (\<forall>y\<in>set_tree r. x \<le> y) \<and> heap l \<and> heap r)"

consts heapify :: "'a::linorder tree  \<Rightarrow> 'a::linorder tree"


end

Template File

theory Submission
  imports Defs
begin

fun siftdown::"'a::linorder tree  \<Rightarrow> 'a::linorder tree" fun heapify :: "'a::linorder tree  \<Rightarrow> 'a::linorder tree"  where
  "heapify _ = undefined"

theorem heapify_heap: "heap (heapify t)"
  sorry

theorem heapify_mset: "mset (inorder (heapify t)) = mset (inorder t)"
  sorry

end

Check File

theory Check
  imports Submission
begin

theorem heapify_heap: "heap (heapify t)"
  by (rule Submission.heapify_heap)

theorem heapify_mset: "mset (inorder (heapify t)) = mset (inorder t)"
  by (rule Submission.heapify_mset)

end

Terms and Conditions