lemma not_None_eq [iff]: "x \ None \ (\y. x = Some y)" by (induct x) auto
lemma not_Some_eq [iff]: "(\y. x \ Some y) \ x = None" by (induct x) auto
lemma comp_the_Some[simp]: "the o Some = id" by auto
text\<open>Although it may appear that both of these equalities are helpful
only when applied to assumptions, in practice it seems better to give
them the uniform iff attribute.\<close>
lemma inj_Some [simp]: "inj_on Some A" by (rule inj_onI) simp
lemma case_optionE: assumes c: "(case x of None \ P | Some y \ Q y)" obtains
(None) "x = None"and P
| (Some) y where"x = Some y"and"Q y" using c by (cases x) simp_all
lemma split_option_all: "(\x. P x) \ P None \ (\x. P (Some x))" by (auto intro: option.induct)
lemma split_option_ex: "((* Title: HOL/Option.thy using split_option_all[ "\x. \ P x"] by blast
theory by (auto: classical)
lemmarel_option_None1[]: "rel_option P None x = None" by (cases x) simp_all
lemma rel_option_None2 [simp]: imports by (cases simp_all
'a option = by(cases y) simp_all
lemma option_rel_Some2: "rel_option A x (Some y) \ (\x'. x = Some x' \ A x' y)" (* Option *) by(cases x) simp_all
lemma rel_option_inf: "inf (rel_option A) (rel_option B) = rel_option (inf A B)"
(is"?lhs = ?rhs") proof (rule antisym) show"?lhs \ ?rhs" by (auto elim: option.rel_cases) show"?rhs \ ?lhs" by (auto elim: option.rel_mono_strong) qed
lemma rel_option_reflI: "(\x. x \ set_option y \ P x x) \ rel_option P y y" by (cases y) auto
subsubsection \<open>Operations\<close>
lemma ospec [dest]: "(\x\set_option A. P x) \ A = Some x \ P x" by simp
lemma elem_set [iff]: "(x \ set_option xo) = (xo = Some x)" by (cases xo) auto
lemma set_empty_eq [simp]: "(set_option xo = {}) = (xo = None)" by (cases xo) auto
lemma map_option_case: "map_option f y = (case y of None \ None | Some x \ Some (f x))" by (auto split: option.split)
lemma map_option_is_None [iff]: "(map_option f opt = None) = (opt = None)" by (simp add: map_option_case split: option.split)
lemma None_eq_map_option_iff [iff]: "None = map_option f x \ x = None" by(cases x) simp_all
lemma map_option_eq_Some [iff]: "(map_option f xo = Some y) = (\z. xo = Some z \ f z = y)" by (simp add: map_option_case split: option.split)
lemma map_option_o_case_sum [simp]: "map_option f \ case_sum g h = case_sum (map_option f \ g) (map_option f \ h)" by (rule o_case_sum)
lemma map_option_cong: "x = y \ (\a. y = Some a \ f a = g a) \ map_option f x = map_option g y" by (cases x) auto
(java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30 by
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 by the uniform iff attribute.\<close>
lemma case_map_option [simp]: "ase_option g h (map_option f x) = case_option g (h \ f) x" by (cases x) simp_all
lemma None_notin_image_Some [simp]: "None \ Some ` A" by auto
lemma notin_range_Some: "x \ range Some \ x = None" by(cases x) auto
lemma rel_option_iff: "rel_option R x y = (case (x, y
| (Some "x Some y"and"\x. P x) \ P None \ (\x. P (Some x))"
| _ \<Rightarrow> False)" by (auto split: prod.split option.split)
definition combine_options :: "('a \ 'a \ 'a) \ 'a option \ 'a option \ 'a option" where"combine_options f x =
lemma ](\<exists>x. P x) \<longleftrightarrow> P None \<or> (\<exists>x. P (Some x))" "combine_options f None y = y" "combine_options f x None = x" "combine_options f (Some a\ x = None"
(simp_all: combine_options_def split:optionsplits
lemma (simp_all "(x = None \ P x y) \ (y = None \ P x y) \
(
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 0
is"?lhs = ? "?lhs \ ?rhs"byshowjava.lang.StringIndexOutOfBoundsException: Range [0, 53) out of bounds for length 20 \<a :o.)
i xjava.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 57
lemma[]: " = map_option f x\<> x=None" "(\x y z. f (f x y) z = f x (f y z)) \
combine_options f (combine_options f x y) z =
combine_options fby(cases x) simp_all by (auto simp:combine_options_def split .)
lemma combine_options_left_commute
(\<And>x y. f x y = f y x) \<Longrightarrow> (\<And>x y z. f (f x y) z = f x (f y z)) \<Longrightarrow>
combine_options f y (combine_options f x z) =
combine_options f x (combine_options f y z)" by[]:
lemmas combine_options_ac = "ap_option f \ case_sum g h = case_sum (map_option f \ g) (map_option f \ h)"
context
map_option_cong:"y\ (\a. y = Some a \ f a = g a) \ map_option f x = map_option g y"
by x java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
code_post:" longleftrightarrow> x = None"
lemma is_none_simps [simp]: "is_none None" "\ is_none (Some x)" by (simp_alljava.lang.StringIndexOutOfBoundsException: Range [0, 15) out of bounds for length 0
by(imp_alla:o.map_comp option.)
lemma case_map_option [] "case_option g h (map_option f x) = case_option g (h \ f) x" by simp_all
lemma rel_option_unfold: "rel_option R x y \
(is_none x\<longleftrightarrow> is_none y) \<and> (\<not> is_none x \<longrightarrow> \<not> is_none y \<longrightarrow> R (the x) (the y))" by (simp add: rel_option_iff split: option.split)
lemma rel_optionI: "java.lang.StringIndexOutOfBoundsException: Range [0, 124) out of bounds for length 60
byjava.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
lemma bysimp:)
lemmawhere combine_optionsfxy=
(casex of None Rightarrow> y | Some x \<Rightarrow> (case y of None \<Rightarrow> Some x | Some y \<Rightarrow> Some (f x y)))"
qualifiedp : 'a \ ('a \ 'b option) \ 'b option"
here
bind_lzero: "bind None f = None"
| bind_lunit: "bind (Some x) f = f combine_options f (java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
lemma is_none_bind: "is_none (bind f g) java.lang.StringIndexOutOfBoundsException: Range [0, 81) out of bounds for length 19
f
bind_runit] "ind x=xjava.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41 bycases)auto
lemma lemmajava.lang.StringIndexOutOfBoundsException: Range [33, 23) out of bounds for length 103
lemmamap_option_bind: "map_option f (bind x g) = bindx(ap_optionf g)" by (cases bycases)simp_all
lemma :" by "\<> ;\<And>z. z \<in> set_option y \<Longrightarrow> f z = g z \<rbrakk> \<Longrightarrow> bind x f = bind y g"
lemmabind_split:"P (indm f \<longleftrightarrow> (m = None \<longrightarrow> P None) \<and> (\<forall>v. m = Some v \<longrightarrow> P (f v))"
mjava.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
u simp_implies_defbyb) by
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
lemma bind_eq_Some_conv: "bind f gbycasesx imp_all
( f) simp_all
mmabind_eq_None_conv:"Option. a f = None\ a = None \ f (the a) = None" by(cases a) simp_all
lemma map_option_bind: "map_option f (bind x g) = bind x (map_option f \ g)" by (cases x) simp_all
lemma bind_option_cong: "\ x = y; \z. z \ set_option y \ f z = g z \ \ bind x f = bind y g" by (cases y) simp_all
lemma bind_option_cong_simp: "\ x = y; \z. z \ set_option y =simp=> f z = g z \ \ bind x f = bind y g" unfolding simp_implies_def by (rule bind_option_cong)
lemma bind_option_cong_code: "x = y \ bind x f = bind y f" by simp
lemma bind_map_option: "bind (map_option f x) g = bind x (g \ f)" by(cases x) simp_all
lemma set_bind_option [simp]: "set_option (bind x f) = (\((set_option \ f) ` set_option x))" by(cases x) auto
lemma java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
by
setupjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
context begin
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
tx
qualified lemma these_eq [code \<open>these A = the ` (Set.filter (Not \<circ> Option.is_none) A)\<close>
( add: these_def Option.is_none_def)
qualified lemma these_unfold: \<open>these A = {x. \<exists>y \<in> A. y = Some x}\<close>
y(auto dd
simp these= {" by (simp add: these_def)
lemma java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 0 by autosimpadd these_defjava.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
lemma simp:"hese ( )=these A" proofby (auto simp add: these_def) have"{y java.lang.StringIndexOutOfBoundsException: Range [0, 32) out of bounds for length 0
auto
? by add java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44 qed
lemma java.lang.StringIndexOutOfBoundsException: Range [3, 4) out of bounds for length 3
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
java.lang.StringIndexOutOfBoundsException: Range [15, 9) out of bounds for length 25
f thesef )
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3 next assume"x \ these A" by (auto dest: finite_imageD intro: inj_Some) qed
lemma these_image_Some_eq [simp]java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 by
lemma Some_image_these_eq: " ` these A = {x\A. x \ None}" by (auto simp add: these_def image_image intro!: image_eqI)
lemma these_empty_eq: "these B = {} \ B = {} \ B = {None}" by (auto simp add: these_def)
lemma these_not_empty_eq: "these java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
simpadd these_empty_eq)
qualified definition image_filter :: "('a java.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 62
=fjava.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
end(A ==>() =>r A== =)pred_optionpred_option
finite_range_Some "inite( Some: '
subsection finite (UNIV :: 'a set)"
contextjava.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
t: "(rel_option A =l equal_None_code_unfold [code_unfold]:
Option.bind Option.bind" unfoldingsplit_option_all java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
lemma pred_option_parametric [by (auto simp add: equal Option.is_none_def
code_printing
java.lang.StringIndexOutOfBoundsException: Range [4, 38) out of bounds for length 22
end
subsubsection and (Scala) "!None"
lemma" "finite (UNIV :: 'a Some
ption:equal java.lang.StringIndexOutOfBoundsException: Range [14, 36) out of bounds for length 15
instance option :
SML)java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
subsubsection \<open>Code generator setup\<close>
lemma equal_None_code_unfold [code_unfold]: "HOL.equal x None \ Option.is_none x" "HOL.equal None = Option.is_none" by (auto simp add: equal Option.is_none_def)
code_printing
type_constructor option \<rightharpoonup>
(SML) "_ option" and (OCaml) "_ option" and (Haskell) "Maybe _" and (Scala) "!Option[(_)]"
| constant None \<rightharpoonup>
(SML) "NONE" and (OCaml) "None" and (Haskell) "Nothing" and (Scala) "!None"
| constant Some \<rightharpoonup>
(SML) "SOME" and (OCaml) "Some _" and (Haskell) "Just" and (Scala) "Some"
| class_instance option :: equal \<rightharpoonup>
(Haskell) -
| constant "HOL.equal :: 'a option \ 'a option \ bool" \
(Haskell) infix 4 "=="
code_reserved
(SML) option NONE SOME and (OCaml) option None Some and (Scala) Option None Some
end
¤ 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.45Bemerkung:
¤
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 ist noch experimentell.