author | Christian Urban <urbanc@in.tum.de> |
Mon, 11 Feb 2019 14:36:23 +0000 | |
changeset 308 | 496a37d816e9 |
parent 295 | thys/Spec.thy@c6ec5f369037 |
child 309 | a7769a89c529 |
permissions | -rw-r--r-- |
266 | 1 |
|
308
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
2 |
theory PDerivs |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
3 |
imports Spec |
266 | 4 |
begin |
5 |
||
308
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
6 |
(* |
266 | 7 |
ZERO |
8 |
| ONE |
|
9 |
| CHAR char |
|
10 |
| SEQ rexp rexp |
|
11 |
| ALT rexp rexp |
|
12 |
| STAR rexp |
|
308
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
13 |
*) |
266 | 14 |
|
267 | 15 |
abbreviation |
308
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
16 |
"SEQs rs r \<equiv> (\<Union>r' \<in> rs. {SEQ r' r})" |
266 | 17 |
|
308
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
18 |
lemma Timess_eq_image: |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
19 |
"SEQs rs r = (\<lambda>r'. SEQ r' r) ` rs" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
20 |
by auto |
268 | 21 |
|
308
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
22 |
primrec |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
23 |
pder :: "char \<Rightarrow> rexp \<Rightarrow> rexp set" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
24 |
where |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
25 |
"pder c ZERO = {}" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
26 |
| "pder c ONE = {}" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
27 |
| "pder c (CHAR d) = (if c = d then {ONE} else {})" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
28 |
| "pder c (ALT r1 r2) = (pder c r1) \<union> (pder c r2)" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
29 |
| "pder c (SEQ r1 r2) = |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
30 |
(if nullable r1 then SEQs (pder c r1) r2 \<union> pder c r2 else SEQs (pder c r1) r2)" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
31 |
| "pder c (STAR r) = SEQs (pder c r) (STAR r)" |
266 | 32 |
|
308
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
33 |
primrec |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
34 |
pders :: "char list \<Rightarrow> rexp \<Rightarrow> rexp set" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
35 |
where |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
36 |
"pders [] r = {r}" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
37 |
| "pders (c # s) r = \<Union> (pders s ` pder c r)" |
267 | 38 |
|
39 |
abbreviation |
|
308
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
40 |
pder_set :: "char \<Rightarrow> rexp set \<Rightarrow> rexp set" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
41 |
where |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
42 |
"pder_set c rs \<equiv> \<Union> (pder c ` rs)" |
267 | 43 |
|
44 |
abbreviation |
|
308
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
45 |
pders_set :: "char list \<Rightarrow> rexp set \<Rightarrow> rexp set" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
46 |
where |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
47 |
"pders_set s rs \<equiv> \<Union> (pders s ` rs)" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
48 |
|
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
49 |
lemma pders_append: |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
50 |
"pders (s1 @ s2) r = \<Union> (pders s2 ` pders s1 r)" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
51 |
by (induct s1 arbitrary: r) (simp_all) |
266 | 52 |
|
308
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
53 |
lemma pders_snoc: |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
54 |
shows "pders (s @ [c]) r = pder_set c (pders s r)" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
55 |
by (simp add: pders_append) |
267 | 56 |
|
308
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
57 |
lemma pders_simps [simp]: |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
58 |
shows "pders s ZERO = (if s = [] then {ZERO} else {})" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
59 |
and "pders s ONE = (if s = [] then {ONE} else {})" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
60 |
and "pders s (ALT r1 r2) = (if s = [] then {ALT r1 r2} else (pders s r1) \<union> (pders s r2))" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
61 |
by (induct s) (simp_all) |
267 | 62 |
|
308
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
63 |
lemma pders_CHAR: |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
64 |
shows "pders s (CHAR c) \<subseteq> {CHAR c, ONE}" |
267 | 65 |
by (induct s) (simp_all) |
266 | 66 |
|
308
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
67 |
subsection \<open>Relating left-quotients and partial derivatives\<close> |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
68 |
|
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
69 |
lemma Sequ_UNION_distrib: |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
70 |
shows "A ;; \<Union>(M ` I) = \<Union>((%i. A ;; M i) ` I)" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
71 |
and "\<Union>(M ` I) ;; A = \<Union>((%i. M i ;; A) ` I)" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
72 |
by (auto simp add: Sequ_def) |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
73 |
|
267 | 74 |
|
308
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
75 |
lemma Der_pder: |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
76 |
shows "Der c (L r) = \<Union> (L ` pder c r)" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
77 |
by (induct r) (simp_all add: nullable_correctness Sequ_UNION_distrib) |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
78 |
|
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
79 |
lemma Ders_pders: |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
80 |
shows "Ders s (L r) = \<Union> (L ` pders s r)" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
81 |
proof (induct s arbitrary: r) |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
82 |
case (Cons c s) |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
83 |
have ih: "\<And>r. Ders s (L r) = \<Union> (L ` pders s r)" by fact |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
84 |
have "Ders (c # s) (L r) = Ders s (Der c (L r))" by (simp add: Ders_def Der_def) |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
85 |
also have "\<dots> = Ders s (\<Union> (L ` pder c r))" by (simp add: Der_pder) |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
86 |
also have "\<dots> = (\<Union>A\<in>(L ` (pder c r)). (Ders s A))" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
87 |
by (auto simp add: Ders_def) |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
88 |
also have "\<dots> = \<Union> (L ` (pders_set s (pder c r)))" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
89 |
using ih by auto |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
90 |
also have "\<dots> = \<Union> (L ` (pders (c # s) r))" by simp |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
91 |
finally show "Ders (c # s) (L r) = \<Union> (L ` pders (c # s) r)" . |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
92 |
qed (simp add: Ders_def) |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
93 |
|
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
94 |
subsection \<open>Relating derivatives and partial derivatives\<close> |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
95 |
|
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
96 |
lemma der_pder: |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
97 |
shows "\<Union> (L ` (pder c r)) = L (der c r)" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
98 |
unfolding der_correctness Der_pder by simp |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
99 |
|
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
100 |
lemma ders_pders: |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
101 |
shows "\<Union> (L ` (pders s r)) = L (ders s r)" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
102 |
unfolding der_correctness ders_correctness Ders_pders by simp |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
103 |
|
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
104 |
|
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
105 |
subsection \<open>Finiteness property of partial derivatives\<close> |
267 | 106 |
|
308
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
107 |
definition |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
108 |
pders_Set :: "string set \<Rightarrow> rexp \<Rightarrow> rexp set" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
109 |
where |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
110 |
"pders_Set A r \<equiv> \<Union>x \<in> A. pders x r" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
111 |
|
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
112 |
lemma pders_Set_subsetI: |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
113 |
assumes "\<And>s. s \<in> A \<Longrightarrow> pders s r \<subseteq> C" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
114 |
shows "pders_Set A r \<subseteq> C" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
115 |
using assms unfolding pders_Set_def by (rule UN_least) |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
116 |
|
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
117 |
lemma pders_Set_union: |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
118 |
shows "pders_Set (A \<union> B) r = (pders_Set A r \<union> pders_Set B r)" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
119 |
by (simp add: pders_Set_def) |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
120 |
|
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
121 |
lemma pders_Set_subset: |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
122 |
shows "A \<subseteq> B \<Longrightarrow> pders_Set A r \<subseteq> pders_Set B r" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
123 |
by (auto simp add: pders_Set_def) |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
124 |
|
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
125 |
definition |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
126 |
"UNIV1 \<equiv> UNIV - {[]}" |
267 | 127 |
|
308
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
128 |
lemma pders_Set_ZERO [simp]: |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
129 |
shows "pders_Set UNIV1 ZERO = {}" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
130 |
unfolding UNIV1_def pders_Set_def by auto |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
131 |
|
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
132 |
lemma pders_Set_ONE [simp]: |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
133 |
shows "pders_Set UNIV1 ONE = {}" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
134 |
unfolding UNIV1_def pders_Set_def by (auto split: if_splits) |
267 | 135 |
|
308
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
136 |
lemma pders_Set_CHAR [simp]: |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
137 |
shows "pders_Set UNIV1 (CHAR c) = {ONE}" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
138 |
unfolding UNIV1_def pders_Set_def |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
139 |
apply(auto) |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
140 |
apply(frule rev_subsetD) |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
141 |
apply(rule pders_CHAR) |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
142 |
apply(simp) |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
143 |
apply(case_tac xa) |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
144 |
apply(auto split: if_splits) |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
145 |
done |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
146 |
|
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
147 |
lemma pders_Set_ALT [simp]: |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
148 |
shows "pders_Set UNIV1 (ALT r1 r2) = pders_Set UNIV1 r1 \<union> pders_Set UNIV1 r2" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
149 |
unfolding UNIV1_def pders_Set_def by auto |
267 | 150 |
|
266 | 151 |
|
308
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
152 |
text \<open>Non-empty suffixes of a string (needed for the cases of @{const SEQ} and @{const STAR} below)\<close> |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
153 |
|
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
154 |
definition |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
155 |
"PSuf s \<equiv> {v. v \<noteq> [] \<and> (\<exists>u. u @ v = s)}" |
266 | 156 |
|
308
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
157 |
lemma PSuf_snoc: |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
158 |
shows "PSuf (s @ [c]) = (PSuf s) ;; {[c]} \<union> {[c]}" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
159 |
unfolding PSuf_def Sequ_def |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
160 |
by (auto simp add: append_eq_append_conv2 append_eq_Cons_conv) |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
161 |
|
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
162 |
lemma PSuf_Union: |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
163 |
shows "(\<Union>v \<in> PSuf s ;; {[c]}. f v) = (\<Union>v \<in> PSuf s. f (v @ [c]))" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
164 |
by (auto simp add: Sequ_def) |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
165 |
|
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
166 |
lemma pders_Set_snoc: |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
167 |
shows "pders_Set (PSuf s ;; {[c]}) r = (pder_set c (pders_Set (PSuf s) r))" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
168 |
unfolding pders_Set_def |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
169 |
by (simp add: PSuf_Union pders_snoc) |
266 | 170 |
|
308
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
171 |
lemma pderivs_Times: |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
172 |
shows "pders s (SEQ r1 r2) \<subseteq> SEQs (pders s r1) r2 \<union> (pders_Set (PSuf s) r2)" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
173 |
proof (induct s rule: rev_induct) |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
174 |
case (snoc c s) |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
175 |
have ih: "pders s (SEQ r1 r2) \<subseteq> SEQs (pders s r1) r2 \<union> (pders_Set (PSuf s) r2)" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
176 |
by fact |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
177 |
have "pders (s @ [c]) (SEQ r1 r2) = pder_set c (pders s (SEQ r1 r2))" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
178 |
by (simp add: pders_snoc) |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
179 |
also have "\<dots> \<subseteq> pder_set c (SEQs (pders s r1) r2 \<union> (pders_Set (PSuf s) r2))" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
180 |
using ih by fastforce |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
181 |
also have "\<dots> = pder_set c (SEQs (pders s r1) r2) \<union> pder_set c (pders_Set (PSuf s) r2)" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
182 |
by (simp) |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
183 |
also have "\<dots> = pder_set c (SEQs (pders s r1) r2) \<union> pders_Set (PSuf s ;; {[c]}) r2" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
184 |
by (simp add: pders_Set_snoc) |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
185 |
also |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
186 |
have "\<dots> \<subseteq> pder_set c (SEQs (pders s r1) r2) \<union> pder c r2 \<union> pders_Set (PSuf s ;; {[c]}) r2" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
187 |
by auto |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
188 |
also |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
189 |
have "\<dots> \<subseteq> SEQs (pder_set c (pders s r1)) r2 \<union> pder c r2 \<union> pders_Set (PSuf s ;; {[c]}) r2" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
190 |
by (auto simp add: if_splits) |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
191 |
also have "\<dots> = SEQs (pders (s @ [c]) r1) r2 \<union> pder c r2 \<union> pders_Set (PSuf s ;; {[c]}) r2" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
192 |
by (simp add: pders_snoc) |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
193 |
also have "\<dots> \<subseteq> SEQs (pders (s @ [c]) r1) r2 \<union> pders_Set (PSuf (s @ [c])) r2" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
194 |
unfolding pders_Set_def by (auto simp add: PSuf_snoc) |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
195 |
finally show ?case . |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
196 |
qed (simp) |
266 | 197 |
|
308
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
198 |
lemma pders_Set_SEQ_aux1: |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
199 |
assumes a: "s \<in> UNIV1" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
200 |
shows "pders_Set (PSuf s) r \<subseteq> pders_Set UNIV1 r" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
201 |
using a unfolding UNIV1_def PSuf_def pders_Set_def by auto |
266 | 202 |
|
308
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
203 |
lemma pders_Set_SEQ_aux2: |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
204 |
assumes a: "s \<in> UNIV1" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
205 |
shows "SEQs (pders s r1) r2 \<subseteq> SEQs (pders_Set UNIV1 r1) r2" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
206 |
using a unfolding pders_Set_def by auto |
266 | 207 |
|
308
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
208 |
lemma pders_Set_SEQ: |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
209 |
shows "pders_Set UNIV1 (SEQ r1 r2) \<subseteq> SEQs (pders_Set UNIV1 r1) r2 \<union> pders_Set UNIV1 r2" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
210 |
apply(rule pders_Set_subsetI) |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
211 |
apply(rule subset_trans) |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
212 |
apply(rule pderivs_Times) |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
213 |
using pders_Set_SEQ_aux1 pders_Set_SEQ_aux2 |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
214 |
apply auto |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
215 |
apply blast |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
216 |
done |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
217 |
|
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
218 |
lemma pders_STAR: |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
219 |
assumes a: "s \<noteq> []" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
220 |
shows "pders s (STAR r) \<subseteq> SEQs (pders_Set (PSuf s) r) (STAR r)" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
221 |
using a |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
222 |
proof (induct s rule: rev_induct) |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
223 |
case (snoc c s) |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
224 |
have ih: "s \<noteq> [] \<Longrightarrow> pders s (STAR r) \<subseteq> SEQs (pders_Set (PSuf s) r) (STAR r)" by fact |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
225 |
{ assume asm: "s \<noteq> []" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
226 |
have "pders (s @ [c]) (STAR r) = pder_set c (pders s (STAR r))" by (simp add: pders_snoc) |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
227 |
also have "\<dots> \<subseteq> pder_set c (SEQs (pders_Set (PSuf s) r) (STAR r))" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
228 |
using ih[OF asm] by fast |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
229 |
also have "\<dots> \<subseteq> SEQs (pder_set c (pders_Set (PSuf s) r)) (STAR r) \<union> pder c (STAR r)" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
230 |
by (auto split: if_splits) |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
231 |
also have "\<dots> \<subseteq> SEQs (pders_Set (PSuf (s @ [c])) r) (STAR r) \<union> (SEQs (pder c r) (STAR r))" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
232 |
by (simp only: PSuf_snoc pders_Set_snoc pders_Set_union) |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
233 |
(auto simp add: pders_Set_def) |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
234 |
also have "\<dots> = SEQs (pders_Set (PSuf (s @ [c])) r) (STAR r)" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
235 |
by (auto simp add: PSuf_snoc PSuf_Union pders_snoc pders_Set_def) |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
236 |
finally have ?case . |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
237 |
} |
266 | 238 |
moreover |
308
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
239 |
{ assume asm: "s = []" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
240 |
then have ?case by (auto simp add: pders_Set_def pders_snoc PSuf_def) |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
241 |
} |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
242 |
ultimately show ?case by blast |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
243 |
qed (simp) |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
244 |
|
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
245 |
lemma pders_Set_STAR: |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
246 |
shows "pders_Set UNIV1 (STAR r) \<subseteq> SEQs (pders_Set UNIV1 r) (STAR r)" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
247 |
apply(rule pders_Set_subsetI) |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
248 |
apply(rule subset_trans) |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
249 |
apply(rule pders_STAR) |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
250 |
apply(simp add: UNIV1_def) |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
251 |
apply(simp add: UNIV1_def PSuf_def) |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
252 |
apply(auto simp add: pders_Set_def) |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
253 |
done |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
254 |
|
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
255 |
lemma finite_SEQs [simp]: |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
256 |
assumes a: "finite A" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
257 |
shows "finite (SEQs A r)" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
258 |
using a by auto |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
259 |
|
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
260 |
lemma finite_pders_Set_UNIV1: |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
261 |
shows "finite (pders_Set UNIV1 r)" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
262 |
apply(induct r) |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
263 |
apply(simp_all add: |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
264 |
finite_subset[OF pders_Set_SEQ] |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
265 |
finite_subset[OF pders_Set_STAR]) |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
266 |
done |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
267 |
|
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
268 |
lemma pders_Set_UNIV: |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
269 |
shows "pders_Set UNIV r = pders [] r \<union> pders_Set UNIV1 r" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
270 |
unfolding UNIV1_def pders_Set_def |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
271 |
by blast |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
272 |
|
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
273 |
lemma finite_pders_Set_UNIV: |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
274 |
shows "finite (pders_Set UNIV r)" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
275 |
unfolding pders_Set_UNIV |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
276 |
by (simp add: finite_pders_Set_UNIV1) |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
277 |
|
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
278 |
lemma finite_pders_set: |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
279 |
shows "finite (pders_Set A r)" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
280 |
by (metis finite_pders_Set_UNIV pders_Set_subset rev_finite_subset subset_UNIV) |
266 | 281 |
|
282 |
||
308
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
283 |
text\<open>The following relationship between the alphabetic width of regular expressions |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
284 |
(called \<open>awidth\<close> below) and the number of partial derivatives was proved |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
285 |
by Antimirov~\cite{Antimirov95} and formalized by Max Haslbeck.\<close> |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
286 |
|
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
287 |
fun awidth :: "rexp \<Rightarrow> nat" where |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
288 |
"awidth ZERO = 0" | |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
289 |
"awidth ONE = 0" | |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
290 |
"awidth (CHAR a) = 1" | |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
291 |
"awidth (ALT r1 r2) = awidth r1 + awidth r2" | |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
292 |
"awidth (SEQ r1 r2) = awidth r1 + awidth r2" | |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
293 |
"awidth (STAR r1) = awidth r1" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
294 |
|
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
295 |
lemma card_SEQs_pders_Set_le: |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
296 |
"card (SEQs (pders_Set A r) s) \<le> card (pders_Set A r)" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
297 |
using finite_pders_set unfolding Timess_eq_image by (rule card_image_le) |
266 | 298 |
|
308
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
299 |
lemma card_pders_set_UNIV1_le_awidth: "card (pders_Set UNIV1 r) \<le> awidth r" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
300 |
proof (induction r) |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
301 |
case (ALT r1 r2) |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
302 |
have "card (pders_Set UNIV1 (ALT r1 r2)) = card (pders_Set UNIV1 r1 \<union> pders_Set UNIV1 r2)" by simp |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
303 |
also have "\<dots> \<le> card (pders_Set UNIV1 r1) + card (pders_Set UNIV1 r2)" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
304 |
by(simp add: card_Un_le) |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
305 |
also have "\<dots> \<le> awidth (ALT r1 r2)" using ALT.IH by simp |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
306 |
finally show ?case . |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
307 |
next |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
308 |
case (SEQ r1 r2) |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
309 |
have "card (pders_Set UNIV1 (SEQ r1 r2)) \<le> card (SEQs (pders_Set UNIV1 r1) r2 \<union> pders_Set UNIV1 r2)" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
310 |
by (simp add: card_mono finite_pders_set pders_Set_SEQ) |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
311 |
also have "\<dots> \<le> card (SEQs (pders_Set UNIV1 r1) r2) + card (pders_Set UNIV1 r2)" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
312 |
by (simp add: card_Un_le) |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
313 |
also have "\<dots> \<le> card (pders_Set UNIV1 r1) + card (pders_Set UNIV1 r2)" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
314 |
by (simp add: card_SEQs_pders_Set_le) |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
315 |
also have "\<dots> \<le> awidth (SEQ r1 r2)" using SEQ.IH by simp |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
316 |
finally show ?case . |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
317 |
next |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
318 |
case (STAR r) |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
319 |
have "card (pders_Set UNIV1 (STAR r)) \<le> card (SEQs (pders_Set UNIV1 r) (STAR r))" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
320 |
by (simp add: card_mono finite_pders_set pders_Set_STAR) |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
321 |
also have "\<dots> \<le> card (pders_Set UNIV1 r)" by (rule card_SEQs_pders_Set_le) |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
322 |
also have "\<dots> \<le> awidth (STAR r)" by (simp add: STAR.IH) |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
323 |
finally show ?case . |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
324 |
qed (auto) |
266 | 325 |
|
308
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
326 |
text\<open>Antimirov's Theorem 3.4:\<close> |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
327 |
theorem card_pders_set_UNIV_le_awidth: "card (pders_Set UNIV r) \<le> awidth r + 1" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
328 |
proof - |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
329 |
have "card (insert r (pders_Set UNIV1 r)) \<le> Suc (card (pders_Set UNIV1 r))" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
330 |
by(auto simp: card_insert_if[OF finite_pders_Set_UNIV1]) |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
331 |
also have "\<dots> \<le> Suc (awidth r)" by(simp add: card_pders_set_UNIV1_le_awidth) |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
332 |
finally show ?thesis by(simp add: pders_Set_UNIV) |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
333 |
qed |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
334 |
|
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
335 |
text\<open>Antimirov's Corollary 3.5:\<close> |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
336 |
corollary card_pders_set_le_awidth: "card (pders_Set A r) \<le> awidth r + 1" |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
337 |
by(rule order_trans[OF |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
338 |
card_mono[OF finite_pders_Set_UNIV pders_Set_subset[OF subset_UNIV]] |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
339 |
card_pders_set_UNIV_le_awidth]) |
496a37d816e9
added partial derivative proof from Antimirov
Christian Urban <urbanc@in.tum.de>
parents:
295
diff
changeset
|
340 |
|
286
804fbb227568
added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents:
279
diff
changeset
|
341 |
|
266 | 342 |
end |