Myhill_2.thy
author urbanc
Sun, 31 Jul 2011 10:27:41 +0000
changeset 181 97090fc7aa9f
parent 180 b755090d0f3d
child 182 560712a29a36
permissions -rw-r--r--
some experiments with the proofs in Myhill_2
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 
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
     9
   tag_eq :: "('a list \<Rightarrow> 'b) \<Rightarrow> ('a list \<times> 'a list) set" ("=_=")
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
    10
where
166
7743d2ad71d1 updated theories and itp-paper
urbanc
parents: 162
diff changeset
    11
   "=tag= \<equiv> {(x, y). tag x = tag y}"
117
22ba25b808c8 updated second direction
urbanc
parents: 113
diff changeset
    12
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
    13
abbreviation
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
    14
   tag_eq_applied :: "'a list \<Rightarrow> ('a list \<Rightarrow> 'b) \<Rightarrow> 'a list \<Rightarrow> bool" ("_ =_= _")
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
    15
where
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
    16
   "x =tag= y \<equiv> (x, y) \<in> =tag="
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
    17
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
    18
lemma test:
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
    19
  shows "(\<approx>A) `` {x} = (\<approx>A) `` {y} \<longleftrightarrow> x \<approx>A y"
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
    20
unfolding str_eq_def
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
    21
by auto
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
    22
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
    23
lemma test_refined_intro:
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
    24
  assumes "\<And>x y z. \<lbrakk>x =tag= y; x @ z \<in> A\<rbrakk> \<Longrightarrow> y @ z \<in> A"
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
    25
  shows "=tag= \<subseteq> \<approx>A"
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
    26
using assms
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
    27
unfolding str_eq_def tag_eq_def
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
    28
apply(clarify, simp (no_asm_use))
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
    29
by metis
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
    30
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
    31
117
22ba25b808c8 updated second direction
urbanc
parents: 113
diff changeset
    32
lemma finite_eq_tag_rel:
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
    33
  assumes rng_fnt: "finite (range tag)"
109
79b37ef9505f minor updated
urbanc
parents: 99
diff changeset
    34
  shows "finite (UNIV // =tag=)"
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
    35
proof -
119
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
    36
  let "?f" =  "\<lambda>X. tag ` X" and ?A = "(UNIV // =tag=)"
118
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    37
  have "finite (?f ` ?A)" 
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    38
  proof -
119
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
    39
    have "range ?f \<subseteq> (Pow (range tag))" unfolding Pow_def by auto
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
    40
    moreover 
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
    41
    have "finite (Pow (range tag))" using rng_fnt by simp
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
    42
    ultimately 
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
    43
    have "finite (range ?f)" unfolding image_def by (blast intro: finite_subset)
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
    44
    moreover
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
    45
    have "?f ` ?A \<subseteq> range ?f" by auto
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
    46
    ultimately show "finite (?f ` ?A)" by (rule rev_finite_subset) 
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
    47
  qed
118
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    48
  moreover
119
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
    49
  have "inj_on ?f ?A"
118
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    50
  proof -
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    51
    { fix X Y
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    52
      assume X_in: "X \<in> ?A"
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    53
        and  Y_in: "Y \<in> ?A"
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    54
        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
    55
      then obtain x y 
119
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
    56
        where "x \<in> X" "y \<in> Y" "tag x = tag y"
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
    57
        unfolding quotient_def Image_def image_def tag_eq_def
119
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
    58
        by (simp) (blast)
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
    59
      with X_in Y_in 
118
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    60
      have "X = Y"
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
    61
	unfolding quotient_def tag_eq_def by auto
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
    62
    } 
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
    63
    then show "inj_on ?f ?A" unfolding inj_on_def by auto
118
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    64
  qed
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
    65
  ultimately show "finite (UNIV // =tag=)" by (rule finite_imageD)
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
    66
qed
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
    67
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
    68
lemma refined_partition_finite:
118
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    69
  assumes fnt: "finite (UNIV // R1)"
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
    70
  and refined: "R1 \<subseteq> R2"
118
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    71
  and eq1: "equiv UNIV R1" and eq2: "equiv UNIV R2"
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    72
  shows "finite (UNIV // R2)"
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
    73
proof -
118
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    74
  let ?f = "\<lambda>X. {R1 `` {x} | x. x \<in> X}" 
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    75
    and ?A = "UNIV // R2" and ?B = "UNIV // R1"
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    76
  have "?f ` ?A \<subseteq> Pow ?B"
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    77
    unfolding image_def Pow_def quotient_def by auto
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    78
  moreover
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    79
  have "finite (Pow ?B)" using fnt by simp
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    80
  ultimately  
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    81
  have "finite (?f ` ?A)" by (rule finite_subset)
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    82
  moreover
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    83
  have "inj_on ?f ?A"
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    84
  proof -
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    85
    { fix X Y
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    86
      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
    87
      from quotientE [OF X_in]
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    88
      obtain x where "X = R2 `` {x}" by blast
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    89
      with equiv_class_self[OF eq2] have x_in: "x \<in> X" by simp
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    90
      then have "R1 ``{x} \<in> ?f X" by auto
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    91
      with eq_f have "R1 `` {x} \<in> ?f Y" by simp
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    92
      then obtain y 
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    93
        where y_in: "y \<in> Y" and eq_r1_xy: "R1 `` {x} = R1 `` {y}" by auto
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    94
      with eq_equiv_class[OF _ eq1] 
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    95
      have "(x, y) \<in> R1" by blast
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    96
      with refined have "(x, y) \<in> R2" by auto
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    97
      with quotient_eqI [OF eq2 X_in Y_in x_in y_in]
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    98
      have "X = Y" .
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
    99
    } 
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
   100
    then show "inj_on ?f ?A" unfolding inj_on_def by blast 
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   101
  qed
118
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
   102
  ultimately show "finite (UNIV // R2)" by (rule finite_imageD)
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   103
qed
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   104
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   105
lemma tag_finite_imageD:
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   106
  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
   107
  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
   108
  shows "finite (UNIV // \<approx>A)"
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
   109
proof (rule_tac refined_partition_finite [of "=tag="])
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
   110
  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
   111
next
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
   112
  from same_tag_eqvt
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   113
  show "=tag= \<subseteq> \<approx>A" unfolding tag_eq_def str_eq_def
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   114
    by blast
119
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
   115
next
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
   116
  show "equiv UNIV =tag="
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   117
    unfolding equiv_def tag_eq_def refl_on_def sym_def trans_def
119
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
   118
    by auto
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
   119
next
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
   120
  show "equiv UNIV (\<approx>A)" 
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   121
    unfolding equiv_def str_eq_def sym_def refl_on_def trans_def
119
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
   122
    by blast
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   123
qed
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   124
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   125
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   126
subsection {* The proof *}
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   127
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
   128
subsubsection {* The base case for @{const "Zero"} *}
63
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
lemma quot_zero_eq:
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   131
  shows "UNIV // \<approx>{} = {UNIV}"
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   132
unfolding quotient_def Image_def str_eq_def by auto
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   133
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
   134
lemma quot_zero_finiteI [intro]:
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   135
  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
   136
unfolding quot_zero_eq by simp
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   137
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   138
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
   139
subsubsection {* The base case for @{const "One"} *}
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   140
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
   141
lemma quot_one_subset:
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   142
  shows "UNIV // \<approx>{[]} \<subseteq> {{[]}, UNIV - {[]}}"
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   143
proof
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   144
  fix x
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   145
  assume "x \<in> UNIV // \<approx>{[]}"
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   146
  then obtain y where h: "x = {z. (y, z) \<in> \<approx>{[]}}" 
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   147
    unfolding quotient_def Image_def by blast
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   148
  show "x \<in> {{[]}, UNIV - {[]}}"
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   149
  proof (cases "y = []")
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   150
    case True with h
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   151
    have "x = {[]}" by (auto simp: str_eq_def)
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   152
    thus ?thesis by simp
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   153
  next
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   154
    case False with h
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   155
    have "x = UNIV - {[]}" by (auto simp: str_eq_def)
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   156
    thus ?thesis by simp
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   157
  qed
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   158
qed
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   159
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
   160
lemma quot_one_finiteI [intro]:
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   161
  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
   162
by (rule finite_subset[OF quot_one_subset]) (simp)
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   163
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   164
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
   165
subsubsection {* The base case for @{const "Atom"} *}
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   166
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
   167
lemma quot_atom_subset:
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   168
  "UNIV // (\<approx>{[c]}) \<subseteq> {{[]},{[c]}, UNIV - {[], [c]}}"
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   169
proof 
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   170
  fix x 
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   171
  assume "x \<in> UNIV // \<approx>{[c]}"
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   172
  then obtain y where h: "x = {z. (y, z) \<in> \<approx>{[c]}}" 
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   173
    unfolding quotient_def Image_def by blast
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   174
  show "x \<in> {{[]},{[c]}, UNIV - {[], [c]}}"
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   175
  proof -
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   176
    { assume "y = []" hence "x = {[]}" using h 
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   177
        by (auto simp: str_eq_def) } 
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   178
    moreover 
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   179
    { assume "y = [c]" hence "x = {[c]}" using h 
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   180
        by (auto dest!: spec[where x = "[]"] simp: str_eq_def) } 
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   181
    moreover 
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   182
    { assume "y \<noteq> []" and "y \<noteq> [c]"
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   183
      hence "\<forall> z. (y @ z) \<noteq> [c]" by (case_tac y, auto)
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   184
      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
   185
        by (case_tac p, auto)
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   186
      ultimately have "x = UNIV - {[],[c]}" using h
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   187
        by (auto simp add: str_eq_def)
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   188
    } 
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   189
    ultimately show ?thesis by blast
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   190
  qed
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   191
qed
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   192
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
   193
lemma quot_atom_finiteI [intro]:
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   194
  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
   195
by (rule finite_subset[OF quot_atom_subset]) (simp)
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   196
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   197
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
   198
subsubsection {* The inductive case for @{const Plus} *}
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   199
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   200
definition 
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   201
  tag_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
   202
where
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   203
  "tag_Plus A B \<equiv> (\<lambda>x. (\<approx>A `` {x}, \<approx>B `` {x}))"
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   204
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   205
lemma quot_plus_finiteI [intro]:
119
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
   206
  assumes finite1: "finite (UNIV // \<approx>A)"
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
   207
  and     finite2: "finite (UNIV // \<approx>B)"
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
   208
  shows "finite (UNIV // \<approx>(A \<union> B))"
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   209
proof (rule_tac tag = "tag_Plus A B" in tag_finite_imageD)
119
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
   210
  have "finite ((UNIV // \<approx>A) \<times> (UNIV // \<approx>B))" 
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
   211
    using finite1 finite2 by auto
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   212
  then show "finite (range (tag_Plus A B))"
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   213
    unfolding tag_Plus_def quotient_def
119
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
   214
    by (rule rev_finite_subset) (auto)
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
   215
next
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   216
  show "\<And>x y. tag_Plus A B x = tag_Plus A B y \<Longrightarrow> x \<approx>(A \<union> B) y"
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   217
    unfolding tag_Plus_def
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   218
    unfolding str_eq_def
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   219
    by auto
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   220
qed
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   221
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   222
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
   223
subsubsection {* The inductive case for @{text "Times"}*}
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   224
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   225
definition
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   226
  "Partitions s \<equiv> {(u, v). u @ v = s}"
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   227
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   228
lemma conc_elim:
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   229
  assumes "x \<in> A \<cdot> B"
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   230
  shows "\<exists>(u, v) \<in> Partitions x. u \<in> A \<and> v \<in> B"
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   231
using assms
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   232
unfolding conc_def Partitions_def
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   233
by auto
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   234
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   235
lemma conc_intro:
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   236
  assumes "(u, v) \<in> Partitions x \<and> u \<in> A \<and>  v \<in> B"
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   237
  shows "x \<in> A \<cdot> B"
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   238
using assms
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   239
unfolding conc_def Partitions_def
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   240
by auto
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   241
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   242
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   243
lemma y:
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   244
  "\<lbrakk>x \<in> A; x \<approx>A y\<rbrakk> \<Longrightarrow> y \<in> A"
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   245
apply(simp add: str_eq_def)
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   246
apply(drule_tac x="[]" in spec)
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   247
apply(simp)
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   248
done
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   249
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   250
definition 
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   251
  tag_Times3a :: "'a lang \<Rightarrow> 'a lang \<Rightarrow> 'a list \<Rightarrow> 'a lang"
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   252
where
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   253
  "tag_Times3a A B \<equiv> (\<lambda>x. \<approx>A `` {x})"
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   254
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   255
definition 
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   256
  tag_Times3b :: "'a lang \<Rightarrow> 'a lang \<Rightarrow> 'a list \<Rightarrow> ('a lang \<times> 'a lang) set"
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   257
where
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   258
  "tag_Times3b A B \<equiv>
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   259
     (\<lambda>x. ({(\<approx>A `` {u}, \<approx>B `` {v}) | u v. (u, v) \<in> Partitions x}))"
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   260
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   261
definition 
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   262
  tag_Times3 :: "'a lang \<Rightarrow> 'a lang \<Rightarrow> 'a list \<Rightarrow> 'a lang \<times> ('a lang \<times> 'a lang) set"
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   263
where
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   264
  "tag_Times3 A B \<equiv>
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   265
     (\<lambda>x. (tag_Times3a A B x, tag_Times3b A B x))"
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   266
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   267
lemma
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   268
  assumes a: "tag_Times3a A B x = tag_Times3a A B y"
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   269
  and     b: "tag_Times3b A B x = tag_Times3b A B y"
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   270
  and     c: "x @ z \<in> A \<cdot> B"
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   271
  shows "y @ z \<in> A \<cdot> B"
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   272
proof -
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   273
  from c obtain u v where 
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   274
    h1: "(u, v) \<in> Partitions (x @ z)" and
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   275
    h2: "u \<in> A" and
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   276
    h3: "v \<in> B" by (auto dest: conc_elim)
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   277
  from h1 have "x @ z = u @ v" unfolding Partitions_def by simp
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   278
  then obtain us 
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   279
    where "(x = u @ us \<and> us @ z = v) \<or> (x @ us = u \<and> z = us @ v)"
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   280
    by (auto simp add: append_eq_append_conv2)
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   281
  moreover
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   282
  { assume eq: "x = u @ us" "us @ z = v"
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   283
    have "(\<approx>A `` {u}, \<approx>B `` {us}) \<in> tag_Times3b A B x"
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   284
      unfolding tag_Times3b_def Partitions_def using eq by auto
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   285
    then have "(\<approx>A `` {u}, \<approx>B `` {us}) \<in> tag_Times3b A B y"
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   286
      using b by simp
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   287
    then obtain u' us' where
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   288
      q1: "\<approx>A `` {u} = \<approx>A `` {u'}" and
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   289
      q2: "\<approx>B `` {us} = \<approx>B `` {us'}" and
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   290
      q3: "(u', us') \<in> Partitions y"
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   291
      by (auto simp add: tag_Times3b_def)
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   292
    from q1 h2 have "u' \<in> A" 
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   293
      using y unfolding Image_def str_eq_def by blast
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   294
    moreover from q2 h3 eq 
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   295
    have "us' @ z \<in> B"
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   296
      unfolding Image_def str_eq_def by auto
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   297
    ultimately have "y @ z \<in> A \<cdot> B" using q3 
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   298
      unfolding Partitions_def by auto
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   299
  }
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   300
  moreover
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   301
  { assume eq: "x @ us = u" "z = us @ v"
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   302
    have "(\<approx>A `` {x}) = tag_Times3a A B x" 
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   303
      unfolding tag_Times3a_def by simp
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   304
    then have "(\<approx>A `` {x}) = tag_Times3a A B y"
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   305
      using a by simp
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   306
    then have "\<approx>A `` {x} = \<approx>A `` {y}" 
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   307
      unfolding tag_Times3a_def by simp
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   308
    moreover 
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   309
    have "x @ us \<in> A" using h2 eq by simp
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   310
    ultimately 
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   311
    have "y @ us \<in> A" using y 
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   312
      unfolding Image_def str_eq_def by blast
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   313
    then have "(y @ us) @ v \<in> A \<cdot> B" 
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   314
      using h3 unfolding conc_def by blast
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   315
    then have "y @ z \<in> A \<cdot> B" using eq by simp 
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   316
  }
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   317
  ultimately show "y @ z \<in> A \<cdot> B" by blast
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   318
qed
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   319
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   320
lemma conc_in_cases2:
166
7743d2ad71d1 updated theories and itp-paper
urbanc
parents: 162
diff changeset
   321
  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
   322
  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
   323
         (\<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
   324
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
   325
unfolding conc_def prefix_def
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   326
by (auto simp add: append_eq_append_conv2)
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   327
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   328
definition 
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   329
  tag_Times :: "'a lang \<Rightarrow> 'a lang \<Rightarrow> 'a list \<Rightarrow> ('a lang \<times> 'a lang set)"
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   330
where
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   331
  "tag_Times A B \<equiv>
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   332
     (\<lambda>x. (\<approx>A `` {x}, {(\<approx>B `` {x - x'}) | x'.  x' \<le> x \<and> x' \<in> A}))"
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   333
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   334
lemma tag_Times_injI:
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   335
  assumes eq_tag: "tag_Times A B x = tag_Times A B y" 
166
7743d2ad71d1 updated theories and itp-paper
urbanc
parents: 162
diff changeset
   336
  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
   337
proof -
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   338
  { fix x y z
166
7743d2ad71d1 updated theories and itp-paper
urbanc
parents: 162
diff changeset
   339
    assume xz_in_seq: "x @ z \<in> A \<cdot> B"
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   340
    and tag_xy: "tag_Times A B x = tag_Times A B y"
166
7743d2ad71d1 updated theories and itp-paper
urbanc
parents: 162
diff changeset
   341
    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
   342
    proof -
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   343
      { (* 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
   344
        fix x'
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   345
        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
   346
        obtain y' 
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   347
          where "y' \<le> y" 
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   348
          and "y' \<in> A" 
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   349
          and "(y - y') @ z \<in> B"
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   350
        proof -
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   351
          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
   352
                {\<approx>B `` {y - y'} |y'. y' \<le> y \<and> y' \<in> A}" (is "?Left = ?Right")
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   353
            using tag_xy unfolding tag_Times_def by simp
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   354
          moreover 
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   355
	  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
   356
          ultimately 
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   357
	  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
   358
          then obtain y' 
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   359
            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
   360
            and pref_y': "y' \<le> y" and y'_in: "y' \<in> A"
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   361
            by simp blast
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   362
	  have "(x - x')  \<approx>B (y - y')" using eq_xy'
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   363
            unfolding Image_def str_eq_def by auto
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   364
          with h3 have "(y - y') @ z \<in> B" 
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   365
	    unfolding str_eq_def by simp
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   366
          with pref_y' y'_in 
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   367
          show ?thesis using that by blast
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   368
        qed
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   369
	then have "y @ z \<in> A \<cdot> B"
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   370
	  unfolding prefix_def by auto
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   371
      } 
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   372
      moreover 
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   373
      { (* 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
   374
        fix z'
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   375
        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
   376
	 have "\<approx>A `` {x} = \<approx>A `` {y}" 
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   377
           using tag_xy unfolding tag_Times_def by simp
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   378
         with h2 have "y @ z' \<in> A"
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   379
            unfolding Image_def str_eq_def by auto
166
7743d2ad71d1 updated theories and itp-paper
urbanc
parents: 162
diff changeset
   380
        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
   381
	  unfolding prefix_def conc_def
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   382
	  by (auto) (metis append_assoc)
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   383
      }
166
7743d2ad71d1 updated theories and itp-paper
urbanc
parents: 162
diff changeset
   384
      ultimately show "y @ z \<in> A \<cdot> B" 
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   385
	using conc_in_cases2 [OF xz_in_seq] by blast
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   386
    qed
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   387
  }
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   388
  from this [OF _ eq_tag] and this [OF _ eq_tag [THEN sym]]
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   389
    show "x \<approx>(A \<cdot> B) y" unfolding str_eq_def by blast
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   390
qed 
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   391
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   392
lemma quot_conc_finiteI [intro]:
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   393
  fixes A B::"'a lang"
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   394
  assumes fin1: "finite (UNIV // \<approx>A)" 
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   395
  and     fin2: "finite (UNIV // \<approx>B)" 
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   396
  shows "finite (UNIV // \<approx>(A \<cdot> B))"
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   397
proof (rule_tac tag = "tag_Times A B" in tag_finite_imageD)
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   398
  show "\<And>x y. tag_Times A B x = tag_Times A B y \<Longrightarrow> x \<approx>(A \<cdot> B) y"
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   399
    by (rule tag_Times_injI)
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   400
next
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   401
  have *: "finite ((UNIV // \<approx>A) \<times> (Pow (UNIV // \<approx>B)))" 
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   402
    using fin1 fin2 by auto
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   403
  show "finite (range (tag_Times A B))" 
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   404
    unfolding tag_Times_def
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   405
    apply(rule finite_subset[OF _ *])
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   406
    unfolding quotient_def
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   407
    by auto
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   408
qed
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   409
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   410
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
   411
subsubsection {* The inductive case for @{const "Star"} *}
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   412
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   413
definition
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   414
  "SPartitions s \<equiv> {(u, v). u @ v = s \<and> u < s}"
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   415
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   416
lemma
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   417
  assumes "x \<in> A\<star>" "x \<noteq> []"
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   418
  shows "\<exists>(u, v) \<in> SPartitions x. u \<in> A\<star> \<and> v \<in> A\<star>"
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   419
using assms
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   420
apply(subst (asm) star_unfold_left)
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   421
apply(simp)
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   422
apply(simp add: conc_def)
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   423
apply(erule exE)+
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   424
apply(erule conjE)+
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   425
apply(rule_tac x="([], xs @ ys)" in bexI)
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   426
apply(simp)
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   427
apply(simp add: SPartitions_def)
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   428
apply(auto)
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   429
apply (metis append_Cons list.exhaust strict_prefix_simps(2))
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   430
by (metis Nil_is_append_conv Nil_prefix xt1(11))
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   431
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   432
lemma
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   433
  assumes "x @ z \<in> A\<star>" "x \<noteq> []"
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   434
  shows "\<exists>(u, v) \<in> SPartitions x. u \<in> A\<star> \<and> v @ z \<in> A\<star>"
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   435
using assms
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   436
apply(subst (asm) star_unfold_left)
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   437
apply(simp)
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   438
apply(simp add: conc_def)
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   439
apply(erule exE)+
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   440
apply(erule conjE)+
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   441
apply(rule_tac x="([], x)" in bexI)
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   442
apply(simp)
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   443
apply(simp add: SPartitions_def)
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   444
by (metis Nil_prefix xt1(11))
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   445
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   446
lemma finite_set_has_max: 
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   447
  "\<lbrakk>finite A; A \<noteq> {}\<rbrakk> \<Longrightarrow> \<exists> max \<in> A. \<forall> a \<in> A. length a \<le> length max"
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   448
apply (induct rule:finite.induct)
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   449
apply(simp)
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   450
by (metis (full_types) all_not_in_conv insertI1 insert_iff linorder_linear order_eq_iff order_trans prefix_length_le)
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   451
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   452
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   453
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   454
definition 
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   455
  tag_Star3 :: "'a lang \<Rightarrow> 'a list \<Rightarrow> (bool \<times> 'a lang) set"
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   456
where
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   457
  "tag_Star3 A \<equiv>
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   458
     (\<lambda>x. ({(u \<in> A\<star>, \<approx>A `` {v}) | u v. (u, v) \<in> Partitions x}))"
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   459
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   460
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   461
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   462
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   463
definition 
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   464
  tag_Star :: "'a lang \<Rightarrow> 'a list \<Rightarrow> ('a lang) set"
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   465
where
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   466
  "tag_Star A \<equiv> (\<lambda>x. {\<approx>A `` {x - xa} | xa. xa < x \<and> xa \<in> A\<star>})"
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   467
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   468
text {* A technical lemma. *}
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   469
lemma finite_set_has_max: "\<lbrakk>finite A; A \<noteq> {}\<rbrakk> \<Longrightarrow> 
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   470
           (\<exists> max \<in> A. \<forall> a \<in> A. f a <= (f max :: nat))"
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   471
proof (induct rule:finite.induct)
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   472
  case emptyI thus ?case by simp
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   473
next
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   474
  case (insertI A a)
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   475
  show ?case
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   476
  proof (cases "A = {}")
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   477
    case True thus ?thesis by (rule_tac x = a in bexI, auto)
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   478
  next
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   479
    case False
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   480
    with insertI.hyps and False  
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   481
    obtain max 
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   482
      where h1: "max \<in> A" 
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   483
      and h2: "\<forall>a\<in>A. f a \<le> f max" by blast
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   484
    show ?thesis
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   485
    proof (cases "f a \<le> f max")
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   486
      assume "f a \<le> f max"
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   487
      with h1 h2 show ?thesis by (rule_tac x = max in bexI, auto)
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   488
    next
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   489
      assume "\<not> (f a \<le> f max)"
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   490
      thus ?thesis using h2 by (rule_tac x = a in bexI, auto)
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   491
    qed
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   492
  qed
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   493
qed
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   494
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   495
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   496
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
   497
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
   498
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
   499
  shows "finite {xa. xa < (x::'a list)}"
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   500
apply (induct x rule:rev_induct, simp)
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   501
apply (subgoal_tac "{xa. xa < xs @ [x]} = {xa. xa < xs} \<union> {xs}")
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   502
by (auto simp:strict_prefix_def)
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   503
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   504
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   505
lemma tag_Star_injI:
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
   506
  fixes L\<^isub>1::"('a::finite) lang"
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   507
  assumes eq_tag: "tag_Star L\<^isub>1 v = tag_Star L\<^isub>1 w"
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   508
  shows "v \<approx>(L\<^isub>1\<star>) w"
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   509
proof-
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   510
  { fix x y z
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   511
    assume xz_in_star: "x @ z \<in> L\<^isub>1\<star>" 
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   512
      and tag_xy: "tag_Star L\<^isub>1 x = tag_Star L\<^isub>1 y"
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   513
    have "y @ z \<in> L\<^isub>1\<star>"
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   514
    proof(cases "x = []")
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   515
      case True
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   516
      with tag_xy have "y = []" 
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   517
        by (auto simp add: tag_Star_def strict_prefix_def)
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   518
      thus ?thesis using xz_in_star True by simp
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   519
    next
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   520
      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
   521
      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
   522
      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
   523
	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
   524
	   (auto simp: finite_strict_prefix_set)
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   525
      moreover have "?S \<noteq> {}" using False xz_in_star
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   526
        by (simp, rule_tac x = "[]" in exI, auto simp:strict_prefix_def)
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   527
      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
   528
        using finite_set_has_max by blast
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   529
      then obtain xa_max 
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   530
        where h1: "xa_max < x" 
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   531
        and h2: "xa_max \<in> L\<^isub>1\<star>" 
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   532
        and h3: "(x - xa_max) @ z \<in> L\<^isub>1\<star>" 
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   533
        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
   534
                                     \<longrightarrow> length xa \<le> length xa_max"
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   535
        by blast
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   536
      obtain ya 
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   537
        where h5: "ya < y" and h6: "ya \<in> L\<^isub>1\<star>" 
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   538
        and eq_xya: "(x - xa_max) \<approx>L\<^isub>1 (y - ya)"
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   539
      proof-
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   540
        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
   541
          {\<approx>L\<^isub>1 `` {y - xa} |xa. xa < y \<and> xa \<in> L\<^isub>1\<star>}" (is "?left = ?right")
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   542
          by (auto simp:tag_Star_def)
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   543
        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
   544
        ultimately have "\<approx>L\<^isub>1 `` {x - xa_max} \<in> ?right" by simp
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   545
        thus ?thesis using that 
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   546
          apply (simp add: Image_def str_eq_def) by blast
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   547
      qed 
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   548
      have "(y - ya) @ z \<in> L\<^isub>1\<star>" 
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   549
      proof-
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   550
        obtain za zb where eq_zab: "z = za @ zb" 
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   551
          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
   552
        proof -
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   553
          from h1 have "(x - xa_max) @ z \<noteq> []"
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   554
	    unfolding strict_prefix_def prefix_def by auto
180
b755090d0f3d added a picture
urbanc
parents: 170
diff changeset
   555
	  from star_decom [OF h3 this]
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   556
          obtain a b where a_in: "a \<in> L\<^isub>1" 
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   557
            and a_neq: "a \<noteq> []" and b_in: "b \<in> L\<^isub>1\<star>" 
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   558
            and ab_max: "(x - xa_max) @ z = a @ b" by blast
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   559
          let ?za = "a - (x - xa_max)" and ?zb = "b"
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   560
          have pfx: "(x - xa_max) \<le> a" (is "?P1") 
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   561
            and eq_z: "z = ?za @ ?zb" (is "?P2")
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   562
          proof -
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   563
            have "((x - xa_max) \<le> a \<and> (a - (x - xa_max)) @ b = z) \<or> 
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   564
              (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
   565
              using append_eq_dest[OF ab_max] by (auto simp:strict_prefix_def)
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   566
            moreover {
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   567
              assume np: "a < (x - xa_max)" 
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   568
                and b_eqs: "((x - xa_max) - a) @ z = b"
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   569
              have "False"
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   570
              proof -
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   571
                let ?xa_max' = "xa_max @ a"
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   572
                have "?xa_max' < x" 
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   573
                  using np h1 by (clarsimp simp:strict_prefix_def diff_prefix) 
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   574
                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
   575
                  using a_in h2 by (auto)
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   576
                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
   577
                  using b_eqs b_in np h1 by (simp add:diff_diff_append)
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   578
                moreover have "\<not> (length ?xa_max' \<le> length xa_max)" 
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   579
                  using a_neq by simp
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   580
                ultimately show ?thesis using h4 by blast
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   581
              qed }
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   582
            ultimately show ?P1 and ?P2 by auto
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   583
          qed
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   584
          hence "(x - xa_max)@?za \<in> L\<^isub>1" using a_in unfolding prefix_def by auto
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   585
          with eq_xya have "(y - ya) @ ?za \<in> L\<^isub>1" 
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   586
            by (auto simp: str_eq_def)
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   587
           with eq_z and b_in 
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   588
          show ?thesis using that by blast
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   589
        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
   590
        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
   591
	  by (rule_tac append_in_starI) (auto)
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   592
        with eq_zab show ?thesis by simp
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   593
      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
   594
      with h5 h6 show ?thesis 	
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   595
	unfolding strict_prefix_def prefix_def by auto
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   596
    qed
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   597
  } 
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   598
  from this [OF _ eq_tag] and this [OF _ eq_tag [THEN sym]]
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   599
    show  ?thesis unfolding str_eq_def by blast
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   600
qed
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   601
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   602
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
   603
   fixes A::"('a::finite) lang"
166
7743d2ad71d1 updated theories and itp-paper
urbanc
parents: 162
diff changeset
   604
  assumes finite1: "finite (UNIV // \<approx>A)"
7743d2ad71d1 updated theories and itp-paper
urbanc
parents: 162
diff changeset
   605
  shows "finite (UNIV // \<approx>(A\<star>))"
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   606
proof (rule_tac tag = "tag_Star A" in tag_finite_imageD)
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   607
  show "\<And>x y. tag_Star A x = tag_Star A y \<Longrightarrow> x \<approx>(A\<star>) y"
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   608
    by (rule tag_Star_injI)
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   609
next
166
7743d2ad71d1 updated theories and itp-paper
urbanc
parents: 162
diff changeset
   610
  have *: "finite (Pow (UNIV // \<approx>A))" 
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   611
    using finite1 by auto
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   612
  show "finite (range (tag_Star A))"
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   613
    unfolding tag_Star_def
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   614
    apply(rule finite_subset[OF _ *])
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   615
    unfolding quotient_def
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   616
    by auto
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   617
qed
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   618
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   619
subsubsection{* The conclusion *}
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   620
112
62fdb4bf7239 more on the conclusion
urbanc
parents: 109
diff changeset
   621
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
   622
  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
   623
  shows "finite (UNIV // \<approx>(lang r))"
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   624
by (induct r) (auto)
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   625
132
f77a7138f791 comments by Xingyuan
urbanc
parents: 128
diff changeset
   626
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
   627
  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
   628
  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
   629
using Myhill_Nerode1 Myhill_Nerode2 by auto
112
62fdb4bf7239 more on the conclusion
urbanc
parents: 109
diff changeset
   630
63
649ff0b8766d Myhill_2.thy added
zhang
parents:
diff changeset
   631
end