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.

Week 8 bonus 1

Week 8 bonus 1

Resources

Download Files

Definitions File

theory Defs
  imports Main
begin

type_synonym intervals = "(nat*nat) list"

fun inv' :: "nat \<Rightarrow> intervals \<Rightarrow> bool" where
  "inv' x [] \<longleftrightarrow> True"
| "inv' x ((a,b)#is) \<longleftrightarrow> (x\<le>a \<and> a\<le>b \<and> inv' (Suc (Suc b)) is)"

definition inv where "inv \<equiv> inv' 0"


fun set_of :: "intervals => nat set"
where
  "set_of [] = {}"
| "set_of ((a,b)#is) = {a..b} \<union> set_of is"

end

Template File

theory Submission
  imports Defs
begin

lemma inv'_mono: "inv' n is \<Longrightarrow> m\<le>n \<Longrightarrow> inv' m is"
  by (induction m "is" rule: inv'.induct) auto

fun addi :: "nat \<Rightarrow> nat \<Rightarrow> intervals \<Rightarrow> intervals" where
  "addi _ = undefined"

lemma addi_correct:
  assumes "inv is" "i\<le>j"
  shows "inv (addi i j is)" "set_of (addi i j is) = {i..j} \<union> (set_of is)"
  sorry

end

Check File

theory Check
  imports Submission
begin

lemma addi_correct:
  assumes "inv is" "i\<le>j"
  shows "inv (addi i j is)" "set_of (addi i j is) = {i..j} \<union> (set_of is)"
  by (rule addi_correct[OF assms])+

end

Terms and Conditions