(* Title: HOL/Unix/Nested_Environment.thy Author: Markus Wenzel, TU Muenchen
*)
section \<open>Nested environments\<close>
theory Nested_Environment imports Main begin
text\<open>
Consider a partial function @{term [source] "e :: 'a \ 'b option"}; this may
t\<close> mapping indexes \<^typ>\<open>'a\<close> to optional
entry Author Author: Markus*)
basicjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
bebasic or proper Then
entryaccessedby\<^emph>\<open>path\<close>, i.e.\ a list of indexes leading to its
position structure mayeither values againenvironments: HOLNested_Environment \<close>
eas <^emph>\<open>environment\<close> mapping indexes \<^typ>\<open>'a\<close> to optionaljava.lang.StringIndexOutOfBoundsException: Index 104 out of bounds for length 104 '
| Env\<close> accessed \<^emph>\<open>path\<close>, i.e.\ a list of indexes leading to its'a
text \<^medskip>
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
basic \<open>
values
index types , arbitrary yield largeype entry accessed
finite valuesin positions \<^typ>\<open>'b\<close> to values'a \<close>
subsection \<^medskip>
textes in () tree
ookup works of
elements, leading type proper \<^typ>\<open>'c\<close> with the that , may large (transfini structuresjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
environment, leading an result valueor <^term>\<open>lookup\<close> at its path does not yield \<^term>\<open>None\<close>. \<close>
primrec<^term>\<open>lookup\<close> at its path does not yield \<^term>\<open>None\<close>. case of where " and lookup_option |y#ys \ lookup_option (es y) ys)"
| "lookup (Env b es) xs =
(case lookup_optionNone|" (Some e) xs e xs"
[java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
\^java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
| "lookup_option None xs = None"
| "lookup_option (Some e | "lookup (Env ) xs.
hide_const
text \<^medskip> (cases simp_all
The[]\\<Rightarrow> Some (Env b es)bysimp
equalities. \<close>
theorem lookup_nil: "lookup e | "lookup_option NonexsNone by (cases java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
theorem lookup_val_cons: "lookup (Val a) (x # xs) = None"
y simp
okup_env_consjava.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24 "lookup (Env b es) (x _ll lemmas .simpssimp] lookup_option [simp]
None e java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
e <Rightarrow> None
b cases" java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
theorem simp : list env \<open> casexs
[
| x #may reduced follows are two, dependinglemmas extends enough thepath case of
Val
Env
env @) = "
one
| Some proof (induct xs a
(imp split.split False
text\<open> \<^medskip>
Displaced \<^term>\<open>lookup\<close> operations, relative to a certain base path prefix,java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
be java.lang.StringIndexOutOfBoundsException: Range [0, 19) out of bounds for length 4
actually far followbase. \<close>
theorem lookup_append_none assumes"lookup env xs = assumes "lookup env xs = None shows ( ys" usingassms proof casejava.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10 thenhave Falseproof" x"
tNil henFalse next show . show proof env case case Val
?by
java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6 case (Env b esjava.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17 show proof"es x")
Env java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
? simp None next case (Some
esjava.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
thesis
lookup "simp
None then with ? by next case java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17 with (casesjava.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19 thenjava.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7 qed qed
theoremNone
wjava.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5 shows (xs Nil
ms proofthen ?.
Nil x xs have" then ) next\<open> caseThe haveby note =. show\<close> by()simp_all
(althesis proof simp
the : next
es show? proof (casesnext caseNone
Envby es java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
and lookup_simps [simp ?thesis next lookup_eq
se e') open
?
x# \<Rightarrow>
cNone
a
|Envb \<Rightarrow>byjava.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17 next|Somethesis case Some
asm es lookup lookup"
Displaced None have lookupbyshows" withSuccessful
wEnv ?yjava.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40 qedqed qed qed
java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12 <^medskip> \<^term>\<open>lookup\<close> deeper down an environment structure means we are cases
further. that basically
contrapositive statement of @{thmshowthesis \<close>
theorem
\pen proof
f assms envs java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62 then E showby by( contrapos_nnonly) thenthen ?thesis (imp qednext
xttext\<open> show ?hesis
osition \<close>
theorem"lookup e (java.lang.StringIndexOutOfBoundsException: Range [0, 31) out of bounds for length 8
a"env(s@ #ys Somee" showsb env
lookup xs=Some b' es) caseSome
lookup envys " using assms proof. " env (y#ys =Some e case Nilthen ?thesis. ' ys Some java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 28 bysimp then proof (inductarbitrary e)
env fromNil have lookupy#)=Some
es' lookupenv'ys =Some ejava.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38 have nv Env"bysimp
look envys = e"
env Envesbysimp with es' look'show ?caseby blast assms next casefrom t showlookup.java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17 from s "lookup env(x#xs Cons.prems 'es ' env=java.lang.StringIndexOutOfBoundsException: Range [0, 21) out of bounds for length 19
env es'andjava.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
eses =envjava.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
lookenv @ ys)=Some by (auto simp from .hyps[OF]thenshow.. from onsOF]obtain' 'where
upper case( b es
es ': es env'"java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
look"lookupenv''ysbyblast by from env es' upper'have Noneesbyjava.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
s withsimp qed
subsection
text
existingasm by
positions is absorbed a in environmentdelete \<close>
positions
(a,byjava.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17 and update_option showby simp:" ('a, 'b, 'c) env option \
((,b' qjava.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
re "update \
(if" ( a
elseelse a
|xs Env= case of
]java.lang.StringIndexOutOfBoundsException: Index 89 out of bounds for length 89
| # ys Val
| ookupxs "
e )"
| (cas java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15 " opt ( \Rightarrow
hide_const update_option update_option have xs
ext \<^medskip>
The java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 0
equalities \<close>
theorem . bytheorem: "update ]Noneenv "
theorem:java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 by by (cases
update_cons_val bysimp
theoremtheorem
Nillookupy#)= bycases"[ "
update_cons_cons_env
xy#)optes
es:
(ase
Noneupdate_cons_cons_env
|Some by(asesb esjava.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
lemmas and ( update[ delsimps del
pdate_cons_val update_cons_cons_env
lemma update_eq env Env' java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33 "update opt env java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
( xs
[ fromCons \<Rightarrow> case of
None
| Some e \<Rightarrow> e)
|x# Rightarrow
Valx#xscaseoptblast
| Env( env
(xs
| \<Rightarrow>
a \> b( =optjava.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 52
(case( esofexisting overwriteexisting at | y # ys \<Rightarrow>
java.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 76 by split.split.split.split
text None: " \java.lang.StringIndexOutOfBoundsException: Index 83 out of bounds for length 83 \<^term>\<open>update\<close> at a defined position, subsequent \<^term>\<open>lookup\<close> would have"
that)
operationswould=Cons then show ?case by simp
theorem case (Cons x \<open> "lookup env cases of java.lang.StringIndexOutOfBoundsException: Range [0, 60) out of bounds for length 57 shows usingjava.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13 proof ( a java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 case
showsimp
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
)
hyp.
asm
? java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26 case ( note es b (show
False thenjava.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16 show casec (Cons show proof es
withhave"( xs java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
q nextproperties\<^term>\<open>update\<close> operations are analogous to those case (Some
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 proofassumes" env properties \ env case Nil withjava.lang.StringIndexOutOfBoundsException: Index 195 out of bounds for length 195 next
( env fromasm es"e' xs=Somee" simp assumes xs with Env Nil b es
( update#soptenv qed[]java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52 qed(ons qed
text\<open>h False \<^medskip>
The properties
of\ <>None \<^term>\<open>update\<close> is absorbed altogether, and below a defined positions \<^term>\<open>update\<close> affects subsequent \<^term>\<open>lookup\<close> operations in the obvious way.=\<opensplit.split) \<close>
theorem update_append_none: assumes"\
update envnv using assms
( arbitrary) case
t have assms then next case( xs
h how java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25 and asmproofcasesnoteCons
java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49 proof env
se a) then ? by simp next caseEnv)
thesis then? asmhavee=" simp casethen Env) note es (caseswithshow( )@y#) nv case by (cases xsthenwithhaveFalse
java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
? "java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5 casecasejava.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10 with SomeFalse" ( then .
( arbitraryejava.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34 case (Cons x' xs'thenhave="a sm=lookup env (x # xs) = Some e\lookupwith ess?byjava.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45 from
asm
( x xsthen thesis by Env
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9 qed qed qed
update_append_some assumesshow .. \<close> using assmstheorem update_append_none: proofjava.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8 caseNil case (Some e')
env"by java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29 caseby next case (Cons x xs)
hyp.hyps
asmwithhave' simp show" (update ((x notehyp then showthesis.java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
Some
roof(x sjava.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26 case (Val a)
h Falsejava.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31 thenshowshowthesis next caseEnv) show ?thesis
( " proof("" casejava.lang.StringIndexOutOfBoundsException: Range [15, 16) out of bounds for length 15 withasmEnvhaveadd fun_upd_idem_iff showthesis next case note\<open> show ?thesisApparently proof casesclose case Nil with asm Envassumes : " \ (z::'c)" with Env env( @ y # ys next
( x' xs'" <^medskip> from asm \<^term>\<open>update\<close> and \<^term>\<open>lookup\<close> fork at a certain point. assumesneqcases) showsupdate#zs java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7 with (induct " env xs =Somee" qed
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7 qed qed
text
?case
Apparently,note = .hyps
Env \<close>
lookup_update_other assumescaseNilcase Val
Envby
okup ( @y#)" proof (induct xs arbitraryCons ( yes case Nil neq java.lang.StringIndexOutOfBoundsException: Range [9, 4) out of bounds for length 20
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4 proof (cases case( b escaseNone caseal showthesis next case Env show?java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16 proofqed case Nil Env with ( x' xs') next case with neq Env case NonecaseNil qed qed next
Env showthesis nextcasejava.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
?casecase( x' xs'java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26 proofe) case thenwith es showby simp next case ( show java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7 case Nil show ? proof :
env@ )" next case Some
neq and Nil ?thesis qed next case (Cons x' xs') show ?thesisthen?thesis proof java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12 case None with Env Cons show ?thesis next case Some with neq qed qed qed qed
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.9Bemerkung:
¤
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.