Theories/Derivs.thy
author urbanc
Fri, 25 Mar 2011 09:42:33 +0000
changeset 152 c265a1689bdc
parent 149 e122cb146ecc
permissions -rw-r--r--
MN via partial derivatives
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
152
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   169
149
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   170
lemma pders_append:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   171
  "pders (s1 @ s2) r = \<Union> (pders s2) ` (pders s1 r)"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   172
apply(induct s2 arbitrary: s1 r rule: rev_induct)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   173
apply(simp)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   174
apply(subst append_assoc[symmetric])
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   175
apply(simp only: pders.simps)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   176
apply(auto)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   177
done
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   178
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   179
lemma pders_singleton:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   180
  "pders [c] r = pder c r"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   181
apply(subst append_Nil[symmetric])
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   182
apply(simp only: pders.simps)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   183
apply(simp)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   184
done
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   185
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   186
lemma pder_set_lang:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   187
  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
   188
unfolding image_def 
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   189
by auto
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   190
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   191
lemma
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   192
  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
   193
  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
   194
unfolding Seq_def by auto
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   195
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   196
lemma Der_pder:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   197
  fixes r::rexp
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   198
  shows "Der c (L r) = \<Union> L ` (pder c r)"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   199
by (induct r) (auto simp add: Delta_nullable seq_UNION_right)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   200
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   201
lemma Ders_pders:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   202
  fixes r::rexp
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   203
  shows "Ders s (L r) = \<Union> L ` (pders s r)"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   204
proof (induct s rule: rev_induct)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   205
  case (snoc c s)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   206
  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
   207
  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
   208
    by (simp add: Ders_append)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   209
  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
   210
    by (simp add: Ders_singleton)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   211
  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
   212
    unfolding Der_def image_def by auto
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   213
  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
   214
    by (simp add: Der_pder)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   215
  also have "\<dots> = (\<Union>L ` (pder_set c (pders s r)))"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   216
    by (simp add: pder_set_lang)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   217
  also have "\<dots> = (\<Union>L ` (pders (s @ [c]) r))"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   218
    by simp
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   219
  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
   220
qed (simp add: Ders_def)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   221
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   222
lemma Ders_set_pders_set:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   223
  fixes r::rexp
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   224
  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
   225
by (simp add: Ders_set_Ders Ders_pders)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   226
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   227
lemma pders_NULL [simp]:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   228
  shows "pders s NULL = {NULL}"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   229
by (induct s rule: rev_induct) (simp_all)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   230
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   231
lemma pders_EMPTY [simp]:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   232
  shows "pders s EMPTY = (if s = [] then {EMPTY} else {NULL})"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   233
by (induct s rule: rev_induct) (auto)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   234
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   235
lemma pders_CHAR [simp]:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   236
  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
   237
by (induct s rule: rev_induct) (auto)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   238
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   239
lemma pders_ALT [simp]:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   240
  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
   241
by (induct s rule: rev_induct) (auto)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   242
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   243
definition
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   244
  "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
   245
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   246
lemma Suf:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   247
  shows "Suf (s @ [c]) = (Suf s) ;; {[c]} \<union> {[c]}"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   248
unfolding Suf_def Seq_def
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   249
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
   250
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   251
lemma Suf_Union:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   252
  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
   253
by (auto simp add: Seq_def)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   254
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   255
lemma inclusion1:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   256
  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
   257
apply(auto simp add: if_splits)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   258
apply(blast)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   259
done
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   260
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   261
lemma pders_SEQ:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   262
  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
   263
proof (induct s rule: rev_induct)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   264
  case (snoc c s)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   265
  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
   266
    by fact
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   267
  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
   268
  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
   269
    using ih by auto 
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   270
  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
   271
    by (simp)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   272
  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
   273
    by (simp)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   274
  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
   275
    by (auto)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   276
  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
   277
    using inclusion1 by blast
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   278
  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
   279
    apply(subst (2) pders.simps)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   280
    apply(simp only: Suf)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   281
    apply(simp add: Suf_Union pders_singleton)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   282
    apply(auto)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   283
    done
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   284
  finally show ?case .
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   285
qed (simp)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   286
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   287
lemma pders_STAR:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   288
  assumes a: "s \<noteq> []"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   289
  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
   290
using a
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   291
proof (induct s rule: rev_induct)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   292
  case (snoc c s)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   293
  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
   294
  { assume asm: "s \<noteq> []"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   295
    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
   296
    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
   297
      using ih[OF asm] by blast
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   298
    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
   299
      by simp
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   300
    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
   301
      using inclusion1 by blast
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   302
    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
   303
      using asm by (auto simp add: Suf_def)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   304
    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
   305
      by simp
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   306
    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
   307
      apply(simp only: Suf)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   308
      apply(simp add: Suf_Union pders_singleton)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   309
      apply(auto)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   310
      done
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   311
    finally have ?case .
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   312
  }
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   313
  moreover
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   314
  { assume asm: "s = []"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   315
    then have ?case
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   316
      apply(simp add: pders_singleton Suf_def)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   317
      apply(auto)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   318
      apply(rule_tac x="[c]" in exI)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   319
      apply(simp add: pders_singleton)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   320
      done
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   321
  }
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   322
  ultimately show ?case by blast
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   323
qed (simp)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   324
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   325
abbreviation 
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   326
  "UNIV1 \<equiv> UNIV - {[]}"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   327
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   328
lemma pders_set_NULL:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   329
  shows "pders_set UNIV1 NULL = {NULL}"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   330
by auto
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   331
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   332
lemma pders_set_EMPTY:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   333
  shows "pders_set UNIV1 EMPTY = {NULL}"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   334
by (auto split: if_splits)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   335
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   336
lemma pders_set_CHAR:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   337
  shows "pders_set UNIV1 (CHAR c) \<subseteq> {EMPTY, NULL}"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   338
by (auto split: if_splits)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   339
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   340
lemma pders_set_ALT:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   341
  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
   342
by auto
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   343
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   344
lemma pders_set_SEQ_aux:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   345
  assumes a: "s \<in> UNIV1"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   346
  shows "pders_set (Suf s) r2 \<subseteq> pders_set UNIV1 r2"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   347
using a by (auto simp add: Suf_def)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   348
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   349
lemma pders_set_SEQ:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   350
  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
   351
apply(rule UN_least)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   352
apply(rule subset_trans)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   353
apply(rule pders_SEQ)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   354
apply(simp)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   355
apply(rule conjI) 
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   356
apply(auto)[1]
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   357
apply(rule subset_trans)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   358
apply(rule pders_set_SEQ_aux)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   359
apply(auto)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   360
done
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   361
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   362
lemma pders_set_STAR:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   363
  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
   364
apply(rule UN_least)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   365
apply(rule subset_trans)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   366
apply(rule pders_STAR)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   367
apply(simp)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   368
apply(simp add: Suf_def)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   369
apply(auto)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   370
done
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   371
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   372
lemma finite_SEQS:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   373
  assumes a: "finite A"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   374
  shows "finite (SEQS A r)"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   375
using a by (auto)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   376
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   377
lemma finite_pders_set_UNIV1:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   378
  shows "finite (pders_set UNIV1 r)"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   379
apply(induct r)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   380
apply(simp)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   381
apply(simp only: pders_set_EMPTY)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   382
apply(simp)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   383
apply(rule finite_subset)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   384
apply(rule pders_set_CHAR)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   385
apply(simp)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   386
apply(rule finite_subset)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   387
apply(rule pders_set_SEQ)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   388
apply(simp only: finite_SEQS finite_Un)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   389
apply(simp)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   390
apply(simp only: pders_set_ALT)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   391
apply(simp)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   392
apply(rule finite_subset)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   393
apply(rule pders_set_STAR)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   394
apply(simp only: finite_SEQS)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   395
done
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   396
    
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   397
lemma pders_set_UNIV_UNIV1:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   398
  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
   399
apply(auto)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   400
apply(rule_tac x="[]" in exI)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   401
apply(simp)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   402
done
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   403
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   404
lemma finite_pders_set_UNIV:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   405
  shows "finite (pders_set UNIV r)"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   406
unfolding pders_set_UNIV_UNIV1
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   407
by (simp add: finite_pders_set_UNIV1)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   408
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   409
lemma finite_pders_set:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   410
  shows "finite (pders_set A r)"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   411
apply(rule rev_finite_subset)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   412
apply(rule_tac r="r" in finite_pders_set_UNIV)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   413
apply(auto)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   414
done
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   415
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   416
lemma finite_pders:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   417
  shows "finite (pders s r)"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   418
using finite_pders_set[where A="{s}" and r="r"]
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   419
by simp
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   420
152
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   421
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   422
lemma test: 
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   423
  shows "pders_set A r = (\<Union> {pders s r | s. s \<in> A})"
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   424
by auto
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   425
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   426
lemma finite_pow_pders:
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   427
  shows "finite (Pow (\<Union> {pders s r | s. s \<in> A}))"
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   428
using finite_pders_set
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   429
by (simp add: test)
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   430
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   431
lemma test2:
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   432
  shows "{pders s r | s. s \<in> A} \<subseteq> Pow (\<Union> {pders s r | s. s \<in> A})"
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   433
  by auto
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   434
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   435
lemma test3:
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   436
  shows "finite ({pders s r | s. s \<in> A})"
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   437
apply(rule finite_subset)
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   438
apply(rule test2)
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   439
apply(rule finite_pow_pders)
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   440
done
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   441
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   442
lemma Myhill_Nerode_aux:
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   443
  fixes r::"rexp"
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   444
  shows "finite (UNIV // =(\<lambda>x. pders x r)=)"
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   445
apply(rule finite_eq_tag_rel)
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   446
apply(rule rev_finite_subset)
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   447
apply(rule test3)
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   448
apply(auto)
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   449
done
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   450
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   451
lemma Myhill_Nerode3:
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   452
  fixes r::"rexp"
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   453
  shows "finite (UNIV // \<approx>(L r))"
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   454
apply(rule refined_partition_finite)
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   455
apply(rule Myhill_Nerode_aux[where r="r"])
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   456
apply(simp add: tag_eq_rel_def)
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   457
apply(auto)[1]
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   458
unfolding str_eq_def[symmetric]
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   459
unfolding MN_Rel_Ders
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   460
apply(simp add: Ders_pders)
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   461
apply(rule equivI)
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   462
apply(auto simp add: tag_eq_rel_def refl_on_def sym_def trans_def)
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   463
apply(rule equivI)
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   464
apply(auto simp add: str_eq_rel_def refl_on_def sym_def trans_def)
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   465
done
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   466
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   467
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   468
section {* Closure under Left-Quotients *}
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   469
149
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   470
lemma closure_left_quotient:
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   471
  assumes "regular A"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   472
  shows "regular (Ders_set B A)"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   473
proof -
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   474
  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
   475
  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
   476
  
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   477
  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
   478
    by (simp add: Ders_set_pders_set)
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   479
  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
   480
  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
   481
    by simp
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   482
  then show "regular (Ders_set B A)" by auto
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   483
qed
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   484
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   485
152
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   486
section {* Relating standard and partial derivations *}
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   487
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   488
lemma
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   489
  shows "(\<Union> L ` (pder c r)) = L (der c r)"
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   490
unfolding Der_der[symmetric] Der_pder by simp
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   491
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   492
lemma
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   493
  shows "(\<Union> L ` (pders s r)) = L (ders s r)"
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   494
unfolding Ders_ders[symmetric] Ders_pders by simp
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   495
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   496
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   497
section {* attempt to prove MN *}
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   498
(*
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   499
lemma Myhill_Nerode3:
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   500
  fixes r::"rexp"
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   501
  shows "finite (UNIV // =(\<lambda>x. pders x r)=)"
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   502
apply(rule finite_eq_tag_rel)
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   503
apply(rule finite_pders_set)
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   504
apply(simp add: Range_def)
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   505
unfolding Quotien_def
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   506
by (induct r) (auto)
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   507
*)
c265a1689bdc MN via partial derivatives
urbanc
parents: 149
diff changeset
   508
149
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   509
fun
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   510
  width :: "rexp \<Rightarrow> nat"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   511
where
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   512
  "width (NULL) = 0"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   513
| "width (EMPTY) = 0"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   514
| "width (CHAR c) = 1"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   515
| "width (ALT r1 r2) = width r1 + width r2"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   516
| "width (SEQ r1 r2) = width r1 + width r2"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   517
| "width (STAR r) = width r"
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   518
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   519
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   520
 
e122cb146ecc added the most current versions of the theories.
urbanc
parents:
diff changeset
   521
end