Theory Global
theory Global
imports "HOL-Library.Library" Result Env List_util Option_Extra Map_Extra AList_Extra
begin
sledgehammer_params [timeout = 30]
sledgehammer_params [provers = "cvc4 e spass vampire z3 zipperposition"]
declare K_record_comp[simp]
lemma if_then_Some_else_None_eq[simp]:
"(if a then Some b else None) = Some c ⟷ a ∧ b = c"
"(if a then Some b else None) = None ⟷ ¬ a"
by (cases a) simp_all
lemma if_then_else_distributive: "(if a then f b else f c) = f (if a then b else c)"
by simp
section ‹Rest›
lemma map_ofD:
fixes xs k opt
assumes "map_of xs k = opt"
shows "opt = None ∨ (∃n < length xs. opt = Some (snd (xs ! n)))"
using assms
by (metis in_set_conv_nth map_of_SomeD not_Some_eq snd_conv)
lemma list_all2_assoc_map_rel_get:
assumes "list_all2 (=) (map fst xs) (map fst ys)" and "list_all2 R (map snd xs) (map snd ys)"
shows "rel_option R (map_of xs k) (map_of ys k)"
using assms[unfolded list.rel_map]
proof (induction xs ys rule: list.rel_induct)
case Nil
thus ?case by simp
next
case (Cons x xs y ys)
thus ?case by (cases "k = fst x") auto
qed
subsection ‹Function definition›