author | Christian Urban <christian dot urban at kcl dot ac dot uk> |
Fri, 16 Oct 2015 14:27:20 +0100 | |
changeset 354 | 86b2aeae3e98 |
parent 272 | 1446bc47a294 |
child 355 | a259eec25156 |
permissions | -rw-r--r-- |
191
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1 |
theory Matcher2 |
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 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
5 |
section {* Regular Expressions *} |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
6 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
7 |
datatype rexp = |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
8 |
NULL |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
9 |
| EMPTY |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
10 |
| CHAR char |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
11 |
| SEQ rexp rexp |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
12 |
| ALT rexp rexp |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
13 |
| STAR rexp |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
14 |
| NOT rexp |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
15 |
| PLUS rexp |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
16 |
| OPT rexp |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
17 |
| NTIMES rexp nat |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
18 |
| NMTIMES rexp nat nat |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
19 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
20 |
fun M :: "rexp \<Rightarrow> nat" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
21 |
where |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
22 |
"M (NULL) = 0" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
23 |
| "M (EMPTY) = 0" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
24 |
| "M (CHAR char) = 0" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
25 |
| "M (SEQ r1 r2) = Suc ((M r1) + (M r2))" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
26 |
| "M (ALT r1 r2) = Suc ((M r1) + (M r2))" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
27 |
| "M (STAR r) = Suc (M r)" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
28 |
| "M (NOT r) = Suc (M r)" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
29 |
| "M (PLUS r) = Suc (M r)" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
30 |
| "M (OPT r) = Suc (M r)" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
31 |
| "M (NTIMES r n) = Suc (M r) * 2 * (Suc n)" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
32 |
| "M (NMTIMES r n m) = Suc (M r) * 2 * (Suc n + Suc m)" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
33 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
34 |
section {* Sequential Composition of Sets *} |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
35 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
36 |
definition |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
37 |
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
|
38 |
where |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
39 |
"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
|
40 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
41 |
text {* Two Simple Properties about Sequential Composition *} |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
42 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
43 |
lemma seq_empty [simp]: |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
44 |
shows "A ;; {[]} = A" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
45 |
and "{[]} ;; A = A" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
46 |
by (simp_all add: Seq_def) |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
47 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
48 |
lemma seq_null [simp]: |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
49 |
shows "A ;; {} = {}" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
50 |
and "{} ;; A = {}" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
51 |
by (simp_all add: Seq_def) |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
52 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
53 |
lemma seq_union: |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
54 |
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
|
55 |
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
|
56 |
by (auto simp add: Seq_def) |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
57 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
58 |
lemma seq_Union: |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
59 |
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
|
60 |
by (auto simp add: Seq_def) |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
61 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
62 |
lemma seq_empty_in [simp]: |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
63 |
"[] \<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
|
64 |
by (simp add: Seq_def) |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
65 |
|
194
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
66 |
lemma seq_assoc: |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
67 |
shows "A ;; (B ;; C) = (A ;; B) ;; C" |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
68 |
apply(auto simp add: Seq_def) |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
69 |
apply(metis append_assoc) |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
70 |
apply(metis) |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
71 |
done |
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 |
|
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
74 |
section {* Power for Sets *} |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
75 |
|
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
76 |
fun |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
77 |
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
|
78 |
where |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
79 |
"A \<up> 0 = {[]}" |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
80 |
| "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
|
81 |
|
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
82 |
lemma pow_empty [simp]: |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
83 |
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
|
84 |
by (induct n) (auto) |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
85 |
|
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
86 |
lemma pow_plus: |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
87 |
"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
|
88 |
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
|
89 |
|
191
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
90 |
section {* Kleene Star for Sets *} |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
91 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
92 |
inductive_set |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
93 |
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
|
94 |
for A :: "string set" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
95 |
where |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
96 |
start[intro]: "[] \<in> A\<star>" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
97 |
| 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
|
98 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
99 |
text {* A Standard Property of Star *} |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
100 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
101 |
lemma star_decomp: |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
102 |
assumes a: "c # x \<in> A\<star>" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
103 |
shows "\<exists>a b. x = a @ b \<and> c # a \<in> A \<and> b \<in> A\<star>" |
194
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
104 |
using a |
191
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
105 |
using a |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
106 |
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
|
107 |
(auto simp add: append_eq_Cons_conv) |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
108 |
|
194
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
109 |
lemma star_cases: |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
110 |
shows "A\<star> = {[]} \<union> A ;; A\<star>" |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
111 |
unfolding Seq_def |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
112 |
by (auto) (metis Star.simps) |
191
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
113 |
|
194
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
114 |
lemma Star_in_Pow: |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
115 |
assumes a: "s \<in> A\<star>" |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
116 |
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
|
117 |
using a |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
118 |
apply(induct) |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
119 |
apply(auto) |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
120 |
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
|
121 |
apply(auto simp add: Seq_def) |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
122 |
done |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
123 |
|
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
124 |
lemma Pow_in_Star: |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
125 |
assumes a: "s \<in> A \<up> n" |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
126 |
shows "s \<in> A\<star>" |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
127 |
using a |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
128 |
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
|
129 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
130 |
|
194
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
131 |
lemma Star_def2: |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
132 |
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
|
133 |
using Star_in_Pow Pow_in_Star |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
134 |
by (auto) |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
193
diff
changeset
|
135 |
|
191
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 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
138 |
section {* Semantics of Regular Expressions *} |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
139 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
140 |
fun |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
141 |
L :: "rexp \<Rightarrow> string set" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
142 |
where |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
143 |
"L (NULL) = {}" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
144 |
| "L (EMPTY) = {[]}" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
145 |
| "L (CHAR c) = {[c]}" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
146 |
| "L (SEQ r1 r2) = (L r1) ;; (L r2)" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
147 |
| "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
|
148 |
| "L (STAR r) = (L r)\<star>" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
149 |
| "L (NOT r) = UNIV - (L r)" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
150 |
| "L (PLUS r) = (L r) ;; ((L r)\<star>)" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
151 |
| "L (OPT r) = (L r) \<union> {[]}" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
152 |
| "L (NTIMES r n) = (L r) \<up> n" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
153 |
| "L (NMTIMES r n m) = (\<Union>i\<in> {n..n+m} . ((L r) \<up> i))" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
154 |
|
227
93bd75031ced
added handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
198
diff
changeset
|
155 |
lemma "L (NOT NULL) = UNIV" |
93bd75031ced
added handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
198
diff
changeset
|
156 |
apply(simp) |
93bd75031ced
added handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
198
diff
changeset
|
157 |
done |
93bd75031ced
added handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
198
diff
changeset
|
158 |
|
191
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
159 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
160 |
section {* The Matcher *} |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
161 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
162 |
fun |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
163 |
nullable :: "rexp \<Rightarrow> bool" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
164 |
where |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
165 |
"nullable (NULL) = False" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
166 |
| "nullable (EMPTY) = True" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
167 |
| "nullable (CHAR c) = False" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
168 |
| "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
|
169 |
| "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
|
170 |
| "nullable (STAR r) = True" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
171 |
| "nullable (NOT r) = (\<not>(nullable r))" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
172 |
| "nullable (PLUS r) = (nullable r)" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
173 |
| "nullable (OPT r) = True" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
174 |
| "nullable (NTIMES r n) = (if n = 0 then True else nullable r)" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
175 |
| "nullable (NMTIMES r n m) = (if n = 0 then True else nullable r)" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
176 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
177 |
function |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
178 |
der :: "char \<Rightarrow> rexp \<Rightarrow> rexp" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
179 |
where |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
180 |
"der c (NULL) = NULL" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
181 |
| "der c (EMPTY) = NULL" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
182 |
| "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
|
183 |
| "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
|
184 |
| "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
|
185 |
| "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
|
186 |
| "der c (NOT r) = NOT(der c r)" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
187 |
| "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
|
188 |
| "der c (OPT r) = der c r" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
189 |
| "der c (NTIMES r 0) = NULL" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
190 |
| "der c (NTIMES r (Suc n)) = der c (SEQ r (NTIMES r n))" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
191 |
| "der c (NMTIMES r 0 0) = NULL" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
192 |
| "der c (NMTIMES r 0 (Suc m)) = ALT (der c (NTIMES r (Suc m))) (der c (NMTIMES r 0 m))" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
193 |
| "der c (NMTIMES r (Suc n) m) = der c (SEQ r (NMTIMES r n m))" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
194 |
by pat_completeness auto |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
195 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
196 |
termination der |
193
6518475020fc
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
191
diff
changeset
|
197 |
by (relation "measure (\<lambda>(c, r). M r)") (simp_all) |
6518475020fc
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
191
diff
changeset
|
198 |
|
191
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
199 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
200 |
fun |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
201 |
ders :: "string \<Rightarrow> rexp \<Rightarrow> rexp" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
202 |
where |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
203 |
"ders [] r = r" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
204 |
| "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
|
205 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
206 |
fun |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
207 |
matcher :: "rexp \<Rightarrow> string \<Rightarrow> bool" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
208 |
where |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
209 |
"matcher r s = nullable (ders s r)" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
210 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
211 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
212 |
section {* Correctness Proof of the Matcher *} |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
213 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
214 |
lemma nullable_correctness: |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
215 |
shows "nullable r \<longleftrightarrow> [] \<in> (L r)" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
216 |
by(induct r) (auto simp add: Seq_def) |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
217 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
218 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
219 |
section {* Left-Quotient of a Set *} |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
220 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
221 |
definition |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
222 |
Der :: "char \<Rightarrow> string set \<Rightarrow> string set" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
223 |
where |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
224 |
"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
|
225 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
226 |
lemma Der_null [simp]: |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
227 |
shows "Der c {} = {}" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
228 |
unfolding Der_def |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
229 |
by auto |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
230 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
231 |
lemma Der_empty [simp]: |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
232 |
shows "Der c {[]} = {}" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
233 |
unfolding Der_def |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
234 |
by auto |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
235 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
236 |
lemma Der_char [simp]: |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
237 |
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
|
238 |
unfolding Der_def |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
239 |
by auto |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
240 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
241 |
lemma Der_union [simp]: |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
242 |
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
|
243 |
unfolding Der_def |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
244 |
by auto |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
245 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
246 |
lemma Der_insert_nil [simp]: |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
247 |
shows "Der c (insert [] A) = Der c A" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
248 |
unfolding Der_def |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
249 |
by auto |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
250 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
251 |
lemma Der_seq [simp]: |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
252 |
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
|
253 |
unfolding Der_def Seq_def |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
254 |
by (auto simp add: Cons_eq_append_conv) |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
255 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
256 |
lemma Der_star [simp]: |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
257 |
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
|
258 |
proof - |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
259 |
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
|
260 |
by (simp only: star_cases[symmetric]) |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
261 |
also have "... = Der c (A ;; A\<star>)" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
262 |
by (simp only: Der_union Der_empty) (simp) |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
263 |
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
|
264 |
by simp |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
265 |
also have "... = (Der c A) ;; A\<star>" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
266 |
unfolding Seq_def Der_def |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
267 |
by (auto dest: star_decomp) |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
268 |
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
|
269 |
qed |
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 |
lemma Der_UNIV [simp]: |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
272 |
"Der c (UNIV - A) = UNIV - Der c A" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
273 |
unfolding Der_def |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
274 |
by (auto) |
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 |
lemma Der_pow [simp]: |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
277 |
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
|
278 |
unfolding Der_def |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
279 |
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
|
280 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
281 |
lemma Der_UNION [simp]: |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
282 |
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
|
283 |
by (auto simp add: Der_def) |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
284 |
|
193
6518475020fc
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
191
diff
changeset
|
285 |
lemma Suc_Union: |
191
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
286 |
"(\<Union> x\<le>Suc m. B x) = (B (Suc m) \<union> (\<Union> x\<le>m. B x))" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
287 |
by (metis UN_insert atMost_Suc) |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
288 |
|
193
6518475020fc
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
191
diff
changeset
|
289 |
lemma Suc_reduce_Union: |
191
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
290 |
"(\<Union>x\<in>{Suc n..Suc m}. B x) = (\<Union>x\<in>{n..m}. B (Suc x))" |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
291 |
by (metis UN_extend_simps(10) image_Suc_atLeastAtMost) |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
292 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
293 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
294 |
lemma der_correctness: |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
295 |
shows "L (der c r) = Der c (L r)" |
193
6518475020fc
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
191
diff
changeset
|
296 |
by (induct rule: der.induct) |
6518475020fc
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
191
diff
changeset
|
297 |
(simp_all add: nullable_correctness |
6518475020fc
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
191
diff
changeset
|
298 |
Suc_Union Suc_reduce_Union seq_Union atLeast0AtMost) |
6518475020fc
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
191
diff
changeset
|
299 |
|
191
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
300 |
|
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
301 |
lemma matcher_correctness: |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
302 |
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
|
303 |
by (induct s arbitrary: r) |
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
304 |
(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
|
305 |
|
272
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
227
diff
changeset
|
306 |
|
191
ff6665581ced
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
307 |
end |