Derivatives.thy
author urbanc
Fri, 05 Aug 2011 05:34:11 +0000
changeset 187 9f46a9571e37
parent 181 97090fc7aa9f
child 190 b73478aaf33e
permissions -rw-r--r--
more on the derivatives section
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
     1
theory Derivatives
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
     2
imports Myhill_2
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
     3
begin
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
     4
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
     5
section {* Left-Quotients and Derivatives *}
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
     6
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
     7
subsection {* Left-Quotients *}
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
     8
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
     9
definition
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    10
  Delta :: "'a lang \<Rightarrow> 'a lang"
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    11
where
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    12
  "Delta A = (if [] \<in> A then {[]} else {})"
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    13
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    14
definition
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    15
  Der :: "'a \<Rightarrow> 'a lang \<Rightarrow> 'a lang"
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    16
where
179
edacc141060f small improvements
urbanc
parents: 174
diff changeset
    17
  "Der c A \<equiv> {s'. [c] @ s' \<in> A}"
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    18
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    19
definition
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    20
  Ders :: "'a list \<Rightarrow> 'a lang \<Rightarrow> 'a lang"
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    21
where
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    22
  "Ders s A \<equiv> {s'. s @ s' \<in> A}"
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    23
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
    24
abbreviation 
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
    25
  "Derss s A \<equiv> \<Union> (Ders s) ` A"
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    26
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
    27
lemma Der_simps [simp]:
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
    28
  shows "Der c {} = {}"
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
    29
  and   "Der c {[]} = {}"
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
    30
  and   "Der c {[d]} = (if c = d then {[]} else {})"
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
    31
  and   "Der c (A \<union> B) = Der c A \<union> Der c B"
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
    32
unfolding Der_def by auto
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    33
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    34
lemma Der_conc [simp]:
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    35
  shows "Der c (A \<cdot> B) = (Der c A) \<cdot> B \<union> (Delta A \<cdot> Der c B)"
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    36
unfolding Der_def Delta_def conc_def
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    37
by (auto simp add: Cons_eq_append_conv)
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    38
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    39
lemma Der_star [simp]:
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    40
  shows "Der c (A\<star>) = (Der c A) \<cdot> A\<star>"
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    41
proof -
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    42
  have incl: "Delta A \<cdot> Der c (A\<star>) \<subseteq> (Der c A) \<cdot> A\<star>"
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
    43
    unfolding Der_def Delta_def conc_def 
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    44
    apply(auto)
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    45
    apply(drule star_decom)
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    46
    apply(auto simp add: Cons_eq_append_conv)
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    47
    done
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    48
    
180
b755090d0f3d added a picture
urbanc
parents: 179
diff changeset
    49
  have "Der c (A\<star>) = Der c (A \<cdot> A\<star> \<union> {[]})"
b755090d0f3d added a picture
urbanc
parents: 179
diff changeset
    50
    by (simp only: star_unfold_left[symmetric])
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    51
  also have "... = Der c (A \<cdot> A\<star>)"
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
    52
    by (simp only: Der_simps) (simp)
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    53
  also have "... = (Der c A) \<cdot> A\<star> \<union> (Delta A \<cdot> Der c (A\<star>))"
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    54
    by simp
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    55
  also have "... =  (Der c A) \<cdot> A\<star>"
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    56
    using incl by auto
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    57
  finally show "Der c (A\<star>) = (Der c A) \<cdot> A\<star>" . 
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    58
qed
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    59
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
    60
lemma Ders_simps [simp]:
179
edacc141060f small improvements
urbanc
parents: 174
diff changeset
    61
  shows "Ders [] A = A"
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
    62
  and   "Ders (c # s) A = Ders s (Der c A)"
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
    63
  and   "Ders (s1 @ s2) A = Ders s2 (Ders s1 A)"
179
edacc141060f small improvements
urbanc
parents: 174
diff changeset
    64
unfolding Ders_def Der_def by auto
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    65
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    66
subsection {* Brozowsky's derivatives of regular expressions *}
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    67
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    68
fun
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    69
  nullable :: "'a rexp \<Rightarrow> bool"
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    70
where
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    71
  "nullable (Zero) = False"
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    72
| "nullable (One) = True"
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    73
| "nullable (Atom c) = False"
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    74
| "nullable (Plus r1 r2) = (nullable r1 \<or> nullable r2)"
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    75
| "nullable (Times r1 r2) = (nullable r1 \<and> nullable r2)"
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    76
| "nullable (Star r) = True"
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    77
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    78
fun
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    79
  der :: "'a \<Rightarrow> 'a rexp \<Rightarrow> 'a rexp"
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    80
where
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    81
  "der c (Zero) = Zero"
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    82
| "der c (One) = Zero"
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    83
| "der c (Atom c') = (if c = c' then One else Zero)"
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    84
| "der c (Plus r1 r2) = Plus (der c r1) (der c r2)"
174
2b414a8a7132 more on the section about derivatives
urbanc
parents: 170
diff changeset
    85
| "der c (Times r1 r2) = 
2b414a8a7132 more on the section about derivatives
urbanc
parents: 170
diff changeset
    86
    (if nullable r1 then Plus (Times (der c r1) r2) (der c r2) else Times (der c r1) r2)"
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    87
| "der c (Star r) = Times (der c r) (Star r)"
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    88
179
edacc141060f small improvements
urbanc
parents: 174
diff changeset
    89
fun 
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    90
  ders :: "'a list \<Rightarrow> 'a rexp \<Rightarrow> 'a rexp"
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    91
where
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    92
  "ders [] r = r"
179
edacc141060f small improvements
urbanc
parents: 174
diff changeset
    93
| "ders (c # s) r = ders s (der c r)"
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    94
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    95
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    96
lemma Delta_nullable:
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    97
  shows "Delta (lang r) = (if nullable r then {[]} else {})"
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    98
unfolding Delta_def
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
    99
by (induct r) (auto simp add: conc_def split: if_splits)
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   100
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   101
lemma Der_der:
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   102
  shows "Der c (lang r) = lang (der c r)"
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   103
by (induct r) (simp_all add: Delta_nullable)
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   104
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   105
lemma Ders_ders:
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   106
  shows "Ders s (lang r) = lang (ders s r)"
179
edacc141060f small improvements
urbanc
parents: 174
diff changeset
   107
by (induct s arbitrary: r) (simp_all add: Der_der)
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   108
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   109
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   110
subsection {* Antimirov's Partial Derivatives *}
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   111
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   112
abbreviation
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   113
  "Timess rs r \<equiv> {Times r' r | r'. r' \<in> rs}"
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   114
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   115
fun
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   116
  pder :: "'a \<Rightarrow> 'a rexp \<Rightarrow> ('a rexp) set"
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   117
where
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   118
  "pder c Zero = {Zero}"
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   119
| "pder c One = {Zero}"
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   120
| "pder c (Atom c') = (if c = c' then {One} else {Zero})"
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   121
| "pder c (Plus r1 r2) = (pder c r1) \<union> (pder c r2)"
179
edacc141060f small improvements
urbanc
parents: 174
diff changeset
   122
| "pder c (Times r1 r2) = 
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   123
    (if nullable r1 then Timess (pder c r1) r2 \<union>  pder c r2 else Timess (pder c r1) r2)"
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   124
| "pder c (Star r) = Timess (pder c r) (Star r)"
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   125
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   126
abbreviation
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   127
  "pder_set c rs \<equiv> \<Union> pder c ` rs"
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   128
179
edacc141060f small improvements
urbanc
parents: 174
diff changeset
   129
fun
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   130
  pders :: "'a list \<Rightarrow> 'a rexp \<Rightarrow> ('a rexp) set"
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   131
where
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   132
  "pders [] r = {r}"
180
b755090d0f3d added a picture
urbanc
parents: 179
diff changeset
   133
| "pders (c # s) r = \<Union> (pders s) ` (pder c r)"
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   134
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   135
abbreviation
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   136
  "pderss s A \<equiv> \<Union> (pders s) ` A"
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   137
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   138
lemma pders_append:
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   139
  "pders (s1 @ s2) r = \<Union> (pders s2) ` (pders s1 r)"
179
edacc141060f small improvements
urbanc
parents: 174
diff changeset
   140
by (induct s1 arbitrary: r) (simp_all)
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   141
179
edacc141060f small improvements
urbanc
parents: 174
diff changeset
   142
lemma pders_snoc:
edacc141060f small improvements
urbanc
parents: 174
diff changeset
   143
  shows "pders (s @ [c]) r = pder_set c (pders s r)"
edacc141060f small improvements
urbanc
parents: 174
diff changeset
   144
by (simp add: pders_append)
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   145
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   146
lemma pders_simps [simp]:
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   147
  shows "pders s Zero = {Zero}"
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   148
  and   "pders s One = (if s = [] then {One} else {Zero})"
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   149
  and   "pders s (Atom c) = (if s = [] then {Atom c} else (if s = [c] then {One} else {Zero}))"
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   150
  and   "pders s (Plus r1 r2) = (if s = [] then {Plus r1 r2} else (pders s r1) \<union> (pders s r2))"
179
edacc141060f small improvements
urbanc
parents: 174
diff changeset
   151
by (induct s) (auto)
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   152
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   153
subsection {* Relating left-quotients and partial derivatives *}
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   154
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   155
lemma Der_pder:
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   156
  shows "Der c (lang r) = \<Union> lang ` (pder c r)"
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   157
by (induct r) (auto simp add: Delta_nullable conc_UNION_distrib)
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   158
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   159
lemma Ders_pders:
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   160
  shows "Ders s (lang r) = \<Union> lang ` (pders s r)"
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   161
proof (induct s arbitrary: r)
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   162
  case (Cons c s)
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   163
  have ih: "\<And>r. Ders s (lang r) = \<Union> lang ` (pders s r)" by fact
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   164
  have "Ders (c # s) (lang r) = Ders s (Der c (lang r))" by simp
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   165
  also have "\<dots> = Ders s (\<Union> lang ` (pder c r))" by (simp add: Der_pder)
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   166
  also have "\<dots> = Derss s (lang ` (pder c r))"
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   167
    by (auto simp add:  Ders_def)
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   168
  also have "\<dots> = \<Union> lang ` (pderss s (pder c r))"
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   169
    using ih by auto
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   170
  also have "\<dots> = \<Union> lang ` (pders (c # s) r)" by simp
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   171
  finally show "Ders (c # s) (lang r) = \<Union> lang ` pders (c # s) r" .
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   172
qed (simp add: Ders_def)
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   173
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   174
subsection {* Relating derivatives and partial derivatives *}
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   175
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   176
lemma
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   177
  shows "(\<Union> lang ` (pder c r)) = lang (der c r)"
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   178
unfolding Der_der[symmetric] Der_pder by simp
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   179
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   180
lemma
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   181
  shows "(\<Union> lang ` (pders s r)) = lang (ders s r)"
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   182
unfolding Ders_ders[symmetric] Ders_pders by simp
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   183
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   184
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   185
subsection {* There are only finitely many partial derivatives for a language *}
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   186
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   187
abbreviation
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   188
  "pders_set A r \<equiv> \<Union>s \<in> A. pders s r"
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   189
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   190
text {* Non-empty suffixes of a string *}
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   191
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   192
definition
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   193
  "Suf s \<equiv> {v. v \<noteq> [] \<and> (\<exists>u. u @ v = s)}"
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   194
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   195
lemma Suf_snoc:
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   196
  shows "Suf (s @ [c]) = (Suf s) \<cdot> {[c]} \<union> {[c]}"
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   197
unfolding Suf_def conc_def
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   198
by (auto simp add: append_eq_append_conv2 append_eq_Cons_conv)
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   199
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   200
lemma Suf_Union:
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   201
  shows "(\<Union>v \<in> Suf s \<cdot> {[c]}. f v) = (\<Union>v \<in> Suf s. f (v @ [c]))"
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   202
by (auto simp add: conc_def)
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   203
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   204
lemma pders_set_snoc:
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   205
  shows "pders_set (Suf s \<cdot> {[c]}) r = (pder_set c (pders_set (Suf s) r))"
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   206
by (simp add: Suf_Union pders_snoc)
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   207
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   208
lemma pders_Times:
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   209
  shows "pders s (Times r1 r2) \<subseteq> Timess (pders s r1) r2 \<union> (pders_set (Suf s) r2)"
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   210
proof (induct s rule: rev_induct)
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   211
  case (snoc c s)
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   212
  have ih: "pders s (Times r1 r2) \<subseteq> Timess (pders s r1) r2 \<union> (pders_set (Suf s) r2)" 
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   213
    by fact
179
edacc141060f small improvements
urbanc
parents: 174
diff changeset
   214
  have "pders (s @ [c]) (Times r1 r2) = pder_set c (pders s (Times r1 r2))" 
edacc141060f small improvements
urbanc
parents: 174
diff changeset
   215
    by (simp add: pders_snoc)
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   216
  also have "\<dots> \<subseteq> pder_set c (Timess (pders s r1) r2 \<union> (pders_set (Suf s) r2))"
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   217
    using ih by (auto) (blast)
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   218
  also have "\<dots> = pder_set c (Timess (pders s r1) r2) \<union> pder_set c (pders_set (Suf s) r2)"
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   219
    by (simp)
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   220
  also have "\<dots> = pder_set c (Timess (pders s r1) r2) \<union> pders_set (Suf s \<cdot> {[c]}) r2"
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   221
    by (simp add: pders_set_snoc)
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   222
  also have "\<dots> \<subseteq> pder_set c (Timess (pders s r1) r2) \<union> pder c r2 \<union> pders_set (Suf s \<cdot> {[c]}) r2"
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   223
    by auto
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   224
  also have "\<dots> \<subseteq> Timess (pders (s @ [c]) r1) r2 \<union> pder c r2 \<union> pders_set (Suf s \<cdot> {[c]}) r2"
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   225
    by (auto simp add: if_splits pders_snoc) (blast)
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   226
  also have "\<dots> = Timess (pders (s @ [c]) r1) r2 \<union> pders_set (Suf (s @ [c])) r2"
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   227
    by (auto simp add: Suf_snoc)  
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   228
  finally show ?case .
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   229
qed (simp) 
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   230
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   231
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   232
lemma pders_Star:
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   233
  assumes a: "s \<noteq> []"
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   234
  shows "pders s (Star r) \<subseteq> (\<Union>v \<in> Suf s. Timess (pders v r) (Star r))"
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   235
using a
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   236
proof (induct s rule: rev_induct)
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   237
  case (snoc c s)
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   238
  have ih: "s \<noteq> [] \<Longrightarrow> pders s (Star r) \<subseteq> (\<Union>v\<in>Suf s. Timess (pders v r) (Star r))" by fact
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   239
  { assume asm: "s \<noteq> []"
179
edacc141060f small improvements
urbanc
parents: 174
diff changeset
   240
    have "pders (s @ [c]) (Star r) = pder_set c (pders s (Star r))" by (simp add: pders_snoc)
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   241
    also have "\<dots> \<subseteq> (pder_set c (\<Union>v\<in>Suf s. Timess (pders v r) (Star r)))"
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   242
      using ih[OF asm] by (auto) (blast)
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   243
    also have "\<dots> = (\<Union>v\<in>Suf s. pder_set c (Timess (pders v r) (Star r)))"
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   244
      by simp
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   245
    also have "\<dots> \<subseteq> (\<Union>v\<in>Suf s. (Timess (pder_set c (pders v r)) (Star r) \<union> pder c (Star r)))"
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   246
      by (auto split: if_splits) 
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   247
    also have "\<dots> = (\<Union>v\<in>Suf s. (Timess (pder_set c (pders v r)) (Star r))) \<union> pder c (Star r)"
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   248
      using asm by (auto simp add: Suf_def)
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   249
    also have "\<dots> = (\<Union>v\<in>Suf s. (Timess (pders (v @ [c]) r) (Star r))) \<union> (Timess (pder c r) (Star r))"
179
edacc141060f small improvements
urbanc
parents: 174
diff changeset
   250
      by (simp add: pders_snoc)
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   251
    also have "\<dots> = (\<Union>v\<in>Suf (s @ [c]). (Timess (pders v r) (Star r)))"
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   252
      by (auto simp add: Suf_snoc Suf_Union pders_snoc)
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   253
    finally have ?case .
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   254
  }
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   255
  moreover
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   256
  { assume asm: "s = []"
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   257
    then have ?case
179
edacc141060f small improvements
urbanc
parents: 174
diff changeset
   258
      by (auto simp add: pders_snoc Suf_def)
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   259
  }
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   260
  ultimately show ?case by blast
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   261
qed (simp)
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   262
179
edacc141060f small improvements
urbanc
parents: 174
diff changeset
   263
definition
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   264
  "UNIV1 \<equiv> UNIV - {[]}"
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   265
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   266
lemma pders_set_Zero:
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   267
  shows "pders_set UNIV1 Zero = {Zero}"
179
edacc141060f small improvements
urbanc
parents: 174
diff changeset
   268
unfolding UNIV1_def by auto
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   269
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   270
lemma pders_set_One:
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   271
  shows "pders_set UNIV1 One = {Zero}"
179
edacc141060f small improvements
urbanc
parents: 174
diff changeset
   272
unfolding UNIV1_def by (auto split: if_splits)
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   273
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   274
lemma pders_set_Atom:
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   275
  shows "pders_set UNIV1 (Atom c) \<subseteq> {One, Zero}"
179
edacc141060f small improvements
urbanc
parents: 174
diff changeset
   276
unfolding UNIV1_def by (auto split: if_splits)
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   277
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   278
lemma pders_set_Plus:
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   279
  shows "pders_set UNIV1 (Plus r1 r2) = pders_set UNIV1 r1 \<union> pders_set UNIV1 r2"
179
edacc141060f small improvements
urbanc
parents: 174
diff changeset
   280
unfolding UNIV1_def by auto
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   281
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   282
lemma pders_set_Times_aux:
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   283
  assumes a: "s \<in> UNIV1"
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   284
  shows "pders_set (Suf s) r2 \<subseteq> pders_set UNIV1 r2"
179
edacc141060f small improvements
urbanc
parents: 174
diff changeset
   285
using a unfolding UNIV1_def Suf_def by (auto)
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   286
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   287
lemma pders_set_Times:
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   288
  shows "pders_set UNIV1 (Times r1 r2) \<subseteq> Timess (pders_set UNIV1 r1) r2 \<union> pders_set UNIV1 r2"
179
edacc141060f small improvements
urbanc
parents: 174
diff changeset
   289
unfolding UNIV1_def
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   290
apply(rule UN_least)
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   291
apply(rule subset_trans)
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   292
apply(rule pders_Times)
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   293
apply(simp)
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   294
apply(rule conjI) 
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   295
apply(auto)[1]
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   296
apply(rule subset_trans)
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   297
apply(rule pders_set_Times_aux)
179
edacc141060f small improvements
urbanc
parents: 174
diff changeset
   298
apply(auto simp add: UNIV1_def)
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   299
done
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   300
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   301
lemma pders_set_Star:
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   302
  shows "pders_set UNIV1 (Star r) \<subseteq> Timess (pders_set UNIV1 r) (Star r)"
179
edacc141060f small improvements
urbanc
parents: 174
diff changeset
   303
unfolding UNIV1_def
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   304
apply(rule UN_least)
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   305
apply(rule subset_trans)
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   306
apply(rule pders_Star)
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   307
apply(simp)
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   308
apply(simp add: Suf_def)
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   309
apply(auto)
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   310
done
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   311
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   312
lemma finite_Timess:
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   313
  assumes a: "finite A"
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   314
  shows "finite (Timess A r)"
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   315
using a by (auto)
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   316
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   317
lemma finite_pders_set_UNIV1:
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   318
  shows "finite (pders_set UNIV1 r)"
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   319
apply(induct r)
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   320
apply(simp)
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   321
apply(simp only: pders_set_One)
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   322
apply(simp)
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   323
apply(rule finite_subset)
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   324
apply(rule pders_set_Atom)
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   325
apply(simp)
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   326
apply(simp only: pders_set_Plus)
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   327
apply(simp)
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   328
apply(rule finite_subset)
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   329
apply(rule pders_set_Times)
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   330
apply(simp only: finite_Timess finite_Un)
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   331
apply(simp)
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   332
apply(rule finite_subset)
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   333
apply(rule pders_set_Star)
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 181
diff changeset
   334
apply(simp only: finite_Timess)
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   335
done
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   336
    
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   337
lemma pders_set_UNIV_UNIV1:
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   338
  shows "pders_set UNIV r = pders [] r \<union> pders_set UNIV1 r"
179
edacc141060f small improvements
urbanc
parents: 174
diff changeset
   339
unfolding UNIV1_def
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   340
apply(auto)
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   341
apply(rule_tac x="[]" in exI)
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   342
apply(simp)
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   343
done
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   344
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   345
lemma finite_pders_set_UNIV:
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   346
  shows "finite (pders_set UNIV r)"
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   347
unfolding pders_set_UNIV_UNIV1
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   348
by (simp add: finite_pders_set_UNIV1)
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   349
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   350
lemma finite_pders_set:
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   351
  shows "finite (pders_set A r)"
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   352
apply(rule rev_finite_subset)
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   353
apply(rule_tac r="r" in finite_pders_set_UNIV)
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   354
apply(auto)
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   355
done
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   356
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   357
lemma finite_pders:
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   358
  shows "finite (pders s r)"
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   359
using finite_pders_set[where A="{s}" and r="r"]
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   360
by simp
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   361
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   362
lemma finite_pders2:
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   363
  shows "finite {pders s r | s. s \<in> A}"
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   364
proof -
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   365
  have "{pders s r | s. s \<in> A} \<subseteq> Pow (pders_set A r)" by auto
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   366
  moreover
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   367
  have "finite (Pow (pders_set A r))"
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   368
    using finite_pders_set by simp
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   369
  ultimately 
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   370
  show "finite {pders s r | s. s \<in> A}"
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   371
    by(rule finite_subset)
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   372
qed
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   373
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   374
179
edacc141060f small improvements
urbanc
parents: 174
diff changeset
   375
text {* Relating the Myhill-Nerode relation with left-quotients. *}
edacc141060f small improvements
urbanc
parents: 174
diff changeset
   376
edacc141060f small improvements
urbanc
parents: 174
diff changeset
   377
lemma MN_Rel_Ders:
edacc141060f small improvements
urbanc
parents: 174
diff changeset
   378
  shows "x \<approx>A y \<longleftrightarrow> Ders x A = Ders y A"
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   379
unfolding Ders_def str_eq_def
179
edacc141060f small improvements
urbanc
parents: 174
diff changeset
   380
by auto
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   381
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   382
subsection {*
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   383
  The second direction of the Myhill-Nerode theorem using
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   384
  partial derivatives.
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   385
*}
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   386
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   387
lemma Myhill_Nerode3:
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   388
  fixes r::"'a rexp"
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   389
  shows "finite (UNIV // \<approx>(lang r))"
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   390
proof -
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   391
  have "finite (UNIV // =(\<lambda>x. pders x r)=)"
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   392
  proof - 
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   393
    have "range (\<lambda>x. pders x r) = {pders s r | s. s \<in> UNIV}" by auto
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   394
    moreover 
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   395
    have "finite {pders s r | s. s \<in> UNIV}" by (rule finite_pders2)
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   396
    ultimately
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   397
    have "finite (range (\<lambda>x. pders x r))"
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   398
      by simp
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   399
    then show "finite (UNIV // =(\<lambda>x. pders x r)=)" 
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   400
      by (rule finite_eq_tag_rel)
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   401
  qed
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   402
  moreover 
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   403
  have "=(\<lambda>x. pders x r)= \<subseteq> \<approx>(lang r)"
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   404
    unfolding tag_eq_def
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   405
    by (auto simp add: MN_Rel_Ders Ders_pders)
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   406
  moreover 
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   407
  have "equiv UNIV =(\<lambda>x. pders x r)="
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   408
    unfolding equiv_def refl_on_def sym_def trans_def
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   409
    unfolding tag_eq_def
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   410
    by auto
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   411
  moreover
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   412
  have "equiv UNIV (\<approx>(lang r))"
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   413
    unfolding equiv_def refl_on_def sym_def trans_def
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   414
    unfolding str_eq_def
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   415
    by auto
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   416
  ultimately show "finite (UNIV // \<approx>(lang r))" 
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   417
    by (rule refined_partition_finite)
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   418
qed
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   419
179
edacc141060f small improvements
urbanc
parents: 174
diff changeset
   420
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff changeset
   421
end