author | Christian Urban <christian dot urban at kcl dot ac dot uk> |
Tue, 18 Oct 2016 20:39:54 +0100 | |
changeset 456 | 2fddf8ab744f |
parent 455 | 1dbf84ade62c |
child 971 | 51e00f223792 |
permissions | -rw-r--r-- |
397
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
1 |
theory Matcher2 |
191
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2 |
imports "Main" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3 |
begin |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
4 |
|
355
a259eec25156
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
5 |
lemma Suc_Union: |
a259eec25156
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
6 |
"(\<Union> x\<le>Suc m. B x) = (B (Suc m) \<union> (\<Union> x\<le>m. B x))" |
a259eec25156
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
7 |
by (metis UN_insert atMost_Suc) |
a259eec25156
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
8 |
|
a259eec25156
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
9 |
lemma Suc_reduce_Union: |
a259eec25156
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
10 |
"(\<Union>x\<in>{Suc n..Suc m}. B x) = (\<Union>x\<in>{n..m}. B (Suc x))" |
a259eec25156
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
11 |
by (metis UN_extend_simps(10) image_Suc_atLeastAtMost) |
a259eec25156
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
12 |
|
a259eec25156
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
13 |
|
191
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
14 |
section {* Regular Expressions *} |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
15 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
16 |
datatype rexp = |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
17 |
NULL |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
18 |
| EMPTY |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
19 |
| CHAR char |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
20 |
| SEQ rexp rexp |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
21 |
| ALT rexp rexp |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
22 |
| STAR rexp |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
23 |
| NOT rexp |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
24 |
| PLUS rexp |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
25 |
| OPT rexp |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
26 |
| NTIMES rexp nat |
362
57ea439feaff
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
361
diff
changeset
|
27 |
| NMTIMES rexp nat nat |
455
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
28 |
| UPNTIMES rexp nat |
362
57ea439feaff
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
361
diff
changeset
|
29 |
|
57ea439feaff
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
361
diff
changeset
|
30 |
|
191
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
31 |
section {* Sequential Composition of Sets *} |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
32 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
33 |
definition |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
34 |
Seq :: "string set \<Rightarrow> string set \<Rightarrow> string set" ("_ ;; _" [100,100] 100) |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
35 |
where |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
36 |
"A ;; B = {s1 @ s2 | s1 s2. s1 \<in> A \<and> s2 \<in> B}" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
37 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
38 |
text {* Two Simple Properties about Sequential Composition *} |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
39 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
40 |
lemma seq_empty [simp]: |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
41 |
shows "A ;; {[]} = A" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
42 |
and "{[]} ;; A = A" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
43 |
by (simp_all add: Seq_def) |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
44 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
45 |
lemma seq_null [simp]: |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
46 |
shows "A ;; {} = {}" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
47 |
and "{} ;; A = {}" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
48 |
by (simp_all add: Seq_def) |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
49 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
50 |
lemma seq_union: |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
51 |
shows "A ;; (B \<union> C) = A ;; B \<union> A ;; C" |
194
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
52 |
and "(B \<union> C) ;; A = B ;; A \<union> C ;; A" |
191
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
53 |
by (auto simp add: Seq_def) |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
54 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
55 |
lemma seq_Union: |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
56 |
shows "A ;; (\<Union>x\<in>B. C x) = (\<Union>x\<in>B. A ;; C x)" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
57 |
by (auto simp add: Seq_def) |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
58 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
59 |
lemma seq_empty_in [simp]: |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
60 |
"[] \<in> A ;; B \<longleftrightarrow> ([] \<in> A \<and> [] \<in> B)" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
61 |
by (simp add: Seq_def) |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
62 |
|
194
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
63 |
lemma seq_assoc: |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
64 |
shows "A ;; (B ;; C) = (A ;; B) ;; C" |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
65 |
apply(auto simp add: Seq_def) |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
66 |
apply(metis append_assoc) |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
67 |
apply(metis) |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
68 |
done |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
69 |
|
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
70 |
|
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
71 |
section {* Power for Sets *} |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
72 |
|
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
73 |
fun |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
74 |
pow :: "string set \<Rightarrow> nat \<Rightarrow> string set" ("_ \<up> _" [101, 102] 101) |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
75 |
where |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
76 |
"A \<up> 0 = {[]}" |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
77 |
| "A \<up> (Suc n) = A ;; (A \<up> n)" |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
78 |
|
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
79 |
lemma pow_empty [simp]: |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
80 |
shows "[] \<in> A \<up> n \<longleftrightarrow> (n = 0 \<or> [] \<in> A)" |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
81 |
by (induct n) (auto) |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
82 |
|
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
83 |
lemma pow_plus: |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
84 |
"A \<up> (n + m) = A \<up> n ;; A \<up> m" |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
85 |
by (induct n) (simp_all add: seq_assoc) |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
86 |
|
191
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
87 |
section {* Kleene Star for Sets *} |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
88 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
89 |
inductive_set |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
90 |
Star :: "string set \<Rightarrow> string set" ("_\<star>" [101] 102) |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
91 |
for A :: "string set" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
92 |
where |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
93 |
start[intro]: "[] \<in> A\<star>" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
94 |
| step[intro]: "\<lbrakk>s1 \<in> A; s2 \<in> A\<star>\<rbrakk> \<Longrightarrow> s1 @ s2 \<in> A\<star>" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
95 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
96 |
text {* A Standard Property of Star *} |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
97 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
98 |
lemma star_decomp: |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
99 |
assumes a: "c # x \<in> A\<star>" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
100 |
shows "\<exists>a b. x = a @ b \<and> c # a \<in> A \<and> b \<in> A\<star>" |
194
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
101 |
using a |
191
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
102 |
using a |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
103 |
by (induct x\<equiv>"c # x" rule: Star.induct) |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
104 |
(auto simp add: append_eq_Cons_conv) |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
105 |
|
194
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
106 |
lemma star_cases: |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
107 |
shows "A\<star> = {[]} \<union> A ;; A\<star>" |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
108 |
unfolding Seq_def |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
109 |
by (auto) (metis Star.simps) |
191
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
110 |
|
194
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
111 |
lemma Star_in_Pow: |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
112 |
assumes a: "s \<in> A\<star>" |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
113 |
shows "\<exists>n. s \<in> A \<up> n" |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
114 |
using a |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
115 |
apply(induct) |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
116 |
apply(auto) |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
117 |
apply(rule_tac x="Suc n" in exI) |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
118 |
apply(auto simp add: Seq_def) |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
119 |
done |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
120 |
|
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
121 |
lemma Pow_in_Star: |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
122 |
assumes a: "s \<in> A \<up> n" |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
123 |
shows "s \<in> A\<star>" |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
124 |
using a |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
125 |
by (induct n arbitrary: s) (auto simp add: Seq_def) |
191
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
126 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
127 |
|
194
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
128 |
lemma Star_def2: |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
129 |
shows "A\<star> = (\<Union>n. A \<up> n)" |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
130 |
using Star_in_Pow Pow_in_Star |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
131 |
by (auto) |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
132 |
|
191
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
133 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
134 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
135 |
section {* Semantics of Regular Expressions *} |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
136 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
137 |
fun |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
138 |
L :: "rexp \<Rightarrow> string set" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
139 |
where |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
140 |
"L (NULL) = {}" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
141 |
| "L (EMPTY) = {[]}" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
142 |
| "L (CHAR c) = {[c]}" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
143 |
| "L (SEQ r1 r2) = (L r1) ;; (L r2)" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
144 |
| "L (ALT r1 r2) = (L r1) \<union> (L r2)" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
145 |
| "L (STAR r) = (L r)\<star>" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
146 |
| "L (NOT r) = UNIV - (L r)" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
147 |
| "L (PLUS r) = (L r) ;; ((L r)\<star>)" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
148 |
| "L (OPT r) = (L r) \<union> {[]}" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
149 |
| "L (NTIMES r n) = (L r) \<up> n" |
362
57ea439feaff
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
361
diff
changeset
|
150 |
| "L (NMTIMES r n m) = (\<Union>i\<in> {n..m} . ((L r) \<up> i))" |
455
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
151 |
| "L (UPNTIMES r n) = (\<Union>i\<in> {..n} . ((L r) \<up> i))" |
191
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
152 |
|
227
93bd75031ced
added handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
198
diff
changeset
|
153 |
lemma "L (NOT NULL) = UNIV" |
93bd75031ced
added handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
198
diff
changeset
|
154 |
apply(simp) |
93bd75031ced
added handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
198
diff
changeset
|
155 |
done |
93bd75031ced
added handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
198
diff
changeset
|
156 |
|
191
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
157 |
section {* The Matcher *} |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
158 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
159 |
fun |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
160 |
nullable :: "rexp \<Rightarrow> bool" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
161 |
where |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
162 |
"nullable (NULL) = False" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
163 |
| "nullable (EMPTY) = True" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
164 |
| "nullable (CHAR c) = False" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
165 |
| "nullable (ALT r1 r2) = (nullable r1 \<or> nullable r2)" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
166 |
| "nullable (SEQ r1 r2) = (nullable r1 \<and> nullable r2)" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
167 |
| "nullable (STAR r) = True" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
168 |
| "nullable (NOT r) = (\<not>(nullable r))" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
169 |
| "nullable (PLUS r) = (nullable r)" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
170 |
| "nullable (OPT r) = True" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
171 |
| "nullable (NTIMES r n) = (if n = 0 then True else nullable r)" |
362
57ea439feaff
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
361
diff
changeset
|
172 |
| "nullable (NMTIMES r n m) = (if m < n then False else (if n = 0 then True else nullable r))" |
455
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
173 |
| "nullable (UPNTIMES r n) = True" |
361
9c7eb266594c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
355
diff
changeset
|
174 |
|
397
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
175 |
fun M :: "rexp \<Rightarrow> nat" |
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
176 |
where |
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
177 |
"M (NULL) = 0" |
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
178 |
| "M (EMPTY) = 0" |
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
179 |
| "M (CHAR char) = 0" |
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
180 |
| "M (SEQ r1 r2) = Suc ((M r1) + (M r2))" |
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
181 |
| "M (ALT r1 r2) = Suc ((M r1) + (M r2))" |
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
182 |
| "M (STAR r) = Suc (M r)" |
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
183 |
| "M (NOT r) = Suc (M r)" |
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
184 |
| "M (PLUS r) = Suc (M r)" |
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
185 |
| "M (OPT r) = Suc (M r)" |
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
186 |
| "M (NTIMES r n) = Suc (M r) * 2 * (Suc n)" |
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
187 |
| "M (NMTIMES r n m) = Suc (Suc (M r)) * 2 * (Suc m) * (Suc (Suc m) - Suc n)" |
455
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
188 |
| "M (UPNTIMES r n) = Suc (M r) * 2 * (Suc n)" |
397
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
189 |
|
361
9c7eb266594c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
355
diff
changeset
|
190 |
function der :: "char \<Rightarrow> rexp \<Rightarrow> rexp" |
191
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
191 |
where |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
192 |
"der c (NULL) = NULL" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
193 |
| "der c (EMPTY) = NULL" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
194 |
| "der c (CHAR d) = (if c = d then EMPTY else NULL)" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
195 |
| "der c (ALT r1 r2) = ALT (der c r1) (der c r2)" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
196 |
| "der c (SEQ r1 r2) = ALT (SEQ (der c r1) r2) (if nullable r1 then der c r2 else NULL)" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
197 |
| "der c (STAR r) = SEQ (der c r) (STAR r)" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
198 |
| "der c (NOT r) = NOT(der c r)" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
199 |
| "der c (PLUS r) = SEQ (der c r) (STAR r)" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
200 |
| "der c (OPT r) = der c r" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
201 |
| "der c (NTIMES r 0) = NULL" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
202 |
| "der c (NTIMES r (Suc n)) = der c (SEQ r (NTIMES r n))" |
363
0d6deecdb2eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
362
diff
changeset
|
203 |
| "der c (NMTIMES r n m) = |
397
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
204 |
(if m < n then NULL else |
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
205 |
(if n = m then der c (NTIMES r n) else |
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
206 |
ALT (der c (NTIMES r n)) (der c (NMTIMES r (Suc n) m))))" |
455
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
207 |
| "der c (UPNTIMES r 0) = NULL" |
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
208 |
| "der c (UPNTIMES r (Suc n)) = der c (ALT (NTIMES r (Suc n)) (UPNTIMES r n))" |
397
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
209 |
by pat_completeness auto |
363
0d6deecdb2eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
362
diff
changeset
|
210 |
|
397
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
211 |
lemma bigger1: |
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
212 |
"\<lbrakk>c < (d::nat); a < b; 0 < a; 0 < c\<rbrakk> \<Longrightarrow> c * a < d * b" |
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
213 |
by (metis le0 mult_strict_mono') |
191
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
214 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
215 |
termination der |
361
9c7eb266594c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
355
diff
changeset
|
216 |
apply(relation "measure (\<lambda>(c, r). M r)") |
397
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
217 |
apply(simp) |
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
218 |
apply(simp) |
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
219 |
apply(simp) |
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
220 |
apply(simp) |
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
221 |
apply(simp) |
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
222 |
apply(simp) |
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
223 |
apply(simp) |
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
224 |
apply(simp) |
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
225 |
apply(simp) |
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
226 |
apply(simp) |
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
227 |
apply(simp) |
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
228 |
apply(simp_all del: M.simps) |
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
229 |
apply(simp_all only: M.simps) |
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
230 |
defer |
455
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
231 |
defer |
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
232 |
defer |
397
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
233 |
apply(subgoal_tac "Suc (Suc m) - Suc (Suc n) < Suc (Suc m) - Suc n") |
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
234 |
prefer 2 |
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
235 |
apply(auto)[1] |
455
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
236 |
(* |
397
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
237 |
apply (metis Suc_mult_less_cancel1 mult.assoc numeral_eq_Suc) |
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
238 |
apply(subgoal_tac "0 < (Suc (Suc m) - Suc n)") |
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
239 |
prefer 2 |
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
240 |
apply(auto)[1] |
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
241 |
apply(subgoal_tac "Suc n < Suc m") |
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
242 |
prefer 2 |
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
243 |
apply(auto)[1] |
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
244 |
apply(subgoal_tac "Suc (M r) * 2 * Suc n < Suc (Suc (M r)) * 2 * Suc m") |
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
245 |
prefer 2 |
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
246 |
apply(subgoal_tac "Suc (M r) * 2 < Suc (Suc (M r)) * 2") |
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
247 |
prefer 2 |
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
248 |
apply(auto)[1] |
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
249 |
apply(rule bigger1) |
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
250 |
apply(assumption) |
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
251 |
apply(simp) |
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
252 |
apply (metis zero_less_Suc) |
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
253 |
apply (metis mult_is_0 neq0_conv old.nat.distinct(2)) |
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
254 |
apply(rotate_tac 4) |
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
255 |
apply(drule_tac a="1" and b="(Suc (Suc m) - Suc n)" in bigger1) |
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
256 |
prefer 4 |
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
257 |
apply(simp) |
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
258 |
apply(simp) |
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
259 |
apply (metis zero_less_one) |
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
260 |
apply(simp) |
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
261 |
done |
455
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
262 |
*) |
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
263 |
sorry |
191
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
264 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
265 |
fun |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
266 |
ders :: "string \<Rightarrow> rexp \<Rightarrow> rexp" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
267 |
where |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
268 |
"ders [] r = r" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
269 |
| "ders (c # s) r = ders s (der c r)" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
270 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
271 |
fun |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
272 |
matcher :: "rexp \<Rightarrow> string \<Rightarrow> bool" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
273 |
where |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
274 |
"matcher r s = nullable (ders s r)" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
275 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
276 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
277 |
section {* Correctness Proof of the Matcher *} |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
278 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
279 |
lemma nullable_correctness: |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
280 |
shows "nullable r \<longleftrightarrow> [] \<in> (L r)" |
355
a259eec25156
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
281 |
apply(induct r) |
a259eec25156
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
282 |
apply(auto simp add: Seq_def) |
a259eec25156
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
283 |
done |
191
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
284 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
285 |
section {* Left-Quotient of a Set *} |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
286 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
287 |
definition |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
288 |
Der :: "char \<Rightarrow> string set \<Rightarrow> string set" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
289 |
where |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
290 |
"Der c A \<equiv> {s. [c] @ s \<in> A}" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
291 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
292 |
lemma Der_null [simp]: |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
293 |
shows "Der c {} = {}" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
294 |
unfolding Der_def |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
295 |
by auto |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
296 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
297 |
lemma Der_empty [simp]: |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
298 |
shows "Der c {[]} = {}" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
299 |
unfolding Der_def |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
300 |
by auto |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
301 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
302 |
lemma Der_char [simp]: |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
303 |
shows "Der c {[d]} = (if c = d then {[]} else {})" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
304 |
unfolding Der_def |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
305 |
by auto |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
306 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
307 |
lemma Der_union [simp]: |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
308 |
shows "Der c (A \<union> B) = Der c A \<union> Der c B" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
309 |
unfolding Der_def |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
310 |
by auto |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
311 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
312 |
lemma Der_insert_nil [simp]: |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
313 |
shows "Der c (insert [] A) = Der c A" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
314 |
unfolding Der_def |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
315 |
by auto |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
316 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
317 |
lemma Der_seq [simp]: |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
318 |
shows "Der c (A ;; B) = (Der c A) ;; B \<union> (if [] \<in> A then Der c B else {})" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
319 |
unfolding Der_def Seq_def |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
320 |
by (auto simp add: Cons_eq_append_conv) |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
321 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
322 |
lemma Der_star [simp]: |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
323 |
shows "Der c (A\<star>) = (Der c A) ;; A\<star>" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
324 |
proof - |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
325 |
have "Der c (A\<star>) = Der c ({[]} \<union> A ;; A\<star>)" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
326 |
by (simp only: star_cases[symmetric]) |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
327 |
also have "... = Der c (A ;; A\<star>)" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
328 |
by (simp only: Der_union Der_empty) (simp) |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
329 |
also have "... = (Der c A) ;; A\<star> \<union> (if [] \<in> A then Der c (A\<star>) else {})" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
330 |
by simp |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
331 |
also have "... = (Der c A) ;; A\<star>" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
332 |
unfolding Seq_def Der_def |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
333 |
by (auto dest: star_decomp) |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
334 |
finally show "Der c (A\<star>) = (Der c A) ;; A\<star>" . |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
335 |
qed |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
336 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
337 |
lemma Der_UNIV [simp]: |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
338 |
"Der c (UNIV - A) = UNIV - Der c A" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
339 |
unfolding Der_def |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
340 |
by (auto) |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
341 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
342 |
lemma Der_pow [simp]: |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
343 |
shows "Der c (A \<up> (Suc n)) = (Der c A) ;; (A \<up> n) \<union> (if [] \<in> A then Der c (A \<up> n) else {})" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
344 |
unfolding Der_def |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
345 |
by(auto simp add: Cons_eq_append_conv Seq_def) |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
346 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
347 |
lemma Der_UNION [simp]: |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
348 |
shows "Der c (\<Union>x\<in>A. B x) = (\<Union>x\<in>A. Der c (B x))" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
349 |
by (auto simp add: Der_def) |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
350 |
|
363
0d6deecdb2eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
362
diff
changeset
|
351 |
lemma der_correctness: |
0d6deecdb2eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
362
diff
changeset
|
352 |
shows "L (der c r) = Der c (L r)" |
0d6deecdb2eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
362
diff
changeset
|
353 |
apply(induct rule: der.induct) |
0d6deecdb2eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
362
diff
changeset
|
354 |
apply(simp_all add: nullable_correctness |
0d6deecdb2eb
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
362
diff
changeset
|
355 |
Suc_Union Suc_reduce_Union seq_Union atLeast0AtMost) |
397
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
356 |
apply(rule impI)+ |
cf3ca219c727
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
385
diff
changeset
|
357 |
apply(subgoal_tac "{n..m} = {n} \<union> {Suc n..m}") |
455
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
358 |
apply(auto simp add: Seq_def) |
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
359 |
done |
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
360 |
|
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
361 |
lemma L_der_NTIMES: |
456
2fddf8ab744f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
455
diff
changeset
|
362 |
shows "L(der c (NTIMES r n)) = L (if n = 0 then NULL else if nullable r then |
2fddf8ab744f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
455
diff
changeset
|
363 |
SEQ (der c r) (UPNTIMES r (n - 1)) else SEQ (der c r) (NTIMES r (n - 1)))" |
455
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
364 |
apply(induct n) |
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
365 |
apply(simp) |
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
366 |
apply(simp) |
355
a259eec25156
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
367 |
apply(auto) |
455
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
368 |
apply(auto simp add: Seq_def) |
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
369 |
apply(rule_tac x="s1" in exI) |
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
370 |
apply(simp) |
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
371 |
apply(rule_tac x="xa" in bexI) |
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
372 |
apply(simp) |
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
373 |
apply(simp) |
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
374 |
apply(rule_tac x="s1" in exI) |
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
375 |
apply(simp) |
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
376 |
by (metis Suc_pred atMost_iff le_Suc_eq) |
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
377 |
|
456
2fddf8ab744f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
455
diff
changeset
|
378 |
lemma "L(der c (UPNTIMES r 0)) = {}" |
2fddf8ab744f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
455
diff
changeset
|
379 |
by simp |
2fddf8ab744f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
455
diff
changeset
|
380 |
|
455
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
381 |
lemma "L(der c (UPNTIMES r (Suc n))) = L(SEQ (der c r) (UPNTIMES r n))" |
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
382 |
using assms |
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
383 |
proof(induct n) |
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
384 |
case 0 show ?case by simp |
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
385 |
next |
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
386 |
case (Suc n) |
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
387 |
have IH: "L (der c (UPNTIMES r (Suc n))) = L (SEQ (der c r) (UPNTIMES r n))" by fact |
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
388 |
{ assume a: "nullable r" |
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
389 |
have "L (der c (UPNTIMES r (Suc (Suc n)))) = Der c (L (UPNTIMES r (Suc (Suc n))))" |
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
390 |
by (simp only: der_correctness) |
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
391 |
also have "... = Der c (L (ALT (NTIMES r (Suc (Suc n))) (UPNTIMES r (Suc n))))" |
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
392 |
by(simp only: L.simps Suc_Union) |
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
393 |
also have "... = L (der c (ALT (NTIMES r (Suc (Suc n))) (UPNTIMES r (Suc n))))" |
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
394 |
by (simp only: der_correctness) |
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
395 |
also have "... = L (der c (NTIMES r (Suc (Suc n)))) \<union> L (der c (UPNTIMES r (Suc n)))" |
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
396 |
by(auto simp add: Seq_def) |
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
397 |
also have "... = L (der c (NTIMES r (Suc (Suc n)))) \<union> L (SEQ (der c r) (UPNTIMES r n))" |
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
398 |
using IH by simp |
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
399 |
also have "... = L (SEQ (der c r) (UPNTIMES r (Suc n))) \<union> L (SEQ (der c r) (UPNTIMES r n))" |
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
400 |
using a unfolding L_der_NTIMES by simp |
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
401 |
also have "... = L (SEQ (der c r) (UPNTIMES r (Suc n)))" |
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
402 |
by (auto, metis Suc_Union Un_iff seq_Union) |
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
403 |
finally have "L (der c (UPNTIMES r (Suc (Suc n)))) = L (SEQ (der c r) (UPNTIMES r (Suc n)))" . |
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
404 |
} |
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
405 |
moreover |
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
406 |
{ assume a: "\<not>nullable r" |
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
407 |
have "L (der c (UPNTIMES r (Suc (Suc n)))) = Der c (L (UPNTIMES r (Suc (Suc n))))" |
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
408 |
by (simp only: der_correctness) |
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
409 |
also have "... = Der c (L (ALT (NTIMES r (Suc (Suc n))) (UPNTIMES r (Suc n))))" |
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
410 |
by(simp only: L.simps Suc_Union) |
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
411 |
also have "... = L (der c (ALT (NTIMES r (Suc (Suc n))) (UPNTIMES r (Suc n))))" |
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
412 |
by (simp only: der_correctness) |
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
413 |
also have "... = L (der c (NTIMES r (Suc (Suc n)))) \<union> L (der c (UPNTIMES r (Suc n)))" |
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
414 |
by(auto simp add: Seq_def) |
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
415 |
also have "... = L (der c (NTIMES r (Suc (Suc n)))) \<union> L (SEQ (der c r) (UPNTIMES r n))" |
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
416 |
using IH by simp |
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
417 |
also have "... = L (SEQ (der c r) (NTIMES r (Suc n))) \<union> L (SEQ (der c r) (UPNTIMES r n))" |
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
418 |
using a unfolding L_der_NTIMES by simp |
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
419 |
also have "... = L (SEQ (der c r) (UPNTIMES r (Suc n)))" |
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
420 |
by (simp add: Suc_Union seq_union(1)) |
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
421 |
finally have "L (der c (UPNTIMES r (Suc (Suc n)))) = L (SEQ (der c r) (UPNTIMES r (Suc n)))" . |
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
422 |
} |
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
423 |
ultimately |
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
424 |
show "L (der c (UPNTIMES r (Suc (Suc n)))) = L (SEQ (der c r) (UPNTIMES r (Suc n)))" |
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
425 |
by blast |
1dbf84ade62c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
397
diff
changeset
|
426 |
qed |
191
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
427 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
428 |
lemma matcher_correctness: |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
429 |
shows "matcher r s \<longleftrightarrow> s \<in> L r" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
430 |
by (induct s arbitrary: r) |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
431 |
(simp_all add: nullable_correctness der_correctness Der_def) |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
432 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
433 |
end |