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 11 Homework

Week 11 homework.

## Resources

### Definitions File

```theory Defs
imports "HOL-Library.Multiset" "HOL-Data_Structures.Tree23" "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)"

end
```

### Template File

```theory Template
imports Defs
begin

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

lemma heapify_heap: "heap (heapify t)"
sorry

lemma heapify_mset: "mset (inorder (heapify t)) = mset (Tree23.inorder t)"
sorry

end
```

### Check File

```theory Check
imports Template
begin

lemma heapify_heap: "Defs.heap (heapify t)"
by(rule heapify_heap)

lemma heapify_mset: "mset (inorder (heapify t)) = mset (Tree23.inorder t)"
by(rule heapify_mset)

end
```

Terms and Conditions