author | Christian Urban <urbanc@in.tum.de> |
Tue, 18 Jul 2017 18:39:20 +0100 | |
changeset 265 | d36be1e356c0 |
parent 264 | e2828c4a1e23 |
child 266 | fff2e1b40dfc |
permissions | -rw-r--r-- |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1 |
|
185
841f7b9c0a6a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
172
diff
changeset
|
2 |
theory Lexer |
257 | 3 |
imports Main |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
4 |
begin |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
5 |
|
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
6 |
|
106
489dfa0d7ec9
more cleaning and moving unnessary stuff to the end
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
7 |
section {* Sequential Composition of Languages *} |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
8 |
|
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
9 |
definition |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
10 |
Sequ :: "string set \<Rightarrow> string set \<Rightarrow> string set" ("_ ;; _" [100,100] 100) |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
11 |
where |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
12 |
"A ;; B = {s1 @ s2 | s1 s2. s1 \<in> A \<and> s2 \<in> B}" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
13 |
|
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
14 |
text {* Two Simple Properties about Sequential Composition *} |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
15 |
|
256 | 16 |
lemma Sequ_empty_string [simp]: |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
17 |
shows "A ;; {[]} = A" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
18 |
and "{[]} ;; A = A" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
19 |
by (simp_all add: Sequ_def) |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
20 |
|
256 | 21 |
lemma Sequ_empty [simp]: |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
22 |
shows "A ;; {} = {}" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
23 |
and "{} ;; A = {}" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
24 |
by (simp_all add: Sequ_def) |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
25 |
|
106
489dfa0d7ec9
more cleaning and moving unnessary stuff to the end
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
26 |
|
145
97735ef233be
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
144
diff
changeset
|
27 |
section {* Semantic Derivative (Left Quotient) of Languages *} |
106
489dfa0d7ec9
more cleaning and moving unnessary stuff to the end
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
28 |
|
100
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
29 |
definition |
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
30 |
Der :: "char \<Rightarrow> string set \<Rightarrow> string set" |
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
31 |
where |
112
698967eceaf1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
111
diff
changeset
|
32 |
"Der c A \<equiv> {s. c # s \<in> A}" |
100
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
33 |
|
204
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
34 |
definition |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
35 |
Ders :: "string \<Rightarrow> string set \<Rightarrow> string set" |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
36 |
where |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
37 |
"Ders s A \<equiv> {s'. s @ s' \<in> A}" |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
38 |
|
100
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
39 |
lemma Der_null [simp]: |
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
40 |
shows "Der c {} = {}" |
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
41 |
unfolding Der_def |
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
42 |
by auto |
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
43 |
|
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
44 |
lemma Der_empty [simp]: |
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
45 |
shows "Der c {[]} = {}" |
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
46 |
unfolding Der_def |
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
47 |
by auto |
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
48 |
|
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
49 |
lemma Der_char [simp]: |
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
50 |
shows "Der c {[d]} = (if c = d then {[]} else {})" |
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
51 |
unfolding Der_def |
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
52 |
by auto |
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
53 |
|
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
54 |
lemma Der_union [simp]: |
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
55 |
shows "Der c (A \<union> B) = Der c A \<union> Der c B" |
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
56 |
unfolding Der_def |
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
57 |
by auto |
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
58 |
|
106
489dfa0d7ec9
more cleaning and moving unnessary stuff to the end
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
59 |
lemma Der_Sequ [simp]: |
100
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
60 |
shows "Der c (A ;; B) = (Der c A) ;; B \<union> (if [] \<in> A then Der c B else {})" |
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
61 |
unfolding Der_def Sequ_def |
106
489dfa0d7ec9
more cleaning and moving unnessary stuff to the end
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
62 |
by (auto simp add: Cons_eq_append_conv) |
100
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
63 |
|
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
64 |
|
106
489dfa0d7ec9
more cleaning and moving unnessary stuff to the end
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
65 |
section {* Kleene Star for Languages *} |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
66 |
|
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
67 |
inductive_set |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
68 |
Star :: "string set \<Rightarrow> string set" ("_\<star>" [101] 102) |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
69 |
for A :: "string set" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
70 |
where |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
71 |
start[intro]: "[] \<in> A\<star>" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
72 |
| step[intro]: "\<lbrakk>s1 \<in> A; s2 \<in> A\<star>\<rbrakk> \<Longrightarrow> s1 @ s2 \<in> A\<star>" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
73 |
|
256 | 74 |
(* Arden's lemma *) |
75 |
||
76 |
lemma Star_cases: |
|
100
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
77 |
shows "A\<star> = {[]} \<union> A ;; A\<star>" |
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
78 |
unfolding Sequ_def |
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
79 |
by (auto) (metis Star.simps) |
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
80 |
|
256 | 81 |
lemma Star_decomp: |
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
82 |
assumes "c # x \<in> A\<star>" |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
83 |
shows "\<exists>s1 s2. x = s1 @ s2 \<and> c # s1 \<in> A \<and> s2 \<in> A\<star>" |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
84 |
using assms |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
85 |
by (induct x\<equiv>"c # x" rule: Star.induct) |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
86 |
(auto simp add: append_eq_Cons_conv) |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
87 |
|
264 | 88 |
lemma Star_Der_Sequ: |
89 |
shows "Der c (A\<star>) \<subseteq> (Der c A) ;; A\<star>" |
|
90 |
unfolding Der_def |
|
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
91 |
apply(rule subsetI) |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
92 |
apply(simp) |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
93 |
unfolding Sequ_def |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
94 |
apply(simp) |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
95 |
by(auto simp add: Sequ_def Star_decomp) |
264 | 96 |
|
97 |
||
100
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
98 |
lemma Der_star [simp]: |
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
99 |
shows "Der c (A\<star>) = (Der c A) ;; A\<star>" |
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
100 |
proof - |
113
90fe1a1d7d0e
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
112
diff
changeset
|
101 |
have "Der c (A\<star>) = Der c ({[]} \<union> A ;; A\<star>)" |
256 | 102 |
by (simp only: Star_cases[symmetric]) |
100
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
103 |
also have "... = Der c (A ;; A\<star>)" |
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
104 |
by (simp only: Der_union Der_empty) (simp) |
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
105 |
also have "... = (Der c A) ;; A\<star> \<union> (if [] \<in> A then Der c (A\<star>) else {})" |
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
106 |
by simp |
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
107 |
also have "... = (Der c A) ;; A\<star>" |
264 | 108 |
using Star_Der_Sequ by auto |
100
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
109 |
finally show "Der c (A\<star>) = (Der c A) ;; A\<star>" . |
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
110 |
qed |
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
111 |
|
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
112 |
|
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
113 |
section {* Regular Expressions *} |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
114 |
|
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
115 |
datatype rexp = |
107
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
116 |
ZERO |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
117 |
| ONE |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
118 |
| CHAR char |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
119 |
| SEQ rexp rexp |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
120 |
| ALT rexp rexp |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
121 |
| STAR rexp |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
122 |
|
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
123 |
section {* Semantics of Regular Expressions *} |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
124 |
|
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
125 |
fun |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
126 |
L :: "rexp \<Rightarrow> string set" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
127 |
where |
107
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
128 |
"L (ZERO) = {}" |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
129 |
| "L (ONE) = {[]}" |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
130 |
| "L (CHAR c) = {[c]}" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
131 |
| "L (SEQ r1 r2) = (L r1) ;; (L r2)" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
132 |
| "L (ALT r1 r2) = (L r1) \<union> (L r2)" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
133 |
| "L (STAR r) = (L r)\<star>" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
134 |
|
107
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
135 |
|
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
136 |
section {* Nullable, Derivatives *} |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
137 |
|
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
138 |
fun |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
139 |
nullable :: "rexp \<Rightarrow> bool" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
140 |
where |
107
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
141 |
"nullable (ZERO) = False" |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
142 |
| "nullable (ONE) = True" |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
143 |
| "nullable (CHAR c) = False" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
144 |
| "nullable (ALT r1 r2) = (nullable r1 \<or> nullable r2)" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
145 |
| "nullable (SEQ r1 r2) = (nullable r1 \<and> nullable r2)" |
97
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
146 |
| "nullable (STAR r) = True" |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
147 |
|
107
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
148 |
|
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
149 |
fun |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
150 |
der :: "char \<Rightarrow> rexp \<Rightarrow> rexp" |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
151 |
where |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
152 |
"der c (ZERO) = ZERO" |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
153 |
| "der c (ONE) = ZERO" |
111
289728193164
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
110
diff
changeset
|
154 |
| "der c (CHAR d) = (if c = d then ONE else ZERO)" |
107
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
155 |
| "der c (ALT r1 r2) = ALT (der c r1) (der c r2)" |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
156 |
| "der c (SEQ r1 r2) = |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
157 |
(if nullable r1 |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
158 |
then ALT (SEQ (der c r1) r2) (der c r2) |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
159 |
else SEQ (der c r1) r2)" |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
160 |
| "der c (STAR r) = SEQ (der c r) (STAR r)" |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
161 |
|
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
162 |
fun |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
163 |
ders :: "string \<Rightarrow> rexp \<Rightarrow> rexp" |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
164 |
where |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
165 |
"ders [] r = r" |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
166 |
| "ders (c # s) r = ders s (der c r)" |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
167 |
|
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
168 |
|
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
169 |
lemma nullable_correctness: |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
170 |
shows "nullable r \<longleftrightarrow> [] \<in> (L r)" |
106
489dfa0d7ec9
more cleaning and moving unnessary stuff to the end
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
171 |
by (induct r) (auto simp add: Sequ_def) |
100
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
172 |
|
107
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
173 |
lemma der_correctness: |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
174 |
shows "L (der c r) = Der c (L r)" |
142
08dcf0d20f15
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
127
diff
changeset
|
175 |
by (induct r) (simp_all add: nullable_correctness) |
107
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
176 |
|
204
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
177 |
lemma ders_correctness: |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
178 |
shows "L (ders s r) = Ders s (L r)" |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
179 |
apply(induct s arbitrary: r) |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
180 |
apply(simp_all add: Ders_def der_correctness Der_def) |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
181 |
done |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
182 |
|
261 | 183 |
|
184 |
section {* Lemmas about ders *} |
|
185 |
||
204
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
186 |
lemma ders_ZERO: |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
187 |
shows "ders s (ZERO) = ZERO" |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
188 |
apply(induct s) |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
189 |
apply(simp_all) |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
190 |
done |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
191 |
|
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
192 |
lemma ders_ONE: |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
193 |
shows "ders s (ONE) = (if s = [] then ONE else ZERO)" |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
194 |
apply(induct s) |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
195 |
apply(simp_all add: ders_ZERO) |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
196 |
done |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
197 |
|
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
198 |
lemma ders_CHAR: |
261 | 199 |
shows "ders s (CHAR c) = |
200 |
(if s = [c] then ONE else |
|
201 |
(if s = [] then (CHAR c) else ZERO))" |
|
204
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
202 |
apply(induct s) |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
203 |
apply(simp_all add: ders_ZERO ders_ONE) |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
204 |
done |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
205 |
|
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
206 |
lemma ders_ALT: |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
207 |
shows "ders s (ALT r1 r2) = ALT (ders s r1) (ders s r2)" |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
208 |
apply(induct s arbitrary: r1 r2) |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
209 |
apply(simp_all) |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
210 |
done |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
211 |
|
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
212 |
section {* Values *} |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
213 |
|
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
214 |
datatype val = |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
215 |
Void |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
216 |
| Char char |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
217 |
| Seq val val |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
218 |
| Right val |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
219 |
| Left val |
97
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
220 |
| Stars "val list" |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
221 |
|
108
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
222 |
|
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
223 |
section {* The string behind a value *} |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
224 |
|
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
225 |
fun |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
226 |
flat :: "val \<Rightarrow> string" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
227 |
where |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
228 |
"flat (Void) = []" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
229 |
| "flat (Char c) = [c]" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
230 |
| "flat (Left v) = flat v" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
231 |
| "flat (Right v) = flat v" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
232 |
| "flat (Seq v1 v2) = (flat v1) @ (flat v2)" |
97
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
233 |
| "flat (Stars []) = []" |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
234 |
| "flat (Stars (v#vs)) = (flat v) @ (flat (Stars vs))" |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
235 |
|
106
489dfa0d7ec9
more cleaning and moving unnessary stuff to the end
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
236 |
lemma flat_Stars [simp]: |
97
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
237 |
"flat (Stars vs) = concat (map flat vs)" |
106
489dfa0d7ec9
more cleaning and moving unnessary stuff to the end
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
238 |
by (induct vs) (auto) |
489dfa0d7ec9
more cleaning and moving unnessary stuff to the end
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
239 |
|
90
3c8cfdf95252
proved some lemmas about star and mkeps (injval etc not yet done)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
89
diff
changeset
|
240 |
|
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
241 |
section {* Relation between values and regular expressions *} |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
242 |
|
91
f067e59b58d9
more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
90
diff
changeset
|
243 |
inductive |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
244 |
Prf :: "val \<Rightarrow> rexp \<Rightarrow> bool" ("\<turnstile> _ : _" [100, 100] 100) |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
245 |
where |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
246 |
"\<lbrakk>\<turnstile> v1 : r1; \<turnstile> v2 : r2\<rbrakk> \<Longrightarrow> \<turnstile> Seq v1 v2 : SEQ r1 r2" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
247 |
| "\<turnstile> v1 : r1 \<Longrightarrow> \<turnstile> Left v1 : ALT r1 r2" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
248 |
| "\<turnstile> v2 : r2 \<Longrightarrow> \<turnstile> Right v2 : ALT r1 r2" |
107
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
249 |
| "\<turnstile> Void : ONE" |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
250 |
| "\<turnstile> Char c : CHAR c" |
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
251 |
| "\<forall>v \<in> set vs. \<turnstile> v : r \<Longrightarrow> \<turnstile> Stars vs : STAR r" |
91
f067e59b58d9
more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
90
diff
changeset
|
252 |
|
142
08dcf0d20f15
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
127
diff
changeset
|
253 |
inductive_cases Prf_elims: |
08dcf0d20f15
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
127
diff
changeset
|
254 |
"\<turnstile> v : ZERO" |
08dcf0d20f15
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
127
diff
changeset
|
255 |
"\<turnstile> v : SEQ r1 r2" |
08dcf0d20f15
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
127
diff
changeset
|
256 |
"\<turnstile> v : ALT r1 r2" |
08dcf0d20f15
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
127
diff
changeset
|
257 |
"\<turnstile> v : ONE" |
08dcf0d20f15
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
127
diff
changeset
|
258 |
"\<turnstile> v : CHAR c" |
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
259 |
"\<turnstile> vs : STAR r" |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
260 |
|
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
261 |
lemma Star_concat: |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
262 |
assumes "\<forall>s \<in> set ss. s \<in> A" |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
263 |
shows "concat ss \<in> A\<star>" |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
264 |
using assms by (induct ss) (auto) |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
265 |
|
142
08dcf0d20f15
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
127
diff
changeset
|
266 |
|
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
267 |
lemma Prf_flat_L: |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
268 |
assumes "\<turnstile> v : r" shows "flat v \<in> L r" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
269 |
using assms |
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
270 |
by (induct v r rule: Prf.induct) |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
271 |
(auto simp add: Sequ_def Star_concat) |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
272 |
|
254 | 273 |
lemma Prf_Stars_append: |
274 |
assumes "\<turnstile> Stars vs1 : STAR r" "\<turnstile> Stars vs2 : STAR r" |
|
275 |
shows "\<turnstile> Stars (vs1 @ vs2) : STAR r" |
|
276 |
using assms |
|
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
277 |
by (auto intro!: Prf.intros elim!: Prf_elims) |
254 | 278 |
|
90
3c8cfdf95252
proved some lemmas about star and mkeps (injval etc not yet done)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
89
diff
changeset
|
279 |
lemma Star_string: |
3c8cfdf95252
proved some lemmas about star and mkeps (injval etc not yet done)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
89
diff
changeset
|
280 |
assumes "s \<in> A\<star>" |
3c8cfdf95252
proved some lemmas about star and mkeps (injval etc not yet done)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
89
diff
changeset
|
281 |
shows "\<exists>ss. concat ss = s \<and> (\<forall>s \<in> set ss. s \<in> A)" |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
282 |
using assms |
90
3c8cfdf95252
proved some lemmas about star and mkeps (injval etc not yet done)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
89
diff
changeset
|
283 |
apply(induct rule: Star.induct) |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
284 |
apply(auto) |
90
3c8cfdf95252
proved some lemmas about star and mkeps (injval etc not yet done)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
89
diff
changeset
|
285 |
apply(rule_tac x="[]" in exI) |
3c8cfdf95252
proved some lemmas about star and mkeps (injval etc not yet done)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
89
diff
changeset
|
286 |
apply(simp) |
3c8cfdf95252
proved some lemmas about star and mkeps (injval etc not yet done)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
89
diff
changeset
|
287 |
apply(rule_tac x="s1#ss" in exI) |
3c8cfdf95252
proved some lemmas about star and mkeps (injval etc not yet done)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
89
diff
changeset
|
288 |
apply(simp) |
3c8cfdf95252
proved some lemmas about star and mkeps (injval etc not yet done)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
89
diff
changeset
|
289 |
done |
3c8cfdf95252
proved some lemmas about star and mkeps (injval etc not yet done)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
89
diff
changeset
|
290 |
|
3c8cfdf95252
proved some lemmas about star and mkeps (injval etc not yet done)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
89
diff
changeset
|
291 |
lemma Star_val: |
3c8cfdf95252
proved some lemmas about star and mkeps (injval etc not yet done)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
89
diff
changeset
|
292 |
assumes "\<forall>s\<in>set ss. \<exists>v. s = flat v \<and> \<turnstile> v : r" |
3c8cfdf95252
proved some lemmas about star and mkeps (injval etc not yet done)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
89
diff
changeset
|
293 |
shows "\<exists>vs. concat (map flat vs) = concat ss \<and> (\<forall>v\<in>set vs. \<turnstile> v : r)" |
3c8cfdf95252
proved some lemmas about star and mkeps (injval etc not yet done)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
89
diff
changeset
|
294 |
using assms |
3c8cfdf95252
proved some lemmas about star and mkeps (injval etc not yet done)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
89
diff
changeset
|
295 |
apply(induct ss) |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
296 |
apply(auto) |
90
3c8cfdf95252
proved some lemmas about star and mkeps (injval etc not yet done)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
89
diff
changeset
|
297 |
apply (metis empty_iff list.set(1)) |
3c8cfdf95252
proved some lemmas about star and mkeps (injval etc not yet done)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
89
diff
changeset
|
298 |
by (metis concat.simps(2) list.simps(9) set_ConsD) |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
299 |
|
254 | 300 |
|
185
841f7b9c0a6a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
172
diff
changeset
|
301 |
lemma L_flat_Prf1: |
256 | 302 |
assumes "\<turnstile> v : r" |
303 |
shows "flat v \<in> L r" |
|
185
841f7b9c0a6a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
172
diff
changeset
|
304 |
using assms |
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
305 |
by (induct) (auto simp add: Sequ_def Star_concat) |
185
841f7b9c0a6a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
172
diff
changeset
|
306 |
|
841f7b9c0a6a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
172
diff
changeset
|
307 |
lemma L_flat_Prf2: |
256 | 308 |
assumes "s \<in> L r" |
309 |
shows "\<exists>v. \<turnstile> v : r \<and> flat v = s" |
|
185
841f7b9c0a6a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
172
diff
changeset
|
310 |
using assms |
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
311 |
proof(induct r arbitrary: s) |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
312 |
case (STAR r s) |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
313 |
have IH: "\<And>s. s \<in> L r \<Longrightarrow> \<exists>v. \<turnstile> v : r \<and> flat v = s" by fact |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
314 |
have "s \<in> L (STAR r)" by fact |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
315 |
then obtain ss where "concat ss = s" "\<forall>s \<in> set ss. s \<in> L r" |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
316 |
using Star_string by auto |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
317 |
then obtain vs where "concat (map flat vs) = s" "\<forall>v\<in>set vs. \<turnstile> v : r" |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
318 |
using IH Star_val by blast |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
319 |
then show "\<exists>v. \<turnstile> v : STAR r \<and> flat v = s" |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
320 |
using Prf.intros(6) flat_Stars by blast |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
321 |
next |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
322 |
case (SEQ r1 r2 s) |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
323 |
then show "\<exists>v. \<turnstile> v : SEQ r1 r2 \<and> flat v = s" |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
324 |
unfolding Sequ_def L.simps by (fastforce intro: Prf.intros) |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
325 |
next |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
326 |
case (ALT r1 r2 s) |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
327 |
then show "\<exists>v. \<turnstile> v : ALT r1 r2 \<and> flat v = s" |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
328 |
unfolding L.simps by (fastforce intro: Prf.intros) |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
329 |
qed (auto intro: Prf.intros) |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
330 |
|
185
841f7b9c0a6a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
172
diff
changeset
|
331 |
lemma L_flat_Prf: |
841f7b9c0a6a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
172
diff
changeset
|
332 |
"L(r) = {flat v | v. \<turnstile> v : r}" |
841f7b9c0a6a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
172
diff
changeset
|
333 |
using L_flat_Prf1 L_flat_Prf2 by blast |
841f7b9c0a6a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
172
diff
changeset
|
334 |
|
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
335 |
(* |
254 | 336 |
lemma Star_values_exists: |
337 |
assumes "s \<in> (L r)\<star>" |
|
338 |
shows "\<exists>vs. concat (map flat vs) = s \<and> \<turnstile> Stars vs : STAR r" |
|
339 |
using assms |
|
340 |
apply(drule_tac Star_string) |
|
341 |
apply(auto) |
|
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
342 |
by (metis L_flat_Prf2 Prf.intros(6) Star_val) |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
343 |
*) |
254 | 344 |
|
93
37e3f1174974
extended all proofs that worked before to the Star case...required a stronger notion of non-problematic values |=
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
92
diff
changeset
|
345 |
|
145
97735ef233be
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
144
diff
changeset
|
346 |
section {* Sulzmann and Lu functions *} |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
347 |
|
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
348 |
fun |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
349 |
mkeps :: "rexp \<Rightarrow> val" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
350 |
where |
107
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
351 |
"mkeps(ONE) = Void" |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
352 |
| "mkeps(SEQ r1 r2) = Seq (mkeps r1) (mkeps r2)" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
353 |
| "mkeps(ALT r1 r2) = (if nullable(r1) then Left (mkeps r1) else Right (mkeps r2))" |
97
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
354 |
| "mkeps(STAR r) = Stars []" |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
355 |
|
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
356 |
fun injval :: "rexp \<Rightarrow> char \<Rightarrow> val \<Rightarrow> val" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
357 |
where |
101
7f4f8c34da95
fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
100
diff
changeset
|
358 |
"injval (CHAR d) c Void = Char d" |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
359 |
| "injval (ALT r1 r2) c (Left v1) = Left(injval r1 c v1)" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
360 |
| "injval (ALT r1 r2) c (Right v2) = Right(injval r2 c v2)" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
361 |
| "injval (SEQ r1 r2) c (Seq v1 v2) = Seq (injval r1 c v1) v2" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
362 |
| "injval (SEQ r1 r2) c (Left (Seq v1 v2)) = Seq (injval r1 c v1) v2" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
363 |
| "injval (SEQ r1 r2) c (Right v2) = Seq (mkeps r1) (injval r2 c v2)" |
97
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
364 |
| "injval (STAR r) c (Seq v (Stars vs)) = Stars ((injval r c v) # vs)" |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
365 |
|
107
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
366 |
|
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
367 |
section {* Mkeps, injval *} |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
368 |
|
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
369 |
lemma mkeps_nullable: |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
370 |
assumes "nullable(r)" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
371 |
shows "\<turnstile> mkeps r : r" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
372 |
using assms |
142
08dcf0d20f15
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
127
diff
changeset
|
373 |
by (induct rule: nullable.induct) |
08dcf0d20f15
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
127
diff
changeset
|
374 |
(auto intro: Prf.intros) |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
375 |
|
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
376 |
lemma mkeps_flat: |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
377 |
assumes "nullable(r)" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
378 |
shows "flat (mkeps r) = []" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
379 |
using assms |
142
08dcf0d20f15
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
127
diff
changeset
|
380 |
by (induct rule: nullable.induct) (auto) |
08dcf0d20f15
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
127
diff
changeset
|
381 |
|
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
382 |
|
107
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
383 |
lemma Prf_injval: |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
384 |
assumes "\<turnstile> v : der c r" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
385 |
shows "\<turnstile> (injval r c v) : r" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
386 |
using assms |
107
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
387 |
apply(induct r arbitrary: c v rule: rexp.induct) |
142
08dcf0d20f15
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
127
diff
changeset
|
388 |
apply(auto intro!: Prf.intros mkeps_nullable elim!: Prf_elims split: if_splits) |
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
389 |
done |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
390 |
|
107
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
391 |
lemma Prf_injval_flat: |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
392 |
assumes "\<turnstile> v : der c r" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
393 |
shows "flat (injval r c v) = c # (flat v)" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
394 |
using assms |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
395 |
apply(induct arbitrary: v rule: der.induct) |
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
396 |
apply(auto elim!: Prf_elims intro: mkeps_flat split: if_splits) |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
397 |
done |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
398 |
|
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
399 |
|
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
400 |
|
104
59bad592a009
updated theories and cleaned them up
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
103
diff
changeset
|
401 |
section {* Our Alternative Posix definition *} |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
402 |
|
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
403 |
inductive |
146
da81ffac4b10
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
145
diff
changeset
|
404 |
Posix :: "string \<Rightarrow> rexp \<Rightarrow> val \<Rightarrow> bool" ("_ \<in> _ \<rightarrow> _" [100, 100, 100] 100) |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
405 |
where |
151
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
406 |
Posix_ONE: "[] \<in> ONE \<rightarrow> Void" |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
407 |
| Posix_CHAR: "[c] \<in> (CHAR c) \<rightarrow> (Char c)" |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
408 |
| Posix_ALT1: "s \<in> r1 \<rightarrow> v \<Longrightarrow> s \<in> (ALT r1 r2) \<rightarrow> (Left v)" |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
409 |
| Posix_ALT2: "\<lbrakk>s \<in> r2 \<rightarrow> v; s \<notin> L(r1)\<rbrakk> \<Longrightarrow> s \<in> (ALT r1 r2) \<rightarrow> (Right v)" |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
410 |
| Posix_SEQ: "\<lbrakk>s1 \<in> r1 \<rightarrow> v1; s2 \<in> r2 \<rightarrow> v2; |
97
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
411 |
\<not>(\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> (s1 @ s\<^sub>3) \<in> L r1 \<and> s\<^sub>4 \<in> L r2)\<rbrakk> \<Longrightarrow> |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
412 |
(s1 @ s2) \<in> (SEQ r1 r2) \<rightarrow> (Seq v1 v2)" |
151
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
413 |
| Posix_STAR1: "\<lbrakk>s1 \<in> r \<rightarrow> v; s2 \<in> STAR r \<rightarrow> Stars vs; flat v \<noteq> []; |
100
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
414 |
\<not>(\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> (s1 @ s\<^sub>3) \<in> L r \<and> s\<^sub>4 \<in> L (STAR r))\<rbrakk> |
97
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
415 |
\<Longrightarrow> (s1 @ s2) \<in> STAR r \<rightarrow> Stars (v # vs)" |
151
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
416 |
| Posix_STAR2: "[] \<in> STAR r \<rightarrow> Stars []" |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
417 |
|
146
da81ffac4b10
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
145
diff
changeset
|
418 |
inductive_cases Posix_elims: |
149
ec3d221bfc45
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
146
diff
changeset
|
419 |
"s \<in> ZERO \<rightarrow> v" |
143
1e7b36450d9a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
142
diff
changeset
|
420 |
"s \<in> ONE \<rightarrow> v" |
1e7b36450d9a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
142
diff
changeset
|
421 |
"s \<in> CHAR c \<rightarrow> v" |
1e7b36450d9a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
142
diff
changeset
|
422 |
"s \<in> ALT r1 r2 \<rightarrow> v" |
1e7b36450d9a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
142
diff
changeset
|
423 |
"s \<in> SEQ r1 r2 \<rightarrow> v" |
1e7b36450d9a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
142
diff
changeset
|
424 |
"s \<in> STAR r \<rightarrow> v" |
1e7b36450d9a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
142
diff
changeset
|
425 |
|
146
da81ffac4b10
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
145
diff
changeset
|
426 |
lemma Posix1: |
101
7f4f8c34da95
fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
100
diff
changeset
|
427 |
assumes "s \<in> r \<rightarrow> v" |
123
1bee7006b92b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
428 |
shows "s \<in> L r" "flat v = s" |
101
7f4f8c34da95
fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
100
diff
changeset
|
429 |
using assms |
146
da81ffac4b10
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
145
diff
changeset
|
430 |
by (induct s r v rule: Posix.induct) |
143
1e7b36450d9a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
142
diff
changeset
|
431 |
(auto simp add: Sequ_def) |
1e7b36450d9a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
142
diff
changeset
|
432 |
|
101
7f4f8c34da95
fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
100
diff
changeset
|
433 |
|
146
da81ffac4b10
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
145
diff
changeset
|
434 |
lemma Posix1a: |
122
7c6c907660d8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
121
diff
changeset
|
435 |
assumes "s \<in> r \<rightarrow> v" |
123
1bee7006b92b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
436 |
shows "\<turnstile> v : r" |
122
7c6c907660d8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
121
diff
changeset
|
437 |
using assms |
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
438 |
apply(induct s r v rule: Posix.induct) |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
439 |
apply(auto intro!: Prf.intros elim!: Prf_elims) |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
440 |
done |
185
841f7b9c0a6a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
172
diff
changeset
|
441 |
|
122
7c6c907660d8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
121
diff
changeset
|
442 |
|
146
da81ffac4b10
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
145
diff
changeset
|
443 |
lemma Posix_mkeps: |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
444 |
assumes "nullable r" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
445 |
shows "[] \<in> r \<rightarrow> mkeps r" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
446 |
using assms |
185
841f7b9c0a6a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
172
diff
changeset
|
447 |
apply(induct r rule: nullable.induct) |
146
da81ffac4b10
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
145
diff
changeset
|
448 |
apply(auto intro: Posix.intros simp add: nullable_correctness Sequ_def) |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
449 |
apply(subst append.simps(1)[symmetric]) |
146
da81ffac4b10
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
145
diff
changeset
|
450 |
apply(rule Posix.intros) |
123
1bee7006b92b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
451 |
apply(auto) |
91
f067e59b58d9
more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
90
diff
changeset
|
452 |
done |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
453 |
|
142
08dcf0d20f15
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
127
diff
changeset
|
454 |
|
146
da81ffac4b10
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
145
diff
changeset
|
455 |
lemma Posix_determ: |
122
7c6c907660d8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
121
diff
changeset
|
456 |
assumes "s \<in> r \<rightarrow> v1" "s \<in> r \<rightarrow> v2" |
7c6c907660d8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
121
diff
changeset
|
457 |
shows "v1 = v2" |
7c6c907660d8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
121
diff
changeset
|
458 |
using assms |
151
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
459 |
proof (induct s r v1 arbitrary: v2 rule: Posix.induct) |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
460 |
case (Posix_ONE v2) |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
461 |
have "[] \<in> ONE \<rightarrow> v2" by fact |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
462 |
then show "Void = v2" by cases auto |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
463 |
next |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
464 |
case (Posix_CHAR c v2) |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
465 |
have "[c] \<in> CHAR c \<rightarrow> v2" by fact |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
466 |
then show "Char c = v2" by cases auto |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
467 |
next |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
468 |
case (Posix_ALT1 s r1 v r2 v2) |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
469 |
have "s \<in> ALT r1 r2 \<rightarrow> v2" by fact |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
470 |
moreover |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
471 |
have "s \<in> r1 \<rightarrow> v" by fact |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
472 |
then have "s \<in> L r1" by (simp add: Posix1) |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
473 |
ultimately obtain v' where eq: "v2 = Left v'" "s \<in> r1 \<rightarrow> v'" by cases auto |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
474 |
moreover |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
475 |
have IH: "\<And>v2. s \<in> r1 \<rightarrow> v2 \<Longrightarrow> v = v2" by fact |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
476 |
ultimately have "v = v'" by simp |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
477 |
then show "Left v = v2" using eq by simp |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
478 |
next |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
479 |
case (Posix_ALT2 s r2 v r1 v2) |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
480 |
have "s \<in> ALT r1 r2 \<rightarrow> v2" by fact |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
481 |
moreover |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
482 |
have "s \<notin> L r1" by fact |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
483 |
ultimately obtain v' where eq: "v2 = Right v'" "s \<in> r2 \<rightarrow> v'" |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
484 |
by cases (auto simp add: Posix1) |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
485 |
moreover |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
486 |
have IH: "\<And>v2. s \<in> r2 \<rightarrow> v2 \<Longrightarrow> v = v2" by fact |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
487 |
ultimately have "v = v'" by simp |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
488 |
then show "Right v = v2" using eq by simp |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
489 |
next |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
490 |
case (Posix_SEQ s1 r1 v1 s2 r2 v2 v') |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
491 |
have "(s1 @ s2) \<in> SEQ r1 r2 \<rightarrow> v'" |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
492 |
"s1 \<in> r1 \<rightarrow> v1" "s2 \<in> r2 \<rightarrow> v2" |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
493 |
"\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L r1 \<and> s\<^sub>4 \<in> L r2)" by fact+ |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
494 |
then obtain v1' v2' where "v' = Seq v1' v2'" "s1 \<in> r1 \<rightarrow> v1'" "s2 \<in> r2 \<rightarrow> v2'" |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
495 |
apply(cases) apply (auto simp add: append_eq_append_conv2) |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
496 |
using Posix1(1) by fastforce+ |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
497 |
moreover |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
498 |
have IHs: "\<And>v1'. s1 \<in> r1 \<rightarrow> v1' \<Longrightarrow> v1 = v1'" |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
499 |
"\<And>v2'. s2 \<in> r2 \<rightarrow> v2' \<Longrightarrow> v2 = v2'" by fact+ |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
500 |
ultimately show "Seq v1 v2 = v'" by simp |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
501 |
next |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
502 |
case (Posix_STAR1 s1 r v s2 vs v2) |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
503 |
have "(s1 @ s2) \<in> STAR r \<rightarrow> v2" |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
504 |
"s1 \<in> r \<rightarrow> v" "s2 \<in> STAR r \<rightarrow> Stars vs" "flat v \<noteq> []" |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
505 |
"\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L r \<and> s\<^sub>4 \<in> L (STAR r))" by fact+ |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
506 |
then obtain v' vs' where "v2 = Stars (v' # vs')" "s1 \<in> r \<rightarrow> v'" "s2 \<in> (STAR r) \<rightarrow> (Stars vs')" |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
507 |
apply(cases) apply (auto simp add: append_eq_append_conv2) |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
508 |
using Posix1(1) apply fastforce |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
509 |
apply (metis Posix1(1) Posix_STAR1.hyps(6) append_Nil append_Nil2) |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
510 |
using Posix1(2) by blast |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
511 |
moreover |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
512 |
have IHs: "\<And>v2. s1 \<in> r \<rightarrow> v2 \<Longrightarrow> v = v2" |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
513 |
"\<And>v2. s2 \<in> STAR r \<rightarrow> v2 \<Longrightarrow> Stars vs = v2" by fact+ |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
514 |
ultimately show "Stars (v # vs) = v2" by auto |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
515 |
next |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
516 |
case (Posix_STAR2 r v2) |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
517 |
have "[] \<in> STAR r \<rightarrow> v2" by fact |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
518 |
then show "Stars [] = v2" by cases (auto simp add: Posix1) |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
519 |
qed |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
520 |
|
100
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
521 |
|
172
cdc0bdcfba3f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
151
diff
changeset
|
522 |
lemma Posix_injval: |
106
489dfa0d7ec9
more cleaning and moving unnessary stuff to the end
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
523 |
assumes "s \<in> (der c r) \<rightarrow> v" |
143
1e7b36450d9a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
142
diff
changeset
|
524 |
shows "(c # s) \<in> r \<rightarrow> (injval r c v)" |
106
489dfa0d7ec9
more cleaning and moving unnessary stuff to the end
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
525 |
using assms |
121
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
526 |
proof(induct r arbitrary: s v rule: rexp.induct) |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
527 |
case ZERO |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
528 |
have "s \<in> der c ZERO \<rightarrow> v" by fact |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
529 |
then have "s \<in> ZERO \<rightarrow> v" by simp |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
530 |
then have "False" by cases |
143
1e7b36450d9a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
142
diff
changeset
|
531 |
then show "(c # s) \<in> ZERO \<rightarrow> (injval ZERO c v)" by simp |
121
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
532 |
next |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
533 |
case ONE |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
534 |
have "s \<in> der c ONE \<rightarrow> v" by fact |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
535 |
then have "s \<in> ZERO \<rightarrow> v" by simp |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
536 |
then have "False" by cases |
143
1e7b36450d9a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
142
diff
changeset
|
537 |
then show "(c # s) \<in> ONE \<rightarrow> (injval ONE c v)" by simp |
121
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
538 |
next |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
539 |
case (CHAR d) |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
540 |
consider (eq) "c = d" | (ineq) "c \<noteq> d" by blast |
143
1e7b36450d9a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
142
diff
changeset
|
541 |
then show "(c # s) \<in> (CHAR d) \<rightarrow> (injval (CHAR d) c v)" |
121
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
542 |
proof (cases) |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
543 |
case eq |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
544 |
have "s \<in> der c (CHAR d) \<rightarrow> v" by fact |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
545 |
then have "s \<in> ONE \<rightarrow> v" using eq by simp |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
546 |
then have eqs: "s = [] \<and> v = Void" by cases simp |
142
08dcf0d20f15
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
127
diff
changeset
|
547 |
show "(c # s) \<in> CHAR d \<rightarrow> injval (CHAR d) c v" using eq eqs |
146
da81ffac4b10
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
145
diff
changeset
|
548 |
by (auto intro: Posix.intros) |
121
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
549 |
next |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
550 |
case ineq |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
551 |
have "s \<in> der c (CHAR d) \<rightarrow> v" by fact |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
552 |
then have "s \<in> ZERO \<rightarrow> v" using ineq by simp |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
553 |
then have "False" by cases |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
554 |
then show "(c # s) \<in> CHAR d \<rightarrow> injval (CHAR d) c v" by simp |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
555 |
qed |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
556 |
next |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
557 |
case (ALT r1 r2) |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
558 |
have IH1: "\<And>s v. s \<in> der c r1 \<rightarrow> v \<Longrightarrow> (c # s) \<in> r1 \<rightarrow> injval r1 c v" by fact |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
559 |
have IH2: "\<And>s v. s \<in> der c r2 \<rightarrow> v \<Longrightarrow> (c # s) \<in> r2 \<rightarrow> injval r2 c v" by fact |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
560 |
have "s \<in> der c (ALT r1 r2) \<rightarrow> v" by fact |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
561 |
then have "s \<in> ALT (der c r1) (der c r2) \<rightarrow> v" by simp |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
562 |
then consider (left) v' where "v = Left v'" "s \<in> der c r1 \<rightarrow> v'" |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
563 |
| (right) v' where "v = Right v'" "s \<notin> L (der c r1)" "s \<in> der c r2 \<rightarrow> v'" |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
564 |
by cases auto |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
565 |
then show "(c # s) \<in> ALT r1 r2 \<rightarrow> injval (ALT r1 r2) c v" |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
566 |
proof (cases) |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
567 |
case left |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
568 |
have "s \<in> der c r1 \<rightarrow> v'" by fact |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
569 |
then have "(c # s) \<in> r1 \<rightarrow> injval r1 c v'" using IH1 by simp |
146
da81ffac4b10
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
145
diff
changeset
|
570 |
then have "(c # s) \<in> ALT r1 r2 \<rightarrow> injval (ALT r1 r2) c (Left v')" by (auto intro: Posix.intros) |
121
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
571 |
then show "(c # s) \<in> ALT r1 r2 \<rightarrow> injval (ALT r1 r2) c v" using left by simp |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
572 |
next |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
573 |
case right |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
574 |
have "s \<notin> L (der c r1)" by fact |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
575 |
then have "c # s \<notin> L r1" by (simp add: der_correctness Der_def) |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
576 |
moreover |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
577 |
have "s \<in> der c r2 \<rightarrow> v'" by fact |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
578 |
then have "(c # s) \<in> r2 \<rightarrow> injval r2 c v'" using IH2 by simp |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
579 |
ultimately have "(c # s) \<in> ALT r1 r2 \<rightarrow> injval (ALT r1 r2) c (Right v')" |
146
da81ffac4b10
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
145
diff
changeset
|
580 |
by (auto intro: Posix.intros) |
121
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
581 |
then show "(c # s) \<in> ALT r1 r2 \<rightarrow> injval (ALT r1 r2) c v" using right by simp |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
582 |
qed |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
583 |
next |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
584 |
case (SEQ r1 r2) |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
585 |
have IH1: "\<And>s v. s \<in> der c r1 \<rightarrow> v \<Longrightarrow> (c # s) \<in> r1 \<rightarrow> injval r1 c v" by fact |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
586 |
have IH2: "\<And>s v. s \<in> der c r2 \<rightarrow> v \<Longrightarrow> (c # s) \<in> r2 \<rightarrow> injval r2 c v" by fact |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
587 |
have "s \<in> der c (SEQ r1 r2) \<rightarrow> v" by fact |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
588 |
then consider |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
589 |
(left_nullable) v1 v2 s1 s2 where |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
590 |
"v = Left (Seq v1 v2)" "s = s1 @ s2" |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
591 |
"s1 \<in> der c r1 \<rightarrow> v1" "s2 \<in> r2 \<rightarrow> v2" "nullable r1" |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
592 |
"\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L (der c r1) \<and> s\<^sub>4 \<in> L r2)" |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
593 |
| (right_nullable) v1 s1 s2 where |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
594 |
"v = Right v1" "s = s1 @ s2" |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
595 |
"s \<in> der c r2 \<rightarrow> v1" "nullable r1" "s1 @ s2 \<notin> L (SEQ (der c r1) r2)" |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
596 |
| (not_nullable) v1 v2 s1 s2 where |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
597 |
"v = Seq v1 v2" "s = s1 @ s2" |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
598 |
"s1 \<in> der c r1 \<rightarrow> v1" "s2 \<in> r2 \<rightarrow> v2" "\<not>nullable r1" |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
599 |
"\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L (der c r1) \<and> s\<^sub>4 \<in> L r2)" |
146
da81ffac4b10
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
145
diff
changeset
|
600 |
by (force split: if_splits elim!: Posix_elims simp add: Sequ_def der_correctness Der_def) |
121
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
601 |
then show "(c # s) \<in> SEQ r1 r2 \<rightarrow> injval (SEQ r1 r2) c v" |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
602 |
proof (cases) |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
603 |
case left_nullable |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
604 |
have "s1 \<in> der c r1 \<rightarrow> v1" by fact |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
605 |
then have "(c # s1) \<in> r1 \<rightarrow> injval r1 c v1" using IH1 by simp |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
606 |
moreover |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
607 |
have "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L (der c r1) \<and> s\<^sub>4 \<in> L r2)" by fact |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
608 |
then have "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> (c # s1) @ s\<^sub>3 \<in> L r1 \<and> s\<^sub>4 \<in> L r2)" by (simp add: der_correctness Der_def) |
146
da81ffac4b10
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
145
diff
changeset
|
609 |
ultimately have "((c # s1) @ s2) \<in> SEQ r1 r2 \<rightarrow> Seq (injval r1 c v1) v2" using left_nullable by (rule_tac Posix.intros) |
121
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
610 |
then show "(c # s) \<in> SEQ r1 r2 \<rightarrow> injval (SEQ r1 r2) c v" using left_nullable by simp |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
611 |
next |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
612 |
case right_nullable |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
613 |
have "nullable r1" by fact |
146
da81ffac4b10
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
145
diff
changeset
|
614 |
then have "[] \<in> r1 \<rightarrow> (mkeps r1)" by (rule Posix_mkeps) |
121
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
615 |
moreover |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
616 |
have "s \<in> der c r2 \<rightarrow> v1" by fact |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
617 |
then have "(c # s) \<in> r2 \<rightarrow> (injval r2 c v1)" using IH2 by simp |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
618 |
moreover |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
619 |
have "s1 @ s2 \<notin> L (SEQ (der c r1) r2)" by fact |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
620 |
then have "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = c # s \<and> [] @ s\<^sub>3 \<in> L r1 \<and> s\<^sub>4 \<in> L r2)" using right_nullable |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
621 |
by(auto simp add: der_correctness Der_def append_eq_Cons_conv Sequ_def) |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
622 |
ultimately have "([] @ (c # s)) \<in> SEQ r1 r2 \<rightarrow> Seq (mkeps r1) (injval r2 c v1)" |
146
da81ffac4b10
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
145
diff
changeset
|
623 |
by(rule Posix.intros) |
121
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
624 |
then show "(c # s) \<in> SEQ r1 r2 \<rightarrow> injval (SEQ r1 r2) c v" using right_nullable by simp |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
625 |
next |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
626 |
case not_nullable |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
627 |
have "s1 \<in> der c r1 \<rightarrow> v1" by fact |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
628 |
then have "(c # s1) \<in> r1 \<rightarrow> injval r1 c v1" using IH1 by simp |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
629 |
moreover |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
630 |
have "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L (der c r1) \<and> s\<^sub>4 \<in> L r2)" by fact |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
631 |
then have "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> (c # s1) @ s\<^sub>3 \<in> L r1 \<and> s\<^sub>4 \<in> L r2)" by (simp add: der_correctness Der_def) |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
632 |
ultimately have "((c # s1) @ s2) \<in> SEQ r1 r2 \<rightarrow> Seq (injval r1 c v1) v2" using not_nullable |
146
da81ffac4b10
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
145
diff
changeset
|
633 |
by (rule_tac Posix.intros) (simp_all) |
121
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
634 |
then show "(c # s) \<in> SEQ r1 r2 \<rightarrow> injval (SEQ r1 r2) c v" using not_nullable by simp |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
635 |
qed |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
636 |
next |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
637 |
case (STAR r) |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
638 |
have IH: "\<And>s v. s \<in> der c r \<rightarrow> v \<Longrightarrow> (c # s) \<in> r \<rightarrow> injval r c v" by fact |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
639 |
have "s \<in> der c (STAR r) \<rightarrow> v" by fact |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
640 |
then consider |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
641 |
(cons) v1 vs s1 s2 where |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
642 |
"v = Seq v1 (Stars vs)" "s = s1 @ s2" |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
643 |
"s1 \<in> der c r \<rightarrow> v1" "s2 \<in> (STAR r) \<rightarrow> (Stars vs)" |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
644 |
"\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L (der c r) \<and> s\<^sub>4 \<in> L (STAR r))" |
149
ec3d221bfc45
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
146
diff
changeset
|
645 |
apply(auto elim!: Posix_elims(1-5) simp add: der_correctness Der_def intro: Posix.intros) |
142
08dcf0d20f15
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
127
diff
changeset
|
646 |
apply(rotate_tac 3) |
149
ec3d221bfc45
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
146
diff
changeset
|
647 |
apply(erule_tac Posix_elims(6)) |
146
da81ffac4b10
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
145
diff
changeset
|
648 |
apply (simp add: Posix.intros(6)) |
da81ffac4b10
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
145
diff
changeset
|
649 |
using Posix.intros(7) by blast |
121
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
650 |
then show "(c # s) \<in> STAR r \<rightarrow> injval (STAR r) c v" |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
651 |
proof (cases) |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
652 |
case cons |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
653 |
have "s1 \<in> der c r \<rightarrow> v1" by fact |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
654 |
then have "(c # s1) \<in> r \<rightarrow> injval r c v1" using IH by simp |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
655 |
moreover |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
656 |
have "s2 \<in> STAR r \<rightarrow> Stars vs" by fact |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
657 |
moreover |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
658 |
have "(c # s1) \<in> r \<rightarrow> injval r c v1" by fact |
146
da81ffac4b10
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
145
diff
changeset
|
659 |
then have "flat (injval r c v1) = (c # s1)" by (rule Posix1) |
121
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
660 |
then have "flat (injval r c v1) \<noteq> []" by simp |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
661 |
moreover |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
662 |
have "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L (der c r) \<and> s\<^sub>4 \<in> L (STAR r))" by fact |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
663 |
then have "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> (c # s1) @ s\<^sub>3 \<in> L r \<and> s\<^sub>4 \<in> L (STAR r))" |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
664 |
by (simp add: der_correctness Der_def) |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
665 |
ultimately |
146
da81ffac4b10
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
145
diff
changeset
|
666 |
have "((c # s1) @ s2) \<in> STAR r \<rightarrow> Stars (injval r c v1 # vs)" by (rule Posix.intros) |
121
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
667 |
then show "(c # s) \<in> STAR r \<rightarrow> injval (STAR r) c v" using cons by(simp) |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
668 |
qed |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
669 |
qed |
106
489dfa0d7ec9
more cleaning and moving unnessary stuff to the end
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
670 |
|
145
97735ef233be
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
144
diff
changeset
|
671 |
|
97735ef233be
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
144
diff
changeset
|
672 |
section {* The Lexer by Sulzmann and Lu *} |
97735ef233be
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
144
diff
changeset
|
673 |
|
97735ef233be
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
144
diff
changeset
|
674 |
fun |
97735ef233be
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
144
diff
changeset
|
675 |
lexer :: "rexp \<Rightarrow> string \<Rightarrow> val option" |
97735ef233be
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
144
diff
changeset
|
676 |
where |
97735ef233be
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
144
diff
changeset
|
677 |
"lexer r [] = (if nullable r then Some(mkeps r) else None)" |
97735ef233be
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
144
diff
changeset
|
678 |
| "lexer r (c#s) = (case (lexer (der c r) s) of |
97735ef233be
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
144
diff
changeset
|
679 |
None \<Rightarrow> None |
97735ef233be
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
144
diff
changeset
|
680 |
| Some(v) \<Rightarrow> Some(injval r c v))" |
97735ef233be
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
144
diff
changeset
|
681 |
|
97735ef233be
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
144
diff
changeset
|
682 |
|
151
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
683 |
lemma lexer_correct_None: |
145
97735ef233be
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
144
diff
changeset
|
684 |
shows "s \<notin> L r \<longleftrightarrow> lexer r s = None" |
120
d74bfa11802c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
113
diff
changeset
|
685 |
apply(induct s arbitrary: r) |
143
1e7b36450d9a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
142
diff
changeset
|
686 |
apply(simp add: nullable_correctness) |
120
d74bfa11802c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
113
diff
changeset
|
687 |
apply(drule_tac x="der a r" in meta_spec) |
143
1e7b36450d9a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
142
diff
changeset
|
688 |
apply(auto simp add: der_correctness Der_def) |
120
d74bfa11802c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
113
diff
changeset
|
689 |
done |
106
489dfa0d7ec9
more cleaning and moving unnessary stuff to the end
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
690 |
|
151
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
691 |
lemma lexer_correct_Some: |
185
841f7b9c0a6a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
172
diff
changeset
|
692 |
shows "s \<in> L r \<longleftrightarrow> (\<exists>v. lexer r s = Some(v) \<and> s \<in> r \<rightarrow> v)" |
124
5378ddbd1381
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
123
diff
changeset
|
693 |
apply(induct s arbitrary: r) |
151
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
694 |
apply(auto simp add: Posix_mkeps nullable_correctness)[1] |
124
5378ddbd1381
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
123
diff
changeset
|
695 |
apply(drule_tac x="der a r" in meta_spec) |
5378ddbd1381
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
123
diff
changeset
|
696 |
apply(simp add: der_correctness Der_def) |
5378ddbd1381
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
123
diff
changeset
|
697 |
apply(rule iffI) |
172
cdc0bdcfba3f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
151
diff
changeset
|
698 |
apply(auto intro: Posix_injval simp add: Posix1(1)) |
151
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
699 |
done |
149
ec3d221bfc45
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
146
diff
changeset
|
700 |
|
186
0b94800eb616
added corollary
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
185
diff
changeset
|
701 |
lemma lexer_correctness: |
0b94800eb616
added corollary
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
185
diff
changeset
|
702 |
shows "(lexer r s = Some v) \<longleftrightarrow> s \<in> r \<rightarrow> v" |
0b94800eb616
added corollary
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
185
diff
changeset
|
703 |
and "(lexer r s = None) \<longleftrightarrow> \<not>(\<exists>v. s \<in> r \<rightarrow> v)" |
0b94800eb616
added corollary
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
185
diff
changeset
|
704 |
using Posix1(1) Posix_determ lexer_correct_None lexer_correct_Some apply fastforce |
0b94800eb616
added corollary
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
185
diff
changeset
|
705 |
using Posix1(1) lexer_correct_None lexer_correct_Some by blast |
0b94800eb616
added corollary
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
185
diff
changeset
|
706 |
|
95
a33d3040bf7e
started a paper and moved cruft to Attic
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
94
diff
changeset
|
707 |
end |