author | Christian Urban <urbanc@in.tum.de> |
Wed, 01 Mar 2017 00:13:15 +0000 | |
changeset 226 | d131cd45a346 |
parent 225 | 77d5181490ae |
child 227 | a8749366ad5d |
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 |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
158 |
|
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
159 |
section {* Semantics of Regular Expressions *} |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
160 |
|
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
161 |
fun |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
162 |
L :: "rexp \<Rightarrow> string set" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
163 |
where |
107
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
164 |
"L (ZERO) = {}" |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
165 |
| "L (ONE) = {[]}" |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
166 |
| "L (CHAR c) = {[c]}" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
167 |
| "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
|
168 |
| "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
|
169 |
| "L (STAR r) = (L r)\<star>" |
220 | 170 |
| "L (UPNTIMES r n) = (\<Union>i\<in> {..n} . (L r) \<up> i)" |
221
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
171 |
| "L (NTIMES r n) = ((L r) \<up> n)" |
223 | 172 |
| "L (FROMNTIMES r n) = (\<Union>i\<in> {n..} . (L r) \<up> i)" |
107
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
173 |
|
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
174 |
section {* Nullable, Derivatives *} |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
175 |
|
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
176 |
fun |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
177 |
nullable :: "rexp \<Rightarrow> bool" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
178 |
where |
107
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
179 |
"nullable (ZERO) = False" |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
180 |
| "nullable (ONE) = True" |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
181 |
| "nullable (CHAR c) = False" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
182 |
| "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
|
183 |
| "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
|
184 |
| "nullable (STAR r) = True" |
220 | 185 |
| "nullable (UPNTIMES r n) = True" |
221
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
186 |
| "nullable (NTIMES r n) = (if n = 0 then True else nullable r)" |
223 | 187 |
| "nullable (FROMNTIMES r n) = (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
|
188 |
|
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
189 |
fun |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
190 |
der :: "char \<Rightarrow> rexp \<Rightarrow> rexp" |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
191 |
where |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
192 |
"der c (ZERO) = ZERO" |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
193 |
| "der c (ONE) = ZERO" |
111
289728193164
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
110
diff
changeset
|
194 |
| "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
|
195 |
| "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
|
196 |
| "der c (SEQ r1 r2) = |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
197 |
(if nullable r1 |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
198 |
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
|
199 |
else SEQ (der c r1) r2)" |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
200 |
| "der c (STAR r) = SEQ (der c r) (STAR r)" |
220 | 201 |
| "der c (UPNTIMES r 0) = ZERO" |
202 |
| "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
|
203 |
| "der c (NTIMES r 0) = ZERO" |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
204 |
| "der c (NTIMES r (Suc n)) = SEQ (der c r) (NTIMES r n)" |
225 | 205 |
| "der c (FROMNTIMES r 0) = SEQ (der c r) (FROMNTIMES r 0)" |
223 | 206 |
| "der c (FROMNTIMES r (Suc n)) = SEQ (der c r) (FROMNTIMES r n)" |
107
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
207 |
|
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
208 |
fun |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
209 |
ders :: "string \<Rightarrow> rexp \<Rightarrow> rexp" |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
210 |
where |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
211 |
"ders [] r = r" |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
212 |
| "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
|
213 |
|
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
214 |
|
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
215 |
lemma nullable_correctness: |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
216 |
shows "nullable r \<longleftrightarrow> [] \<in> (L r)" |
221
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
217 |
apply(induct r) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
218 |
apply(auto simp add: Sequ_def) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
219 |
done |
100
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
220 |
|
220 | 221 |
|
222 |
lemma Suc_reduce_Union2: |
|
223 |
"(\<Union>x\<in>{Suc n..}. B x) = (\<Union>x\<in>{n..}. B (Suc x))" |
|
224 |
apply(auto) |
|
225 |
apply(rule_tac x="xa - 1" in bexI) |
|
226 |
apply(simp) |
|
227 |
apply(simp) |
|
228 |
done |
|
229 |
||
230 |
lemma Seq_UNION: |
|
231 |
shows "(\<Union>x\<in>A. B ;; C x) = B ;; (\<Union>x\<in>A. C x)" |
|
232 |
by (auto simp add: Sequ_def) |
|
233 |
||
234 |
lemma Der_Pow [simp]: |
|
235 |
shows "Der c (A \<up> (Suc n)) = |
|
236 |
(Der c A) ;; (A \<up> n) \<union> (if [] \<in> A then Der c (A \<up> n) else {})" |
|
237 |
unfolding Der_def Sequ_def |
|
238 |
by(auto simp add: Cons_eq_append_conv Sequ_def) |
|
239 |
||
240 |
lemma Suc_Union: |
|
241 |
"(\<Union>x\<le>Suc m. B x) = (B (Suc m) \<union> (\<Union>x\<le>m. B x))" |
|
242 |
by (metis UN_insert atMost_Suc) |
|
243 |
||
244 |
||
221
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
245 |
lemma Der_Pow_subseteq: |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
246 |
assumes "[] \<in> A" |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
247 |
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
|
248 |
using assms |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
249 |
apply(induct n) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
250 |
apply(simp add: Sequ_def Der_def) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
251 |
apply(simp) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
252 |
apply(rule conjI) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
253 |
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
|
254 |
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
|
255 |
apply(auto)[1] |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
256 |
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
|
257 |
|
220 | 258 |
lemma test: |
259 |
shows "(\<Union>x\<le>Suc n. Der c (L r \<up> x)) = (\<Union>x\<le>n. Der c (L r) ;; L r \<up> x)" |
|
260 |
apply(induct n) |
|
261 |
apply(simp) |
|
262 |
apply(auto)[1] |
|
263 |
apply(case_tac xa) |
|
264 |
apply(simp) |
|
265 |
apply(simp) |
|
266 |
apply(auto)[1] |
|
267 |
apply(case_tac "[] \<in> L r") |
|
268 |
apply(simp) |
|
269 |
apply(simp) |
|
270 |
by (smt Der_Pow Suc_Union inf_sup_aci(5) inf_sup_aci(7) sup_idem) |
|
271 |
||
226 | 272 |
|
221
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
273 |
|
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
274 |
lemma Der_Pow_notin: |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
275 |
assumes "[] \<notin> A" |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
276 |
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
|
277 |
using assms |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
278 |
by(simp) |
220 | 279 |
|
107
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
280 |
lemma der_correctness: |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
281 |
shows "L (der c r) = Der c (L r)" |
220 | 282 |
apply(induct c r rule: der.induct) |
283 |
apply(simp_all add: nullable_correctness)[7] |
|
284 |
apply(simp only: der.simps L.simps) |
|
285 |
apply(simp only: Der_UNION) |
|
286 |
apply(simp only: Seq_UNION[symmetric]) |
|
287 |
apply(simp add: test) |
|
221
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
288 |
apply(simp) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
289 |
(* NTIMES *) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
290 |
apply(simp only: L.simps der.simps) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
291 |
apply(simp) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
292 |
apply(rule impI) |
223 | 293 |
apply (simp add: Der_Pow_subseteq sup_absorb1) |
294 |
(* FROMNTIMES *) |
|
295 |
apply(simp only: der.simps) |
|
296 |
apply(simp only: L.simps) |
|
225 | 297 |
apply(simp) |
298 |
using Der_star Star_def2 apply auto[1] |
|
223 | 299 |
apply(simp only: der.simps) |
300 |
apply(simp only: L.simps) |
|
301 |
apply(simp add: Der_UNION) |
|
302 |
by (smt Der_Pow Der_Pow_notin Der_Pow_subseteq SUP_cong Seq_UNION Suc_reduce_Union2 sup.absorb_iff1) |
|
107
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
303 |
|
204
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
304 |
lemma ders_correctness: |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
305 |
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
|
306 |
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
|
307 |
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
|
308 |
done |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
309 |
|
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
310 |
lemma ders_ZERO: |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
311 |
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
|
312 |
apply(induct s) |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
313 |
apply(simp_all) |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
314 |
done |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
315 |
|
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
316 |
lemma ders_ONE: |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
317 |
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
|
318 |
apply(induct s) |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
319 |
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
|
320 |
done |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
321 |
|
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
322 |
lemma ders_CHAR: |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
323 |
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
|
324 |
(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
|
325 |
apply(induct s) |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
326 |
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
|
327 |
done |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
328 |
|
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
329 |
lemma ders_ALT: |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
330 |
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
|
331 |
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
|
332 |
apply(simp_all) |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
333 |
done |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
334 |
|
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
335 |
section {* Values *} |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
336 |
|
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
337 |
datatype val = |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
338 |
Void |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
339 |
| Char char |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
340 |
| Seq val val |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
341 |
| Right val |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
342 |
| Left val |
97
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
343 |
| Stars "val list" |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
344 |
|
108
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
345 |
|
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
346 |
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
|
347 |
|
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
348 |
fun |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
349 |
flat :: "val \<Rightarrow> string" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
350 |
where |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
351 |
"flat (Void) = []" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
352 |
| "flat (Char c) = [c]" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
353 |
| "flat (Left v) = flat v" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
354 |
| "flat (Right v) = flat v" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
355 |
| "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
|
356 |
| "flat (Stars []) = []" |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
357 |
| "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
|
358 |
|
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
|
359 |
lemma flat_Stars [simp]: |
97
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
360 |
"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
|
361 |
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
|
362 |
|
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
|
363 |
|
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
364 |
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
|
365 |
|
91
f067e59b58d9
more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
90
diff
changeset
|
366 |
inductive |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
367 |
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
|
368 |
where |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
369 |
"\<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
|
370 |
| "\<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
|
371 |
| "\<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
|
372 |
| "\<turnstile> Void : ONE" |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
373 |
| "\<turnstile> Char c : CHAR c" |
223 | 374 |
| "\<lbrakk>\<forall>v \<in> set vs. \<turnstile> v : r\<rbrakk> \<Longrightarrow> \<turnstile> Stars vs : STAR r" |
375 |
| "\<lbrakk>\<forall>v \<in> set vs. \<turnstile> v : r; length vs \<le> n\<rbrakk> \<Longrightarrow> \<turnstile> Stars vs : UPNTIMES r n" |
|
376 |
| "\<lbrakk>\<forall>v \<in> set vs. \<turnstile> v : r; length vs = n\<rbrakk> \<Longrightarrow> \<turnstile> Stars vs : NTIMES r n" |
|
377 |
| "\<lbrakk>\<forall>v \<in> set vs. \<turnstile> v : r; length vs \<ge> n\<rbrakk> \<Longrightarrow> \<turnstile> Stars vs : FROMNTIMES r n" |
|
91
f067e59b58d9
more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
90
diff
changeset
|
378 |
|
142
08dcf0d20f15
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
127
diff
changeset
|
379 |
inductive_cases Prf_elims: |
08dcf0d20f15
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
127
diff
changeset
|
380 |
"\<turnstile> v : ZERO" |
08dcf0d20f15
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
127
diff
changeset
|
381 |
"\<turnstile> v : SEQ r1 r2" |
08dcf0d20f15
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
127
diff
changeset
|
382 |
"\<turnstile> v : ALT r1 r2" |
08dcf0d20f15
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
127
diff
changeset
|
383 |
"\<turnstile> v : ONE" |
08dcf0d20f15
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
127
diff
changeset
|
384 |
"\<turnstile> v : CHAR c" |
08dcf0d20f15
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
127
diff
changeset
|
385 |
(* "\<turnstile> vs : STAR r"*) |
08dcf0d20f15
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
127
diff
changeset
|
386 |
|
223 | 387 |
lemma Prf_STAR: |
388 |
assumes "\<forall>v\<in>set vs. \<turnstile> v : r \<and> flat v \<in> L r" |
|
389 |
shows "concat (map flat vs) \<in> L r\<star>" |
|
390 |
using assms |
|
391 |
apply(induct vs) |
|
392 |
apply(auto) |
|
393 |
done |
|
394 |
||
395 |
lemma Prf_Pow: |
|
396 |
assumes "\<forall>v\<in>set vs. \<turnstile> v : r \<and> flat v \<in> L r" |
|
397 |
shows "concat (map flat vs) \<in> L r \<up> length vs" |
|
398 |
using assms |
|
399 |
apply(induct vs) |
|
400 |
apply(auto simp add: Sequ_def) |
|
401 |
done |
|
402 |
||
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
403 |
lemma Prf_flat_L: |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
404 |
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
|
405 |
using assms |
220 | 406 |
apply(induct v r rule: Prf.induct) |
407 |
apply(auto simp add: Sequ_def) |
|
223 | 408 |
apply(rule Prf_STAR) |
409 |
apply(simp) |
|
410 |
apply(rule_tac x="length vs" in bexI) |
|
411 |
apply(rule Prf_Pow) |
|
412 |
apply(simp) |
|
413 |
apply(simp) |
|
414 |
apply(rule Prf_Pow) |
|
415 |
apply(simp) |
|
416 |
apply(rule_tac x="length vs" in bexI) |
|
417 |
apply(rule Prf_Pow) |
|
418 |
apply(simp) |
|
419 |
apply(simp) |
|
221
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
420 |
done |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
421 |
|
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
|
422 |
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
|
423 |
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
|
424 |
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
|
425 |
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
|
426 |
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
|
427 |
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
|
428 |
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
|
429 |
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
|
430 |
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
|
431 |
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
|
432 |
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
|
433 |
|
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
|
434 |
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
|
435 |
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
|
436 |
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
|
437 |
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
|
438 |
apply(induct ss) |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
439 |
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
|
440 |
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
|
441 |
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
|
442 |
|
220 | 443 |
lemma Star_val_length: |
444 |
assumes "\<forall>s\<in>set ss. \<exists>v. s = flat v \<and> \<turnstile> v : r" |
|
445 |
shows "\<exists>vs. concat (map flat vs) = concat ss \<and> (\<forall>v\<in>set vs. \<turnstile> v : r) \<and> (length vs) = (length ss)" |
|
446 |
using assms |
|
447 |
apply(induct ss) |
|
448 |
apply(auto) |
|
449 |
by (metis List.bind_def bind_simps(2) length_Suc_conv set_ConsD) |
|
450 |
||
451 |
||
452 |
lemma Star_Pow: |
|
453 |
assumes "s \<in> A \<up> n" |
|
454 |
shows "\<exists>ss. concat ss = s \<and> (\<forall>s \<in> set ss. s \<in> A) \<and> (length ss = n)" |
|
455 |
using assms |
|
456 |
apply(induct n arbitrary: s) |
|
457 |
apply(auto simp add: Sequ_def) |
|
458 |
apply(drule_tac x="s2" in meta_spec) |
|
459 |
apply(auto) |
|
460 |
apply(rule_tac x="s1#ss" in exI) |
|
461 |
apply(simp) |
|
462 |
done |
|
463 |
||
185
841f7b9c0a6a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
172
diff
changeset
|
464 |
|
841f7b9c0a6a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
172
diff
changeset
|
465 |
lemma L_flat_Prf2: |
841f7b9c0a6a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
172
diff
changeset
|
466 |
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
|
467 |
using assms |
841f7b9c0a6a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
172
diff
changeset
|
468 |
apply(induct r arbitrary: s) |
841f7b9c0a6a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
172
diff
changeset
|
469 |
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
|
470 |
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
|
471 |
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
|
472 |
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
|
473 |
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
|
474 |
apply(auto)[1] |
97
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
475 |
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
|
476 |
apply(simp) |
223 | 477 |
apply(rule Prf.intros) |
478 |
apply(simp) |
|
479 |
using Star_string Star_val apply force |
|
220 | 480 |
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)") |
481 |
apply(auto)[1] |
|
482 |
apply(rule_tac x="Stars vs" in exI) |
|
483 |
apply(simp) |
|
223 | 484 |
apply(rule Prf.intros) |
220 | 485 |
apply(simp) |
223 | 486 |
apply(simp) |
487 |
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
|
488 |
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
|
489 |
apply(auto)[1] |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
490 |
apply(rule_tac x="Stars vs" in exI) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
491 |
apply(simp) |
223 | 492 |
apply(rule Prf.intros) |
221
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
493 |
apply(simp) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
494 |
apply(simp) |
223 | 495 |
using Star_Pow Star_val_length apply blast |
496 |
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)") |
|
497 |
apply(auto)[1] |
|
498 |
apply(rule_tac x="Stars vs" in exI) |
|
499 |
apply(simp) |
|
500 |
apply(rule Prf.intros) |
|
501 |
apply(simp) |
|
502 |
apply(simp) |
|
503 |
using Star_Pow Star_val_length apply blast |
|
504 |
done |
|
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
505 |
|
185
841f7b9c0a6a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
172
diff
changeset
|
506 |
lemma L_flat_Prf: |
841f7b9c0a6a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
172
diff
changeset
|
507 |
"L(r) = {flat v | v. \<turnstile> v : r}" |
223 | 508 |
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
|
509 |
|
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
|
510 |
|
145
97735ef233be
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
144
diff
changeset
|
511 |
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
|
512 |
|
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
513 |
fun |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
514 |
mkeps :: "rexp \<Rightarrow> val" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
515 |
where |
107
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
516 |
"mkeps(ONE) = Void" |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
517 |
| "mkeps(SEQ r1 r2) = Seq (mkeps r1) (mkeps r2)" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
518 |
| "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
|
519 |
| "mkeps(STAR r) = Stars []" |
220 | 520 |
| "mkeps(UPNTIMES r n) = Stars []" |
221
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
521 |
| "mkeps(NTIMES r n) = Stars (replicate n (mkeps r))" |
223 | 522 |
| "mkeps(FROMNTIMES r n) = Stars (replicate n (mkeps r))" |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
523 |
|
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
524 |
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
|
525 |
where |
101
7f4f8c34da95
fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
100
diff
changeset
|
526 |
"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
|
527 |
| "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
|
528 |
| "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
|
529 |
| "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
|
530 |
| "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
|
531 |
| "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
|
532 |
| "injval (STAR r) c (Seq v (Stars vs)) = Stars ((injval r c v) # vs)" |
220 | 533 |
| "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
|
534 |
| "injval (NTIMES r n) c (Seq v (Stars vs)) = Stars ((injval r c v) # vs)" |
223 | 535 |
| "injval (FROMNTIMES r n) c (Seq v (Stars vs)) = Stars ((injval r c v) # vs)" |
107
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
536 |
|
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
537 |
section {* Mkeps, injval *} |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
538 |
|
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
539 |
lemma mkeps_nullable: |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
540 |
assumes "nullable(r)" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
541 |
shows "\<turnstile> mkeps r : r" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
542 |
using assms |
221
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
543 |
apply(induct r rule: mkeps.induct) |
220 | 544 |
apply(auto intro: Prf.intros) |
221
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
545 |
done |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
546 |
|
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
547 |
lemma mkeps_flat: |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
548 |
assumes "nullable(r)" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
549 |
shows "flat (mkeps r) = []" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
550 |
using assms |
142
08dcf0d20f15
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
127
diff
changeset
|
551 |
by (induct rule: nullable.induct) (auto) |
08dcf0d20f15
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
127
diff
changeset
|
552 |
|
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
553 |
|
107
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
554 |
lemma Prf_injval: |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
555 |
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
|
556 |
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
|
557 |
using assms |
107
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
558 |
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
|
559 |
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
|
560 |
(* STAR *) |
91
f067e59b58d9
more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
90
diff
changeset
|
561 |
apply(rotate_tac 2) |
f067e59b58d9
more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
90
diff
changeset
|
562 |
apply(erule Prf.cases) |
223 | 563 |
apply(simp_all) |
91
f067e59b58d9
more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
90
diff
changeset
|
564 |
apply(auto) |
223 | 565 |
using Prf.intros(6) apply auto[1] |
220 | 566 |
(* UPNTIMES *) |
567 |
apply(case_tac x2) |
|
568 |
apply(simp) |
|
569 |
using Prf_elims(1) apply auto[1] |
|
570 |
apply(simp) |
|
571 |
apply(erule Prf.cases) |
|
572 |
apply(simp_all) |
|
573 |
apply(clarify) |
|
223 | 574 |
apply(rotate_tac 2) |
575 |
apply(erule Prf.cases) |
|
576 |
apply(simp_all) |
|
220 | 577 |
apply(clarify) |
223 | 578 |
using Prf.intros(7) apply auto[1] |
221
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
579 |
(* NTIMES *) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
580 |
apply(case_tac x2) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
581 |
apply(simp) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
582 |
using Prf_elims(1) apply auto[1] |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
583 |
apply(simp) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
584 |
apply(erule Prf.cases) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
585 |
apply(simp_all) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
586 |
apply(clarify) |
223 | 587 |
apply(rotate_tac 2) |
588 |
apply(erule Prf.cases) |
|
589 |
apply(simp_all) |
|
221
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
590 |
apply(clarify) |
223 | 591 |
using Prf.intros(8) apply auto[1] |
592 |
(* FROMNTIMES *) |
|
593 |
apply(case_tac x2) |
|
221
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
594 |
apply(simp) |
223 | 595 |
apply(erule Prf.cases) |
596 |
apply(simp_all) |
|
597 |
apply(clarify) |
|
598 |
apply(rotate_tac 2) |
|
599 |
apply(erule Prf.cases) |
|
600 |
apply(simp_all) |
|
601 |
apply(clarify) |
|
602 |
using Prf.intros(9) apply auto[1] |
|
603 |
apply(rotate_tac 1) |
|
604 |
apply(erule Prf.cases) |
|
605 |
apply(simp_all) |
|
606 |
apply(clarify) |
|
607 |
apply(rotate_tac 2) |
|
608 |
apply(erule Prf.cases) |
|
609 |
apply(simp_all) |
|
610 |
apply(clarify) |
|
611 |
using Prf.intros(9) by auto |
|
612 |
||
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
613 |
|
107
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
106
diff
changeset
|
614 |
lemma Prf_injval_flat: |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
615 |
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
|
616 |
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
|
617 |
using assms |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
618 |
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
|
619 |
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
|
620 |
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
|
621 |
apply(rotate_tac 2) |
f067e59b58d9
more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
90
diff
changeset
|
622 |
apply(erule Prf.cases) |
220 | 623 |
apply(simp_all) |
223 | 624 |
apply(rotate_tac 2) |
625 |
apply(erule Prf.cases) |
|
626 |
apply(simp_all) |
|
627 |
apply(rotate_tac 2) |
|
628 |
apply(erule Prf.cases) |
|
629 |
apply(simp_all) |
|
630 |
apply(rotate_tac 2) |
|
631 |
apply(erule Prf.cases) |
|
632 |
apply(simp_all) |
|
633 |
apply(rotate_tac 2) |
|
634 |
apply(erule Prf.cases) |
|
635 |
apply(simp_all) |
|
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
636 |
done |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
637 |
|
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
638 |
|
104
59bad592a009
updated theories and cleaned them up
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
103
diff
changeset
|
639 |
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
|
640 |
|
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
641 |
inductive |
146
da81ffac4b10
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
145
diff
changeset
|
642 |
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
|
643 |
where |
151
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
644 |
Posix_ONE: "[] \<in> ONE \<rightarrow> Void" |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
645 |
| 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
|
646 |
| 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
|
647 |
| 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
|
648 |
| 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
|
649 |
\<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
|
650 |
(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
|
651 |
| 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
|
652 |
\<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
|
653 |
\<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
|
654 |
| Posix_STAR2: "[] \<in> STAR r \<rightarrow> Stars []" |
220 | 655 |
| Posix_UPNTIMES1: "\<lbrakk>s1 \<in> r \<rightarrow> v; s2 \<in> UPNTIMES r n \<rightarrow> Stars vs; flat v \<noteq> []; |
656 |
\<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> |
|
657 |
\<Longrightarrow> (s1 @ s2) \<in> UPNTIMES r (Suc n) \<rightarrow> Stars (v # vs)" |
|
658 |
| 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
|
659 |
| 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
|
660 |
\<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
|
661 |
\<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
|
662 |
| Posix_NTIMES2: "[] \<in> NTIMES r 0 \<rightarrow> Stars []" |
223 | 663 |
| Posix_FROMNTIMES1: "\<lbrakk>s1 \<in> r \<rightarrow> v; s2 \<in> FROMNTIMES r n \<rightarrow> Stars vs; |
664 |
\<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> |
|
665 |
\<Longrightarrow> (s1 @ s2) \<in> FROMNTIMES r (Suc n) \<rightarrow> Stars (v # vs)" |
|
225 | 666 |
| Posix_FROMNTIMES2: "s \<in> STAR r \<rightarrow> Stars vs \<Longrightarrow> s \<in> FROMNTIMES r 0 \<rightarrow> Stars vs" |
667 |
||
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
668 |
|
146
da81ffac4b10
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
145
diff
changeset
|
669 |
inductive_cases Posix_elims: |
149
ec3d221bfc45
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
146
diff
changeset
|
670 |
"s \<in> ZERO \<rightarrow> v" |
143
1e7b36450d9a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
142
diff
changeset
|
671 |
"s \<in> ONE \<rightarrow> v" |
1e7b36450d9a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
142
diff
changeset
|
672 |
"s \<in> CHAR c \<rightarrow> v" |
1e7b36450d9a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
142
diff
changeset
|
673 |
"s \<in> ALT r1 r2 \<rightarrow> v" |
1e7b36450d9a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
142
diff
changeset
|
674 |
"s \<in> SEQ r1 r2 \<rightarrow> v" |
1e7b36450d9a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
142
diff
changeset
|
675 |
"s \<in> STAR r \<rightarrow> v" |
1e7b36450d9a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
142
diff
changeset
|
676 |
|
146
da81ffac4b10
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
145
diff
changeset
|
677 |
lemma Posix1: |
101
7f4f8c34da95
fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
100
diff
changeset
|
678 |
assumes "s \<in> r \<rightarrow> v" |
123
1bee7006b92b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
679 |
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
|
680 |
using assms |
220 | 681 |
apply (induct s r v rule: Posix.induct) |
682 |
apply(auto simp add: Sequ_def) |
|
683 |
apply(rule_tac x="Suc x" in bexI) |
|
684 |
apply(auto simp add: Sequ_def) |
|
223 | 685 |
apply(rule_tac x="Suc x" in bexI) |
686 |
apply(auto simp add: Sequ_def) |
|
225 | 687 |
by (simp add: Star_in_Pow) |
143
1e7b36450d9a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
142
diff
changeset
|
688 |
|
101
7f4f8c34da95
fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
100
diff
changeset
|
689 |
|
146
da81ffac4b10
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
145
diff
changeset
|
690 |
lemma Posix1a: |
122
7c6c907660d8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
121
diff
changeset
|
691 |
assumes "s \<in> r \<rightarrow> v" |
123
1bee7006b92b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
692 |
shows "\<turnstile> v : r" |
122
7c6c907660d8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
121
diff
changeset
|
693 |
using assms |
220 | 694 |
apply(induct s r v rule: Posix.induct) |
695 |
apply(auto intro: Prf.intros) |
|
223 | 696 |
apply(rule Prf.intros) |
697 |
apply(auto)[1] |
|
698 |
apply(rotate_tac 3) |
|
699 |
apply(erule Prf.cases) |
|
700 |
apply(simp_all) |
|
701 |
apply(rule Prf.intros) |
|
702 |
apply(auto)[1] |
|
703 |
apply(rotate_tac 3) |
|
704 |
apply(erule Prf.cases) |
|
705 |
apply(simp_all) |
|
706 |
apply (smt Posix_UPNTIMES2 Posix_elims(2) Prf.simps le_0_eq le_Suc_eq length_0_conv nat_induct nullable.simps(3) nullable.simps(7) rexp.distinct(61) rexp.distinct(67) rexp.distinct(69) rexp.inject(5) val.inject(5) val.simps(29) val.simps(33) val.simps(35)) |
|
707 |
apply(rule Prf.intros) |
|
708 |
apply(auto)[1] |
|
709 |
apply(rotate_tac 3) |
|
710 |
apply(erule Prf.cases) |
|
711 |
apply(simp_all) |
|
712 |
apply (smt Prf.simps rexp.distinct(63) rexp.distinct(67) rexp.distinct(71) rexp.inject(6) val.distinct(17) val.distinct(9) val.inject(5) val.simps(29) val.simps(33) val.simps(35)) |
|
713 |
apply(rule Prf.intros) |
|
714 |
apply(auto)[1] |
|
715 |
apply(rotate_tac 3) |
|
716 |
apply(erule Prf.cases) |
|
717 |
apply(simp_all) |
|
225 | 718 |
using Prf.simps apply blast |
719 |
by (smt Prf.simps le0 rexp.distinct(61) rexp.distinct(63) rexp.distinct(65) rexp.inject(4) val.distinct(17) val.distinct(9) val.simps(29) val.simps(33) val.simps(35)) |
|
222 | 720 |
|
221
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
721 |
lemma Posix_NTIMES_mkeps: |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
722 |
assumes "[] \<in> r \<rightarrow> mkeps r" |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
723 |
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
|
724 |
apply(induct n) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
725 |
apply(simp) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
726 |
apply (rule Posix_NTIMES2) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
727 |
apply(simp) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
728 |
apply(subst append_Nil[symmetric]) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
729 |
apply (rule Posix_NTIMES1) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
730 |
apply(auto) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
731 |
apply(rule assms) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
732 |
done |
122
7c6c907660d8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
121
diff
changeset
|
733 |
|
223 | 734 |
lemma Posix_FROMNTIMES_mkeps: |
735 |
assumes "[] \<in> r \<rightarrow> mkeps r" |
|
736 |
shows "[] \<in> FROMNTIMES r n \<rightarrow> Stars (replicate n (mkeps r))" |
|
737 |
apply(induct n) |
|
738 |
apply(simp) |
|
739 |
apply (rule Posix_FROMNTIMES2) |
|
225 | 740 |
apply (rule Posix.intros) |
223 | 741 |
apply(simp) |
742 |
apply(subst append_Nil[symmetric]) |
|
743 |
apply (rule Posix_FROMNTIMES1) |
|
744 |
apply(auto) |
|
745 |
apply(rule assms) |
|
746 |
done |
|
747 |
||
748 |
||
146
da81ffac4b10
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
145
diff
changeset
|
749 |
lemma Posix_mkeps: |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
750 |
assumes "nullable r" |
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
751 |
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
|
752 |
using assms |
185
841f7b9c0a6a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
172
diff
changeset
|
753 |
apply(induct r rule: nullable.induct) |
146
da81ffac4b10
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
145
diff
changeset
|
754 |
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
|
755 |
apply(subst append.simps(1)[symmetric]) |
146
da81ffac4b10
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
145
diff
changeset
|
756 |
apply(rule Posix.intros) |
123
1bee7006b92b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
122
diff
changeset
|
757 |
apply(auto) |
221
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
758 |
apply(case_tac n) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
759 |
apply(simp) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
760 |
apply (simp add: Posix_NTIMES2) |
223 | 761 |
apply(simp) |
762 |
apply(subst append.simps(1)[symmetric]) |
|
763 |
apply(rule Posix.intros) |
|
764 |
apply(auto) |
|
221
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
765 |
apply(rule Posix_NTIMES_mkeps) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
766 |
apply(simp) |
225 | 767 |
apply(rule Posix.intros) |
768 |
apply(rule Posix.intros) |
|
223 | 769 |
apply(case_tac n) |
770 |
apply(simp) |
|
225 | 771 |
apply(rule Posix.intros) |
772 |
apply(rule Posix.intros) |
|
223 | 773 |
apply(simp) |
774 |
apply(subst append.simps(1)[symmetric]) |
|
775 |
apply(rule Posix.intros) |
|
776 |
apply(auto) |
|
777 |
apply(rule Posix_FROMNTIMES_mkeps) |
|
778 |
apply(simp) |
|
91
f067e59b58d9
more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
90
diff
changeset
|
779 |
done |
89
9613e6ace30f
added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
780 |
|
142
08dcf0d20f15
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
127
diff
changeset
|
781 |
|
146
da81ffac4b10
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
145
diff
changeset
|
782 |
lemma Posix_determ: |
122
7c6c907660d8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
121
diff
changeset
|
783 |
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
|
784 |
shows "v1 = v2" |
7c6c907660d8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
121
diff
changeset
|
785 |
using assms |
151
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
786 |
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
|
787 |
case (Posix_ONE v2) |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
788 |
have "[] \<in> ONE \<rightarrow> v2" by fact |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
789 |
then show "Void = v2" by cases auto |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
790 |
next |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
791 |
case (Posix_CHAR c v2) |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
792 |
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
|
793 |
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
|
794 |
next |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
795 |
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
|
796 |
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
|
797 |
moreover |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
798 |
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
|
799 |
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
|
800 |
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
|
801 |
moreover |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
802 |
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
|
803 |
ultimately have "v = v'" by simp |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
804 |
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
|
805 |
next |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
806 |
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
|
807 |
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
|
808 |
moreover |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
809 |
have "s \<notin> L r1" by fact |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
810 |
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
|
811 |
by cases (auto simp add: Posix1) |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
812 |
moreover |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
813 |
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
|
814 |
ultimately have "v = v'" by simp |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
815 |
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
|
816 |
next |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
817 |
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
|
818 |
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
|
819 |
"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
|
820 |
"\<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
|
821 |
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
|
822 |
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
|
823 |
using Posix1(1) by fastforce+ |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
824 |
moreover |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
825 |
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
|
826 |
"\<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
|
827 |
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
|
828 |
next |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
829 |
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
|
830 |
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
|
831 |
"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
|
832 |
"\<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
|
833 |
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
|
834 |
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
|
835 |
using Posix1(1) apply fastforce |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
836 |
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
|
837 |
using Posix1(2) by blast |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
838 |
moreover |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
839 |
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
|
840 |
"\<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
|
841 |
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
|
842 |
next |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
843 |
case (Posix_STAR2 r v2) |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
844 |
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
|
845 |
then show "Stars [] = v2" by cases (auto simp add: Posix1) |
220 | 846 |
next |
847 |
case (Posix_UPNTIMES1 s1 r v s2 n vs v2) |
|
848 |
have "(s1 @ s2) \<in> UPNTIMES r (Suc n) \<rightarrow> v2" |
|
849 |
"s1 \<in> r \<rightarrow> v" "s2 \<in> (UPNTIMES r n) \<rightarrow> Stars vs" "flat v \<noteq> []" |
|
850 |
"\<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+ |
|
851 |
then obtain v' vs' where "v2 = Stars (v' # vs')" "s1 \<in> r \<rightarrow> v'" "s2 \<in> (UPNTIMES r n) \<rightarrow> (Stars vs')" |
|
852 |
apply(cases) apply (auto simp add: append_eq_append_conv2) |
|
853 |
using Posix1(1) apply fastforce |
|
854 |
apply (metis Posix1(1) Posix_UPNTIMES1.hyps(6) append_Nil append_Nil2) |
|
855 |
using Posix1(2) by blast |
|
856 |
moreover |
|
857 |
have IHs: "\<And>v2. s1 \<in> r \<rightarrow> v2 \<Longrightarrow> v = v2" |
|
858 |
"\<And>v2. s2 \<in> UPNTIMES r n \<rightarrow> v2 \<Longrightarrow> Stars vs = v2" by fact+ |
|
859 |
ultimately show "Stars (v # vs) = v2" by auto |
|
860 |
next |
|
861 |
case (Posix_UPNTIMES2 r n v2) |
|
862 |
have "[] \<in> UPNTIMES r n \<rightarrow> v2" by fact |
|
863 |
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
|
864 |
next |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
865 |
case (Posix_NTIMES2 r v2) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
866 |
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
|
867 |
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
|
868 |
next |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
869 |
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
|
870 |
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
|
871 |
"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
|
872 |
"\<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
|
873 |
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
|
874 |
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
|
875 |
using Posix1(1) apply fastforce |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
876 |
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
|
877 |
done |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
878 |
moreover |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
879 |
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
|
880 |
"\<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
|
881 |
ultimately show "Stars (v # vs) = v2" by auto |
223 | 882 |
next |
225 | 883 |
case (Posix_FROMNTIMES2 s r v1 v2) |
884 |
have "s \<in> FROMNTIMES r 0 \<rightarrow> v2" "s \<in> STAR r \<rightarrow> Stars v1" |
|
885 |
"\<And>v3. s \<in> STAR r \<rightarrow> v3 \<Longrightarrow> Stars v1 = v3" by fact+ |
|
886 |
then show ?case |
|
887 |
apply(cases) |
|
888 |
apply(auto) |
|
889 |
done |
|
223 | 890 |
next |
891 |
case (Posix_FROMNTIMES1 s1 r v s2 n vs v2) |
|
892 |
have "(s1 @ s2) \<in> FROMNTIMES r (Suc n) \<rightarrow> v2" |
|
893 |
"s1 \<in> r \<rightarrow> v" "s2 \<in> (FROMNTIMES r n) \<rightarrow> Stars vs" |
|
894 |
"\<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+ |
|
895 |
then obtain v' vs' where "v2 = Stars (v' # vs')" "s1 \<in> r \<rightarrow> v'" "s2 \<in> (FROMNTIMES r n) \<rightarrow> (Stars vs')" |
|
896 |
apply(cases) apply (auto simp add: append_eq_append_conv2) |
|
897 |
using Posix1(1) apply fastforce |
|
898 |
by (metis Posix1(1) Posix_FROMNTIMES1.hyps(5) append_Nil2 self_append_conv2) |
|
899 |
moreover |
|
900 |
have IHs: "\<And>v2. s1 \<in> r \<rightarrow> v2 \<Longrightarrow> v = v2" |
|
901 |
"\<And>v2. s2 \<in> FROMNTIMES r n \<rightarrow> v2 \<Longrightarrow> Stars vs = v2" by fact+ |
|
902 |
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
|
903 |
qed |
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
904 |
|
223 | 905 |
lemma NTIMES_Stars: |
906 |
assumes "\<turnstile> v : NTIMES r n" |
|
907 |
shows "\<exists>vs. v = Stars vs \<and> (\<forall>v \<in> set vs. \<turnstile> v : r) \<and> length vs = n" |
|
908 |
using assms |
|
909 |
apply(induct n arbitrary: v) |
|
910 |
apply(erule Prf.cases) |
|
911 |
apply(simp_all) |
|
912 |
apply(erule Prf.cases) |
|
913 |
apply(simp_all) |
|
914 |
done |
|
915 |
||
916 |
lemma UPNTIMES_Stars: |
|
917 |
assumes "\<turnstile> v : UPNTIMES r n" |
|
918 |
shows "\<exists>vs. v = Stars vs \<and> (\<forall>v \<in> set vs. \<turnstile> v : r) \<and> length vs \<le> n" |
|
919 |
using assms |
|
920 |
apply(induct n arbitrary: v) |
|
921 |
apply(erule Prf.cases) |
|
922 |
apply(simp_all) |
|
923 |
apply(erule Prf.cases) |
|
924 |
apply(simp_all) |
|
925 |
done |
|
926 |
||
927 |
lemma FROMNTIMES_Stars: |
|
928 |
assumes "\<turnstile> v : FROMNTIMES r n" |
|
929 |
shows "\<exists>vs. v = Stars vs \<and> (\<forall>v \<in> set vs. \<turnstile> v : r) \<and> n \<le> length vs" |
|
930 |
using assms |
|
931 |
apply(induct n arbitrary: v) |
|
932 |
apply(erule Prf.cases) |
|
933 |
apply(simp_all) |
|
934 |
apply(erule Prf.cases) |
|
935 |
apply(simp_all) |
|
936 |
done |
|
937 |
||
100
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
938 |
|
172
cdc0bdcfba3f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
151
diff
changeset
|
939 |
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
|
940 |
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
|
941 |
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
|
942 |
using assms |
121
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
943 |
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
|
944 |
case ZERO |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
945 |
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
|
946 |
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
|
947 |
then have "False" by cases |
143
1e7b36450d9a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
142
diff
changeset
|
948 |
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
|
949 |
next |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
950 |
case ONE |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
951 |
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
|
952 |
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
|
953 |
then have "False" by cases |
143
1e7b36450d9a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
142
diff
changeset
|
954 |
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
|
955 |
next |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
956 |
case (CHAR d) |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
957 |
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
|
958 |
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
|
959 |
proof (cases) |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
960 |
case eq |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
961 |
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
|
962 |
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
|
963 |
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
|
964 |
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
|
965 |
by (auto intro: Posix.intros) |
121
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
966 |
next |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
967 |
case ineq |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
968 |
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
|
969 |
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
|
970 |
then have "False" by cases |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
971 |
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
|
972 |
qed |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
973 |
next |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
974 |
case (ALT r1 r2) |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
975 |
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
|
976 |
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
|
977 |
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
|
978 |
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
|
979 |
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
|
980 |
| (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
|
981 |
by cases auto |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
982 |
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
|
983 |
proof (cases) |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
984 |
case left |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
985 |
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
|
986 |
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
|
987 |
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
|
988 |
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
|
989 |
next |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
990 |
case right |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
991 |
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
|
992 |
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
|
993 |
moreover |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
994 |
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
|
995 |
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
|
996 |
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
|
997 |
by (auto intro: Posix.intros) |
121
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
998 |
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
|
999 |
qed |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1000 |
next |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1001 |
case (SEQ r1 r2) |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1002 |
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
|
1003 |
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
|
1004 |
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
|
1005 |
then consider |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1006 |
(left_nullable) v1 v2 s1 s2 where |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1007 |
"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
|
1008 |
"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
|
1009 |
"\<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
|
1010 |
| (right_nullable) v1 s1 s2 where |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1011 |
"v = Right v1" "s = s1 @ s2" |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1012 |
"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
|
1013 |
| (not_nullable) v1 v2 s1 s2 where |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1014 |
"v = Seq v1 v2" "s = s1 @ s2" |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1015 |
"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
|
1016 |
"\<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
|
1017 |
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
|
1018 |
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
|
1019 |
proof (cases) |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1020 |
case left_nullable |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1021 |
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
|
1022 |
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
|
1023 |
moreover |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1024 |
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
|
1025 |
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
|
1026 |
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
|
1027 |
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
|
1028 |
next |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1029 |
case right_nullable |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1030 |
have "nullable r1" by fact |
146
da81ffac4b10
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
145
diff
changeset
|
1031 |
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
|
1032 |
moreover |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1033 |
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
|
1034 |
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
|
1035 |
moreover |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1036 |
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
|
1037 |
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
|
1038 |
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
|
1039 |
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
|
1040 |
by(rule Posix.intros) |
121
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1041 |
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
|
1042 |
next |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1043 |
case not_nullable |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1044 |
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
|
1045 |
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
|
1046 |
moreover |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1047 |
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
|
1048 |
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
|
1049 |
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
|
1050 |
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
|
1051 |
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
|
1052 |
qed |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1053 |
next |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1054 |
case (STAR r) |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1055 |
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
|
1056 |
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
|
1057 |
then consider |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1058 |
(cons) v1 vs s1 s2 where |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1059 |
"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
|
1060 |
"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
|
1061 |
"\<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
|
1062 |
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
|
1063 |
apply(rotate_tac 3) |
149
ec3d221bfc45
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
146
diff
changeset
|
1064 |
apply(erule_tac Posix_elims(6)) |
146
da81ffac4b10
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
145
diff
changeset
|
1065 |
apply (simp add: Posix.intros(6)) |
da81ffac4b10
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
145
diff
changeset
|
1066 |
using Posix.intros(7) by blast |
121
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1067 |
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
|
1068 |
proof (cases) |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1069 |
case cons |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1070 |
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
|
1071 |
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
|
1072 |
moreover |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1073 |
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
|
1074 |
moreover |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1075 |
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
|
1076 |
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
|
1077 |
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
|
1078 |
moreover |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1079 |
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
|
1080 |
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
|
1081 |
by (simp add: der_correctness Der_def) |
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1082 |
ultimately |
146
da81ffac4b10
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
145
diff
changeset
|
1083 |
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
|
1084 |
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
|
1085 |
qed |
220 | 1086 |
next |
1087 |
case (UPNTIMES r n) |
|
1088 |
have IH: "\<And>s v. s \<in> der c r \<rightarrow> v \<Longrightarrow> (c # s) \<in> r \<rightarrow> injval r c v" by fact |
|
1089 |
have "s \<in> der c (UPNTIMES r n) \<rightarrow> v" by fact |
|
1090 |
then consider |
|
1091 |
(cons) m v1 vs s1 s2 where |
|
1092 |
"n = Suc m" |
|
1093 |
"v = Seq v1 (Stars vs)" "s = s1 @ s2" |
|
1094 |
"s1 \<in> der c r \<rightarrow> v1" "s2 \<in> (UPNTIMES r m) \<rightarrow> (Stars vs)" |
|
1095 |
"\<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))" |
|
1096 |
apply(case_tac n) |
|
1097 |
apply(simp) |
|
1098 |
using Posix_elims(1) apply blast |
|
1099 |
apply(simp) |
|
223 | 1100 |
apply(auto elim!: Posix_elims(1-5) simp add: der_correctness Der_def intro: Posix.intros) |
220 | 1101 |
by (metis Posix1a UPNTIMES_Stars) |
1102 |
then show "(c # s) \<in> UPNTIMES r n \<rightarrow> injval (UPNTIMES r n) c v" |
|
1103 |
proof (cases) |
|
1104 |
case cons |
|
1105 |
have "n = Suc m" by fact |
|
1106 |
moreover |
|
1107 |
have "s1 \<in> der c r \<rightarrow> v1" by fact |
|
1108 |
then have "(c # s1) \<in> r \<rightarrow> injval r c v1" using IH by simp |
|
1109 |
moreover |
|
1110 |
have "s2 \<in> UPNTIMES r m \<rightarrow> Stars vs" by fact |
|
1111 |
moreover |
|
1112 |
have "(c # s1) \<in> r \<rightarrow> injval r c v1" by fact |
|
1113 |
then have "flat (injval r c v1) = (c # s1)" by (rule Posix1) |
|
1114 |
then have "flat (injval r c v1) \<noteq> []" by simp |
|
1115 |
moreover |
|
1116 |
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 |
|
1117 |
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))" |
|
1118 |
by (simp add: der_correctness Der_def) |
|
1119 |
ultimately |
|
1120 |
have "((c # s1) @ s2) \<in> UPNTIMES r (Suc m) \<rightarrow> Stars (injval r c v1 # vs)" |
|
1121 |
apply(rule_tac Posix.intros(8)) |
|
1122 |
apply(simp_all) |
|
1123 |
done |
|
1124 |
then show "(c # s) \<in> UPNTIMES r n \<rightarrow> injval (UPNTIMES r n) c v" using cons by(simp) |
|
1125 |
qed |
|
221
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1126 |
next |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1127 |
case (NTIMES r n) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1128 |
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
|
1129 |
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
|
1130 |
then consider |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1131 |
(cons) m v1 vs s1 s2 where |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1132 |
"n = Suc m" |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1133 |
"v = Seq v1 (Stars vs)" "s = s1 @ s2" |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1134 |
"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
|
1135 |
"\<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
|
1136 |
apply(case_tac n) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1137 |
apply(simp) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1138 |
using Posix_elims(1) apply blast |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1139 |
apply(simp) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1140 |
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
|
1141 |
by (metis NTIMES_Stars Posix1a) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1142 |
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
|
1143 |
proof (cases) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1144 |
case cons |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1145 |
have "n = Suc m" by fact |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1146 |
moreover |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1147 |
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
|
1148 |
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
|
1149 |
moreover |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1150 |
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
|
1151 |
moreover |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1152 |
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
|
1153 |
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
|
1154 |
by (simp add: der_correctness Der_def) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1155 |
ultimately |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1156 |
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
|
1157 |
apply(rule_tac Posix.intros(10)) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1158 |
apply(simp_all) |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1159 |
done |
c21938d0b396
added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents:
220
diff
changeset
|
1160 |
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
|
1161 |
qed |
223 | 1162 |
next |
1163 |
case (FROMNTIMES r n) |
|
1164 |
have IH: "\<And>s v. s \<in> der c r \<rightarrow> v \<Longrightarrow> (c # s) \<in> r \<rightarrow> injval r c v" by fact |
|
1165 |
have "s \<in> der c (FROMNTIMES r n) \<rightarrow> v" by fact |
|
1166 |
then consider |
|
1167 |
(null) v1 vs s1 s2 where |
|
224 | 1168 |
"n = 0" |
223 | 1169 |
"v = Seq v1 (Stars vs)" "s = s1 @ s2" |
225 | 1170 |
"s1 \<in> der c r \<rightarrow> v1" "s2 \<in> (FROMNTIMES r 0) \<rightarrow> (Stars vs)" |
223 | 1171 |
"\<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))" |
1172 |
| (cons) m v1 vs s1 s2 where |
|
1173 |
"n = Suc m" |
|
1174 |
"v = Seq v1 (Stars vs)" "s = s1 @ s2" |
|
1175 |
"s1 \<in> der c r \<rightarrow> v1" "s2 \<in> (FROMNTIMES r m) \<rightarrow> (Stars vs)" |
|
1176 |
"\<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))" |
|
1177 |
apply(case_tac n) |
|
1178 |
apply(simp) |
|
1179 |
apply(auto elim!: Posix_elims(1-5) simp add: der_correctness Der_def intro: Posix.intros) |
|
1180 |
defer |
|
1181 |
apply (metis FROMNTIMES_Stars Posix1a) |
|
1182 |
apply(rotate_tac 5) |
|
225 | 1183 |
apply(erule Posix.cases) |
1184 |
apply(simp_all) |
|
1185 |
apply(clarify) |
|
1186 |
by (simp add: Posix_FROMNTIMES2) |
|
223 | 1187 |
then show "(c # s) \<in> FROMNTIMES r n \<rightarrow> injval (FROMNTIMES r n) c v" |
1188 |
proof (cases) |
|
1189 |
case cons |
|
1190 |
have "n = Suc m" by fact |
|
1191 |
moreover |
|
1192 |
have "s1 \<in> der c r \<rightarrow> v1" by fact |
|
1193 |
then have "(c # s1) \<in> r \<rightarrow> injval r c v1" using IH by simp |
|
1194 |
moreover |
|
1195 |
have "s2 \<in> FROMNTIMES r m \<rightarrow> Stars vs" by fact |
|
1196 |
moreover |
|
1197 |
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 |
|
1198 |
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))" |
|
1199 |
by (simp add: der_correctness Der_def) |
|
1200 |
ultimately |
|
1201 |
have "((c # s1) @ s2) \<in> FROMNTIMES r (Suc m) \<rightarrow> Stars (injval r c v1 # vs)" |
|
1202 |
apply(rule_tac Posix.intros(12)) |
|
1203 |
apply(simp_all) |
|
1204 |
done |
|
1205 |
then show "(c # s) \<in> FROMNTIMES r n \<rightarrow> injval (FROMNTIMES r n) c v" using cons by(simp) |
|
224 | 1206 |
next |
1207 |
case null |
|
225 | 1208 |
then have "((c # s1) @ s2) \<in> FROMNTIMES r 0 \<rightarrow> Stars (injval r c v1 # vs)" |
1209 |
apply(rule_tac Posix.intros) |
|
1210 |
apply(rule_tac Posix.intros) |
|
1211 |
apply(rule IH) |
|
224 | 1212 |
apply(simp) |
225 | 1213 |
apply(rotate_tac 4) |
1214 |
apply(erule Posix.cases) |
|
1215 |
apply(simp_all) |
|
1216 |
apply (simp add: Posix1a Prf_injval_flat) |
|
1217 |
apply(simp only: Star_def2) |
|
1218 |
apply(simp only: der_correctness Der_def) |
|
1219 |
apply(simp) |
|
1220 |
done |
|
1221 |
then show "(c # s) \<in> FROMNTIMES r n \<rightarrow> injval (FROMNTIMES r n) c v" using null by simp |
|
223 | 1222 |
qed |
121
4c85af262ee7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
120
diff
changeset
|
1223 |
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
|
1224 |
|
145
97735ef233be
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
144
diff
changeset
|
1225 |
|
97735ef233be
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
144
diff
changeset
|
1226 |
section {* The Lexer by Sulzmann and Lu *} |
97735ef233be
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
144
diff
changeset
|
1227 |
|
97735ef233be
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
144
diff
changeset
|
1228 |
fun |
97735ef233be
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
144
diff
changeset
|
1229 |
lexer :: "rexp \<Rightarrow> string \<Rightarrow> val option" |
97735ef233be
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
144
diff
changeset
|
1230 |
where |
97735ef233be
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
144
diff
changeset
|
1231 |
"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
|
1232 |
| "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
|
1233 |
None \<Rightarrow> None |
97735ef233be
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
144
diff
changeset
|
1234 |
| 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
|
1235 |
|
97735ef233be
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
144
diff
changeset
|
1236 |
|
151
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
1237 |
lemma lexer_correct_None: |
145
97735ef233be
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
144
diff
changeset
|
1238 |
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
|
1239 |
apply(induct s arbitrary: r) |
143
1e7b36450d9a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
142
diff
changeset
|
1240 |
apply(simp add: nullable_correctness) |
120
d74bfa11802c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
113
diff
changeset
|
1241 |
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
|
1242 |
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
|
1243 |
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
|
1244 |
|
151
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
1245 |
lemma lexer_correct_Some: |
185
841f7b9c0a6a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
172
diff
changeset
|
1246 |
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
|
1247 |
apply(induct s arbitrary: r) |
151
5a1196466a9c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
150
diff
changeset
|
1248 |
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
|
1249 |
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
|
1250 |
apply(simp add: der_correctness Der_def) |
5378ddbd1381
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
123
diff
changeset
|
1251 |
apply(rule iffI) |
172
cdc0bdcfba3f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
151
diff
changeset
|
1252 |
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
|
1253 |
done |
149
ec3d221bfc45
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
146
diff
changeset
|
1254 |
|
186
0b94800eb616
added corollary
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
185
diff
changeset
|
1255 |
lemma lexer_correctness: |
0b94800eb616
added corollary
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
185
diff
changeset
|
1256 |
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
|
1257 |
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
|
1258 |
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
|
1259 |
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
|
1260 |
|
226 | 1261 |
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
|
1262 |
end |