author | urbanc |
Sat, 19 Feb 2011 22:05:22 +0000 | |
changeset 122 | ab6637008963 |
parent 5 | 074d9a4b2bc9 |
child 162 | e93760534354 |
permissions | -rw-r--r-- |
5
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
1 |
theory "RegSet" |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
2 |
imports "Main" |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
3 |
begin |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
4 |
|
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
5 |
|
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
6 |
text {* Sequential composition of sets *} |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
7 |
|
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
8 |
definition |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
9 |
lang_seq :: "string set \<Rightarrow> string set \<Rightarrow> string set" ("_ ; _" [100,100] 100) |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
10 |
where |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
11 |
"L1 ; L2 = {s1@s2 | s1 s2. s1 \<in> L1 \<and> s2 \<in> L2}" |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
12 |
|
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
13 |
|
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
14 |
section {* Kleene star for sets *} |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
15 |
|
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
16 |
inductive_set |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
17 |
Star :: "string set \<Rightarrow> string set" ("_\<star>" [101] 102) |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
18 |
for L :: "string set" |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
19 |
where |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
20 |
start[intro]: "[] \<in> L\<star>" |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
21 |
| step[intro]: "\<lbrakk>s1 \<in> L; s2 \<in> L\<star>\<rbrakk> \<Longrightarrow> s1 @ s2 \<in> L\<star>" |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
22 |
|
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
23 |
|
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
24 |
text {* A standard property of star *} |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
25 |
|
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
26 |
lemma lang_star_cases: |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
27 |
shows "L\<star> = {[]} \<union> L ; L\<star>" |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
28 |
proof |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
29 |
{ fix x |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
30 |
have "x \<in> L\<star> \<Longrightarrow> x \<in> {[]} \<union> L ; L\<star>" |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
31 |
unfolding lang_seq_def |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
32 |
by (induct rule: Star.induct) (auto) |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
33 |
} |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
34 |
then show "L\<star> \<subseteq> {[]} \<union> L ; L\<star>" by auto |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
35 |
next |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
36 |
show "{[]} \<union> L ; L\<star> \<subseteq> L\<star>" |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
37 |
unfolding lang_seq_def by auto |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
38 |
qed |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
39 |
|
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
40 |
|
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
41 |
lemma lang_star_cases2: |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
42 |
shows "[] \<notin> L \<Longrightarrow> L\<star> - {[]} = L ; L\<star>" |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
43 |
by (subst lang_star_cases) |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
44 |
(simp add: lang_seq_def) |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
45 |
|
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
46 |
|
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
47 |
section {* Regular Expressions *} |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
48 |
|
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
49 |
datatype rexp = |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
50 |
NULL |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
51 |
| EMPTY |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
52 |
| CHAR char |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
53 |
| SEQ rexp rexp |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
54 |
| ALT rexp rexp |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
55 |
| STAR rexp |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
56 |
|
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
57 |
|
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
58 |
section {* Semantics of Regular Expressions *} |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
59 |
|
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
60 |
fun |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
61 |
L :: "rexp \<Rightarrow> string set" |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
62 |
where |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
63 |
"L (NULL) = {}" |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
64 |
| "L (EMPTY) = {[]}" |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
65 |
| "L (CHAR c) = {[c]}" |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
66 |
| "L (SEQ r1 r2) = (L r1) ; (L r2)" |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
67 |
| "L (ALT r1 r2) = (L r1) \<union> (L r2)" |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
68 |
| "L (STAR r) = (L r)\<star>" |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
69 |
|
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
70 |
abbreviation |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
71 |
CUNIV :: "string set" |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
72 |
where |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
73 |
"CUNIV \<equiv> (\<lambda>x. [x]) ` (UNIV::char set)" |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
74 |
|
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
75 |
lemma CUNIV_star_minus: |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
76 |
"(CUNIV\<star> - {[c]}) = {[]} \<union> (CUNIV - {[c]}; (CUNIV\<star>))" |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
77 |
apply(subst lang_star_cases) |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
78 |
apply(simp add: lang_seq_def) |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
79 |
oops |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
80 |
|
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
81 |
|
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
82 |
lemma string_in_CUNIV: |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
83 |
shows "s \<in> CUNIV\<star>" |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
84 |
proof (induct s) |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
85 |
case Nil |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
86 |
show "[] \<in> CUNIV\<star>" by (rule start) |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
87 |
next |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
88 |
case (Cons c s) |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
89 |
have "[c] \<in> CUNIV" by simp |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
90 |
moreover |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
91 |
have "s \<in> CUNIV\<star>" by fact |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
92 |
ultimately have "[c] @ s \<in> CUNIV\<star>" by (rule step) |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
93 |
then show "c # s \<in> CUNIV\<star>" by simp |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
94 |
qed |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
95 |
|
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
96 |
lemma UNIV_CUNIV_star: |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
97 |
shows "UNIV = CUNIV\<star>" |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
98 |
using string_in_CUNIV |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
99 |
by (auto) |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
100 |
|
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
101 |
abbreviation |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
102 |
reg :: "string set => bool" |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
103 |
where |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
104 |
"reg L1 \<equiv> (\<exists>r. L r = L1)" |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
105 |
|
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
106 |
lemma reg_null [intro]: |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
107 |
shows "reg {}" |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
108 |
by (metis L.simps(1)) |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
109 |
|
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
110 |
lemma reg_empty [intro]: |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
111 |
shows "reg {[]}" |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
112 |
by (metis L.simps(2)) |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
113 |
|
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
114 |
lemma reg_star [intro]: |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
115 |
shows "reg L1 \<Longrightarrow> reg (L1\<star>)" |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
116 |
by (metis L.simps(6)) |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
117 |
|
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
118 |
lemma reg_seq [intro]: |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
119 |
assumes a: "reg L1" "reg L2" |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
120 |
shows "reg (L1 ; L2)" |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
121 |
using a |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
122 |
by (metis L.simps(4)) |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
123 |
|
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
124 |
lemma reg_union [intro]: |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
125 |
assumes a: "reg L1" "reg L2" |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
126 |
shows "reg (L1 \<union> L2)" |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
127 |
using a |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
128 |
by (metis L.simps(5)) |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
129 |
|
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
130 |
lemma reg_string [intro]: |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
131 |
fixes s::string |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
132 |
shows "reg {s}" |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
133 |
proof (induct s) |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
134 |
case Nil |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
135 |
show "reg {[]}" by (rule reg_empty) |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
136 |
next |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
137 |
case (Cons c s) |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
138 |
have "reg {s}" by fact |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
139 |
then obtain r where "L r = {s}" by auto |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
140 |
then have "L (SEQ (CHAR c) r) = {[c]} ; {s}" by simp |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
141 |
also have "\<dots> = {c # s}" by (simp add: lang_seq_def) |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
142 |
finally show "reg {c # s}" by blast |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
143 |
qed |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
144 |
|
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
145 |
lemma reg_finite [intro]: |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
146 |
assumes a: "finite L1" |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
147 |
shows "reg L1" |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
148 |
using a |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
149 |
proof(induct) |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
150 |
case empty |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
151 |
show "reg {}" by (rule reg_null) |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
152 |
next |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
153 |
case (insert s S) |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
154 |
have "reg {s}" by (rule reg_string) |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
155 |
moreover |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
156 |
have "reg S" by fact |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
157 |
ultimately have "reg ({s} \<union> S)" by (rule reg_union) |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
158 |
then show "reg (insert s S)" by simp |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
159 |
qed |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
160 |
|
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
161 |
lemma reg_cuniv [intro]: |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
162 |
shows "reg (CUNIV)" |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
163 |
by (rule reg_finite) (auto) |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
164 |
|
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
165 |
lemma reg_univ: |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
166 |
shows "reg (UNIV::string set)" |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
167 |
proof - |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
168 |
have "reg CUNIV" by (rule reg_cuniv) |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
169 |
then have "reg (CUNIV\<star>)" by (rule reg_star) |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
170 |
then show "reg UNIV" by (simp add: UNIV_CUNIV_star) |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
171 |
qed |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
172 |
|
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
173 |
lemma reg_finite_subset: |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
174 |
assumes a: "finite L1" |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
175 |
and b: "reg L1" "L2 \<subseteq> L1" |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
176 |
shows "reg L2" |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
177 |
using a b |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
178 |
apply(induct arbitrary: L2) |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
179 |
apply(simp add: reg_empty) |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
180 |
oops |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
181 |
|
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
182 |
|
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
183 |
lemma reg_not: |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
184 |
shows "reg (UNIV - L r)" |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
185 |
proof (induct r) |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
186 |
case NULL |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
187 |
have "reg UNIV" by (rule reg_univ) |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
188 |
then show "reg (UNIV - L NULL)" by simp |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
189 |
next |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
190 |
case EMPTY |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
191 |
have "[] \<notin> CUNIV" by auto |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
192 |
moreover |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
193 |
have "reg (CUNIV; CUNIV\<star>)" by auto |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
194 |
ultimately have "reg (CUNIV\<star> - {[]})" |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
195 |
using lang_star_cases2 by simp |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
196 |
then show "reg (UNIV - L EMPTY)" by (simp add: UNIV_CUNIV_star) |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
197 |
next |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
198 |
case (CHAR c) |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
199 |
then show "?case" |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
200 |
apply(simp) |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
201 |
|
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
202 |
using reg_UNIV |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
203 |
apply(simp) |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
204 |
apply(simp add: char_star2[symmetric]) |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
205 |
apply(rule reg_seq) |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
206 |
apply(rule reg_cuniv) |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
207 |
apply(rule reg_star) |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
208 |
apply(rule reg_cuniv) |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
209 |
oops |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
210 |
|
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
211 |
|
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
212 |
|
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
213 |
end |
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
214 |
|
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
215 |
|
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
216 |
|
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
217 |
|
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
218 |
|
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
219 |
|
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
220 |
|
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
221 |
|
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
222 |
|
074d9a4b2bc9
added a file about the easy closure properties of regular sets (the difficult parts, like complement, are missing)
urbanc
parents:
diff
changeset
|
223 |