Theories/Derivs.thy
author urbanc
Wed, 23 Mar 2011 12:17:30 +0000
changeset 149 e122cb146ecc
child 152 c265a1689bdc
permissions -rw-r--r--
added the most current versions of the theories.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
149
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
     1
theory Derivs
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
     2
imports Closure
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
     3
begin
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
     4
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
     5
section {* Experiments with Derivatives -- independent of Myhill-Nerode *}
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
     6
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
     7
subsection {* Left-Quotients *}
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
     8
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
     9
definition
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    10
  Delta :: "lang \<Rightarrow> lang"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    11
where
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    12
  "Delta A = (if [] \<in> A then {[]} else {})"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    13
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    14
definition
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    15
  Der :: "char \<Rightarrow> lang \<Rightarrow> lang"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    16
where
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    17
  "Der c A \<equiv> {s. [c] @ s \<in> A}"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    18
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    19
definition
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    20
  Ders :: "string \<Rightarrow> lang \<Rightarrow> lang"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    21
where
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    22
  "Ders s A \<equiv> {s'. s @ s' \<in> A}"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    23
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    24
definition
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    25
  Ders_set :: "lang \<Rightarrow> lang \<Rightarrow> lang"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    26
where
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    27
  "Ders_set A B \<equiv> {s' | s s'. s @ s' \<in> B \<and> s \<in> A}"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    28
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    29
lemma Ders_set_Ders:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    30
  shows "Ders_set A B = (\<Union>s \<in> A. Ders s B)"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    31
unfolding Ders_set_def Ders_def
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    32
by auto
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    33
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    34
lemma Der_null [simp]:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    35
  shows "Der c {} = {}"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    36
unfolding Der_def
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    37
by auto
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    38
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    39
lemma Der_empty [simp]:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    40
  shows "Der c {[]} = {}"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    41
unfolding Der_def
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    42
by auto
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    43
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    44
lemma Der_char [simp]:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    45
  shows "Der c {[d]} = (if c = d then {[]} else {})"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    46
unfolding Der_def
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    47
by auto
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    48
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    49
lemma Der_union [simp]:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    50
  shows "Der c (A \<union> B) = Der c A \<union> Der c B"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    51
unfolding Der_def
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    52
by auto
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    53
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    54
lemma Der_seq [simp]:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    55
  shows "Der c (A ;; B) = (Der c A) ;; B \<union> (Delta A ;; Der c B)"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    56
unfolding Der_def Delta_def
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    57
unfolding Seq_def
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    58
by (auto simp add: Cons_eq_append_conv)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    59
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    60
lemma Der_star [simp]:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    61
  shows "Der c (A\<star>) = (Der c A) ;; A\<star>"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    62
apply(subst star_cases)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    63
apply(simp only: Delta_def Der_union Der_seq Der_empty)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    64
apply(simp add: Der_def Seq_def)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    65
apply(auto)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    66
apply(drule star_decom)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    67
apply(auto simp add: Cons_eq_append_conv)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    68
done
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    69
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    70
lemma Ders_singleton:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    71
  shows "Ders [c] A = Der c A"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    72
unfolding Der_def Ders_def
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    73
by simp
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    74
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    75
lemma Ders_append:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    76
  shows "Ders (s1 @ s2) A = Ders s2 (Ders s1 A)"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    77
unfolding Ders_def by simp 
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    78
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    79
lemma MN_Rel_Ders:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    80
  shows "x \<approx>A y \<longleftrightarrow> Ders x A = Ders y A"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    81
unfolding Ders_def str_eq_def str_eq_rel_def
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    82
by auto
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    83
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    84
subsection {* Brozowsky's derivatives of regular expressions *}
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    85
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    86
fun
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    87
  nullable :: "rexp \<Rightarrow> bool"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    88
where
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    89
  "nullable (NULL) = False"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    90
| "nullable (EMPTY) = True"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    91
| "nullable (CHAR c) = False"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    92
| "nullable (ALT r1 r2) = (nullable r1 \<or> nullable r2)"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    93
| "nullable (SEQ r1 r2) = (nullable r1 \<and> nullable r2)"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    94
| "nullable (STAR r) = True"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    95
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    96
fun
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    97
  der :: "char \<Rightarrow> rexp \<Rightarrow> rexp"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    98
where
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
    99
  "der c (NULL) = NULL"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   100
| "der c (EMPTY) = NULL"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   101
| "der c (CHAR c') = (if c = c' then EMPTY else NULL)"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   102
| "der c (ALT r1 r2) = ALT (der c r1) (der c r2)"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   103
| "der c (SEQ r1 r2) = ALT (SEQ (der c r1) r2) (if nullable r1 then der c r2 else NULL)"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   104
| "der c (STAR r) = SEQ (der c r) (STAR r)"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   105
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   106
function 
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   107
  ders :: "string \<Rightarrow> rexp \<Rightarrow> rexp"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   108
where
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   109
  "ders [] r = r"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   110
| "ders (s @ [c]) r = der c (ders s r)"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   111
by (auto) (metis rev_cases)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   112
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   113
termination
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   114
  by (relation "measure (length o fst)") (auto)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   115
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   116
lemma Delta_nullable:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   117
  shows "Delta (L r) = (if nullable r then {[]} else {})"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   118
unfolding Delta_def
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   119
by (induct r) (auto simp add: Seq_def split: if_splits)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   120
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   121
lemma Der_der:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   122
  fixes r::rexp
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   123
  shows "Der c (L r) = L (der c r)"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   124
by (induct r) (simp_all add: Delta_nullable)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   125
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   126
lemma Ders_ders:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   127
  fixes r::rexp
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   128
  shows "Ders s (L r) = L (ders s r)"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   129
apply(induct s rule: rev_induct)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   130
apply(simp add: Ders_def)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   131
apply(simp only: ders.simps)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   132
apply(simp only: Ders_append)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   133
apply(simp only: Ders_singleton)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   134
apply(simp only: Der_der)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   135
done
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   136
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   137
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   138
subsection {* Antimirov's Partial Derivatives *}
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   139
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   140
abbreviation
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   141
  "SEQS R r \<equiv> {SEQ r' r | r'. r' \<in> R}"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   142
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   143
fun
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   144
  pder :: "char \<Rightarrow> rexp \<Rightarrow> rexp set"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   145
where
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   146
  "pder c NULL = {NULL}"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   147
| "pder c EMPTY = {NULL}"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   148
| "pder c (CHAR c') = (if c = c' then {EMPTY} else {NULL})"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   149
| "pder c (ALT r1 r2) = (pder c r1) \<union> (pder c r2)"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   150
| "pder c (SEQ r1 r2) = SEQS (pder c r1) r2 \<union> (if nullable r1 then pder c r2 else {})"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   151
| "pder c (STAR r) = SEQS (pder c r) (STAR r)"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   152
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   153
abbreviation
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   154
  "pder_set c R \<equiv> \<Union>r \<in> R. pder c r"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   155
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   156
function 
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   157
  pders :: "string \<Rightarrow> rexp \<Rightarrow> rexp set"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   158
where
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   159
  "pders [] r = {r}"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   160
| "pders (s @ [c]) r = pder_set c (pders s r)"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   161
by (auto) (metis rev_cases)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   162
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   163
termination
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   164
  by (relation "measure (length o fst)") (auto)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   165
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   166
abbreviation
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   167
  "pders_set A r \<equiv> \<Union>s \<in> A. pders s r"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   168
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   169
lemma pders_append:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   170
  "pders (s1 @ s2) r = \<Union> (pders s2) ` (pders s1 r)"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   171
apply(induct s2 arbitrary: s1 r rule: rev_induct)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   172
apply(simp)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   173
apply(subst append_assoc[symmetric])
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   174
apply(simp only: pders.simps)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   175
apply(auto)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   176
done
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   177
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   178
lemma pders_singleton:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   179
  "pders [c] r = pder c r"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   180
apply(subst append_Nil[symmetric])
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   181
apply(simp only: pders.simps)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   182
apply(simp)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   183
done
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   184
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   185
lemma pder_set_lang:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   186
  shows "(\<Union> (L ` pder_set c R)) = (\<Union>r \<in> R. (\<Union>L ` (pder c r)))"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   187
unfolding image_def 
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   188
by auto
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   189
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   190
lemma
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   191
  shows seq_UNION_left:  "B ;; (\<Union>n\<in>C. A n) = (\<Union>n\<in>C. B ;; A n)"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   192
  and   seq_UNION_right: "(\<Union>n\<in>C. A n) ;; B = (\<Union>n\<in>C. A n ;; B)"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   193
unfolding Seq_def by auto
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   194
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   195
lemma Der_pder:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   196
  fixes r::rexp
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   197
  shows "Der c (L r) = \<Union> L ` (pder c r)"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   198
by (induct r) (auto simp add: Delta_nullable seq_UNION_right)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   199
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   200
lemma Ders_pders:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   201
  fixes r::rexp
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   202
  shows "Ders s (L r) = \<Union> L ` (pders s r)"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   203
proof (induct s rule: rev_induct)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   204
  case (snoc c s)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   205
  have ih: "Ders s (L r) = \<Union> L ` (pders s r)" by fact
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   206
  have "Ders (s @ [c]) (L r) = Ders [c] (Ders s (L r))"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   207
    by (simp add: Ders_append)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   208
  also have "\<dots> = Der c (\<Union> L ` (pders s r))" using ih
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   209
    by (simp add: Ders_singleton)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   210
  also have "\<dots> = (\<Union>r\<in>pders s r. Der c (L r))" 
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   211
    unfolding Der_def image_def by auto
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   212
  also have "\<dots> = (\<Union>r\<in>pders s r. (\<Union> L `  (pder c r)))"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   213
    by (simp add: Der_pder)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   214
  also have "\<dots> = (\<Union>L ` (pder_set c (pders s r)))"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   215
    by (simp add: pder_set_lang)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   216
  also have "\<dots> = (\<Union>L ` (pders (s @ [c]) r))"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   217
    by simp
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   218
  finally show "Ders (s @ [c]) (L r) = \<Union>L ` pders (s @ [c]) r" .
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   219
qed (simp add: Ders_def)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   220
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   221
lemma Ders_set_pders_set:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   222
  fixes r::rexp
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   223
  shows "Ders_set A (L r) = (\<Union> L ` (pders_set A r))"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   224
by (simp add: Ders_set_Ders Ders_pders)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   225
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   226
lemma pders_NULL [simp]:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   227
  shows "pders s NULL = {NULL}"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   228
by (induct s rule: rev_induct) (simp_all)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   229
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   230
lemma pders_EMPTY [simp]:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   231
  shows "pders s EMPTY = (if s = [] then {EMPTY} else {NULL})"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   232
by (induct s rule: rev_induct) (auto)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   233
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   234
lemma pders_CHAR [simp]:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   235
  shows "pders s (CHAR c) = (if s = [] then {CHAR c} else (if s = [c] then {EMPTY} else {NULL}))"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   236
by (induct s rule: rev_induct) (auto)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   237
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   238
lemma pders_ALT [simp]:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   239
  shows "pders s (ALT r1 r2) = (if s = [] then {ALT r1 r2} else (pders s r1) \<union> (pders s r2))"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   240
by (induct s rule: rev_induct) (auto)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   241
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   242
definition
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   243
  "Suf s \<equiv> {v. v \<noteq> [] \<and> (\<exists>u. u @ v = s)}"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   244
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   245
lemma Suf:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   246
  shows "Suf (s @ [c]) = (Suf s) ;; {[c]} \<union> {[c]}"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   247
unfolding Suf_def Seq_def
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   248
by (auto simp add: append_eq_append_conv2 append_eq_Cons_conv)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   249
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   250
lemma Suf_Union:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   251
  shows "(\<Union>v \<in> Suf s ;; {[c]}. P v) = (\<Union>v \<in> Suf s. P (v @ [c]))"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   252
by (auto simp add: Seq_def)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   253
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   254
lemma inclusion1:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   255
  shows "pder_set c (SEQS R r2) \<subseteq> SEQS (pder_set c R) r2 \<union> (pder c r2)"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   256
apply(auto simp add: if_splits)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   257
apply(blast)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   258
done
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   259
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   260
lemma pders_SEQ:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   261
  shows "pders s (SEQ r1 r2) \<subseteq> SEQS (pders s r1) r2 \<union> (\<Union>v \<in> Suf s. pders v r2)"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   262
proof (induct s rule: rev_induct)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   263
  case (snoc c s)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   264
  have ih: "pders s (SEQ r1 r2) \<subseteq> SEQS (pders s r1) r2 \<union> (\<Union>v \<in> Suf s. pders v r2)" 
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   265
    by fact
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   266
  have "pders (s @ [c]) (SEQ r1 r2) = pder_set c (pders s (SEQ r1 r2))" by simp
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   267
  also have "\<dots> \<subseteq> pder_set c (SEQS (pders s r1) r2 \<union> (\<Union>v \<in> Suf s. pders v r2))"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   268
    using ih by auto 
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   269
  also have "\<dots> = pder_set c (SEQS (pders s r1) r2) \<union> pder_set c (\<Union>v \<in> Suf s. pders v r2)"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   270
    by (simp)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   271
  also have "\<dots> = pder_set c (SEQS (pders s r1) r2) \<union> (\<Union>v \<in> Suf s. pder_set c (pders v r2))"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   272
    by (simp)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   273
  also have "\<dots> \<subseteq> pder_set c (SEQS (pders s r1) r2) \<union> (pder c r2) \<union> (\<Union>v \<in> Suf s. pders (v @ [c]) r2)"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   274
    by (auto)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   275
  also have "\<dots> \<subseteq> SEQS (pder_set c (pders s r1)) r2 \<union> (pder c r2) \<union> (\<Union>v \<in> Suf s. pders (v @ [c]) r2)"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   276
    using inclusion1 by blast
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   277
  also have "\<dots> = SEQS (pders (s @ [c]) r1) r2 \<union> (\<Union>v \<in> Suf (s @ [c]). pders v r2)"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   278
    apply(subst (2) pders.simps)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   279
    apply(simp only: Suf)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   280
    apply(simp add: Suf_Union pders_singleton)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   281
    apply(auto)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   282
    done
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   283
  finally show ?case .
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   284
qed (simp)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   285
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   286
lemma pders_STAR:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   287
  assumes a: "s \<noteq> []"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   288
  shows "pders s (STAR r) \<subseteq> (\<Union>v \<in> Suf s. SEQS (pders v r) (STAR r))"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   289
using a
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   290
proof (induct s rule: rev_induct)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   291
  case (snoc c s)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   292
  have ih: "s \<noteq> [] \<Longrightarrow> pders s (STAR r) \<subseteq> (\<Union>v\<in>Suf s. SEQS (pders v r) (STAR r))" by fact
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   293
  { assume asm: "s \<noteq> []"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   294
    have "pders (s @ [c]) (STAR r) = pder_set c (pders s (STAR r))" by simp
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   295
    also have "\<dots> \<subseteq> (pder_set c (\<Union>v\<in>Suf s. SEQS (pders v r) (STAR r)))"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   296
      using ih[OF asm] by blast
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   297
    also have "\<dots> = (\<Union>v\<in>Suf s. pder_set c (SEQS (pders v r) (STAR r)))"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   298
      by simp
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   299
    also have "\<dots> \<subseteq> (\<Union>v\<in>Suf s. (SEQS (pder_set c (pders v r)) (STAR r) \<union> pder c (STAR r)))"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   300
      using inclusion1 by blast
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   301
    also have "\<dots> = (\<Union>v\<in>Suf s. (SEQS (pder_set c (pders v r)) (STAR r))) \<union> pder c (STAR r)"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   302
      using asm by (auto simp add: Suf_def)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   303
    also have "\<dots> = (\<Union>v\<in>Suf s. (SEQS (pders (v @ [c]) r) (STAR r))) \<union> (SEQS (pder c r) (STAR r))"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   304
      by simp
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   305
    also have "\<dots> = (\<Union>v\<in>Suf (s @ [c]). (SEQS (pders v r) (STAR r)))"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   306
      apply(simp only: Suf)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   307
      apply(simp add: Suf_Union pders_singleton)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   308
      apply(auto)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   309
      done
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   310
    finally have ?case .
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   311
  }
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   312
  moreover
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   313
  { assume asm: "s = []"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   314
    then have ?case
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   315
      apply(simp add: pders_singleton Suf_def)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   316
      apply(auto)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   317
      apply(rule_tac x="[c]" in exI)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   318
      apply(simp add: pders_singleton)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   319
      done
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   320
  }
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   321
  ultimately show ?case by blast
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   322
qed (simp)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   323
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   324
abbreviation 
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   325
  "UNIV1 \<equiv> UNIV - {[]}"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   326
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   327
lemma pders_set_NULL:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   328
  shows "pders_set UNIV1 NULL = {NULL}"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   329
by auto
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   330
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   331
lemma pders_set_EMPTY:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   332
  shows "pders_set UNIV1 EMPTY = {NULL}"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   333
by (auto split: if_splits)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   334
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   335
lemma pders_set_CHAR:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   336
  shows "pders_set UNIV1 (CHAR c) \<subseteq> {EMPTY, NULL}"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   337
by (auto split: if_splits)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   338
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   339
lemma pders_set_ALT:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   340
  shows "pders_set UNIV1 (ALT r1 r2) = pders_set UNIV1 r1 \<union> pders_set UNIV1 r2"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   341
by auto
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   342
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   343
lemma pders_set_SEQ_aux:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   344
  assumes a: "s \<in> UNIV1"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   345
  shows "pders_set (Suf s) r2 \<subseteq> pders_set UNIV1 r2"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   346
using a by (auto simp add: Suf_def)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   347
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   348
lemma pders_set_SEQ:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   349
  shows "pders_set UNIV1 (SEQ r1 r2) \<subseteq> SEQS (pders_set UNIV1 r1) r2 \<union> pders_set UNIV1 r2"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   350
apply(rule UN_least)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   351
apply(rule subset_trans)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   352
apply(rule pders_SEQ)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   353
apply(simp)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   354
apply(rule conjI) 
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   355
apply(auto)[1]
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   356
apply(rule subset_trans)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   357
apply(rule pders_set_SEQ_aux)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   358
apply(auto)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   359
done
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   360
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   361
lemma pders_set_STAR:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   362
  shows "pders_set UNIV1 (STAR r) \<subseteq> SEQS (pders_set UNIV1 r) (STAR r)"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   363
apply(rule UN_least)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   364
apply(rule subset_trans)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   365
apply(rule pders_STAR)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   366
apply(simp)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   367
apply(simp add: Suf_def)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   368
apply(auto)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   369
done
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   370
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   371
lemma finite_SEQS:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   372
  assumes a: "finite A"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   373
  shows "finite (SEQS A r)"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   374
using a by (auto)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   375
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   376
lemma finite_pders_set_UNIV1:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   377
  shows "finite (pders_set UNIV1 r)"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   378
apply(induct r)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   379
apply(simp)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   380
apply(simp only: pders_set_EMPTY)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   381
apply(simp)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   382
apply(rule finite_subset)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   383
apply(rule pders_set_CHAR)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   384
apply(simp)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   385
apply(rule finite_subset)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   386
apply(rule pders_set_SEQ)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   387
apply(simp only: finite_SEQS finite_Un)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   388
apply(simp)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   389
apply(simp only: pders_set_ALT)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   390
apply(simp)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   391
apply(rule finite_subset)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   392
apply(rule pders_set_STAR)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   393
apply(simp only: finite_SEQS)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   394
done
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   395
    
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   396
lemma pders_set_UNIV_UNIV1:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   397
  shows "pders_set UNIV r = pders [] r \<union> pders_set UNIV1 r"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   398
apply(auto)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   399
apply(rule_tac x="[]" in exI)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   400
apply(simp)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   401
done
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   402
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   403
lemma finite_pders_set_UNIV:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   404
  shows "finite (pders_set UNIV r)"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   405
unfolding pders_set_UNIV_UNIV1
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   406
by (simp add: finite_pders_set_UNIV1)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   407
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   408
lemma finite_pders_set:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   409
  shows "finite (pders_set A r)"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   410
apply(rule rev_finite_subset)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   411
apply(rule_tac r="r" in finite_pders_set_UNIV)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   412
apply(auto)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   413
done
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   414
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   415
lemma finite_pders:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   416
  shows "finite (pders s r)"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   417
using finite_pders_set[where A="{s}" and r="r"]
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   418
by simp
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   419
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   420
lemma closure_left_quotient:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   421
  assumes "regular A"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   422
  shows "regular (Ders_set B A)"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   423
proof -
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   424
  from assms obtain r::rexp where eq: "L r = A" by auto
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   425
  have fin: "finite (pders_set B r)" by (rule finite_pders_set)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   426
  
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   427
  have "Ders_set B (L r) = (\<Union> L ` (pders_set B r))"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   428
    by (simp add: Ders_set_pders_set)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   429
  also have "\<dots> = L (\<Uplus>(pders_set B r))" using fin by simp
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   430
  finally have "Ders_set B A = L (\<Uplus>(pders_set B r))" using eq
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   431
    by simp
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   432
  then show "regular (Ders_set B A)" by auto
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   433
qed
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   434
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   435
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   436
fun
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   437
  width :: "rexp \<Rightarrow> nat"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   438
where
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   439
  "width (NULL) = 0"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   440
| "width (EMPTY) = 0"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   441
| "width (CHAR c) = 1"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   442
| "width (ALT r1 r2) = width r1 + width r2"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   443
| "width (SEQ r1 r2) = width r1 + width r2"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   444
| "width (STAR r) = width r"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   445
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   446
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   447
 
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   448
end