Myhill_2.thy
author urbanc
Tue, 26 Jul 2011 10:58:26 +0000
changeset 173 d371536861bc
parent 170 b1258b7d2789
child 180 b755090d0f3d
permissions -rw-r--r--
more on the introduction of the journal paper
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
     1
theory Myhill_2
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
     2
  imports Myhill_1 Prefix_subtract
149
e122cb146ecc added the most current versions of the theories.
urbanc
parents: 132
diff changeset
     3
          "~~/src/HOL/Library/List_Prefix"
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
     4
begin
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
     5
166
7743d2ad71d1 updated theories and itp-paper
urbanc
parents: 162
diff changeset
     6
section {* Direction @{text "regular language \<Rightarrow> finite partition"} *}
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
     7
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
     8
definition
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
     9
  str_eq :: "'a list \<Rightarrow> 'a lang \<Rightarrow> 'a list \<Rightarrow> bool" ("_ \<approx>_ _")
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
    10
where
75
d63baacbdb16 parts of the 3 section
urbanc
parents: 63
diff changeset
    11
  "x \<approx>A y \<equiv> (x, y) \<in> (\<approx>A)"
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
    12
166
7743d2ad71d1 updated theories and itp-paper
urbanc
parents: 162
diff changeset
    13
lemma str_eq_def2:
7743d2ad71d1 updated theories and itp-paper
urbanc
parents: 162
diff changeset
    14
  shows "\<approx>A = {(x, y) | x y. x \<approx>A y}"
7743d2ad71d1 updated theories and itp-paper
urbanc
parents: 162
diff changeset
    15
unfolding str_eq_def
7743d2ad71d1 updated theories and itp-paper
urbanc
parents: 162
diff changeset
    16
by simp
7743d2ad71d1 updated theories and itp-paper
urbanc
parents: 162
diff changeset
    17
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
    18
definition 
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
    19
   tag_eq_rel :: "('a list \<Rightarrow> 'b) \<Rightarrow> ('a list \<times> 'a list) set" ("=_=")
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
    20
where
166
7743d2ad71d1 updated theories and itp-paper
urbanc
parents: 162
diff changeset
    21
   "=tag= \<equiv> {(x, y). tag x = tag y}"
117
22ba25b808c8 updated second direction
urbanc
parents: 113
diff changeset
    22
22ba25b808c8 updated second direction
urbanc
parents: 113
diff changeset
    23
lemma finite_eq_tag_rel:
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
    24
  assumes rng_fnt: "finite (range tag)"
109
79b37ef9505f minor updated
urbanc
parents: 99
diff changeset
    25
  shows "finite (UNIV // =tag=)"
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
    26
proof -
119
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
    27
  let "?f" =  "\<lambda>X. tag ` X" and ?A = "(UNIV // =tag=)"
118
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    28
  have "finite (?f ` ?A)" 
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    29
  proof -
119
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
    30
    have "range ?f \<subseteq> (Pow (range tag))" unfolding Pow_def by auto
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
    31
    moreover 
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
    32
    have "finite (Pow (range tag))" using rng_fnt by simp
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
    33
    ultimately 
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
    34
    have "finite (range ?f)" unfolding image_def by (blast intro: finite_subset)
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
    35
    moreover
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
    36
    have "?f ` ?A \<subseteq> range ?f" by auto
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
    37
    ultimately show "finite (?f ` ?A)" by (rule rev_finite_subset) 
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
    38
  qed
118
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    39
  moreover
119
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
    40
  have "inj_on ?f ?A"
118
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    41
  proof -
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    42
    { fix X Y
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    43
      assume X_in: "X \<in> ?A"
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    44
        and  Y_in: "Y \<in> ?A"
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    45
        and  tag_eq: "?f X = ?f Y"
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
    46
      then obtain x y 
119
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
    47
        where "x \<in> X" "y \<in> Y" "tag x = tag y"
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
    48
        unfolding quotient_def Image_def image_def tag_eq_rel_def
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
    49
        by (simp) (blast)
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
    50
      with X_in Y_in 
118
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    51
      have "X = Y"
119
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
    52
	unfolding quotient_def tag_eq_rel_def by auto
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
    53
    } 
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
    54
    then show "inj_on ?f ?A" unfolding inj_on_def by auto
118
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    55
  qed
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
    56
  ultimately show "finite (UNIV // =tag=)" by (rule finite_imageD)
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
    57
qed
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
    58
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
    59
lemma refined_partition_finite:
118
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    60
  assumes fnt: "finite (UNIV // R1)"
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
    61
  and refined: "R1 \<subseteq> R2"
118
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    62
  and eq1: "equiv UNIV R1" and eq2: "equiv UNIV R2"
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    63
  shows "finite (UNIV // R2)"
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
    64
proof -
118
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    65
  let ?f = "\<lambda>X. {R1 `` {x} | x. x \<in> X}" 
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    66
    and ?A = "UNIV // R2" and ?B = "UNIV // R1"
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    67
  have "?f ` ?A \<subseteq> Pow ?B"
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    68
    unfolding image_def Pow_def quotient_def by auto
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    69
  moreover
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    70
  have "finite (Pow ?B)" using fnt by simp
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    71
  ultimately  
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    72
  have "finite (?f ` ?A)" by (rule finite_subset)
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    73
  moreover
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    74
  have "inj_on ?f ?A"
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    75
  proof -
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    76
    { fix X Y
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    77
      assume X_in: "X \<in> ?A" and Y_in: "Y \<in> ?A" and eq_f: "?f X = ?f Y"
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    78
      from quotientE [OF X_in]
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    79
      obtain x where "X = R2 `` {x}" by blast
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    80
      with equiv_class_self[OF eq2] have x_in: "x \<in> X" by simp
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    81
      then have "R1 ``{x} \<in> ?f X" by auto
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    82
      with eq_f have "R1 `` {x} \<in> ?f Y" by simp
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    83
      then obtain y 
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    84
        where y_in: "y \<in> Y" and eq_r1_xy: "R1 `` {x} = R1 `` {y}" by auto
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    85
      with eq_equiv_class[OF _ eq1] 
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    86
      have "(x, y) \<in> R1" by blast
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    87
      with refined have "(x, y) \<in> R2" by auto
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    88
      with quotient_eqI [OF eq2 X_in Y_in x_in y_in]
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    89
      have "X = Y" .
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    90
    } 
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    91
    then show "inj_on ?f ?A" unfolding inj_on_def by blast 
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
    92
  qed
118
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    93
  ultimately show "finite (UNIV // R2)" by (rule finite_imageD)
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
    94
qed
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
    95
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
    96
lemma tag_finite_imageD:
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
    97
  assumes rng_fnt: "finite (range tag)" 
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
    98
  and same_tag_eqvt: "\<And>m n. tag m = tag n \<Longrightarrow> m \<approx>A n"
119
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
    99
  shows "finite (UNIV // \<approx>A)"
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
   100
proof (rule_tac refined_partition_finite [of "=tag="])
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
   101
  show "finite (UNIV // =tag=)" by (rule finite_eq_tag_rel[OF rng_fnt])
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
   102
next
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
   103
  from same_tag_eqvt
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
   104
  show "=tag= \<subseteq> \<approx>A" unfolding tag_eq_rel_def str_eq_def
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
   105
    by auto
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
   106
next
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
   107
  show "equiv UNIV =tag="
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
   108
    unfolding equiv_def tag_eq_rel_def refl_on_def sym_def trans_def
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
   109
    by auto
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
   110
next
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
   111
  show "equiv UNIV (\<approx>A)" 
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
   112
    unfolding equiv_def str_eq_rel_def sym_def refl_on_def trans_def
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
   113
    by blast
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   114
qed
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   115
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   116
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   117
subsection {* The proof *}
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   118
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   119
subsubsection {* The base case for @{const "Zero"} *}
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   120
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   121
lemma quot_zero_eq:
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   122
  shows "UNIV // \<approx>{} = {UNIV}"
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   123
unfolding quotient_def Image_def str_eq_rel_def by auto
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   124
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   125
lemma quot_zero_finiteI [intro]:
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   126
  shows "finite (UNIV // \<approx>{})"
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   127
unfolding quot_zero_eq by simp
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   128
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   129
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   130
subsubsection {* The base case for @{const "One"} *}
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   131
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   132
lemma quot_one_subset:
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   133
  shows "UNIV // \<approx>{[]} \<subseteq> {{[]}, UNIV - {[]}}"
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   134
proof
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   135
  fix x
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   136
  assume "x \<in> UNIV // \<approx>{[]}"
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   137
  then obtain y where h: "x = {z. (y, z) \<in> \<approx>{[]}}" 
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   138
    unfolding quotient_def Image_def by blast
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   139
  show "x \<in> {{[]}, UNIV - {[]}}"
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   140
  proof (cases "y = []")
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   141
    case True with h
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   142
    have "x = {[]}" by (auto simp: str_eq_rel_def)
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   143
    thus ?thesis by simp
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   144
  next
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   145
    case False with h
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   146
    have "x = UNIV - {[]}" by (auto simp: str_eq_rel_def)
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   147
    thus ?thesis by simp
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   148
  qed
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   149
qed
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   150
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   151
lemma quot_one_finiteI [intro]:
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   152
  shows "finite (UNIV // \<approx>{[]})"
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   153
by (rule finite_subset[OF quot_one_subset]) (simp)
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   154
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   155
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   156
subsubsection {* The base case for @{const "Atom"} *}
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   157
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   158
lemma quot_atom_subset:
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   159
  "UNIV // (\<approx>{[c]}) \<subseteq> {{[]},{[c]}, UNIV - {[], [c]}}"
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   160
proof 
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   161
  fix x 
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   162
  assume "x \<in> UNIV // \<approx>{[c]}"
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   163
  then obtain y where h: "x = {z. (y, z) \<in> \<approx>{[c]}}" 
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   164
    unfolding quotient_def Image_def by blast
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   165
  show "x \<in> {{[]},{[c]}, UNIV - {[], [c]}}"
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   166
  proof -
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   167
    { assume "y = []" hence "x = {[]}" using h 
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   168
        by (auto simp:str_eq_rel_def) } 
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   169
    moreover 
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   170
    { assume "y = [c]" hence "x = {[c]}" using h 
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   171
        by (auto dest!:spec[where x = "[]"] simp:str_eq_rel_def) } 
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   172
    moreover 
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   173
    { assume "y \<noteq> []" and "y \<noteq> [c]"
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   174
      hence "\<forall> z. (y @ z) \<noteq> [c]" by (case_tac y, auto)
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   175
      moreover have "\<And> p. (p \<noteq> [] \<and> p \<noteq> [c]) = (\<forall> q. p @ q \<noteq> [c])" 
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   176
        by (case_tac p, auto)
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   177
      ultimately have "x = UNIV - {[],[c]}" using h
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   178
        by (auto simp add:str_eq_rel_def)
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   179
    } 
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   180
    ultimately show ?thesis by blast
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   181
  qed
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   182
qed
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   183
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   184
lemma quot_atom_finiteI [intro]:
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   185
  shows "finite (UNIV // \<approx>{[c]})"
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   186
by (rule finite_subset[OF quot_atom_subset]) (simp)
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   187
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   188
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   189
subsubsection {* The inductive case for @{const Plus} *}
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   190
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   191
definition 
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   192
  tag_str_Plus :: "'a lang \<Rightarrow> 'a lang \<Rightarrow> 'a list \<Rightarrow> ('a lang \<times> 'a lang)"
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   193
where
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   194
  "tag_str_Plus A B \<equiv> (\<lambda>x. (\<approx>A `` {x}, \<approx>B `` {x}))"
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   195
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   196
lemma quot_union_finiteI [intro]:
119
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
   197
  assumes finite1: "finite (UNIV // \<approx>A)"
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
   198
  and     finite2: "finite (UNIV // \<approx>B)"
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
   199
  shows "finite (UNIV // \<approx>(A \<union> B))"
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   200
proof (rule_tac tag = "tag_str_Plus A B" in tag_finite_imageD)
119
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
   201
  have "finite ((UNIV // \<approx>A) \<times> (UNIV // \<approx>B))" 
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
   202
    using finite1 finite2 by auto
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   203
  then show "finite (range (tag_str_Plus A B))"
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   204
    unfolding tag_str_Plus_def quotient_def
119
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
   205
    by (rule rev_finite_subset) (auto)
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
   206
next
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   207
  show "\<And>x y. tag_str_Plus A B x = tag_str_Plus A B y \<Longrightarrow> x \<approx>(A \<union> B) y"
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   208
    unfolding tag_str_Plus_def
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   209
    unfolding str_eq_def
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   210
    unfolding str_eq_rel_def
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   211
    by auto
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   212
qed
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   213
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   214
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   215
subsubsection {* The inductive case for @{text "Times"}*}
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   216
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   217
definition 
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   218
  tag_str_Times :: "'a lang \<Rightarrow> 'a lang \<Rightarrow> 'a list \<Rightarrow> ('a lang \<times> 'a lang set)"
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   219
where
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   220
  "tag_str_Times L1 L2 \<equiv>
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   221
     (\<lambda>x. (\<approx>L1 `` {x}, {(\<approx>L2 `` {x - xa}) | xa.  xa \<le> x \<and> xa \<in> L1}))"
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   222
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   223
lemma Seq_in_cases:
166
7743d2ad71d1 updated theories and itp-paper
urbanc
parents: 162
diff changeset
   224
  assumes "x @ z \<in> A \<cdot> B"
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   225
  shows "(\<exists> x' \<le> x. x' \<in> A \<and> (x - x') @ z \<in> B) \<or> 
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   226
         (\<exists> z' \<le> z. (x @ z') \<in> A \<and> (z - z') \<in> B)"
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   227
using assms
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   228
unfolding conc_def prefix_def
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   229
by (auto simp add: append_eq_append_conv2)
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
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: 166
diff changeset
   231
lemma tag_str_Times_injI:
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   232
  assumes eq_tag: "tag_str_Times A B x = tag_str_Times A B y" 
166
7743d2ad71d1 updated theories and itp-paper
urbanc
parents: 162
diff changeset
   233
  shows "x \<approx>(A \<cdot> B) y"
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   234
proof -
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   235
  { fix x y z
166
7743d2ad71d1 updated theories and itp-paper
urbanc
parents: 162
diff changeset
   236
    assume xz_in_seq: "x @ z \<in> A \<cdot> B"
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   237
    and tag_xy: "tag_str_Times A B x = tag_str_Times A B y"
166
7743d2ad71d1 updated theories and itp-paper
urbanc
parents: 162
diff changeset
   238
    have"y @ z \<in> A \<cdot> B" 
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   239
    proof -
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   240
      { (* first case with x' in A and (x - x') @ z in B *)
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   241
        fix x'
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   242
        assume h1: "x' \<le> x" and h2: "x' \<in> A" and h3: "(x - x') @ z \<in> B"
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   243
        obtain y' 
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   244
          where "y' \<le> y" 
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   245
          and "y' \<in> A" 
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   246
          and "(y - y') @ z \<in> B"
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   247
        proof -
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   248
          have "{\<approx>B `` {x - x'} |x'. x' \<le> x \<and> x' \<in> A} = 
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   249
                {\<approx>B `` {y - y'} |y'. y' \<le> y \<and> y' \<in> A}" (is "?Left = ?Right")
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   250
            using tag_xy unfolding tag_str_Times_def by simp
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   251
          moreover 
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   252
	  have "\<approx>B `` {x - x'} \<in> ?Left" using h1 h2 by auto
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   253
          ultimately 
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   254
	  have "\<approx>B `` {x - x'} \<in> ?Right" by simp
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   255
          then obtain y' 
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   256
            where eq_xy': "\<approx>B `` {x - x'} = \<approx>B `` {y - y'}" 
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   257
            and pref_y': "y' \<le> y" and y'_in: "y' \<in> A"
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   258
            by simp blast
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   259
	  
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   260
	  have "(x - x')  \<approx>B (y - y')" using eq_xy'
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   261
            unfolding Image_def str_eq_rel_def str_eq_def by auto
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   262
          with h3 have "(y - y') @ z \<in> B" 
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   263
	    unfolding str_eq_rel_def str_eq_def by simp
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   264
          with pref_y' y'_in 
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   265
          show ?thesis using that by blast
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   266
        qed
166
7743d2ad71d1 updated theories and itp-paper
urbanc
parents: 162
diff changeset
   267
	then have "y @ z \<in> A \<cdot> B" by (erule_tac prefixE) (auto simp: Seq_def)
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   268
      } 
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   269
      moreover 
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   270
      { (* second case with x @ z' in A and z - z' in B *)
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   271
        fix z'
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   272
        assume h1: "z' \<le> z" and h2: "(x @ z') \<in> A" and h3: "z - z' \<in> B"
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   273
	 have "\<approx>A `` {x} = \<approx>A `` {y}" 
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   274
           using tag_xy unfolding tag_str_Times_def by simp
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   275
         with h2 have "y @ z' \<in> A"
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   276
            unfolding Image_def str_eq_rel_def str_eq_def by auto
166
7743d2ad71d1 updated theories and itp-paper
urbanc
parents: 162
diff changeset
   277
        with h1 h3 have "y @ z \<in> A \<cdot> B"
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   278
	  unfolding prefix_def conc_def
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   279
	  by (auto) (metis append_assoc)
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   280
      }
166
7743d2ad71d1 updated theories and itp-paper
urbanc
parents: 162
diff changeset
   281
      ultimately show "y @ z \<in> A \<cdot> B" 
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   282
	using Seq_in_cases [OF xz_in_seq] by blast
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   283
    qed
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   284
  }
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   285
  from this [OF _ eq_tag] and this [OF _ eq_tag [THEN sym]]
166
7743d2ad71d1 updated theories and itp-paper
urbanc
parents: 162
diff changeset
   286
    show "x \<approx>(A \<cdot> B) y" unfolding str_eq_def str_eq_rel_def by blast
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   287
qed 
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   288
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   289
lemma quot_seq_finiteI [intro]:
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   290
  fixes L1 L2::"'a lang"
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   291
  assumes fin1: "finite (UNIV // \<approx>L1)" 
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   292
  and     fin2: "finite (UNIV // \<approx>L2)" 
166
7743d2ad71d1 updated theories and itp-paper
urbanc
parents: 162
diff changeset
   293
  shows "finite (UNIV // \<approx>(L1 \<cdot> L2))"
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   294
proof (rule_tac tag = "tag_str_Times L1 L2" in tag_finite_imageD)
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   295
  show "\<And>x y. tag_str_Times L1 L2 x = tag_str_Times L1 L2 y \<Longrightarrow> x \<approx>(L1 \<cdot> L2) y"
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   296
    by (rule tag_str_Times_injI)
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   297
next
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   298
  have *: "finite ((UNIV // \<approx>L1) \<times> (Pow (UNIV // \<approx>L2)))" 
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   299
    using fin1 fin2 by auto
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   300
  show "finite (range (tag_str_Times L1 L2))" 
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   301
    unfolding tag_str_Times_def
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   302
    apply(rule finite_subset[OF _ *])
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   303
    unfolding quotient_def
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   304
    by auto
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   305
qed
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   306
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   307
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   308
subsubsection {* The inductive case for @{const "Star"} *}
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   309
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   310
definition 
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   311
  tag_str_Star :: "'a lang \<Rightarrow> 'a list \<Rightarrow> ('a lang) set"
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   312
where
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   313
  "tag_str_Star L1 \<equiv> (\<lambda>x. {\<approx>L1 `` {x - xa} | xa. xa < x \<and> xa \<in> L1\<star>})"
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   314
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   315
text {* A technical lemma. *}
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   316
lemma finite_set_has_max: "\<lbrakk>finite A; A \<noteq> {}\<rbrakk> \<Longrightarrow> 
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   317
           (\<exists> max \<in> A. \<forall> a \<in> A. f a <= (f max :: nat))"
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   318
proof (induct rule:finite.induct)
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   319
  case emptyI thus ?case by simp
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   320
next
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   321
  case (insertI A a)
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   322
  show ?case
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   323
  proof (cases "A = {}")
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   324
    case True thus ?thesis by (rule_tac x = a in bexI, auto)
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   325
  next
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   326
    case False
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   327
    with insertI.hyps and False  
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   328
    obtain max 
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   329
      where h1: "max \<in> A" 
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   330
      and h2: "\<forall>a\<in>A. f a \<le> f max" by blast
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   331
    show ?thesis
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   332
    proof (cases "f a \<le> f max")
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   333
      assume "f a \<le> f max"
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   334
      with h1 h2 show ?thesis by (rule_tac x = max in bexI, auto)
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   335
    next
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   336
      assume "\<not> (f a \<le> f max)"
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   337
      thus ?thesis using h2 by (rule_tac x = a in bexI, auto)
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   338
    qed
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   339
  qed
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   340
qed
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   341
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   342
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   343
text {* The following is a technical lemma, which helps to show the range finiteness of tag function. *}
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   344
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   345
lemma finite_strict_prefix_set: 
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   346
  shows "finite {xa. xa < (x::'a list)}"
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   347
apply (induct x rule:rev_induct, simp)
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   348
apply (subgoal_tac "{xa. xa < xs @ [x]} = {xa. xa < xs} \<union> {xs}")
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   349
by (auto simp:strict_prefix_def)
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   350
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   351
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   352
lemma tag_str_Star_injI:
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   353
  fixes L\<^isub>1::"('a::finite) lang"
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   354
  assumes eq_tag: "tag_str_Star L\<^isub>1 v = tag_str_Star L\<^isub>1 w"
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   355
  shows "v \<approx>(L\<^isub>1\<star>) w"
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   356
proof-
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   357
  { fix x y z
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   358
    assume xz_in_star: "x @ z \<in> L\<^isub>1\<star>" 
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   359
      and tag_xy: "tag_str_Star L\<^isub>1 x = tag_str_Star L\<^isub>1 y"
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   360
    have "y @ z \<in> L\<^isub>1\<star>"
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   361
    proof(cases "x = []")
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   362
      case True
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   363
      with tag_xy have "y = []" 
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   364
        by (auto simp add: tag_str_Star_def strict_prefix_def)
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   365
      thus ?thesis using xz_in_star True by simp
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   366
    next
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   367
      case False
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   368
      let ?S = "{xa::('a::finite) list. xa < x \<and> xa \<in> L\<^isub>1\<star> \<and> (x - xa) @ z \<in> L\<^isub>1\<star>}"
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   369
      have "finite ?S"
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   370
	by (rule_tac B = "{xa. xa < x}" in finite_subset)
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   371
	   (auto simp: finite_strict_prefix_set)
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   372
      moreover have "?S \<noteq> {}" using False xz_in_star
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   373
        by (simp, rule_tac x = "[]" in exI, auto simp:strict_prefix_def)
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   374
      ultimately have "\<exists> xa_max \<in> ?S. \<forall> xa \<in> ?S. length xa \<le> length xa_max" 
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   375
        using finite_set_has_max by blast
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   376
      then obtain xa_max 
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   377
        where h1: "xa_max < x" 
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   378
        and h2: "xa_max \<in> L\<^isub>1\<star>" 
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   379
        and h3: "(x - xa_max) @ z \<in> L\<^isub>1\<star>" 
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   380
        and h4:"\<forall> xa < x. xa \<in> L\<^isub>1\<star> \<and> (x - xa) @ z \<in> L\<^isub>1\<star>  
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   381
                                     \<longrightarrow> length xa \<le> length xa_max"
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   382
        by blast
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   383
      obtain ya 
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   384
        where h5: "ya < y" and h6: "ya \<in> L\<^isub>1\<star>" 
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   385
        and eq_xya: "(x - xa_max) \<approx>L\<^isub>1 (y - ya)"
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   386
      proof-
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   387
        from tag_xy have "{\<approx>L\<^isub>1 `` {x - xa} |xa. xa < x \<and> xa \<in> L\<^isub>1\<star>} = 
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   388
          {\<approx>L\<^isub>1 `` {y - xa} |xa. xa < y \<and> xa \<in> L\<^isub>1\<star>}" (is "?left = ?right")
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   389
          by (auto simp:tag_str_Star_def)
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   390
        moreover have "\<approx>L\<^isub>1 `` {x - xa_max} \<in> ?left" using h1 h2 by auto
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   391
        ultimately have "\<approx>L\<^isub>1 `` {x - xa_max} \<in> ?right" by simp
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   392
        thus ?thesis using that 
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   393
          apply (simp add:Image_def str_eq_rel_def str_eq_def) by blast
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   394
      qed 
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   395
      have "(y - ya) @ z \<in> L\<^isub>1\<star>" 
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   396
      proof-
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   397
        obtain za zb where eq_zab: "z = za @ zb" 
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   398
          and l_za: "(y - ya)@za \<in> L\<^isub>1" and ls_zb: "zb \<in> L\<^isub>1\<star>"
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   399
        proof -
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   400
          from h1 have "(x - xa_max) @ z \<noteq> []" 
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   401
            by (auto simp:strict_prefix_def elim:prefixE)
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   402
          from star_decom [OF h3 this]
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   403
          obtain a b where a_in: "a \<in> L\<^isub>1" 
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   404
            and a_neq: "a \<noteq> []" and b_in: "b \<in> L\<^isub>1\<star>" 
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   405
            and ab_max: "(x - xa_max) @ z = a @ b" by blast
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   406
          let ?za = "a - (x - xa_max)" and ?zb = "b"
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   407
          have pfx: "(x - xa_max) \<le> a" (is "?P1") 
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   408
            and eq_z: "z = ?za @ ?zb" (is "?P2")
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   409
          proof -
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   410
            have "((x - xa_max) \<le> a \<and> (a - (x - xa_max)) @ b = z) \<or> 
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   411
              (a < (x - xa_max) \<and> ((x - xa_max) - a) @ z = b)" 
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   412
              using append_eq_dest[OF ab_max] by (auto simp:strict_prefix_def)
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   413
            moreover {
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   414
              assume np: "a < (x - xa_max)" 
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   415
                and b_eqs: "((x - xa_max) - a) @ z = b"
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   416
              have "False"
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   417
              proof -
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   418
                let ?xa_max' = "xa_max @ a"
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   419
                have "?xa_max' < x" 
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   420
                  using np h1 by (clarsimp simp:strict_prefix_def diff_prefix) 
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   421
                moreover have "?xa_max' \<in> L\<^isub>1\<star>" 
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   422
                  using a_in h2 by (auto)
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   423
                moreover have "(x - ?xa_max') @ z \<in> L\<^isub>1\<star>" 
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   424
                  using b_eqs b_in np h1 by (simp add:diff_diff_append)
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   425
                moreover have "\<not> (length ?xa_max' \<le> length xa_max)" 
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   426
                  using a_neq by simp
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   427
                ultimately show ?thesis using h4 by blast
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   428
              qed }
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   429
            ultimately show ?P1 and ?P2 by auto
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   430
          qed
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   431
          hence "(x - xa_max)@?za \<in> L\<^isub>1" using a_in by (auto elim:prefixE)
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   432
          with eq_xya have "(y - ya) @ ?za \<in> L\<^isub>1" 
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   433
            by (auto simp:str_eq_def str_eq_rel_def)
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   434
           with eq_z and b_in 
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   435
          show ?thesis using that by blast
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   436
        qed
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   437
        have "((y - ya) @ za) @ zb \<in> L\<^isub>1\<star>" using  l_za ls_zb 
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   438
	  by (rule_tac append_in_starI) (auto)
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   439
        with eq_zab show ?thesis by simp
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   440
      qed
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   441
      with h5 h6 show ?thesis 	
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   442
        by (auto simp:strict_prefix_def elim: prefixE)
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   443
    qed
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   444
  } 
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   445
  from this [OF _ eq_tag] and this [OF _ eq_tag [THEN sym]]
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   446
    show  ?thesis unfolding str_eq_def str_eq_rel_def by blast
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   447
qed
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   448
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   449
lemma quot_star_finiteI [intro]:
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   450
   fixes A::"('a::finite) lang"
166
7743d2ad71d1 updated theories and itp-paper
urbanc
parents: 162
diff changeset
   451
  assumes finite1: "finite (UNIV // \<approx>A)"
7743d2ad71d1 updated theories and itp-paper
urbanc
parents: 162
diff changeset
   452
  shows "finite (UNIV // \<approx>(A\<star>))"
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   453
proof (rule_tac tag = "tag_str_Star A" in tag_finite_imageD)
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   454
  show "\<And>x y. tag_str_Star A x = tag_str_Star A y \<Longrightarrow> x \<approx>(A\<star>) y"
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   455
    by (rule tag_str_Star_injI)
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   456
next
166
7743d2ad71d1 updated theories and itp-paper
urbanc
parents: 162
diff changeset
   457
  have *: "finite (Pow (UNIV // \<approx>A))" 
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   458
    using finite1 by auto
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   459
  show "finite (range (tag_str_Star A))"
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   460
    unfolding tag_str_Star_def
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   461
    apply(rule finite_subset[OF _ *])
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   462
    unfolding quotient_def
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   463
    by auto
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   464
qed
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   465
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   466
subsubsection{* The conclusion *}
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   467
112
62fdb4bf7239 more on the conclusion
urbanc
parents: 109
diff changeset
   468
lemma Myhill_Nerode2:
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   469
  fixes r::"('a::finite) rexp"
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   470
  shows "finite (UNIV // \<approx>(lang r))"
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   471
by (induct r) (auto)
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   472
132
f77a7138f791 comments by Xingyuan
urbanc
parents: 128
diff changeset
   473
theorem Myhill_Nerode:
170
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   474
  fixes A::"('a::finite) lang"
b1258b7d2789 made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents: 166
diff changeset
   475
  shows "(\<exists>r. A = lang r) \<longleftrightarrow> finite (UNIV // \<approx>A)"
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   476
using Myhill_Nerode1 Myhill_Nerode2 by auto
112
62fdb4bf7239 more on the conclusion
urbanc
parents: 109
diff changeset
   477
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   478
end