Myhill.thy
author urbanc
Wed, 01 Feb 2012 15:00:17 +0000
changeset 274 83b0317370c2
parent 203 5d724fe0e096
permissions -rw-r--r--
more on intro
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
203
5d724fe0e096 changes according to afp-submission
urbanc
parents:
diff changeset
     1
theory Myhill
5d724fe0e096 changes according to afp-submission
urbanc
parents:
diff changeset
     2
  imports Myhill_2 "Derivatives"
5d724fe0e096 changes according to afp-submission
urbanc
parents:
diff changeset
     3
begin
5d724fe0e096 changes according to afp-submission
urbanc
parents:
diff changeset
     4
5d724fe0e096 changes according to afp-submission
urbanc
parents:
diff changeset
     5
section {* The theorem *}
5d724fe0e096 changes according to afp-submission
urbanc
parents:
diff changeset
     6
5d724fe0e096 changes according to afp-submission
urbanc
parents:
diff changeset
     7
theorem Myhill_Nerode:
5d724fe0e096 changes according to afp-submission
urbanc
parents:
diff changeset
     8
  fixes A::"('a::finite) lang"
5d724fe0e096 changes according to afp-submission
urbanc
parents:
diff changeset
     9
  shows "(\<exists>r. A = lang r) \<longleftrightarrow> finite (UNIV // \<approx>A)"
5d724fe0e096 changes according to afp-submission
urbanc
parents:
diff changeset
    10
using Myhill_Nerode1 Myhill_Nerode2 by auto
5d724fe0e096 changes according to afp-submission
urbanc
parents:
diff changeset
    11
5d724fe0e096 changes according to afp-submission
urbanc
parents:
diff changeset
    12
5d724fe0e096 changes according to afp-submission
urbanc
parents:
diff changeset
    13
subsection {* Second direction proved using partial derivatives *}
5d724fe0e096 changes according to afp-submission
urbanc
parents:
diff changeset
    14
5d724fe0e096 changes according to afp-submission
urbanc
parents:
diff changeset
    15
text {*
5d724fe0e096 changes according to afp-submission
urbanc
parents:
diff changeset
    16
  An alternaive proof using the notion of partial derivatives for regular 
5d724fe0e096 changes according to afp-submission
urbanc
parents:
diff changeset
    17
  expressions due to Antimirov \cite{Antimirov95}.
5d724fe0e096 changes according to afp-submission
urbanc
parents:
diff changeset
    18
*}
5d724fe0e096 changes according to afp-submission
urbanc
parents:
diff changeset
    19
5d724fe0e096 changes according to afp-submission
urbanc
parents:
diff changeset
    20
lemma MN_Rel_Derivs:
5d724fe0e096 changes according to afp-submission
urbanc
parents:
diff changeset
    21
  shows "x \<approx>A y \<longleftrightarrow> Derivs x A = Derivs y A"
5d724fe0e096 changes according to afp-submission
urbanc
parents:
diff changeset
    22
unfolding Derivs_def str_eq_def
5d724fe0e096 changes according to afp-submission
urbanc
parents:
diff changeset
    23
by auto
5d724fe0e096 changes according to afp-submission
urbanc
parents:
diff changeset
    24
5d724fe0e096 changes according to afp-submission
urbanc
parents:
diff changeset
    25
lemma Myhill_Nerode3:
5d724fe0e096 changes according to afp-submission
urbanc
parents:
diff changeset
    26
  fixes r::"'a rexp"
5d724fe0e096 changes according to afp-submission
urbanc
parents:
diff changeset
    27
  shows "finite (UNIV // \<approx>(lang r))"
5d724fe0e096 changes according to afp-submission
urbanc
parents:
diff changeset
    28
proof -
5d724fe0e096 changes according to afp-submission
urbanc
parents:
diff changeset
    29
  have "finite (UNIV // =(\<lambda>x. pderivs x r)=)"
5d724fe0e096 changes according to afp-submission
urbanc
parents:
diff changeset
    30
  proof - 
5d724fe0e096 changes according to afp-submission
urbanc
parents:
diff changeset
    31
    have "range (\<lambda>x. pderivs x r) \<subseteq> Pow (pderivs_lang UNIV r)"
5d724fe0e096 changes according to afp-submission
urbanc
parents:
diff changeset
    32
      unfolding pderivs_lang_def by auto
5d724fe0e096 changes according to afp-submission
urbanc
parents:
diff changeset
    33
    moreover 
5d724fe0e096 changes according to afp-submission
urbanc
parents:
diff changeset
    34
    have "finite (Pow (pderivs_lang UNIV r))" by (simp add: finite_pderivs_lang)
5d724fe0e096 changes according to afp-submission
urbanc
parents:
diff changeset
    35
    ultimately
5d724fe0e096 changes according to afp-submission
urbanc
parents:
diff changeset
    36
    have "finite (range (\<lambda>x. pderivs x r))"
5d724fe0e096 changes according to afp-submission
urbanc
parents:
diff changeset
    37
      by (simp add: finite_subset)
5d724fe0e096 changes according to afp-submission
urbanc
parents:
diff changeset
    38
    then show "finite (UNIV // =(\<lambda>x. pderivs x r)=)" 
5d724fe0e096 changes according to afp-submission
urbanc
parents:
diff changeset
    39
      by (rule finite_eq_tag_rel)
5d724fe0e096 changes according to afp-submission
urbanc
parents:
diff changeset
    40
  qed
5d724fe0e096 changes according to afp-submission
urbanc
parents:
diff changeset
    41
  moreover 
5d724fe0e096 changes according to afp-submission
urbanc
parents:
diff changeset
    42
  have "=(\<lambda>x. pderivs x r)= \<subseteq> \<approx>(lang r)"
5d724fe0e096 changes according to afp-submission
urbanc
parents:
diff changeset
    43
    unfolding tag_eq_def
5d724fe0e096 changes according to afp-submission
urbanc
parents:
diff changeset
    44
    by (auto simp add: MN_Rel_Derivs Derivs_pderivs)
5d724fe0e096 changes according to afp-submission
urbanc
parents:
diff changeset
    45
  moreover 
5d724fe0e096 changes according to afp-submission
urbanc
parents:
diff changeset
    46
  have "equiv UNIV =(\<lambda>x. pderivs x r)="
5d724fe0e096 changes according to afp-submission
urbanc
parents:
diff changeset
    47
  and  "equiv UNIV (\<approx>(lang r))"
5d724fe0e096 changes according to afp-submission
urbanc
parents:
diff changeset
    48
    unfolding equiv_def refl_on_def sym_def trans_def
5d724fe0e096 changes according to afp-submission
urbanc
parents:
diff changeset
    49
    unfolding tag_eq_def str_eq_def
5d724fe0e096 changes according to afp-submission
urbanc
parents:
diff changeset
    50
    by auto
5d724fe0e096 changes according to afp-submission
urbanc
parents:
diff changeset
    51
  ultimately show "finite (UNIV // \<approx>(lang r))" 
5d724fe0e096 changes according to afp-submission
urbanc
parents:
diff changeset
    52
    by (rule refined_partition_finite)
5d724fe0e096 changes according to afp-submission
urbanc
parents:
diff changeset
    53
qed
5d724fe0e096 changes according to afp-submission
urbanc
parents:
diff changeset
    54
5d724fe0e096 changes according to afp-submission
urbanc
parents:
diff changeset
    55
end