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 4

This is the task corresponding to homework 4.

Resources

Download Files

Definitions File

theory Defs
  imports Main
begin

datatype 'a mtree = Leaf | Node (left: "'a mtree") (maximum: 'a) (element: 'a) (right: "'a mtree")


consts set_mtree :: "'a mtree \<Rightarrow> 'a set"

consts mbst :: "'a::linorder mtree \<Rightarrow> bool"

consts max_val :: "'a::{linorder,zero} mtree \<Rightarrow> 'a"

consts mins :: "'a::linorder \<Rightarrow> 'a mtree \<Rightarrow> 'a mtree"

consts misin :: "'a::linorder \<Rightarrow> 'a mtree \<Rightarrow> bool"

consts mtree_in_range :: "'a::linorder mtree \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> 'a list"


end

Template File

theory Submission
  imports Defs
begin

fun set_mtree :: "'a mtree \<Rightarrow> 'a set"  where
  "set_mtree _ = undefined"

fun mbst :: "'a::linorder mtree \<Rightarrow> bool"  where
  "mbst _ = undefined"

fun max_val :: "'a::{linorder,zero} mtree \<Rightarrow> 'a"  where
  "max_val _ = undefined"

lemma mbst_max: "mbst (Node l m a r) \<Longrightarrow> max_val (Node l m a r) = m"
  sorry

fun mins :: "'a::linorder \<Rightarrow> 'a mtree \<Rightarrow> 'a mtree"  where
  "mins _ = undefined"

lemma mins_mbst: "mbst t \<Longrightarrow> mbst (mins x t)"
  sorry

fun misin :: "'a::linorder \<Rightarrow> 'a mtree \<Rightarrow> bool"  where
  "misin _ = undefined"

lemma misin_set: "mbst t \<Longrightarrow> misin x t \<longleftrightarrow> x\<in>set_mtree t"
  sorry

fun mtree_in_range :: "'a::linorder mtree \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> 'a list"  where
  "mtree_in_range _ = undefined"

lemma mbst_range: "mbst t \<Longrightarrow> set (mtree_in_range t u v) = {x\<in>set_mtree t. u\<le>x \<and> x\<le>v}"
  sorry

end

Check File

theory Check
  imports Submission
begin

lemma mbst_max: "mbst (Node l m a r) \<Longrightarrow> max_val (Node l m a r) = m"
  by (rule Submission.mbst_max)

lemma mins_mbst: "mbst t \<Longrightarrow> mbst (mins x t)"
  by (rule Submission.mins_mbst)

lemma misin_set: "mbst t \<Longrightarrow> misin x t \<longleftrightarrow> x\<in>set_mtree t"
  by (rule Submission.misin_set)

lemma mbst_range: "mbst t \<Longrightarrow> set (mtree_in_range t u v) = {x\<in>set_mtree t. u\<le>x \<and> x\<le>v}"
  by (rule Submission.mbst_range)

end

Terms and Conditions