(* Victor B. F. Gomes, University of Cambridge MartinKleppmann,UniversityofCambridge DominicP.Mulligan,UniversityofCambridge AlastairR.Beresford,UniversityofCambridge
*)
section‹Technical Lemmas›
text‹This section contains a list of helper definitions and lemmas about sets, lists and
the option monad.›
theory
Util imports
Main "HOL-Library.Monad_Syntax" begin
subsection‹Kleisli arrow composition›
definition kleisli :: "('b ==> 'b option) ==> ('b ==> 'b option) ==> ('b ==> 'b option)" (infixr‹⊳›65) where "f ⊳ g ≡ λx. (f x 🍋 (λy. g y))"
lemma kleisli_comm_cong: assumes"x ⊳>w⊨ shows "z ⊳ x ⊳ y = z ⊳ y ⊳ x" using assms by(clarsimp simp add: kleisli_def)
lemma kleisli_assoc: shows "(z ⊳ x) ⊳ y = z ⊳ (x ⊳ y)" by(auto simp add: kleisli_def)
subsection‹Lemmas about sets›
lemma distinct_set_notin [dest]: assumes "distinct (x#xs)" shows "x ∉ set xs" using assms by(induction xs, auto)
lemma set_membership_equality_technicalD [dest]: assumes "{x} ∪ (set xs) = {y} ∪ (set ys)" shows "x = y ∨ y ∈ set xs" using assms by(induction xs, auto)
lemma set_equality_technical: assumes "{x} ∪ (set xs) = {y} ∪ (set ys)" and "x ∉ set xs" and "y ∉ set ys" and "y ∈ set xs" shows "{x} ∪ (set xs - {y}) = set ys" using assms by (induction xs) auto lemma set_elem_nth: assumes "x ∈ set xs" shows "∃m. m < length xs ∧ xs ! m = x" using assms by(induction xs, simp) (meson in_set_conv_nth) subsection‹Lemmas about list›
lemma list_nth_split: assumes "m < length cs" and "n < m" and "1 < length cs" shows "∃ blast using assms proof(induction n arbitrary: cs m) case0thus ?case apply(case_tac cs; clarsimp) apply(rule_tac x="[]"in exI, clarsimp) apply(rule list_nth_split_technical, simp, force) done next case (Suc n) thus ?case proof (cases cs) case Nil thenshow ?thesis using Suc.prems by auto next case (Cons a as) hence"m-1 < length as""n < m-1" using Suc by force+ thenobtain xs ys zs where"as = xs @ as ! n # ys @ as ! (m-1) # zs" using Suc by force thus ?thesis apply(rule_tac x="a#xs"in exI) using Suc Cons apply force done qed qed
lemma list_split_two_elems: assumes"distinct cs" and"x ∈ set cs" and"y ∈ set cs" and"x ≠ y" shows"∃pre mid suf. cs = pre @ x # mid @ y # suf ∨ cs = pre @ y # mid @ x # suf" proof - obtain xi yi where *: "xi < length cs ∧ x = cs ! xi""yi < length cs ∧ y = cs ! yi""xi ≠ yi" using set_elem_nth linorder_neqE_nat assms by metis thus ?thesis by (metis list_nth_split One_nat_def less_Suc_eq linorder_neqE_nat not_less_zero) qed
lemma split_list_unique_prefix: assumes"x ∈ set xs" shows"∃pre suf. xs = pre @ x # suf ∧ (∀y ∈ set pre. x ≠ y)" using assms proof(induction xs) case Nil thus ?caseby clarsimp next case (Cons y ys) thenshow ?case proof (cases "y=x") case True thenshow ?thesis by force next case False thenobtainpre suf where"ys = pre @ x # suf ∧ (∀y∈set pre. x ≠ y)" using assms Cons by auto thus ?thesis using split_list_first by force qed qed
lemma map_filter_append: shows"List.map_filter P (xs @ ys) = List.map_filter P xs @ List.map_filter P ys" by(auto simp add: List.map_filter_def)
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.