author | Christian Urban <urbanc@in.tum.de> |
Thu, 02 Mar 2017 00:56:40 +0000 | |
changeset 227 | a8749366ad5d |
parent 226 | d131cd45a346 |
child 228 | 8b432cef3805 |
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 |
|
220 | 2 |
theory LexerExt |
185
841f7b9c0a6a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
172
diff
changeset
|
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 |
|
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
16 |
lemma seq_empty [simp]: |
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 |
|
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
21 |
lemma seq_null [simp]: |
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 |
|
220 | 26 |
lemma seq_assoc: |
27 |
shows "A ;; (B ;; C) = (A ;; B) ;; C" |
|
28 |
apply(auto simp add: Sequ_def) |
|
29 |
apply(metis append_assoc) |
|
30 |
apply(metis) |
|
31 |
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
|
32 |
|
145
97735ef233be
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
144
diff
changeset
|
33 |
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
|
34 |
|
100
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
35 |
definition |
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
36 |
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
|
37 |
where |
112
698967eceaf1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
111
diff
changeset
|
38 |
"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
|
39 |
|
204
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
40 |
definition |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
41 |
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
|
42 |
where |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
43 |
"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
|
44 |
|
100
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
45 |
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
|
46 |
shows "Der c {} = {}" |
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
47 |
unfolding Der_def |
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
48 |
by auto |
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
49 |
|
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
50 |
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
|
51 |
shows "Der c {[]} = {}" |
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
52 |
unfolding Der_def |
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
53 |
by auto |
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
54 |
|
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
55 |
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
|
56 |
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
|
57 |
unfolding Der_def |
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
58 |
by auto |
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
59 |
|
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
60 |
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
|
61 |
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
|
62 |
unfolding Der_def |
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
63 |
by auto |
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
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 |
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
|
66 |
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
|
67 |
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
|
68 |
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
|
69 |
|
220 | 70 |
lemma Der_UNION: |
71 |
shows "Der c (\<Union>x\<in>A. B x) = (\<Union>x\<in>A. Der c (B x))" |
|
72 |
by (auto simp add: Der_def) |
|
73 |
||
74 |
||
75 |
section {* Power operation for Sets *} |
|
76 |
||
77 |
fun |
|
78 |
Pow :: "string set \<Rightarrow> nat \<Rightarrow> string set" ("_ \<up> _" [101, 102] 101) |
|
79 |
where |
|
80 |
"A \<up> 0 = {[]}" |
|
81 |
| "A \<up> (Suc n) = A ;; (A \<up> n)" |
|
82 |
||
83 |
lemma Pow_empty [simp]: |
|
84 |
shows "[] \<in> A \<up> n \<longleftrightarrow> (n = 0 \<or> [] \<in> A)" |
|
85 |
by(induct n) (auto simp add: Sequ_def) |
|
86 |
||
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
|
87 |
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
|
88 |
|
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
89 |
inductive_set |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
90 |
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
|
91 |
for A :: "string set" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
92 |
where |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
93 |
start[intro]: "[] \<in> A\<star>" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
94 |
| 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
|
95 |
|
100
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
96 |
lemma star_cases: |
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
97 |
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
|
98 |
unfolding Sequ_def |
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
99 |
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
|
100 |
|
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
101 |
lemma star_decomp: |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
102 |
assumes a: "c # x \<in> A\<star>" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
103 |
shows "\<exists>a b. x = a @ b \<and> c # a \<in> A \<and> b \<in> A\<star>" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
104 |
using a |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
105 |
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
|
106 |
(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
|
107 |
|
100
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
108 |
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
|
109 |
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
|
110 |
proof - |
113
90fe1a1d7d0e
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
112
diff
changeset
|
111 |
have "Der c (A\<star>) = Der c ({[]} \<union> A ;; A\<star>)" |
100
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
112 |
by (simp only: star_cases[symmetric]) |
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
113 |
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
|
114 |
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
|
115 |
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
|
116 |
by simp |
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
117 |
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
|
118 |
unfolding Sequ_def Der_def |
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
119 |
by (auto dest: star_decomp) |
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
120 |
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
|
121 |
qed |
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
122 |
|
220 | 123 |
lemma Star_in_Pow: |
124 |
assumes a: "s \<in> A\<star>" |
|
125 |
shows "\<exists>n. s \<in> A \<up> n" |
|
126 |
using a |
|
127 |
apply(induct) |
|
128 |
apply(auto) |
|
129 |
apply(rule_tac x="Suc n" in exI) |
|
130 |
apply(auto simp add: Sequ_def) |
|
131 |
done |
|
132 |
||
133 |
lemma Pow_in_Star: |
|
134 |
assumes a: "s \<in> A \<up> n" |
|
135 |
shows "s \<in> A\<star>" |
|
136 |
using a |
|
137 |
by (induct n arbitrary: s) (auto simp add: Sequ_def) |
|
138 |
||
139 |
||
140 |
lemma Star_def2: |
|
141 |
shows "A\<star> = (\<Union>n. A \<up> n)" |
|
142 |
using Star_in_Pow Pow_in_Star |
|
143 |
by (auto) |
|
144 |
||
100
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
145 |
|
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
146 |
section {* Regular Expressions *} |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
147 |
|
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
148 |
datatype rexp = |
107
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
149 |
ZERO |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
150 |
| ONE |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
151 |
| CHAR char |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
152 |
| SEQ rexp rexp |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
153 |
| ALT rexp rexp |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
154 |
| STAR rexp |
220 | 155 |
| UPNTIMES rexp nat |
221
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
156 |
| NTIMES rexp nat |
223 | 157 |
| FROMNTIMES rexp nat |
227 | 158 |
| NMTIMES rexp nat nat |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
159 |
|
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
160 |
section {* Semantics of Regular Expressions *} |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
161 |
|
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
162 |
fun |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
163 |
L :: "rexp \<Rightarrow> string set" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
164 |
where |
107
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
165 |
"L (ZERO) = {}" |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
166 |
| "L (ONE) = {[]}" |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
167 |
| "L (CHAR c) = {[c]}" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
168 |
| "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
|
169 |
| "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
|
170 |
| "L (STAR r) = (L r)\<star>" |
220 | 171 |
| "L (UPNTIMES r n) = (\<Union>i\<in> {..n} . (L r) \<up> i)" |
227 | 172 |
| "L (NTIMES r n) = (L r) \<up> n" |
223 | 173 |
| "L (FROMNTIMES r n) = (\<Union>i\<in> {n..} . (L r) \<up> i)" |
227 | 174 |
| "L (NMTIMES r n m) = (\<Union>i\<in>{n..m} . (L r) \<up> i)" |
107
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
175 |
|
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
176 |
section {* Nullable, Derivatives *} |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
177 |
|
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
178 |
fun |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
179 |
nullable :: "rexp \<Rightarrow> bool" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
180 |
where |
107
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
181 |
"nullable (ZERO) = False" |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
182 |
| "nullable (ONE) = True" |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
183 |
| "nullable (CHAR c) = False" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
184 |
| "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
|
185 |
| "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
|
186 |
| "nullable (STAR r) = True" |
220 | 187 |
| "nullable (UPNTIMES r n) = True" |
221
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
188 |
| "nullable (NTIMES r n) = (if n = 0 then True else nullable r)" |
223 | 189 |
| "nullable (FROMNTIMES r n) = (if n = 0 then True else nullable r)" |
227 | 190 |
| "nullable (NMTIMES r n m) = (if m < n then False else (if n = 0 then True else nullable r))" |
107
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
191 |
|
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
192 |
fun |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
193 |
der :: "char \<Rightarrow> rexp \<Rightarrow> rexp" |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
194 |
where |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
195 |
"der c (ZERO) = ZERO" |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
196 |
| "der c (ONE) = ZERO" |
111
289728193164
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
110
diff
changeset
|
197 |
| "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
|
198 |
| "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
|
199 |
| "der c (SEQ r1 r2) = |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
200 |
(if nullable r1 |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
201 |
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
|
202 |
else SEQ (der c r1) r2)" |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
203 |
| "der c (STAR r) = SEQ (der c r) (STAR r)" |
220 | 204 |
| "der c (UPNTIMES r 0) = ZERO" |
205 |
| "der c (UPNTIMES r (Suc n)) = SEQ (der c r) (UPNTIMES r n)" |
|
221
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
206 |
| "der c (NTIMES r 0) = ZERO" |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
207 |
| "der c (NTIMES r (Suc n)) = SEQ (der c r) (NTIMES r n)" |
225 | 208 |
| "der c (FROMNTIMES r 0) = SEQ (der c r) (FROMNTIMES r 0)" |
223 | 209 |
| "der c (FROMNTIMES r (Suc n)) = SEQ (der c r) (FROMNTIMES r n)" |
227 | 210 |
| "der c (NMTIMES r n m) = |
211 |
(if m < n then ZERO else (if n = 0 then (if m = 0 then ZERO else SEQ (der c r) (UPNTIMES r (m - 1))) else |
|
212 |
SEQ (der c r) (NMTIMES r (n - 1) (m - 1))))" |
|
107
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
213 |
|
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
214 |
fun |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
215 |
ders :: "string \<Rightarrow> rexp \<Rightarrow> rexp" |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
216 |
where |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
217 |
"ders [] r = r" |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
218 |
| "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
|
219 |
|
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
220 |
|
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
221 |
lemma nullable_correctness: |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
222 |
shows "nullable r \<longleftrightarrow> [] \<in> (L r)" |
221
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
223 |
apply(induct r) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
224 |
apply(auto simp add: Sequ_def) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
225 |
done |
100
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
226 |
|
220 | 227 |
|
228 |
lemma Suc_reduce_Union2: |
|
229 |
"(\<Union>x\<in>{Suc n..}. B x) = (\<Union>x\<in>{n..}. B (Suc x))" |
|
230 |
apply(auto) |
|
231 |
apply(rule_tac x="xa - 1" in bexI) |
|
232 |
apply(simp) |
|
233 |
apply(simp) |
|
234 |
done |
|
235 |
||
236 |
lemma Seq_UNION: |
|
237 |
shows "(\<Union>x\<in>A. B ;; C x) = B ;; (\<Union>x\<in>A. C x)" |
|
238 |
by (auto simp add: Sequ_def) |
|
239 |
||
240 |
lemma Der_Pow [simp]: |
|
241 |
shows "Der c (A \<up> (Suc n)) = |
|
242 |
(Der c A) ;; (A \<up> n) \<union> (if [] \<in> A then Der c (A \<up> n) else {})" |
|
243 |
unfolding Der_def Sequ_def |
|
244 |
by(auto simp add: Cons_eq_append_conv Sequ_def) |
|
245 |
||
246 |
lemma Suc_Union: |
|
247 |
"(\<Union>x\<le>Suc m. B x) = (B (Suc m) \<union> (\<Union>x\<le>m. B x))" |
|
248 |
by (metis UN_insert atMost_Suc) |
|
249 |
||
250 |
||
221
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
251 |
lemma Der_Pow_subseteq: |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
252 |
assumes "[] \<in> A" |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
253 |
shows "Der c (A \<up> n) \<subseteq> (Der c A) ;; (A \<up> n)" |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
254 |
using assms |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
255 |
apply(induct n) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
256 |
apply(simp add: Sequ_def Der_def) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
257 |
apply(simp) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
258 |
apply(rule conjI) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
259 |
apply (smt Sequ_def append_Nil2 mem_Collect_eq seq_assoc subsetI) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
260 |
apply(subgoal_tac "((Der c A) ;; (A \<up> n)) \<subseteq> ((Der c A) ;; (A ;; (A \<up> n)))") |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
261 |
apply(auto)[1] |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
262 |
by (smt Sequ_def append_Nil2 mem_Collect_eq seq_assoc subsetI) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
263 |
|
220 | 264 |
lemma test: |
265 |
shows "(\<Union>x\<le>Suc n. Der c (L r \<up> x)) = (\<Union>x\<le>n. Der c (L r) ;; L r \<up> x)" |
|
266 |
apply(induct n) |
|
267 |
apply(simp) |
|
268 |
apply(auto)[1] |
|
269 |
apply(case_tac xa) |
|
270 |
apply(simp) |
|
271 |
apply(simp) |
|
272 |
apply(auto)[1] |
|
273 |
apply(case_tac "[] \<in> L r") |
|
274 |
apply(simp) |
|
275 |
apply(simp) |
|
276 |
by (smt Der_Pow Suc_Union inf_sup_aci(5) inf_sup_aci(7) sup_idem) |
|
277 |
||
227 | 278 |
lemma test2: |
279 |
shows "(\<Union>x\<in>(Suc ` A). Der c (L r \<up> x)) = (\<Union>x\<in>A. Der c (L r) ;; L r \<up> x)" |
|
280 |
apply(auto)[1] |
|
281 |
apply(case_tac "[] \<in> L r") |
|
282 |
apply(simp) |
|
283 |
defer |
|
284 |
apply(simp) |
|
285 |
using Der_Pow_subseteq by blast |
|
226 | 286 |
|
221
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
287 |
|
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
288 |
lemma Der_Pow_notin: |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
289 |
assumes "[] \<notin> A" |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
290 |
shows "Der c (A \<up> (Suc n)) = (Der c A) ;; (A \<up> n)" |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
291 |
using assms |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
292 |
by(simp) |
220 | 293 |
|
107
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
294 |
lemma der_correctness: |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
295 |
shows "L (der c r) = Der c (L r)" |
220 | 296 |
apply(induct c r rule: der.induct) |
297 |
apply(simp_all add: nullable_correctness)[7] |
|
298 |
apply(simp only: der.simps L.simps) |
|
299 |
apply(simp only: Der_UNION) |
|
300 |
apply(simp only: Seq_UNION[symmetric]) |
|
301 |
apply(simp add: test) |
|
221
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
302 |
apply(simp) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
303 |
(* NTIMES *) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
304 |
apply(simp only: L.simps der.simps) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
305 |
apply(simp) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
306 |
apply(rule impI) |
223 | 307 |
apply (simp add: Der_Pow_subseteq sup_absorb1) |
308 |
(* FROMNTIMES *) |
|
309 |
apply(simp only: der.simps) |
|
310 |
apply(simp only: L.simps) |
|
225 | 311 |
apply(simp) |
312 |
using Der_star Star_def2 apply auto[1] |
|
223 | 313 |
apply(simp only: der.simps) |
314 |
apply(simp only: L.simps) |
|
315 |
apply(simp add: Der_UNION) |
|
227 | 316 |
apply(smt Der_Pow Der_Pow_notin Der_Pow_subseteq SUP_cong Seq_UNION Suc_reduce_Union2 sup.absorb_iff1) |
317 |
(* NMTIMES *) |
|
318 |
apply(case_tac "n \<le> m") |
|
319 |
prefer 2 |
|
320 |
apply(simp only: der.simps if_True) |
|
321 |
apply(simp only: L.simps) |
|
322 |
apply(simp) |
|
323 |
apply(auto) |
|
324 |
apply(subst (asm) Seq_UNION[symmetric]) |
|
325 |
apply(subst (asm) test[symmetric]) |
|
326 |
apply(auto simp add: Der_UNION)[1] |
|
327 |
apply(auto simp add: Der_UNION)[1] |
|
328 |
apply(subst Seq_UNION[symmetric]) |
|
329 |
apply(subst test[symmetric]) |
|
330 |
apply(auto)[1] |
|
331 |
apply(subst (asm) Seq_UNION[symmetric]) |
|
332 |
apply(subst (asm) test2[symmetric]) |
|
333 |
apply(auto simp add: Der_UNION)[1] |
|
334 |
apply(subst Seq_UNION[symmetric]) |
|
335 |
apply(subst test2[symmetric]) |
|
336 |
apply(auto simp add: Der_UNION)[1] |
|
337 |
done |
|
107
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
338 |
|
204
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
339 |
lemma ders_correctness: |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
340 |
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
|
341 |
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
|
342 |
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
|
343 |
done |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
344 |
|
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
345 |
lemma ders_ZERO: |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
346 |
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
|
347 |
apply(induct s) |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
348 |
apply(simp_all) |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
349 |
done |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
350 |
|
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
351 |
lemma ders_ONE: |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
352 |
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
|
353 |
apply(induct s) |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
354 |
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
|
355 |
done |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
356 |
|
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
357 |
lemma ders_CHAR: |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
358 |
shows "ders s (CHAR c) = (if s = [c] then ONE else |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
359 |
(if s = [] then (CHAR c) else ZERO))" |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
360 |
apply(induct s) |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
361 |
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
|
362 |
done |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
363 |
|
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
364 |
lemma ders_ALT: |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
365 |
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
|
366 |
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
|
367 |
apply(simp_all) |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
368 |
done |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
369 |
|
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
370 |
section {* Values *} |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
371 |
|
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
372 |
datatype val = |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
373 |
Void |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
374 |
| Char char |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
375 |
| Seq val val |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
376 |
| Right val |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
377 |
| Left val |
97
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
378 |
| Stars "val list" |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
379 |
|
108
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
380 |
|
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
381 |
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
|
382 |
|
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
383 |
fun |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
384 |
flat :: "val \<Rightarrow> string" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
385 |
where |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
386 |
"flat (Void) = []" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
387 |
| "flat (Char c) = [c]" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
388 |
| "flat (Left v) = flat v" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
389 |
| "flat (Right v) = flat v" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
390 |
| "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
|
391 |
| "flat (Stars []) = []" |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
392 |
| "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
|
393 |
|
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
|
394 |
lemma flat_Stars [simp]: |
97
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
395 |
"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
|
396 |
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
|
397 |
|
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
|
398 |
|
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
399 |
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
|
400 |
|
91
f067e59b58d9
more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
90
diff
changeset
|
401 |
inductive |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
402 |
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
|
403 |
where |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
404 |
"\<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
|
405 |
| "\<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
|
406 |
| "\<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
|
407 |
| "\<turnstile> Void : ONE" |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
408 |
| "\<turnstile> Char c : CHAR c" |
223 | 409 |
| "\<lbrakk>\<forall>v \<in> set vs. \<turnstile> v : r\<rbrakk> \<Longrightarrow> \<turnstile> Stars vs : STAR r" |
410 |
| "\<lbrakk>\<forall>v \<in> set vs. \<turnstile> v : r; length vs \<le> n\<rbrakk> \<Longrightarrow> \<turnstile> Stars vs : UPNTIMES r n" |
|
411 |
| "\<lbrakk>\<forall>v \<in> set vs. \<turnstile> v : r; length vs = n\<rbrakk> \<Longrightarrow> \<turnstile> Stars vs : NTIMES r n" |
|
412 |
| "\<lbrakk>\<forall>v \<in> set vs. \<turnstile> v : r; length vs \<ge> n\<rbrakk> \<Longrightarrow> \<turnstile> Stars vs : FROMNTIMES r n" |
|
227 | 413 |
| "\<lbrakk>\<forall>v \<in> set vs. \<turnstile> v : r; length vs \<ge> n; length vs \<le> m\<rbrakk> \<Longrightarrow> \<turnstile> Stars vs : NMTIMES r n m" |
91
f067e59b58d9
more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
90
diff
changeset
|
414 |
|
142
08dcf0d20f15
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
127
diff
changeset
|
415 |
inductive_cases Prf_elims: |
08dcf0d20f15
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
127
diff
changeset
|
416 |
"\<turnstile> v : ZERO" |
08dcf0d20f15
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
127
diff
changeset
|
417 |
"\<turnstile> v : SEQ r1 r2" |
08dcf0d20f15
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
127
diff
changeset
|
418 |
"\<turnstile> v : ALT r1 r2" |
08dcf0d20f15
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
127
diff
changeset
|
419 |
"\<turnstile> v : ONE" |
08dcf0d20f15
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
127
diff
changeset
|
420 |
"\<turnstile> v : CHAR c" |
08dcf0d20f15
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
127
diff
changeset
|
421 |
(* "\<turnstile> vs : STAR r"*) |
08dcf0d20f15
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
127
diff
changeset
|
422 |
|
223 | 423 |
lemma Prf_STAR: |
424 |
assumes "\<forall>v\<in>set vs. \<turnstile> v : r \<and> flat v \<in> L r" |
|
425 |
shows "concat (map flat vs) \<in> L r\<star>" |
|
426 |
using assms |
|
427 |
apply(induct vs) |
|
428 |
apply(auto) |
|
429 |
done |
|
430 |
||
431 |
lemma Prf_Pow: |
|
432 |
assumes "\<forall>v\<in>set vs. \<turnstile> v : r \<and> flat v \<in> L r" |
|
433 |
shows "concat (map flat vs) \<in> L r \<up> length vs" |
|
434 |
using assms |
|
435 |
apply(induct vs) |
|
436 |
apply(auto simp add: Sequ_def) |
|
437 |
done |
|
438 |
||
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
439 |
lemma Prf_flat_L: |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
440 |
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
|
441 |
using assms |
220 | 442 |
apply(induct v r rule: Prf.induct) |
443 |
apply(auto simp add: Sequ_def) |
|
223 | 444 |
apply(rule Prf_STAR) |
445 |
apply(simp) |
|
446 |
apply(rule_tac x="length vs" in bexI) |
|
447 |
apply(rule Prf_Pow) |
|
448 |
apply(simp) |
|
449 |
apply(simp) |
|
450 |
apply(rule Prf_Pow) |
|
451 |
apply(simp) |
|
452 |
apply(rule_tac x="length vs" in bexI) |
|
453 |
apply(rule Prf_Pow) |
|
454 |
apply(simp) |
|
455 |
apply(simp) |
|
227 | 456 |
apply(rule_tac x="length vs" in bexI) |
457 |
apply(rule Prf_Pow) |
|
458 |
apply(simp) |
|
459 |
apply(simp) |
|
221
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
460 |
done |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
461 |
|
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
|
462 |
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
|
463 |
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
|
464 |
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
|
465 |
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
|
466 |
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
|
467 |
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
|
468 |
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
|
469 |
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
|
470 |
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
|
471 |
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
|
472 |
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
|
473 |
|
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
|
474 |
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
|
475 |
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
|
476 |
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
|
477 |
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
|
478 |
apply(induct ss) |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
479 |
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
|
480 |
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
|
481 |
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
|
482 |
|
220 | 483 |
lemma Star_val_length: |
484 |
assumes "\<forall>s\<in>set ss. \<exists>v. s = flat v \<and> \<turnstile> v : r" |
|
485 |
shows "\<exists>vs. concat (map flat vs) = concat ss \<and> (\<forall>v\<in>set vs. \<turnstile> v : r) \<and> (length vs) = (length ss)" |
|
486 |
using assms |
|
487 |
apply(induct ss) |
|
488 |
apply(auto) |
|
489 |
by (metis List.bind_def bind_simps(2) length_Suc_conv set_ConsD) |
|
490 |
||
491 |
||
492 |
lemma Star_Pow: |
|
493 |
assumes "s \<in> A \<up> n" |
|
494 |
shows "\<exists>ss. concat ss = s \<and> (\<forall>s \<in> set ss. s \<in> A) \<and> (length ss = n)" |
|
495 |
using assms |
|
496 |
apply(induct n arbitrary: s) |
|
497 |
apply(auto simp add: Sequ_def) |
|
498 |
apply(drule_tac x="s2" in meta_spec) |
|
499 |
apply(auto) |
|
500 |
apply(rule_tac x="s1#ss" in exI) |
|
501 |
apply(simp) |
|
502 |
done |
|
503 |
||
185
841f7b9c0a6a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
172
diff
changeset
|
504 |
|
841f7b9c0a6a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
172
diff
changeset
|
505 |
lemma L_flat_Prf2: |
841f7b9c0a6a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
172
diff
changeset
|
506 |
assumes "s \<in> L r" shows "\<exists>v. \<turnstile> v : r \<and> flat v = s" |
841f7b9c0a6a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
172
diff
changeset
|
507 |
using assms |
841f7b9c0a6a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
172
diff
changeset
|
508 |
apply(induct r arbitrary: s) |
841f7b9c0a6a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
172
diff
changeset
|
509 |
apply(auto simp add: Sequ_def intro: Prf.intros) |
841f7b9c0a6a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
172
diff
changeset
|
510 |
using Prf.intros(1) flat.simps(5) apply blast |
841f7b9c0a6a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
172
diff
changeset
|
511 |
using Prf.intros(2) flat.simps(3) apply blast |
841f7b9c0a6a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
172
diff
changeset
|
512 |
using Prf.intros(3) flat.simps(4) apply blast |
841f7b9c0a6a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
172
diff
changeset
|
513 |
apply(subgoal_tac "\<exists>vs::val list. concat (map flat vs) = s \<and> (\<forall>v \<in> set vs. \<turnstile> v : r)") |
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
|
514 |
apply(auto)[1] |
97
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
515 |
apply(rule_tac x="Stars vs" in exI) |
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
|
516 |
apply(simp) |
223 | 517 |
apply(rule Prf.intros) |
518 |
apply(simp) |
|
519 |
using Star_string Star_val apply force |
|
220 | 520 |
apply(subgoal_tac "\<exists>vs::val list. concat (map flat vs) = s \<and> (\<forall>v \<in> set vs. \<turnstile> v : r) \<and> (length vs = x)") |
521 |
apply(auto)[1] |
|
522 |
apply(rule_tac x="Stars vs" in exI) |
|
523 |
apply(simp) |
|
223 | 524 |
apply(rule Prf.intros) |
220 | 525 |
apply(simp) |
223 | 526 |
apply(simp) |
527 |
using Star_Pow Star_val_length apply blast |
|
221
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
528 |
apply(subgoal_tac "\<exists>vs::val list. concat (map flat vs) = s \<and> (\<forall>v \<in> set vs. \<turnstile> v : r) \<and> (length vs = x2)") |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
529 |
apply(auto)[1] |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
530 |
apply(rule_tac x="Stars vs" in exI) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
531 |
apply(simp) |
223 | 532 |
apply(rule Prf.intros) |
221
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
533 |
apply(simp) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
534 |
apply(simp) |
223 | 535 |
using Star_Pow Star_val_length apply blast |
536 |
apply(subgoal_tac "\<exists>vs::val list. concat (map flat vs) = s \<and> (\<forall>v \<in> set vs. \<turnstile> v : r) \<and> (length vs = x)") |
|
537 |
apply(auto)[1] |
|
538 |
apply(rule_tac x="Stars vs" in exI) |
|
539 |
apply(simp) |
|
540 |
apply(rule Prf.intros) |
|
541 |
apply(simp) |
|
542 |
apply(simp) |
|
543 |
using Star_Pow Star_val_length apply blast |
|
227 | 544 |
apply(subgoal_tac "\<exists>vs::val list. concat (map flat vs) = s \<and> (\<forall>v \<in> set vs. \<turnstile> v : r) \<and> (length vs = x)") |
545 |
apply(auto)[1] |
|
546 |
apply(rule_tac x="Stars vs" in exI) |
|
547 |
apply(simp) |
|
548 |
apply(rule Prf.intros) |
|
549 |
apply(simp) |
|
550 |
apply(simp) |
|
551 |
apply(simp) |
|
552 |
using Star_Pow Star_val_length apply blast |
|
223 | 553 |
done |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
554 |
|
185
841f7b9c0a6a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
172
diff
changeset
|
555 |
lemma L_flat_Prf: |
841f7b9c0a6a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
172
diff
changeset
|
556 |
"L(r) = {flat v | v. \<turnstile> v : r}" |
223 | 557 |
using Prf_flat_L L_flat_Prf2 by blast |
185
841f7b9c0a6a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
172
diff
changeset
|
558 |
|
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
|
559 |
|
145
97735ef233be
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
144
diff
changeset
|
560 |
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
|
561 |
|
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
562 |
fun |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
563 |
mkeps :: "rexp \<Rightarrow> val" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
564 |
where |
107
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
565 |
"mkeps(ONE) = Void" |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
566 |
| "mkeps(SEQ r1 r2) = Seq (mkeps r1) (mkeps r2)" |
227 | 567 |
| "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
|
568 |
| "mkeps(STAR r) = Stars []" |
220 | 569 |
| "mkeps(UPNTIMES r n) = Stars []" |
221
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
570 |
| "mkeps(NTIMES r n) = Stars (replicate n (mkeps r))" |
223 | 571 |
| "mkeps(FROMNTIMES r n) = Stars (replicate n (mkeps r))" |
227 | 572 |
| "mkeps(NMTIMES r n m) = Stars (replicate n (mkeps r))" |
573 |
||
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
574 |
|
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
575 |
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
|
576 |
where |
101
7f4f8c34da95
fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
100
diff
changeset
|
577 |
"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
|
578 |
| "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
|
579 |
| "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
|
580 |
| "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
|
581 |
| "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
|
582 |
| "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
|
583 |
| "injval (STAR r) c (Seq v (Stars vs)) = Stars ((injval r c v) # vs)" |
220 | 584 |
| "injval (UPNTIMES r n) c (Seq v (Stars vs)) = Stars ((injval r c v) # vs)" |
221
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
585 |
| "injval (NTIMES r n) c (Seq v (Stars vs)) = Stars ((injval r c v) # vs)" |
223 | 586 |
| "injval (FROMNTIMES r n) c (Seq v (Stars vs)) = Stars ((injval r c v) # vs)" |
227 | 587 |
| "injval (NMTIMES r n m) c (Seq v (Stars vs)) = Stars ((injval r c v) # vs)" |
588 |
||
107
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
589 |
|
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
590 |
section {* Mkeps, injval *} |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
591 |
|
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
592 |
lemma mkeps_nullable: |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
593 |
assumes "nullable(r)" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
594 |
shows "\<turnstile> mkeps r : r" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
595 |
using assms |
221
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
596 |
apply(induct r rule: mkeps.induct) |
220 | 597 |
apply(auto intro: Prf.intros) |
227 | 598 |
by (metis Prf.intros(10) in_set_replicate length_replicate not_le order_refl) |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
599 |
|
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
600 |
lemma mkeps_flat: |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
601 |
assumes "nullable(r)" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
602 |
shows "flat (mkeps r) = []" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
603 |
using assms |
227 | 604 |
apply (induct rule: nullable.induct) |
605 |
apply(auto) |
|
606 |
by meson |
|
142
08dcf0d20f15
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
127
diff
changeset
|
607 |
|
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
608 |
|
107
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
609 |
lemma Prf_injval: |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
610 |
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
|
611 |
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
|
612 |
using assms |
107
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
613 |
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
|
614 |
apply(auto intro!: Prf.intros mkeps_nullable elim!: Prf_elims split: if_splits) |
107
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
615 |
(* STAR *) |
91
f067e59b58d9
more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
90
diff
changeset
|
616 |
apply(rotate_tac 2) |
f067e59b58d9
more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
90
diff
changeset
|
617 |
apply(erule Prf.cases) |
223 | 618 |
apply(simp_all) |
91
f067e59b58d9
more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
90
diff
changeset
|
619 |
apply(auto) |
223 | 620 |
using Prf.intros(6) apply auto[1] |
220 | 621 |
(* UPNTIMES *) |
622 |
apply(case_tac x2) |
|
623 |
apply(simp) |
|
624 |
using Prf_elims(1) apply auto[1] |
|
625 |
apply(simp) |
|
626 |
apply(erule Prf.cases) |
|
627 |
apply(simp_all) |
|
628 |
apply(clarify) |
|
223 | 629 |
apply(rotate_tac 2) |
630 |
apply(erule Prf.cases) |
|
631 |
apply(simp_all) |
|
220 | 632 |
apply(clarify) |
223 | 633 |
using Prf.intros(7) apply auto[1] |
221
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
634 |
(* NTIMES *) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
635 |
apply(case_tac x2) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
636 |
apply(simp) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
637 |
using Prf_elims(1) apply auto[1] |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
638 |
apply(simp) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
639 |
apply(erule Prf.cases) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
640 |
apply(simp_all) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
641 |
apply(clarify) |
223 | 642 |
apply(rotate_tac 2) |
643 |
apply(erule Prf.cases) |
|
644 |
apply(simp_all) |
|
221
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
645 |
apply(clarify) |
223 | 646 |
using Prf.intros(8) apply auto[1] |
647 |
(* FROMNTIMES *) |
|
648 |
apply(case_tac x2) |
|
221
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
649 |
apply(simp) |
223 | 650 |
apply(erule Prf.cases) |
651 |
apply(simp_all) |
|
652 |
apply(clarify) |
|
653 |
apply(rotate_tac 2) |
|
654 |
apply(erule Prf.cases) |
|
655 |
apply(simp_all) |
|
656 |
apply(clarify) |
|
657 |
using Prf.intros(9) apply auto[1] |
|
658 |
apply(rotate_tac 1) |
|
659 |
apply(erule Prf.cases) |
|
660 |
apply(simp_all) |
|
661 |
apply(clarify) |
|
662 |
apply(rotate_tac 2) |
|
663 |
apply(erule Prf.cases) |
|
664 |
apply(simp_all) |
|
665 |
apply(clarify) |
|
227 | 666 |
using Prf.intros(9) apply auto |
667 |
(* NMTIMES *) |
|
668 |
apply(rotate_tac 3) |
|
669 |
apply(erule Prf.cases) |
|
670 |
apply(simp_all) |
|
671 |
apply(clarify) |
|
672 |
apply(rule Prf.intros) |
|
673 |
apply(auto)[2] |
|
674 |
apply simp |
|
675 |
apply(rotate_tac 4) |
|
676 |
apply(erule Prf.cases) |
|
677 |
apply(simp_all) |
|
678 |
apply(clarify) |
|
679 |
apply(rule Prf.intros) |
|
680 |
apply(auto)[2] |
|
681 |
apply simp |
|
682 |
done |
|
223 | 683 |
|
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
684 |
|
107
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
685 |
lemma Prf_injval_flat: |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
686 |
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
|
687 |
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
|
688 |
using assms |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
689 |
apply(induct arbitrary: v rule: der.induct) |
144
b356c7adf61a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
143
diff
changeset
|
690 |
apply(auto elim!: Prf_elims split: if_splits) |
b356c7adf61a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
143
diff
changeset
|
691 |
apply(metis mkeps_flat) |
91
f067e59b58d9
more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
90
diff
changeset
|
692 |
apply(rotate_tac 2) |
f067e59b58d9
more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
90
diff
changeset
|
693 |
apply(erule Prf.cases) |
220 | 694 |
apply(simp_all) |
223 | 695 |
apply(rotate_tac 2) |
696 |
apply(erule Prf.cases) |
|
697 |
apply(simp_all) |
|
698 |
apply(rotate_tac 2) |
|
699 |
apply(erule Prf.cases) |
|
700 |
apply(simp_all) |
|
701 |
apply(rotate_tac 2) |
|
702 |
apply(erule Prf.cases) |
|
703 |
apply(simp_all) |
|
704 |
apply(rotate_tac 2) |
|
705 |
apply(erule Prf.cases) |
|
706 |
apply(simp_all) |
|
227 | 707 |
apply(rotate_tac 3) |
708 |
apply(erule Prf.cases) |
|
709 |
apply(simp_all) |
|
710 |
apply(rotate_tac 4) |
|
711 |
apply(erule Prf.cases) |
|
712 |
apply(simp_all) |
|
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
713 |
done |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
714 |
|
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
715 |
|
104
59bad592a009
updated theories and cleaned them up
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
103
diff
changeset
|
716 |
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
|
717 |
|
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
718 |
inductive |
146
da81ffac4b10
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
145
diff
changeset
|
719 |
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
|
720 |
where |
151
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
721 |
Posix_ONE: "[] \<in> ONE \<rightarrow> Void" |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
722 |
| 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
|
723 |
| 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
|
724 |
| 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
|
725 |
| 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
|
726 |
\<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
|
727 |
(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
|
728 |
| 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
|
729 |
\<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
|
730 |
\<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
|
731 |
| Posix_STAR2: "[] \<in> STAR r \<rightarrow> Stars []" |
220 | 732 |
| Posix_UPNTIMES1: "\<lbrakk>s1 \<in> r \<rightarrow> v; s2 \<in> UPNTIMES r n \<rightarrow> Stars vs; flat v \<noteq> []; |
733 |
\<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 (UPNTIMES r n))\<rbrakk> |
|
734 |
\<Longrightarrow> (s1 @ s2) \<in> UPNTIMES r (Suc n) \<rightarrow> Stars (v # vs)" |
|
735 |
| Posix_UPNTIMES2: "[] \<in> UPNTIMES r n \<rightarrow> Stars []" |
|
221
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
736 |
| Posix_NTIMES1: "\<lbrakk>s1 \<in> r \<rightarrow> v; s2 \<in> NTIMES r n \<rightarrow> Stars vs; |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
737 |
\<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 (NTIMES r n))\<rbrakk> |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
738 |
\<Longrightarrow> (s1 @ s2) \<in> NTIMES r (Suc n) \<rightarrow> Stars (v # vs)" |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
739 |
| Posix_NTIMES2: "[] \<in> NTIMES r 0 \<rightarrow> Stars []" |
223 | 740 |
| Posix_FROMNTIMES1: "\<lbrakk>s1 \<in> r \<rightarrow> v; s2 \<in> FROMNTIMES r n \<rightarrow> Stars vs; |
741 |
\<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 (FROMNTIMES r n))\<rbrakk> |
|
742 |
\<Longrightarrow> (s1 @ s2) \<in> FROMNTIMES r (Suc n) \<rightarrow> Stars (v # vs)" |
|
225 | 743 |
| Posix_FROMNTIMES2: "s \<in> STAR r \<rightarrow> Stars vs \<Longrightarrow> s \<in> FROMNTIMES r 0 \<rightarrow> Stars vs" |
227 | 744 |
| Posix_NMTIMES1: "\<lbrakk>s1 \<in> r \<rightarrow> v; s2 \<in> NMTIMES r n m \<rightarrow> Stars vs; |
745 |
\<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 (NMTIMES r n m))\<rbrakk> |
|
746 |
\<Longrightarrow> (s1 @ s2) \<in> NMTIMES r (Suc n) (Suc m) \<rightarrow> Stars (v # vs)" |
|
747 |
| Posix_NMTIMES2: "s \<in> UPNTIMES r m \<rightarrow> Stars vs \<Longrightarrow> s \<in> NMTIMES r 0 m \<rightarrow> Stars vs" |
|
225 | 748 |
|
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
749 |
|
146
da81ffac4b10
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
145
diff
changeset
|
750 |
inductive_cases Posix_elims: |
149
ec3d221bfc45
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
146
diff
changeset
|
751 |
"s \<in> ZERO \<rightarrow> v" |
143
1e7b36450d9a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
142
diff
changeset
|
752 |
"s \<in> ONE \<rightarrow> v" |
1e7b36450d9a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
142
diff
changeset
|
753 |
"s \<in> CHAR c \<rightarrow> v" |
1e7b36450d9a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
142
diff
changeset
|
754 |
"s \<in> ALT r1 r2 \<rightarrow> v" |
1e7b36450d9a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
142
diff
changeset
|
755 |
"s \<in> SEQ r1 r2 \<rightarrow> v" |
1e7b36450d9a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
142
diff
changeset
|
756 |
"s \<in> STAR r \<rightarrow> v" |
1e7b36450d9a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
142
diff
changeset
|
757 |
|
146
da81ffac4b10
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
145
diff
changeset
|
758 |
lemma Posix1: |
101
7f4f8c34da95
fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
100
diff
changeset
|
759 |
assumes "s \<in> r \<rightarrow> v" |
123
1bee7006b92b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
760 |
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
|
761 |
using assms |
220 | 762 |
apply (induct s r v rule: Posix.induct) |
763 |
apply(auto simp add: Sequ_def) |
|
764 |
apply(rule_tac x="Suc x" in bexI) |
|
765 |
apply(auto simp add: Sequ_def) |
|
223 | 766 |
apply(rule_tac x="Suc x" in bexI) |
767 |
apply(auto simp add: Sequ_def) |
|
227 | 768 |
apply(simp add: Star_in_Pow) |
769 |
apply(rule_tac x="Suc x" in bexI) |
|
770 |
apply(auto simp add: Sequ_def) |
|
771 |
done |
|
143
1e7b36450d9a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
142
diff
changeset
|
772 |
|
101
7f4f8c34da95
fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
100
diff
changeset
|
773 |
|
146
da81ffac4b10
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
145
diff
changeset
|
774 |
lemma Posix1a: |
122
7c6c907660d8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
121
diff
changeset
|
775 |
assumes "s \<in> r \<rightarrow> v" |
123
1bee7006b92b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
776 |
shows "\<turnstile> v : r" |
122
7c6c907660d8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
121
diff
changeset
|
777 |
using assms |
220 | 778 |
apply(induct s r v rule: Posix.induct) |
779 |
apply(auto intro: Prf.intros) |
|
223 | 780 |
apply(rule Prf.intros) |
781 |
apply(auto)[1] |
|
782 |
apply(rotate_tac 3) |
|
783 |
apply(erule Prf.cases) |
|
784 |
apply(simp_all) |
|
785 |
apply(rule Prf.intros) |
|
786 |
apply(auto)[1] |
|
787 |
apply(rotate_tac 3) |
|
788 |
apply(erule Prf.cases) |
|
789 |
apply(simp_all) |
|
227 | 790 |
apply(rotate_tac 3) |
791 |
apply(erule Prf.cases) |
|
792 |
apply(simp_all) |
|
793 |
apply(rule Prf.intros) |
|
794 |
apply(auto)[1] |
|
795 |
apply(rotate_tac 3) |
|
796 |
apply(erule Prf.cases) |
|
797 |
apply(simp_all) |
|
798 |
apply(rotate_tac 3) |
|
799 |
apply(erule Prf.cases) |
|
800 |
apply(simp_all) |
|
223 | 801 |
apply(rule Prf.intros) |
802 |
apply(auto)[1] |
|
803 |
apply(rotate_tac 3) |
|
804 |
apply(erule Prf.cases) |
|
805 |
apply(simp_all) |
|
227 | 806 |
apply(rotate_tac 3) |
807 |
apply(erule Prf.cases) |
|
808 |
apply(simp_all) |
|
223 | 809 |
apply(rule Prf.intros) |
227 | 810 |
apply(auto)[2] |
811 |
apply(rotate_tac 3) |
|
812 |
apply(erule Prf.cases) |
|
813 |
apply(simp_all) |
|
814 |
apply(rule Prf.intros) |
|
815 |
apply(auto)[3] |
|
223 | 816 |
apply(rotate_tac 3) |
817 |
apply(erule Prf.cases) |
|
818 |
apply(simp_all) |
|
227 | 819 |
apply(rotate_tac 3) |
820 |
apply(erule Prf.cases) |
|
821 |
apply(simp_all) |
|
822 |
apply(rotate_tac 3) |
|
823 |
apply(erule Prf.cases) |
|
824 |
apply(simp_all) |
|
825 |
apply(rule Prf.intros) |
|
826 |
apply(auto)[3] |
|
827 |
apply(rotate_tac 3) |
|
828 |
apply(erule Prf.cases) |
|
829 |
apply(simp_all) |
|
830 |
apply(erule Prf.cases) |
|
831 |
apply(simp_all) |
|
832 |
done |
|
833 |
||
222 | 834 |
|
221
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
835 |
lemma Posix_NTIMES_mkeps: |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
836 |
assumes "[] \<in> r \<rightarrow> mkeps r" |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
837 |
shows "[] \<in> NTIMES r n \<rightarrow> Stars (replicate n (mkeps r))" |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
838 |
apply(induct n) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
839 |
apply(simp) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
840 |
apply (rule Posix_NTIMES2) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
841 |
apply(simp) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
842 |
apply(subst append_Nil[symmetric]) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
843 |
apply (rule Posix_NTIMES1) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
844 |
apply(auto) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
845 |
apply(rule assms) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
846 |
done |
122
7c6c907660d8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
121
diff
changeset
|
847 |
|
223 | 848 |
lemma Posix_FROMNTIMES_mkeps: |
849 |
assumes "[] \<in> r \<rightarrow> mkeps r" |
|
850 |
shows "[] \<in> FROMNTIMES r n \<rightarrow> Stars (replicate n (mkeps r))" |
|
851 |
apply(induct n) |
|
852 |
apply(simp) |
|
853 |
apply (rule Posix_FROMNTIMES2) |
|
225 | 854 |
apply (rule Posix.intros) |
223 | 855 |
apply(simp) |
856 |
apply(subst append_Nil[symmetric]) |
|
857 |
apply (rule Posix_FROMNTIMES1) |
|
858 |
apply(auto) |
|
859 |
apply(rule assms) |
|
860 |
done |
|
861 |
||
227 | 862 |
lemma Posix_NMTIMES_mkeps: |
863 |
assumes "[] \<in> r \<rightarrow> mkeps r" "n \<le> m" |
|
864 |
shows "[] \<in> NMTIMES r n m \<rightarrow> Stars (replicate n (mkeps r))" |
|
865 |
using assms(2) |
|
866 |
apply(induct n arbitrary: m) |
|
867 |
apply(simp) |
|
868 |
apply(rule Posix.intros) |
|
869 |
apply(rule Posix.intros) |
|
870 |
apply(case_tac m) |
|
871 |
apply(simp) |
|
872 |
apply(simp) |
|
873 |
apply(subst append_Nil[symmetric]) |
|
874 |
apply(rule Posix.intros) |
|
875 |
apply(auto) |
|
876 |
apply(rule assms) |
|
877 |
done |
|
878 |
||
879 |
||
223 | 880 |
|
146
da81ffac4b10
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
145
diff
changeset
|
881 |
lemma Posix_mkeps: |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
882 |
assumes "nullable r" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
883 |
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
|
884 |
using assms |
185
841f7b9c0a6a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
172
diff
changeset
|
885 |
apply(induct r rule: nullable.induct) |
146
da81ffac4b10
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
145
diff
changeset
|
886 |
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
|
887 |
apply(subst append.simps(1)[symmetric]) |
146
da81ffac4b10
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
145
diff
changeset
|
888 |
apply(rule Posix.intros) |
123
1bee7006b92b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
889 |
apply(auto) |
221
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
890 |
apply(case_tac n) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
891 |
apply(simp) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
892 |
apply (simp add: Posix_NTIMES2) |
223 | 893 |
apply(simp) |
894 |
apply(subst append.simps(1)[symmetric]) |
|
895 |
apply(rule Posix.intros) |
|
896 |
apply(auto) |
|
221
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
897 |
apply(rule Posix_NTIMES_mkeps) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
898 |
apply(simp) |
225 | 899 |
apply(rule Posix.intros) |
900 |
apply(rule Posix.intros) |
|
223 | 901 |
apply(case_tac n) |
902 |
apply(simp) |
|
225 | 903 |
apply(rule Posix.intros) |
904 |
apply(rule Posix.intros) |
|
223 | 905 |
apply(simp) |
906 |
apply(subst append.simps(1)[symmetric]) |
|
907 |
apply(rule Posix.intros) |
|
908 |
apply(auto) |
|
909 |
apply(rule Posix_FROMNTIMES_mkeps) |
|
910 |
apply(simp) |
|
227 | 911 |
apply(rule Posix.intros) |
912 |
apply(rule Posix.intros) |
|
913 |
apply(case_tac n) |
|
914 |
apply(simp) |
|
915 |
apply(rule Posix.intros) |
|
916 |
apply(rule Posix.intros) |
|
917 |
apply(simp) |
|
918 |
apply(case_tac m) |
|
919 |
apply(simp) |
|
920 |
apply(simp) |
|
921 |
apply(subst append_Nil[symmetric]) |
|
922 |
apply(rule Posix.intros) |
|
923 |
apply(auto) |
|
924 |
apply(rule Posix_NMTIMES_mkeps) |
|
925 |
apply(auto) |
|
91
f067e59b58d9
more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
90
diff
changeset
|
926 |
done |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
927 |
|
142
08dcf0d20f15
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
127
diff
changeset
|
928 |
|
146
da81ffac4b10
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
145
diff
changeset
|
929 |
lemma Posix_determ: |
122
7c6c907660d8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
121
diff
changeset
|
930 |
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
|
931 |
shows "v1 = v2" |
7c6c907660d8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
121
diff
changeset
|
932 |
using assms |
151
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
933 |
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
|
934 |
case (Posix_ONE v2) |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
935 |
have "[] \<in> ONE \<rightarrow> v2" by fact |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
936 |
then show "Void = v2" by cases auto |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
937 |
next |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
938 |
case (Posix_CHAR c v2) |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
939 |
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
|
940 |
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
|
941 |
next |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
942 |
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
|
943 |
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
|
944 |
moreover |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
945 |
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
|
946 |
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
|
947 |
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
|
948 |
moreover |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
949 |
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
|
950 |
ultimately have "v = v'" by simp |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
951 |
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
|
952 |
next |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
953 |
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
|
954 |
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
|
955 |
moreover |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
956 |
have "s \<notin> L r1" by fact |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
957 |
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
|
958 |
by cases (auto simp add: Posix1) |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
959 |
moreover |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
960 |
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
|
961 |
ultimately have "v = v'" by simp |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
962 |
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
|
963 |
next |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
964 |
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
|
965 |
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
|
966 |
"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
|
967 |
"\<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
|
968 |
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
|
969 |
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
|
970 |
using Posix1(1) by fastforce+ |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
971 |
moreover |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
972 |
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
|
973 |
"\<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
|
974 |
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
|
975 |
next |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
976 |
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
|
977 |
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
|
978 |
"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
|
979 |
"\<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
|
980 |
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
|
981 |
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
|
982 |
using Posix1(1) apply fastforce |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
983 |
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
|
984 |
using Posix1(2) by blast |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
985 |
moreover |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
986 |
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
|
987 |
"\<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
|
988 |
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
|
989 |
next |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
990 |
case (Posix_STAR2 r v2) |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
991 |
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
|
992 |
then show "Stars [] = v2" by cases (auto simp add: Posix1) |
220 | 993 |
next |
994 |
case (Posix_UPNTIMES1 s1 r v s2 n vs v2) |
|
995 |
have "(s1 @ s2) \<in> UPNTIMES r (Suc n) \<rightarrow> v2" |
|
996 |
"s1 \<in> r \<rightarrow> v" "s2 \<in> (UPNTIMES r n) \<rightarrow> Stars vs" "flat v \<noteq> []" |
|
997 |
"\<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 (UPNTIMES r n))" by fact+ |
|
998 |
then obtain v' vs' where "v2 = Stars (v' # vs')" "s1 \<in> r \<rightarrow> v'" "s2 \<in> (UPNTIMES r n) \<rightarrow> (Stars vs')" |
|
999 |
apply(cases) apply (auto simp add: append_eq_append_conv2) |
|
1000 |
using Posix1(1) apply fastforce |
|
1001 |
apply (metis Posix1(1) Posix_UPNTIMES1.hyps(6) append_Nil append_Nil2) |
|
1002 |
using Posix1(2) by blast |
|
1003 |
moreover |
|
1004 |
have IHs: "\<And>v2. s1 \<in> r \<rightarrow> v2 \<Longrightarrow> v = v2" |
|
1005 |
"\<And>v2. s2 \<in> UPNTIMES r n \<rightarrow> v2 \<Longrightarrow> Stars vs = v2" by fact+ |
|
1006 |
ultimately show "Stars (v # vs) = v2" by auto |
|
1007 |
next |
|
1008 |
case (Posix_UPNTIMES2 r n v2) |
|
1009 |
have "[] \<in> UPNTIMES r n \<rightarrow> v2" by fact |
|
1010 |
then show "Stars [] = v2" by cases (auto simp add: Posix1) |
|
221
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1011 |
next |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1012 |
case (Posix_NTIMES2 r v2) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1013 |
have "[] \<in> NTIMES r 0 \<rightarrow> v2" by fact |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1014 |
then show "Stars [] = v2" by cases (auto simp add: Posix1) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1015 |
next |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1016 |
case (Posix_NTIMES1 s1 r v s2 n vs v2) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1017 |
have "(s1 @ s2) \<in> NTIMES r (Suc n) \<rightarrow> v2" |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1018 |
"s1 \<in> r \<rightarrow> v" "s2 \<in> (NTIMES r n) \<rightarrow> Stars vs" |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1019 |
"\<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 (NTIMES r n))" by fact+ |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1020 |
then obtain v' vs' where "v2 = Stars (v' # vs')" "s1 \<in> r \<rightarrow> v'" "s2 \<in> (NTIMES r n) \<rightarrow> (Stars vs')" |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1021 |
apply(cases) apply (auto simp add: append_eq_append_conv2) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1022 |
using Posix1(1) apply fastforce |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1023 |
apply (metis Posix1(1) Posix_NTIMES1.hyps(5) append_Nil append_Nil2) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1024 |
done |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1025 |
moreover |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1026 |
have IHs: "\<And>v2. s1 \<in> r \<rightarrow> v2 \<Longrightarrow> v = v2" |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1027 |
"\<And>v2. s2 \<in> NTIMES r n \<rightarrow> v2 \<Longrightarrow> Stars vs = v2" by fact+ |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1028 |
ultimately show "Stars (v # vs) = v2" by auto |
223 | 1029 |
next |
225 | 1030 |
case (Posix_FROMNTIMES2 s r v1 v2) |
1031 |
have "s \<in> FROMNTIMES r 0 \<rightarrow> v2" "s \<in> STAR r \<rightarrow> Stars v1" |
|
1032 |
"\<And>v3. s \<in> STAR r \<rightarrow> v3 \<Longrightarrow> Stars v1 = v3" by fact+ |
|
1033 |
then show ?case |
|
1034 |
apply(cases) |
|
1035 |
apply(auto) |
|
1036 |
done |
|
223 | 1037 |
next |
1038 |
case (Posix_FROMNTIMES1 s1 r v s2 n vs v2) |
|
1039 |
have "(s1 @ s2) \<in> FROMNTIMES r (Suc n) \<rightarrow> v2" |
|
1040 |
"s1 \<in> r \<rightarrow> v" "s2 \<in> (FROMNTIMES r n) \<rightarrow> Stars vs" |
|
1041 |
"\<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 (FROMNTIMES r n))" by fact+ |
|
1042 |
then obtain v' vs' where "v2 = Stars (v' # vs')" "s1 \<in> r \<rightarrow> v'" "s2 \<in> (FROMNTIMES r n) \<rightarrow> (Stars vs')" |
|
1043 |
apply(cases) apply (auto simp add: append_eq_append_conv2) |
|
1044 |
using Posix1(1) apply fastforce |
|
1045 |
by (metis Posix1(1) Posix_FROMNTIMES1.hyps(5) append_Nil2 self_append_conv2) |
|
1046 |
moreover |
|
1047 |
have IHs: "\<And>v2. s1 \<in> r \<rightarrow> v2 \<Longrightarrow> v = v2" |
|
1048 |
"\<And>v2. s2 \<in> FROMNTIMES r n \<rightarrow> v2 \<Longrightarrow> Stars vs = v2" by fact+ |
|
1049 |
ultimately show "Stars (v # vs) = v2" by auto |
|
227 | 1050 |
next |
1051 |
case (Posix_NMTIMES2 s r m v1 v2) |
|
1052 |
have "s \<in> NMTIMES r 0 m \<rightarrow> v2" "s \<in> UPNTIMES r m \<rightarrow> Stars v1" |
|
1053 |
"\<And>v3. s \<in> UPNTIMES r m \<rightarrow> v3 \<Longrightarrow> Stars v1 = v3" by fact+ |
|
1054 |
then show ?case |
|
1055 |
apply(cases) |
|
1056 |
apply(auto) |
|
1057 |
done |
|
1058 |
next |
|
1059 |
case (Posix_NMTIMES1 s1 r v s2 n m vs v2) |
|
1060 |
have "(s1 @ s2) \<in> NMTIMES r (Suc n) (Suc m) \<rightarrow> v2" |
|
1061 |
"s1 \<in> r \<rightarrow> v" "s2 \<in> (NMTIMES r n m) \<rightarrow> Stars vs" |
|
1062 |
"\<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 (NMTIMES r n m))" by fact+ |
|
1063 |
then obtain v' vs' where "v2 = Stars (v' # vs')" "s1 \<in> r \<rightarrow> v'" "s2 \<in> (NMTIMES r n m) \<rightarrow> (Stars vs')" |
|
1064 |
apply(cases) apply (auto simp add: append_eq_append_conv2) |
|
1065 |
using Posix1(1) apply fastforce |
|
1066 |
by (metis Posix1(1) Posix_NMTIMES1.hyps(5) append_Nil append_Nil2) |
|
1067 |
moreover |
|
1068 |
have IHs: "\<And>v2. s1 \<in> r \<rightarrow> v2 \<Longrightarrow> v = v2" |
|
1069 |
"\<And>v2. s2 \<in> NMTIMES r n m \<rightarrow> v2 \<Longrightarrow> Stars vs = v2" by fact+ |
|
1070 |
ultimately show "Stars (v # vs) = v2" by auto |
|
151
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
1071 |
qed |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
1072 |
|
223 | 1073 |
lemma NTIMES_Stars: |
1074 |
assumes "\<turnstile> v : NTIMES r n" |
|
1075 |
shows "\<exists>vs. v = Stars vs \<and> (\<forall>v \<in> set vs. \<turnstile> v : r) \<and> length vs = n" |
|
1076 |
using assms |
|
1077 |
apply(induct n arbitrary: v) |
|
1078 |
apply(erule Prf.cases) |
|
1079 |
apply(simp_all) |
|
1080 |
apply(erule Prf.cases) |
|
1081 |
apply(simp_all) |
|
1082 |
done |
|
1083 |
||
1084 |
lemma UPNTIMES_Stars: |
|
1085 |
assumes "\<turnstile> v : UPNTIMES r n" |
|
1086 |
shows "\<exists>vs. v = Stars vs \<and> (\<forall>v \<in> set vs. \<turnstile> v : r) \<and> length vs \<le> n" |
|
1087 |
using assms |
|
1088 |
apply(induct n arbitrary: v) |
|
1089 |
apply(erule Prf.cases) |
|
1090 |
apply(simp_all) |
|
1091 |
apply(erule Prf.cases) |
|
1092 |
apply(simp_all) |
|
1093 |
done |
|
1094 |
||
1095 |
lemma FROMNTIMES_Stars: |
|
1096 |
assumes "\<turnstile> v : FROMNTIMES r n" |
|
1097 |
shows "\<exists>vs. v = Stars vs \<and> (\<forall>v \<in> set vs. \<turnstile> v : r) \<and> n \<le> length vs" |
|
1098 |
using assms |
|
1099 |
apply(induct n arbitrary: v) |
|
1100 |
apply(erule Prf.cases) |
|
1101 |
apply(simp_all) |
|
1102 |
apply(erule Prf.cases) |
|
1103 |
apply(simp_all) |
|
1104 |
done |
|
1105 |
||
227 | 1106 |
lemma NMTIMES_Stars: |
1107 |
assumes "\<turnstile> v : NMTIMES r n m" |
|
1108 |
shows "\<exists>vs. v = Stars vs \<and> (\<forall>v \<in> set vs. \<turnstile> v : r) \<and> n \<le> length vs \<and> length vs \<le> m" |
|
1109 |
using assms |
|
1110 |
apply(induct n arbitrary: m v) |
|
1111 |
apply(erule Prf.cases) |
|
1112 |
apply(simp_all) |
|
1113 |
apply(erule Prf.cases) |
|
1114 |
apply(simp_all) |
|
1115 |
done |
|
1116 |
||
100
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
1117 |
|
172
cdc0bdcfba3f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
151
diff
changeset
|
1118 |
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
|
1119 |
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
|
1120 |
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
|
1121 |
using assms |
121
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1122 |
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
|
1123 |
case ZERO |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1124 |
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
|
1125 |
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
|
1126 |
then have "False" by cases |
143
1e7b36450d9a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
142
diff
changeset
|
1127 |
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
|
1128 |
next |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1129 |
case ONE |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1130 |
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
|
1131 |
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
|
1132 |
then have "False" by cases |
143
1e7b36450d9a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
142
diff
changeset
|
1133 |
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
|
1134 |
next |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1135 |
case (CHAR d) |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1136 |
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
|
1137 |
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
|
1138 |
proof (cases) |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1139 |
case eq |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1140 |
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
|
1141 |
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
|
1142 |
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
|
1143 |
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
|
1144 |
by (auto intro: Posix.intros) |
121
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1145 |
next |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1146 |
case ineq |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1147 |
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
|
1148 |
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
|
1149 |
then have "False" by cases |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1150 |
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
|
1151 |
qed |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1152 |
next |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1153 |
case (ALT r1 r2) |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1154 |
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
|
1155 |
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
|
1156 |
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
|
1157 |
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
|
1158 |
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
|
1159 |
| (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
|
1160 |
by cases auto |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1161 |
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
|
1162 |
proof (cases) |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1163 |
case left |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1164 |
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
|
1165 |
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
|
1166 |
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
|
1167 |
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
|
1168 |
next |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1169 |
case right |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1170 |
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
|
1171 |
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
|
1172 |
moreover |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1173 |
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
|
1174 |
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
|
1175 |
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
|
1176 |
by (auto intro: Posix.intros) |
121
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1177 |
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
|
1178 |
qed |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1179 |
next |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1180 |
case (SEQ r1 r2) |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1181 |
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
|
1182 |
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
|
1183 |
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
|
1184 |
then consider |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1185 |
(left_nullable) v1 v2 s1 s2 where |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1186 |
"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
|
1187 |
"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
|
1188 |
"\<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
|
1189 |
| (right_nullable) v1 s1 s2 where |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1190 |
"v = Right v1" "s = s1 @ s2" |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1191 |
"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
|
1192 |
| (not_nullable) v1 v2 s1 s2 where |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1193 |
"v = Seq v1 v2" "s = s1 @ s2" |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1194 |
"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
|
1195 |
"\<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
|
1196 |
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
|
1197 |
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
|
1198 |
proof (cases) |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1199 |
case left_nullable |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1200 |
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
|
1201 |
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
|
1202 |
moreover |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1203 |
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
|
1204 |
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
|
1205 |
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
|
1206 |
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
|
1207 |
next |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1208 |
case right_nullable |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1209 |
have "nullable r1" by fact |
146
da81ffac4b10
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
145
diff
changeset
|
1210 |
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
|
1211 |
moreover |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1212 |
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
|
1213 |
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
|
1214 |
moreover |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1215 |
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
|
1216 |
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
|
1217 |
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
|
1218 |
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
|
1219 |
by(rule Posix.intros) |
121
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1220 |
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
|
1221 |
next |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1222 |
case not_nullable |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1223 |
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
|
1224 |
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
|
1225 |
moreover |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1226 |
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
|
1227 |
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
|
1228 |
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
|
1229 |
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
|
1230 |
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
|
1231 |
qed |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1232 |
next |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1233 |
case (STAR r) |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1234 |
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
|
1235 |
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
|
1236 |
then consider |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1237 |
(cons) v1 vs s1 s2 where |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1238 |
"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
|
1239 |
"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
|
1240 |
"\<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
|
1241 |
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
|
1242 |
apply(rotate_tac 3) |
149
ec3d221bfc45
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
146
diff
changeset
|
1243 |
apply(erule_tac Posix_elims(6)) |
146
da81ffac4b10
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
145
diff
changeset
|
1244 |
apply (simp add: Posix.intros(6)) |
da81ffac4b10
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
145
diff
changeset
|
1245 |
using Posix.intros(7) by blast |
121
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1246 |
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
|
1247 |
proof (cases) |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1248 |
case cons |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1249 |
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
|
1250 |
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
|
1251 |
moreover |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1252 |
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
|
1253 |
moreover |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1254 |
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
|
1255 |
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
|
1256 |
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
|
1257 |
moreover |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1258 |
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
|
1259 |
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
|
1260 |
by (simp add: der_correctness Der_def) |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1261 |
ultimately |
146
da81ffac4b10
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
145
diff
changeset
|
1262 |
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
|
1263 |
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
|
1264 |
qed |
220 | 1265 |
next |
1266 |
case (UPNTIMES r n) |
|
1267 |
have IH: "\<And>s v. s \<in> der c r \<rightarrow> v \<Longrightarrow> (c # s) \<in> r \<rightarrow> injval r c v" by fact |
|
1268 |
have "s \<in> der c (UPNTIMES r n) \<rightarrow> v" by fact |
|
1269 |
then consider |
|
1270 |
(cons) m v1 vs s1 s2 where |
|
1271 |
"n = Suc m" |
|
1272 |
"v = Seq v1 (Stars vs)" "s = s1 @ s2" |
|
1273 |
"s1 \<in> der c r \<rightarrow> v1" "s2 \<in> (UPNTIMES r m) \<rightarrow> (Stars vs)" |
|
1274 |
"\<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 (UPNTIMES r m))" |
|
1275 |
apply(case_tac n) |
|
1276 |
apply(simp) |
|
1277 |
using Posix_elims(1) apply blast |
|
1278 |
apply(simp) |
|
223 | 1279 |
apply(auto elim!: Posix_elims(1-5) simp add: der_correctness Der_def intro: Posix.intros) |
220 | 1280 |
by (metis Posix1a UPNTIMES_Stars) |
1281 |
then show "(c # s) \<in> UPNTIMES r n \<rightarrow> injval (UPNTIMES r n) c v" |
|
1282 |
proof (cases) |
|
1283 |
case cons |
|
1284 |
have "n = Suc m" by fact |
|
1285 |
moreover |
|
1286 |
have "s1 \<in> der c r \<rightarrow> v1" by fact |
|
1287 |
then have "(c # s1) \<in> r \<rightarrow> injval r c v1" using IH by simp |
|
1288 |
moreover |
|
1289 |
have "s2 \<in> UPNTIMES r m \<rightarrow> Stars vs" by fact |
|
1290 |
moreover |
|
1291 |
have "(c # s1) \<in> r \<rightarrow> injval r c v1" by fact |
|
1292 |
then have "flat (injval r c v1) = (c # s1)" by (rule Posix1) |
|
1293 |
then have "flat (injval r c v1) \<noteq> []" by simp |
|
1294 |
moreover |
|
1295 |
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 (UPNTIMES r m))" by fact |
|
1296 |
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 (UPNTIMES r m))" |
|
1297 |
by (simp add: der_correctness Der_def) |
|
1298 |
ultimately |
|
1299 |
have "((c # s1) @ s2) \<in> UPNTIMES r (Suc m) \<rightarrow> Stars (injval r c v1 # vs)" |
|
1300 |
apply(rule_tac Posix.intros(8)) |
|
1301 |
apply(simp_all) |
|
1302 |
done |
|
1303 |
then show "(c # s) \<in> UPNTIMES r n \<rightarrow> injval (UPNTIMES r n) c v" using cons by(simp) |
|
1304 |
qed |
|
221
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1305 |
next |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1306 |
case (NTIMES r n) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1307 |
have IH: "\<And>s v. s \<in> der c r \<rightarrow> v \<Longrightarrow> (c # s) \<in> r \<rightarrow> injval r c v" by fact |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1308 |
have "s \<in> der c (NTIMES r n) \<rightarrow> v" by fact |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1309 |
then consider |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1310 |
(cons) m v1 vs s1 s2 where |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1311 |
"n = Suc m" |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1312 |
"v = Seq v1 (Stars vs)" "s = s1 @ s2" |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1313 |
"s1 \<in> der c r \<rightarrow> v1" "s2 \<in> (NTIMES r m) \<rightarrow> (Stars vs)" |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1314 |
"\<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 (NTIMES r m))" |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1315 |
apply(case_tac n) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1316 |
apply(simp) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1317 |
using Posix_elims(1) apply blast |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1318 |
apply(simp) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1319 |
apply(auto elim!: Posix_elims(1-5) simp add: der_correctness Der_def intro: Posix.intros) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1320 |
by (metis NTIMES_Stars Posix1a) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1321 |
then show "(c # s) \<in> NTIMES r n \<rightarrow> injval (NTIMES r n) c v" |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1322 |
proof (cases) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1323 |
case cons |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1324 |
have "n = Suc m" by fact |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1325 |
moreover |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1326 |
have "s1 \<in> der c r \<rightarrow> v1" by fact |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1327 |
then have "(c # s1) \<in> r \<rightarrow> injval r c v1" using IH by simp |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1328 |
moreover |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1329 |
have "s2 \<in> NTIMES r m \<rightarrow> Stars vs" by fact |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1330 |
moreover |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1331 |
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 (NTIMES r m))" by fact |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1332 |
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 (NTIMES r m))" |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1333 |
by (simp add: der_correctness Der_def) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1334 |
ultimately |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1335 |
have "((c # s1) @ s2) \<in> NTIMES r (Suc m) \<rightarrow> Stars (injval r c v1 # vs)" |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1336 |
apply(rule_tac Posix.intros(10)) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1337 |
apply(simp_all) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1338 |
done |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1339 |
then show "(c # s) \<in> NTIMES r n \<rightarrow> injval (NTIMES r n) c v" using cons by(simp) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1340 |
qed |
223 | 1341 |
next |
1342 |
case (FROMNTIMES r n) |
|
1343 |
have IH: "\<And>s v. s \<in> der c r \<rightarrow> v \<Longrightarrow> (c # s) \<in> r \<rightarrow> injval r c v" by fact |
|
1344 |
have "s \<in> der c (FROMNTIMES r n) \<rightarrow> v" by fact |
|
1345 |
then consider |
|
1346 |
(null) v1 vs s1 s2 where |
|
224 | 1347 |
"n = 0" |
223 | 1348 |
"v = Seq v1 (Stars vs)" "s = s1 @ s2" |
225 | 1349 |
"s1 \<in> der c r \<rightarrow> v1" "s2 \<in> (FROMNTIMES r 0) \<rightarrow> (Stars vs)" |
223 | 1350 |
"\<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 (FROMNTIMES r 0))" |
1351 |
| (cons) m v1 vs s1 s2 where |
|
1352 |
"n = Suc m" |
|
1353 |
"v = Seq v1 (Stars vs)" "s = s1 @ s2" |
|
1354 |
"s1 \<in> der c r \<rightarrow> v1" "s2 \<in> (FROMNTIMES r m) \<rightarrow> (Stars vs)" |
|
1355 |
"\<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 (FROMNTIMES r m))" |
|
1356 |
apply(case_tac n) |
|
1357 |
apply(simp) |
|
1358 |
apply(auto elim!: Posix_elims(1-5) simp add: der_correctness Der_def intro: Posix.intros) |
|
1359 |
defer |
|
1360 |
apply (metis FROMNTIMES_Stars Posix1a) |
|
1361 |
apply(rotate_tac 5) |
|
225 | 1362 |
apply(erule Posix.cases) |
1363 |
apply(simp_all) |
|
1364 |
apply(clarify) |
|
1365 |
by (simp add: Posix_FROMNTIMES2) |
|
223 | 1366 |
then show "(c # s) \<in> FROMNTIMES r n \<rightarrow> injval (FROMNTIMES r n) c v" |
1367 |
proof (cases) |
|
1368 |
case cons |
|
1369 |
have "n = Suc m" by fact |
|
1370 |
moreover |
|
1371 |
have "s1 \<in> der c r \<rightarrow> v1" by fact |
|
1372 |
then have "(c # s1) \<in> r \<rightarrow> injval r c v1" using IH by simp |
|
1373 |
moreover |
|
1374 |
have "s2 \<in> FROMNTIMES r m \<rightarrow> Stars vs" by fact |
|
1375 |
moreover |
|
1376 |
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 (FROMNTIMES r m))" by fact |
|
1377 |
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 (FROMNTIMES r m))" |
|
1378 |
by (simp add: der_correctness Der_def) |
|
1379 |
ultimately |
|
1380 |
have "((c # s1) @ s2) \<in> FROMNTIMES r (Suc m) \<rightarrow> Stars (injval r c v1 # vs)" |
|
1381 |
apply(rule_tac Posix.intros(12)) |
|
1382 |
apply(simp_all) |
|
1383 |
done |
|
1384 |
then show "(c # s) \<in> FROMNTIMES r n \<rightarrow> injval (FROMNTIMES r n) c v" using cons by(simp) |
|
224 | 1385 |
next |
1386 |
case null |
|
225 | 1387 |
then have "((c # s1) @ s2) \<in> FROMNTIMES r 0 \<rightarrow> Stars (injval r c v1 # vs)" |
1388 |
apply(rule_tac Posix.intros) |
|
1389 |
apply(rule_tac Posix.intros) |
|
1390 |
apply(rule IH) |
|
224 | 1391 |
apply(simp) |
225 | 1392 |
apply(rotate_tac 4) |
1393 |
apply(erule Posix.cases) |
|
1394 |
apply(simp_all) |
|
1395 |
apply (simp add: Posix1a Prf_injval_flat) |
|
1396 |
apply(simp only: Star_def2) |
|
1397 |
apply(simp only: der_correctness Der_def) |
|
1398 |
apply(simp) |
|
1399 |
done |
|
1400 |
then show "(c # s) \<in> FROMNTIMES r n \<rightarrow> injval (FROMNTIMES r n) c v" using null by simp |
|
223 | 1401 |
qed |
227 | 1402 |
next |
1403 |
case (NMTIMES r n m) |
|
1404 |
have IH: "\<And>s v. s \<in> der c r \<rightarrow> v \<Longrightarrow> (c # s) \<in> r \<rightarrow> injval r c v" by fact |
|
1405 |
have "s \<in> der c (NMTIMES r n m) \<rightarrow> v" by fact |
|
1406 |
then show "(c # s) \<in> (NMTIMES r n m) \<rightarrow> injval (NMTIMES r n m) c v" |
|
1407 |
apply(case_tac "m < n") |
|
1408 |
apply(simp) |
|
1409 |
using Posix_elims(1) apply blast |
|
1410 |
apply(case_tac n) |
|
1411 |
apply(simp_all) |
|
1412 |
apply(case_tac m) |
|
1413 |
apply(simp) |
|
1414 |
apply(erule Posix_elims(1)) |
|
1415 |
apply(simp) |
|
1416 |
apply(erule Posix.cases) |
|
1417 |
apply(simp_all) |
|
1418 |
apply(clarify) |
|
1419 |
apply(rotate_tac 5) |
|
1420 |
apply(frule Posix1a) |
|
1421 |
apply(drule UPNTIMES_Stars) |
|
1422 |
apply(clarify) |
|
1423 |
apply(simp) |
|
1424 |
apply(subst append_Cons[symmetric]) |
|
1425 |
apply(rule Posix.intros) |
|
1426 |
apply(rule Posix.intros) |
|
1427 |
apply(auto) |
|
1428 |
apply(rule IH) |
|
1429 |
apply blast |
|
1430 |
using Posix1a Prf_injval_flat apply auto[1] |
|
1431 |
apply(simp add: der_correctness Der_def) |
|
1432 |
apply blast |
|
1433 |
apply(case_tac m) |
|
1434 |
apply(simp) |
|
1435 |
apply(simp) |
|
1436 |
apply(erule Posix.cases) |
|
1437 |
apply(simp_all) |
|
1438 |
apply(clarify) |
|
1439 |
apply(rotate_tac 6) |
|
1440 |
apply(frule Posix1a) |
|
1441 |
apply(drule NMTIMES_Stars) |
|
1442 |
apply(clarify) |
|
1443 |
apply(simp) |
|
1444 |
apply(subst append_Cons[symmetric]) |
|
1445 |
apply(rule Posix.intros) |
|
1446 |
apply(rule IH) |
|
1447 |
apply(blast) |
|
1448 |
apply(simp) |
|
1449 |
apply(simp add: der_correctness Der_def) |
|
1450 |
done |
|
121
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1451 |
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
|
1452 |
|
145
97735ef233be
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
144
diff
changeset
|
1453 |
|
227 | 1454 |
|
145
97735ef233be
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
144
diff
changeset
|
1455 |
section {* The Lexer by Sulzmann and Lu *} |
97735ef233be
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
144
diff
changeset
|
1456 |
|
97735ef233be
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
144
diff
changeset
|
1457 |
fun |
97735ef233be
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
144
diff
changeset
|
1458 |
lexer :: "rexp \<Rightarrow> string \<Rightarrow> val option" |
97735ef233be
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
144
diff
changeset
|
1459 |
where |
97735ef233be
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
144
diff
changeset
|
1460 |
"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
|
1461 |
| "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
|
1462 |
None \<Rightarrow> None |
97735ef233be
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
144
diff
changeset
|
1463 |
| 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
|
1464 |
|
97735ef233be
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
144
diff
changeset
|
1465 |
|
151
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
1466 |
lemma lexer_correct_None: |
145
97735ef233be
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
144
diff
changeset
|
1467 |
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
|
1468 |
apply(induct s arbitrary: r) |
143
1e7b36450d9a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
142
diff
changeset
|
1469 |
apply(simp add: nullable_correctness) |
120
d74bfa11802c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
113
diff
changeset
|
1470 |
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
|
1471 |
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
|
1472 |
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
|
1473 |
|
151
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
1474 |
lemma lexer_correct_Some: |
185
841f7b9c0a6a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
172
diff
changeset
|
1475 |
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
|
1476 |
apply(induct s arbitrary: r) |
151
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
1477 |
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
|
1478 |
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
|
1479 |
apply(simp add: der_correctness Der_def) |
5378ddbd1381
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
123
diff
changeset
|
1480 |
apply(rule iffI) |
172
cdc0bdcfba3f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
151
diff
changeset
|
1481 |
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
|
1482 |
done |
149
ec3d221bfc45
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
146
diff
changeset
|
1483 |
|
186
0b94800eb616
added corollary
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
185
diff
changeset
|
1484 |
lemma lexer_correctness: |
0b94800eb616
added corollary
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
185
diff
changeset
|
1485 |
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
|
1486 |
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
|
1487 |
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
|
1488 |
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
|
1489 |
|
226 | 1490 |
unused_thms |
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
|
1491 |
end |