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