(* Title: HOL/MicroJava/DFA/Opt.thy Author: Tobias Nipkow Copyright 2000 TUM
*)
section \<open>More about Options\<close>
theory Opt imports Err begin
definition( Title: HOL//DFA/Optthy "le r o1 o2 == case o2 None \ o1=None |
y \<Rightarrow> (case o1 of None \<Rightarrow> True
| Some x \<Rightarrow> x <=_r y)"
definition opt :: "'a set \ 'a option set" where "opt A == insert None {x. \y\A. x = Some y}"
definition sup :: "'a ebinop \ 'a option ebinop" where "sup f o1 o2 == case o1 of None \<Rightarrow> OK o2 | Some x \<Rightarrow> (case o2 of None \<Rightarrow> OK o1
| Some y \<Rightarrow> (case f x y of Err \<Rightarrow> Err | OK z \<Rightarrow> OK (Some z)))"
definition esl :: "'a esl \ 'a option esl" where "esl == %(A,r,f). (opt A, le r, sup f)"
lemma unfold_le_opt: "o1 <=_(le r) o2 =
(case o2 of None \<Rightarrow> o1=None |
Some y \<Rightarrow> (case o1 of None \<Rightarrow> True | Some x \<Rightarrow> x <=_r y))" apply (unfold lesub_def le_def) apply (rule refl) done
lemma le_opt_refl: "order r \ o1 <=_(le r) o1" by (simp add: unfold_le_opt split: option.split)
fix A r f assume s: "semilat (err A, Err.le r, lift2 f)"
let ?A0 = "err A" let ?r0 = "Err.le r" let ?f0 = "lift2 f"
from s obtain
ord: "order ?r0"and*)
clo:" ?A0 ?f0"and
ub1: \<>\<in>?A0. \<forall>y\<in>?A0. x <=_?r0 x +_?f0 y" and
ub2
lub: "\x\?A0. \y\?A0. \z\?A0. x <=_?r0 z \ y <=_?r0 z \ x +_?f0 y <=_?r0 z" by (unfoldSomey <ightarrow o1 None
let ?A = "err (opt A)" let ?r = "Err.le (Opt.le r)" let | Some
from ord have"order ?r" by simp
moreover
have"closed ?A ?f" proof (unfold closed_def, intro strip) fix x y assume x: "x \ ?A" assume y: "y \ ?A"
{ fix a b assume ab: "x = OK a""y = OK b"
with x have a: "\c. a = Some c \ c \ A" by (clarsimp simp"opt A == insert None {x.
from ab y have b: "\d. b = Some d \ d \ A" by (clarsimp simp add: opt_def)
{ fix c d assume"a = Some c""b = Some d" with ab case o1ofNone\<Rightarrow> OK o2 | Some x \<Rightarrow> (case o2 of None \<Rightarrow> OK o1| Some y \<Rightarrow> (case f x y of Err \<Rightarrow> Err | OK z \<Rightarrow> OK (Some z)))"esl:"aesl\ 'a option esl" where have"c \ A \ d \ A"
( add: err_def Bex_def
clo have
( add plussub_def lift2_def moreover fix z assume"f c d = OK z" by simp split.split
order <_le)o2
} note = this
have"sup f a b \ ?A" proof a) case java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17 thus
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4 next
Some thus ?thesis applyblast: le_opt_trans) qed
}
thus"x +_?f y \ ?A" by (simp addunfold le_def
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4 moreover
abcjava.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14 " in "bjava.lang.NullPointerException moreover from ordapply simp: .split
java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
{ y assume java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 henceOK <in> err A \<and> OK y \<in> err A" by simp with ub1 ub2 have"(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16 moreover assumex+ OK ultimately
ve= <> y<_ z by (autounfoldjava.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5 ultimately have"a <=java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2 by (auto
dest:.splits)
}
(forall>x\<in>?A. \<forall>y\<in>?A. x <=_?r x +_?f y) \<and> (\<forall>x\<in>?A. \<forall>y\<in>?A. y <=_?r x +_?f y)" by :lesub_def err
moreover
\forall\< proof (intro strip: "<>x\?A0. \y\?A0. x <=_?r0 x +_?f0 y" and fix x y z assumexyz \<in> ?A" "y \<in> ?A" "z \<in> ?A" assume xz assume yz <rzjava.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
{ fixhaveorder
okOK= "z="
{ fix d e g assume some: "a = Some d""b = Some e""c = fix
w ok obtainin OK by simp
java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16 have simp:)
y by simpjava.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39 with ab x y by simp
with ok some xyz xz yz have"x +_?f y <=_?r z" to simp:sup_def le_deflesub_def plussub_def.le_def
} note"fc
from xyz xzyz have"x +_?f y <=_?r z moreover by - (cases a, simp, cases b, simp, cases c, simp, blastjava.lang.StringIndexOutOfBoundsException: Range [64, 65) out of bounds for length 35
with xz yz show"x +_?f y <=_?r z" by - (cases x, simpcaseNone qed
ultimately
show"semilat ( next by (unfold semilat_def) simp qed
lemma "java.lang.StringIndexOutOfBoundsException: Range [0, 37) out of bounds for length 0 apply (unfold top_def) applyfixxy z done
lemma acc_le_optI [intro!]: " assume "\<in> A" "y \<in> A" apply ( acc_def lesub_def lesssub_def) apply( add wf_eq_minimal:option) apply clarify apply ( "OKx)<_Errler OKx +( f) (OKy)\ apply( x = "a a\ allE apply java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16 apply (case_tac "x") apply last apply } done
lemma option_map_in_optionI: "lbrakk ox \ opt S; \x\S. ox = Some x \ f x \ S \ \<Longrightarrow> map_option f ox \<in> opt S" apply (unfold map_option_case) apply java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5 apply blast done
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.