map_graph_minus: "map_graph (f -- g) = map_graph f - map_graph g"
by (auto simp add: map_minus_def map_graph_def, (meson option.distinct(1))+)
map_minus_common_subset:
"[ h ⊆m f; h ⊆m g ]==> (f -- h = g -- h) = (f = g)"
by (auto simp add: map_eq_graph map_graph_minus map_le_graph)
‹ Map Bind ›
‹ Create some extra intro/elim rules to help dealing with proof about option bind. ›
option_bindSomeE [elim!]:
"[ X >>= F = Some(v); ∧ x. [ X = Some(x); F(x) = Some(v) ]==> P ]==> P"
by (case_tac X, auto)
option_bindSomeI [intro]:
"[ X = Some(x); F(x) = Some(y) ]==> X >>= F = Some(y)"
by (simp)
ifSomeE [elim]: "[ (if c then Some(x) else None) = Some(y); [ c; x = y ]==> P ]==> P"
by (case_tac c, auto)
‹ Range Restriction ›
‹A range restriction operator; only domain restriction is provided in HOL.›
ran_restrict_map :: "('a ⇀ 'b) ==> 'b set ==> 'a ⇀ 'b" (‹_↿› [111,110] 110) where
ran_restrict_map f B = (λx. do { v <- f(x); if (v ∈ B) then Some(v) else None })"
ran_restrict_empty [simp]: "f↿} = Map.empty"
by (simp add:ran_restrict_map_def)
map_inv_Some [simp]: "map_inv Some = Some"
by (simp add:map_inv_def ran_def)
map_inv_f_f [simp]:
"[ inj_on f (dom f); f x = Some y ]==> map_inv f y = Some x"
apply (auto simp add: map_inv_def)
apply (rule some_equality)
apply (auto simp add:inj_on_def dom_def ran_def)
done
dom_map_inv [simp]:
"dom (map_inv f) = ran f"
by (auto simp add:map_inv_def)
ran_map_inv [simp]:
"inj_on f (dom f) ==> ran (map_inv f) = dom f"
apply (auto simp add:map_inv_def ran_def)
apply (rename_tac a b)
apply (rule_tac x="a" in exI)
apply (force intro:someI)
apply (rename_tac x y)
apply (rule_tac x="y" in exI)
apply (auto)
apply (rule some_equality, simp_all)
apply (auto simp add:inj_on_def dom_def)
done
dom_image_ran: "f ` dom f = Some ` ran f"
by (auto simp add:dom_def ran_def image_def)
inj_map_inv [intro]:
"inj_on f (dom f) ==> inj_on (map_inv f) (ran f)"
apply (auto simp add:map_inv_def inj_on_def dom_def ran_def)
apply (rename_tac x y u v)
apply (frule_tac P="λ xa. f xa = Some x" in some_equality)
apply (auto)
apply (metis (mono_tags) option.sel someI)
done
inj_map_bij: "inj_on f (dom f) ==> bij_betw f (dom f) (Some ` ran f)"
by (auto simp add:inj_on_def dom_def ran_def image_def bij_betw_def)
bij_map_Some:
"bij_betw f a (Some ` b) ==> bij_betw (the ∘ f) a b"
apply (simp add:bij_betw_def)
apply (safe)
apply (metis (opaque_lifting, no_types) comp_inj_on_iff f_the_inv_into_f inj_on_inverseI option.sel)
apply (metis (opaque_lifting, no_types) image_iff option.sel)
apply (metis Option.these_def Some_image_these_eq image_image these_image_Some_eq)
done
ran_map_add [simp]:
"m`(dom m ∩ dom n) = n`(dom m ∩ dom n) ==>
ran(m++n) = ran n ∪ ran m"
apply (auto simp add:ran_def)
apply (metis map_add_find_right)
apply (rename_tac x a)
apply (case_tac "a ∈ dom n")
apply (subgoal_tac "∃ b. n b = Some x")
apply (auto)
apply (rename_tac x a b y)
apply (rule_tac x="b" in exI)
apply (simp)
apply (metis (opaque_lifting, no_types) IntI domI image_iff)
apply (metis (full_types) map_add_None map_add_dom_app_simps(1) map_add_dom_app_simps(3) not_None_eq)
done
ran_maplets [simp]:
"[ length xs = length ys; distinct xs ]==> ran [xs [↦] ys] = set ys"
by (induct rule:list_induct2, simp_all)
inj_map_add:
"[ inj_on f (dom f); inj_on g (dom g); ran f ∩ ran g = {} ]==>
inj_on (f ++ g) (dom f ∪ dom g)"
apply (auto simp add:inj_on_def)
apply (metis (full_types) disjoint_iff_not_equal domI dom_left_map_add map_add_dom_app_simps(3) ranI)
apply (metis domI)
apply (metis disjoint_iff_not_equal ranI)
apply (metis disjoint_iff_not_equal domIff map_add_Some_iff ranI)
apply (metis domI)
done
map_inv_add [simp]:
assumes "inj_on f (dom f)" "inj_on g (dom g)"
"dom f ∩ dom g = {}" "ran f ∩ ran g = {}"
shows "map_inv (f ++ g) = map_inv f ++ map_inv g"
(rule ext)
from assms have minj: "inj_on (f ++ g) (dom (f ++ g))"
by (simp, metis inj_map_add sup_commute)
fix x
have "x ∈ ran g ==> map_inv (f ++ g) x = (map_inv f ++ map_inv g) x"
proof -
assume ran:"x ∈ ran g"
then obtain y where dom:"g y = Some x" "y ∈ dom g"
by (auto simp add:ran_def)
hence "(f ++ g) y = Some x"
by simp
with assms minj ran dom show "map_inv (f ++ g) x = (map_inv f ++ map_inv g) x"
by simp
qed
moreover have "[ x ∉ ran g; x ∈ ran f ]==> map_inv (f ++ g) x = (map_inv f ++ map_inv g) x"
proof -
assume ran:"x ∉ ran g" "x ∈ ran f"
with assms obtain y where dom:"f y = Some x" "y ∈ dom f" "y ∉ dom g"
by (auto simp add:ran_def)
with ran have "(f ++ g) y = Some x"
by (simp)
with assms minj ran dom show "map_inv (f ++ g) x = (map_inv f ++ map_inv g) x"
by simp
qed
moreover from assms minj have "[ x ∉ ran g; x ∉ ran f ]==> map_inv (f ++ g) x = (map_inv f ++ map_inv g) x"
apply (auto simp add:map_inv_def ran_def map_add_def)
apply (metis dom_left_map_add map_add_def map_add_dom_app_simps(3))
done
ultimately show "map_inv (f ++ g) x = (map_inv f ++ map_inv g) x"
apply (case_tac "x ∈ ran g")
apply (simp)
apply (case_tac "x ∈ ran f")
apply (simp_all)
done
map_add_lookup [simp]:
"x ∉ dom f ==> ([x ↦ y] ++ f) x = Some y"
by (simp add:map_add_def dom_def)
map_add_Some: "Some ++ f = map_id_on (- dom f) ++ f"
apply (rule ext)
apply (rename_tac x)
apply (case_tac "x ∈ dom f")
apply (simp_all)
done
distinct_map_dom:
"x ∉ set xs ==> x ∉ dom [xs [↦] ys]"
by (simp add:dom_def)
maplets_lookup[rule_format,dest]:
"[ length xs = length ys; distinct xs ]==> ∀ y. [xs [↦] ys] x = Some y ⟶ y ∈ set ys"
by (induct rule:list_induct2, auto)
maplets_lookup_nth [rule_format,simp]:
"[ length xs = length ys; distinct xs ]==> ∀ i < length ys. [xs [↦] ys] (xs ! i) = Some (ys ! i)"
apply (induct rule:list_induct2)
apply (auto)
apply (rename_tac x xs y ys i)
apply (case_tac i)
apply (simp_all)
apply (metis nth_mem)
apply (rename_tac x xs y ys i)
apply (case_tac i)
apply (auto)
done
inv_map_inv:
"[ inj_on f (dom f); ran f = dom f ] ==> inv (the ∘ (Some ++ f)) = the ∘ map_inv (Some ++ f)"
apply (rule ext)
apply (simp add:map_add_Some)
apply (simp add:inv_def)
apply (rename_tac x)
apply (case_tac "∃ y. f y = Some x")
apply (erule exE)
apply (rename_tac x y)
apply (subgoal_tac "x ∈ ran f")
apply (subgoal_tac "y ∈ dom f")
apply (simp)
apply (rule some_equality)
apply (simp)
apply (metis (opaque_lifting, mono_tags) domD domI dom_left_map_add inj_on_contraD map_add_Some map_add_dom_app_simps(3) option.sel)
apply (simp add:dom_def)
apply (metis ranI)
apply (simp)
apply (rename_tac x)
apply (subgoal_tac "x ∉ ran f")
apply (simp)
apply (rule some_equality)
apply (simp)
apply (metis domD dom_left_map_add map_add_Some map_add_dom_app_simps(3) option.sel)
apply (metis dom_image_ran image_iff)
done
map_comp_dom: "dom (g ∘m f) ⊆ dom f"
by (metis (lifting, full_types) Collect_mono dom_def map_comp_simps(1))
map_comp_assoc: "f ∘m (g ∘m h) = f ∘m g ∘m h"
fix x
show "(f ∘m (g ∘m h)) x = (f ∘m g ∘m h) x"
proof (cases "h x")
case None thus ?thesis
by (auto simp add: map_comp_def)
next
case (Some y) thus ?thesis
by (auto simp add: map_comp_def)
qed
map_comp_runit [simp]: "f ∘m Some = f"
by (simp add: map_comp_def)
map_comp_lunit [simp]: "Some ∘m f = f"
fix x
show "(Some ∘m f) x = f x"
proof (cases "f x")
case None thus ?thesis
by (simp add: map_comp_def)
next
case (Some y) thus ?thesis
by (simp add: map_comp_def)
qed
map_comp_apply [simp]: "(f ∘m g) x = g(x) >>= f"
by (auto simp add: map_comp_def option.case_eq_if)
‹ Merging of compatible maps ›
comp_map :: "('a ⇀ 'b) ==> ('a ⇀ 'b) ==> bool" (infixl ‹∥m› 60) where
comp_map f g = (∀ x ∈ dom(f) ∩ dom(g). the(f(x)) = the(g(x)))"
comp_map_unit: "Map.empty ∥m f"
by (simp add: comp_map_def)
comp_map_refl: "f ∥m f"
by (simp add: comp_map_def)
comp_map_sym: "f ∥m g ==> g ∥m f"
by (simp add: comp_map_def)
merge :: "('a ⇀ 'b) set ==> 'a ⇀ 'b" where
merge fs =
(λ x. if (∃ f ∈ fs. x ∈ dom(f)) then (THE y. ∀ f ∈ fs. x ∈ dom(f) ⟶ f(x) = y) else None)"
merge_empty: "merge {} = Map.empty"
by (simp add: merge_def)
list_of_map :: "(nat ⇀ 'a) ==> 'a list" where
list_of_map f = (if (f = Map.empty) then [] else map (the ∘ f) [0 ..< Suc(GREATEST x. x ∈ dom f)])"
list_of_map_empty [simp]: "list_of_map Map.empty = []"
by (simp add: list_of_map_def)
list_of_map' :: "(nat ⇀ 'a) ⇀ 'a list" where
list_of_map' f = (if (∃ n. dom f = {0..<n}) then Some (list_of_map f) else None)"
map_of_list_inv [simp]: "list_of_map (map_of_list xs) = xs"
(cases "xs = []")
case True thus ?thesis by (simp)
case False
moreover hence "(GREATEST x. x ∈ dom (map_of_list xs)) = length xs - 1"
by (auto intro: Greatest_equality)
moreover from False have "map_of_list xs ≠ Map.empty"
by (metis ran_empty ran_map_of_list set_empty)
ultimately show ?thesis
by (auto simp add: list_of_map_def map_of_list_def intro: nth_equalityI)
‹ Map Comprehension ›
‹ Map comprehension simply converts a relation built through set comprehension into a map. ›
map_compr_simple:
"[x ↦ F x y | x y. (x, y) ∈m f] = (λ x. do { y ← f(x); Some(F x y) })"
apply (rule ext)
apply (auto simp add: graph_map_def image_Collect)
done
map_compr_dom_simple [simp]:
"dom [x ↦ f x | x. P x] = {x. P x}"
by (force simp add: graph_map_dom image_Collect)
map_compr_ran_simple [simp]:
"ran [x ↦ f x | x. P x] = {f x | x. P x}"
apply (auto simp add: graph_map_def ran_def)
apply (metis (mono_tags, lifting) fst_eqD image_eqI mem_Collect_eq someI)
done
map_compr_eval_simple [simp]:
"[x ↦ f x | x. P x] x = (if (P x) then Some (f x) else None)"
by (auto simp add: graph_map_def image_Collect)
‹ Sorted lists from maps ›
sorted_list_of_map :: "('a::linorder ⇀ 'b) ==> ('a × 'b) list" where
sorted_list_of_map f = map (λ k. (k, the (f k))) (sorted_list_of_set(dom(f)))"
sorted_list_of_map_empty [simp]:
"sorted_list_of_map Map.empty = []"
by (simp add: sorted_list_of_map_def)
sorted_list_of_map_inv:
assumes "finite(dom(f))"
shows "map_of (sorted_list_of_map f) = f"
-
obtain A where "finite A" "A = dom(f)"
by (simp add: assms)
thus ?thesis
proof (induct A rule: finite_induct)
case empty thus ?thesis
by (simp add: sorted_list_of_map_def, metis dom_empty empty_iff map_le_antisym map_le_def)
next
case (insert x A) thus ?thesis
by (simp add: assms sorted_list_of_map_def map_of_map_keys)
qed
map_member.simps [simp del]
‹ Extra map lemmas ›
map_eqI:
"[ dom f = dom g; ∀ x∈dom(f). the(f x) = the(g x) ]==> f = g"
by (metis domIff map_le_antisym map_le_def option.expand)
map_restrict_dom [simp]: "f |` dom f = f"
by (simp add: map_eqI)
map_restrict_dom_compl: "f |` (- dom f) = Map.empty"
by (metis dom_eq_empty_conv dom_restrict inf_compl_bot)
restrict_map_neg_disj:
"dom(f) ∩ A = {} ==> f |` (- A) = f"
by (auto simp add: restrict_map_def, rule ext, auto, metis disjoint_iff_not_equal domIff)
map_plus_restrict_dist: "(f ++ g) |` A = (f |` A) ++ (g |` A)"
by (auto simp add: restrict_map_def map_add_def)
map_plus_eq_left:
assumes "f ++ h = g ++ h"
shows "(f |` (- dom h)) = (g |` (- dom h))"
-
have "h |` (- dom h) = Map.empty"
by (metis Compl_disjoint dom_eq_empty_conv dom_restrict)
then have f2: "f |` (- dom h) = (f ++ h) |` (- dom h)"
by (simp add: map_plus_restrict_dist)
have "h |` (- dom h) = Map.empty"
by (metis (no_types) Compl_disjoint dom_eq_empty_conv dom_restrict)
then show ?thesis
using f2 assms by (simp add: map_plus_restrict_dist)
map_add_split:
"dom(f) = A ∪ B ==> (f |` A) ++ (f |` B) = f"
by (rule ext, auto simp add: map_add_def restrict_map_def option.case_eq_if)
map_le_via_restrict:
"f ⊆m g ⟷ g |` dom(f) = f"
by (auto simp add: map_le_def restrict_map_def dom_def fun_eq_iff)
map_add_cancel:
"f ⊆m g ==> f ++ (g -- f) = g"
by (auto simp add: map_le_def map_add_def map_minus_def fun_eq_iff option.case_eq_if)
(metis domIff)
map_le_iff_add: "f ⊆m g ⟷ (∃ h. dom(f) ∩ dom(h) = {} ∧ f ++ h = g)"
apply (auto)
apply (rule_tac x="g -- f" in exI)
apply (metis (no_types, lifting) Int_emptyI domIff map_add_cancel map_le_def map_minus_def)
apply (simp add: map_add_comm)
done
map_add_comm_weak: "(∀ k ∈ dom m1 ∩ dom m2. m1(k) = m2(k)) ==> m1 ++ m2 = m2 ++ m1"
by (auto simp add: map_add_def option.case_eq_if fun_eq_iff)
(metis IntI domI option.inject)
Messung V0.5 in Prozent
¤ 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.0.35Bemerkung:
¤
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.