Attic/Myhill_1.thy
author urbanc
Mon, 21 Feb 2011 03:33:27 +0000
changeset 136 13b0f3dac9a2
parent 84 f41351709800
permissions -rw-r--r--
final final polishing
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
84
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
     1
theory Myhill_1
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
     2
  imports Main 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
     3
begin
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
     4
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
     5
(*
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
     6
text {*
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
     7
     \begin{figure}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
     8
    \centering
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
     9
    \scalebox{0.95}{
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    10
    \begin{tikzpicture}[->,>=latex,shorten >=1pt,auto,node distance=1.2cm, semithick]
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    11
        \node[state,initial] (n1)                   {$1$};
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    12
        \node[state,accepting] (n2) [right = 10em of n1]   {$2$};
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    13
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    14
        \path (n1) edge [bend left] node {$0$} (n2)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    15
            (n1) edge [loop above] node{$1$} (n1)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    16
            (n2) edge [loop above] node{$0$} (n2)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    17
            (n2) edge [bend left]  node {$1$} (n1)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    18
            ;
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    19
    \end{tikzpicture}}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    20
    \caption{An example automaton (or partition)}\label{fig:example_automata}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    21
    \end{figure}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    22
*}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    23
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    24
*)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    25
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    26
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    27
section {* Preliminary definitions *}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    28
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    29
types lang = "string set"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    30
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    31
text {*  Sequential composition of two languages *}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    32
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    33
definition 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    34
  Seq :: "lang \<Rightarrow> lang \<Rightarrow> lang" (infixr ";;" 100)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    35
where 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    36
  "A ;; B = {s\<^isub>1 @ s\<^isub>2 | s\<^isub>1 s\<^isub>2. s\<^isub>1 \<in> A \<and> s\<^isub>2 \<in> B}"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    37
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    38
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    39
text {* Some properties of operator @{text ";;"}. *}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    40
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    41
lemma seq_add_left:
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    42
  assumes a: "A = B"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    43
  shows "C ;; A = C ;; B"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    44
using a by simp
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    45
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    46
lemma seq_union_distrib_right:
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    47
  shows "(A \<union> B) ;; C = (A ;; C) \<union> (B ;; C)"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    48
unfolding Seq_def by auto
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    49
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    50
lemma seq_union_distrib_left:
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    51
  shows "C ;; (A \<union> B) = (C ;; A) \<union> (C ;; B)"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    52
unfolding Seq_def by  auto
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    53
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    54
lemma seq_intro:
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    55
  assumes a: "x \<in> A" "y \<in> B"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    56
  shows "x @ y \<in> A ;; B "
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    57
using a by (auto simp: Seq_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    58
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    59
lemma seq_assoc:
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    60
  shows "(A ;; B) ;; C = A ;; (B ;; C)"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    61
unfolding Seq_def
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    62
apply(auto)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    63
apply(blast)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    64
by (metis append_assoc)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    65
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    66
lemma seq_empty [simp]:
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    67
  shows "A ;; {[]} = A"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    68
  and   "{[]} ;; A = A"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    69
by (simp_all add: Seq_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    70
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    71
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    72
text {* Power and Star of a language *}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    73
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    74
fun 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    75
  pow :: "lang \<Rightarrow> nat \<Rightarrow> lang" (infixl "\<up>" 100)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    76
where
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    77
  "A \<up> 0 = {[]}"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    78
| "A \<up> (Suc n) =  A ;; (A \<up> n)" 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    79
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    80
definition
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    81
  Star :: "lang \<Rightarrow> lang" ("_\<star>" [101] 102)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    82
where
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    83
  "A\<star> \<equiv> (\<Union>n. A \<up> n)"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    84
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    85
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    86
lemma star_start[intro]:
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    87
  shows "[] \<in> A\<star>"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    88
proof -
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    89
  have "[] \<in> A \<up> 0" by auto
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    90
  then show "[] \<in> A\<star>" unfolding Star_def by blast
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    91
qed
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    92
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    93
lemma star_step [intro]:
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    94
  assumes a: "s1 \<in> A" 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    95
  and     b: "s2 \<in> A\<star>"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    96
  shows "s1 @ s2 \<in> A\<star>"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    97
proof -
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    98
  from b obtain n where "s2 \<in> A \<up> n" unfolding Star_def by auto
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
    99
  then have "s1 @ s2 \<in> A \<up> (Suc n)" using a by (auto simp add: Seq_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   100
  then show "s1 @ s2 \<in> A\<star>" unfolding Star_def by blast
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   101
qed
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   102
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   103
lemma star_induct[consumes 1, case_names start step]:
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   104
  assumes a: "x \<in> A\<star>" 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   105
  and     b: "P []"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   106
  and     c: "\<And>s1 s2. \<lbrakk>s1 \<in> A; s2 \<in> A\<star>; P s2\<rbrakk> \<Longrightarrow> P (s1 @ s2)"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   107
  shows "P x"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   108
proof -
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   109
  from a obtain n where "x \<in> A \<up> n" unfolding Star_def by auto
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   110
  then show "P x"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   111
    by (induct n arbitrary: x)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   112
       (auto intro!: b c simp add: Seq_def Star_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   113
qed
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   114
    
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   115
lemma star_intro1:
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   116
  assumes a: "x \<in> A\<star>"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   117
  and     b: "y \<in> A\<star>"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   118
  shows "x @ y \<in> A\<star>"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   119
using a b
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   120
by (induct rule: star_induct) (auto)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   121
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   122
lemma star_intro2: 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   123
  assumes a: "y \<in> A"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   124
  shows "y \<in> A\<star>"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   125
proof -
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   126
  from a have "y @ [] \<in> A\<star>" by blast
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   127
  then show "y \<in> A\<star>" by simp
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   128
qed
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   129
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   130
lemma star_intro3:
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   131
  assumes a: "x \<in> A\<star>"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   132
  and     b: "y \<in> A"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   133
  shows "x @ y \<in> A\<star>"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   134
using a b by (blast intro: star_intro1 star_intro2)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   135
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   136
lemma star_cases:
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   137
  shows "A\<star> =  {[]} \<union> A ;; A\<star>"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   138
proof
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   139
  { fix x
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   140
    have "x \<in> A\<star> \<Longrightarrow> x \<in> {[]} \<union> A ;; A\<star>"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   141
      unfolding Seq_def
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   142
    by (induct rule: star_induct) (auto)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   143
  }
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   144
  then show "A\<star> \<subseteq> {[]} \<union> A ;; A\<star>" by auto
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   145
next
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   146
  show "{[]} \<union> A ;; A\<star> \<subseteq> A\<star>"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   147
    unfolding Seq_def by auto
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   148
qed
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   149
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   150
lemma star_decom: 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   151
  assumes a: "x \<in> A\<star>" "x \<noteq> []"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   152
  shows "\<exists>a b. x = a @ b \<and> a \<noteq> [] \<and> a \<in> A \<and> b \<in> A\<star>"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   153
using a
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   154
apply(induct rule: star_induct)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   155
apply(simp)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   156
apply(blast)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   157
done
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   158
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   159
lemma
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   160
  shows seq_Union_left:  "B ;; (\<Union>n. A \<up> n) = (\<Union>n. B ;; (A \<up> n))"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   161
  and   seq_Union_right: "(\<Union>n. A \<up> n) ;; B = (\<Union>n. (A \<up> n) ;; B)"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   162
unfolding Seq_def by auto
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   163
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   164
lemma seq_pow_comm:
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   165
  shows "A ;; (A \<up> n) = (A \<up> n) ;; A"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   166
by (induct n) (simp_all add: seq_assoc[symmetric])
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   167
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   168
lemma seq_star_comm:
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   169
  shows "A ;; A\<star> = A\<star> ;; A"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   170
unfolding Star_def
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   171
unfolding seq_Union_left
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   172
unfolding seq_pow_comm
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   173
unfolding seq_Union_right 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   174
by simp
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   175
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   176
text {* Two lemmas about the length of strings in @{text "A \<up> n"} *}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   177
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   178
lemma pow_length:
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   179
  assumes a: "[] \<notin> A"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   180
  and     b: "s \<in> A \<up> Suc n"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   181
  shows "n < length s"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   182
using b
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   183
proof (induct n arbitrary: s)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   184
  case 0
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   185
  have "s \<in> A \<up> Suc 0" by fact
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   186
  with a have "s \<noteq> []" by auto
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   187
  then show "0 < length s" by auto
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   188
next
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   189
  case (Suc n)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   190
  have ih: "\<And>s. s \<in> A \<up> Suc n \<Longrightarrow> n < length s" by fact
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   191
  have "s \<in> A \<up> Suc (Suc n)" by fact
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   192
  then obtain s1 s2 where eq: "s = s1 @ s2" and *: "s1 \<in> A" and **: "s2 \<in> A \<up> Suc n"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   193
    by (auto simp add: Seq_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   194
  from ih ** have "n < length s2" by simp
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   195
  moreover have "0 < length s1" using * a by auto
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   196
  ultimately show "Suc n < length s" unfolding eq 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   197
    by (simp only: length_append)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   198
qed
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   199
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   200
lemma seq_pow_length:
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   201
  assumes a: "[] \<notin> A"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   202
  and     b: "s \<in> B ;; (A \<up> Suc n)"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   203
  shows "n < length s"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   204
proof -
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   205
  from b obtain s1 s2 where eq: "s = s1 @ s2" and *: "s2 \<in> A \<up> Suc n"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   206
    unfolding Seq_def by auto
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   207
  from * have " n < length s2" by (rule pow_length[OF a])
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   208
  then show "n < length s" using eq by simp
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   209
qed
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   210
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   211
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   212
section {* A slightly modified version of Arden's lemma *}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   213
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   214
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   215
text {*  A helper lemma for Arden *}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   216
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   217
lemma ardens_helper:
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   218
  assumes eq: "X = X ;; A \<union> B"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   219
  shows "X = X ;; (A \<up> Suc n) \<union> (\<Union>m\<in>{0..n}. B ;; (A \<up> m))"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   220
proof (induct n)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   221
  case 0 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   222
  show "X = X ;; (A \<up> Suc 0) \<union> (\<Union>(m::nat)\<in>{0..0}. B ;; (A \<up> m))"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   223
    using eq by simp
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   224
next
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   225
  case (Suc n)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   226
  have ih: "X = X ;; (A \<up> Suc n) \<union> (\<Union>m\<in>{0..n}. B ;; (A \<up> m))" by fact
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   227
  also have "\<dots> = (X ;; A \<union> B) ;; (A \<up> Suc n) \<union> (\<Union>m\<in>{0..n}. B ;; (A \<up> m))" using eq by simp
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   228
  also have "\<dots> = X ;; (A \<up> Suc (Suc n)) \<union> (B ;; (A \<up> Suc n)) \<union> (\<Union>m\<in>{0..n}. B ;; (A \<up> m))"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   229
    by (simp add: seq_union_distrib_right seq_assoc)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   230
  also have "\<dots> = X ;; (A \<up> Suc (Suc n)) \<union> (\<Union>m\<in>{0..Suc n}. B ;; (A \<up> m))"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   231
    by (auto simp add: le_Suc_eq)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   232
  finally show "X = X ;; (A \<up> Suc (Suc n)) \<union> (\<Union>m\<in>{0..Suc n}. B ;; (A \<up> m))" .
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   233
qed
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   234
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   235
theorem ardens_revised:
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   236
  assumes nemp: "[] \<notin> A"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   237
  shows "X = X ;; A \<union> B \<longleftrightarrow> X = B ;; A\<star>"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   238
proof
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   239
  assume eq: "X = B ;; A\<star>"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   240
  have "A\<star> = {[]} \<union> A\<star> ;; A" 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   241
    unfolding seq_star_comm[symmetric]
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   242
    by (rule star_cases)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   243
  then have "B ;; A\<star> = B ;; ({[]} \<union> A\<star> ;; A)"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   244
    by (rule seq_add_left)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   245
  also have "\<dots> = B \<union> B ;; (A\<star> ;; A)"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   246
    unfolding seq_union_distrib_left by simp
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   247
  also have "\<dots> = B \<union> (B ;; A\<star>) ;; A" 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   248
    by (simp only: seq_assoc)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   249
  finally show "X = X ;; A \<union> B" 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   250
    using eq by blast 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   251
next
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   252
  assume eq: "X = X ;; A \<union> B"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   253
  { fix n::nat
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   254
    have "B ;; (A \<up> n) \<subseteq> X" using ardens_helper[OF eq, of "n"] by auto }
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   255
  then have "B ;; A\<star> \<subseteq> X" 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   256
    unfolding Seq_def Star_def UNION_def
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   257
    by auto
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   258
  moreover
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   259
  { fix s::string
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   260
    obtain k where "k = length s" by auto
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   261
    then have not_in: "s \<notin> X ;; (A \<up> Suc k)" 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   262
      using seq_pow_length[OF nemp] by blast
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   263
    assume "s \<in> X"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   264
    then have "s \<in> X ;; (A \<up> Suc k) \<union> (\<Union>m\<in>{0..k}. B ;; (A \<up> m))"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   265
      using ardens_helper[OF eq, of "k"] by auto
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   266
    then have "s \<in> (\<Union>m\<in>{0..k}. B ;; (A \<up> m))" using not_in by auto
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   267
    moreover
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   268
    have "(\<Union>m\<in>{0..k}. B ;; (A \<up> m)) \<subseteq> (\<Union>n. B ;; (A \<up> n))" by auto
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   269
    ultimately 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   270
    have "s \<in> B ;; A\<star>" 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   271
      unfolding seq_Union_left Star_def
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   272
      by auto }
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   273
  then have "X \<subseteq> B ;; A\<star>" by auto
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   274
  ultimately 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   275
  show "X = B ;; A\<star>" by simp
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   276
qed
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   277
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   278
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   279
section {* Regular Expressions *}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   280
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   281
datatype rexp =
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   282
  NULL
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   283
| EMPTY
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   284
| CHAR char
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   285
| SEQ rexp rexp
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   286
| ALT rexp rexp
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   287
| STAR rexp
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   288
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   289
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   290
text {* 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   291
  The following @{text "L"} is an overloaded operator, where @{text "L(x)"} evaluates to 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   292
  the language represented by the syntactic object @{text "x"}.
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   293
*}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   294
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   295
consts L:: "'a \<Rightarrow> lang"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   296
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   297
text {* The @{text "L (rexp)"} for regular expressions. *}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   298
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   299
overloading L_rexp \<equiv> "L::  rexp \<Rightarrow> lang"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   300
begin
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   301
fun
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   302
  L_rexp :: "rexp \<Rightarrow> string set"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   303
where
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   304
    "L_rexp (NULL) = {}"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   305
  | "L_rexp (EMPTY) = {[]}"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   306
  | "L_rexp (CHAR c) = {[c]}"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   307
  | "L_rexp (SEQ r1 r2) = (L_rexp r1) ;; (L_rexp r2)"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   308
  | "L_rexp (ALT r1 r2) = (L_rexp r1) \<union> (L_rexp r2)"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   309
  | "L_rexp (STAR r) = (L_rexp r)\<star>"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   310
end
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   311
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   312
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   313
section {* Folds for Sets *}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   314
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   315
text {*
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   316
  To obtain equational system out of finite set of equivalence classes, a fold operation
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   317
  on finite sets @{text "folds"} is defined. The use of @{text "SOME"} makes @{text "folds"}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   318
  more robust than the @{text "fold"} in the Isabelle library. The expression @{text "folds f"}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   319
  makes sense when @{text "f"} is not @{text "associative"} and @{text "commutitive"},
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   320
  while @{text "fold f"} does not.  
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   321
*}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   322
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   323
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   324
definition 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   325
  folds :: "('a \<Rightarrow> 'b \<Rightarrow> 'b) \<Rightarrow> 'b \<Rightarrow> 'a set \<Rightarrow> 'b"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   326
where
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   327
  "folds f z S \<equiv> SOME x. fold_graph f z S x"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   328
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   329
abbreviation
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   330
  Setalt  ("\<Uplus>_" [1000] 999) 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   331
where
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   332
  "\<Uplus>A == folds ALT NULL A"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   333
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   334
text {* 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   335
  The following lemma ensures that the arbitrary choice made by the 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   336
  @{text "SOME"} in @{text "folds"} does not affect the @{text "L"}-value 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   337
  of the resultant regular expression. 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   338
*}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   339
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   340
lemma folds_alt_simp [simp]:
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   341
  assumes a: "finite rs"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   342
  shows "L (\<Uplus>rs) = \<Union> (L ` rs)"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   343
apply(rule set_eqI)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   344
apply(simp add: folds_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   345
apply(rule someI2_ex)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   346
apply(rule_tac finite_imp_fold_graph[OF a])
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   347
apply(erule fold_graph.induct)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   348
apply(auto)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   349
done
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   350
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   351
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   352
text {* Just a technical lemma for collections and pairs *}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   353
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   354
lemma Pair_Collect[simp]:
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   355
  shows "(x, y) \<in> {(x, y). P x y} \<longleftrightarrow> P x y"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   356
by simp
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   357
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   358
text {*
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   359
  @{text "\<approx>A"} is an equivalence class defined by language @{text "A"}.
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   360
*}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   361
definition
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   362
  str_eq_rel :: "lang \<Rightarrow> (string \<times> string) set" ("\<approx>_" [100] 100)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   363
where
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   364
  "\<approx>A \<equiv> {(x, y).  (\<forall>z. x @ z \<in> A \<longleftrightarrow> y @ z \<in> A)}"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   365
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   366
text {* 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   367
  Among the equivalence clases of @{text "\<approx>A"}, the set @{text "finals A"} singles out 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   368
  those which contains the strings from @{text "A"}.
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   369
*}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   370
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   371
definition 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   372
  finals :: "lang \<Rightarrow> lang set"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   373
where
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   374
  "finals A \<equiv> {\<approx>A `` {x} | x . x \<in> A}"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   375
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   376
text {* 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   377
  The following lemma establishes the relationshipt between 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   378
  @{text "finals A"} and @{text "A"}.
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   379
*}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   380
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   381
lemma lang_is_union_of_finals: 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   382
  shows "A = \<Union> finals A"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   383
unfolding finals_def
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   384
unfolding Image_def
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   385
unfolding str_eq_rel_def
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   386
apply(auto)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   387
apply(drule_tac x = "[]" in spec)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   388
apply(auto)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   389
done
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   390
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   391
lemma finals_in_partitions:
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   392
  shows "finals A \<subseteq> (UNIV // \<approx>A)"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   393
unfolding finals_def
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   394
unfolding quotient_def
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   395
by auto
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   396
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   397
section {* Direction @{text "finite partition \<Rightarrow> regular language"}*}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   398
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   399
text {* 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   400
  The relationship between equivalent classes can be described by an
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   401
  equational system.  For example, in equational system \eqref{example_eqns},
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   402
  $X_0, X_1$ are equivalent classes. The first equation says every string in
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   403
  $X_0$ is obtained either by appending one $b$ to a string in $X_0$ or by
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   404
  appending one $a$ to a string in $X_1$ or just be an empty string
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   405
  (represented by the regular expression $\lambda$). Similary, the second
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   406
  equation tells how the strings inside $X_1$ are composed.
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   407
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   408
  \begin{equation}\label{example_eqns}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   409
    \begin{aligned}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   410
      X_0 & = X_0 b + X_1 a + \lambda \\
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   411
      X_1 & = X_0 a + X_1 b
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   412
    \end{aligned}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   413
  \end{equation}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   414
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   415
  \noindent
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   416
  The summands on the right hand side is represented by the following data
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   417
  type @{text "rhs_item"}, mnemonic for 'right hand side item'.  Generally,
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   418
  there are two kinds of right hand side items, one kind corresponds to pure
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   419
  regular expressions, like the $\lambda$ in \eqref{example_eqns}, the other
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   420
  kind corresponds to transitions from one one equivalent class to another,
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   421
  like the $X_0 b, X_1 a$ etc.
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   422
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   423
*}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   424
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   425
datatype rhs_item = 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   426
   Lam "rexp"            (* Lambda *)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   427
 | Trn "lang" "rexp"     (* Transition *)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   428
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   429
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   430
text {*
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   431
  In this formalization, pure regular expressions like $\lambda$ is 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   432
  repsented by @{text "Lam(EMPTY)"}, while transitions like $X_0 a$ is 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   433
  represented by @{term "Trn X\<^isub>0 (CHAR a)"}.
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   434
*}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   435
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   436
text {*
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   437
  Every right-hand side item @{text "itm"} defines a language given 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   438
  by @{text "L(itm)"}, defined as:
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   439
*}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   440
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   441
overloading L_rhs_e \<equiv> "L:: rhs_item \<Rightarrow> lang"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   442
begin
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   443
  fun L_rhs_e:: "rhs_item \<Rightarrow> lang"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   444
  where
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   445
    "L_rhs_e (Lam r) = L r" 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   446
  | "L_rhs_e (Trn X r) = X ;; L r"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   447
end
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   448
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   449
text {*
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   450
  The right hand side of every equation is represented by a set of
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   451
  items. The string set defined by such a set @{text "itms"} is given
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   452
  by @{text "L(itms)"}, defined as:
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   453
*}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   454
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   455
overloading L_rhs \<equiv> "L:: rhs_item set \<Rightarrow> lang"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   456
begin
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   457
   fun L_rhs:: "rhs_item set \<Rightarrow> lang"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   458
   where 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   459
     "L_rhs rhs = \<Union> (L ` rhs)"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   460
end
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   461
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   462
text {* 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   463
  Given a set of equivalence classes @{text "CS"} and one equivalence class @{text "X"} among
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   464
  @{text "CS"}, the term @{text "init_rhs CS X"} is used to extract the right hand side of
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   465
  the equation describing the formation of @{text "X"}. The definition of @{text "init_rhs"}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   466
  is:
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   467
*}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   468
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   469
definition 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   470
  transition :: "lang \<Rightarrow> rexp \<Rightarrow> lang \<Rightarrow> bool" ("_ \<Turnstile>_\<Rightarrow>_" [100,100,100] 100)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   471
where
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   472
  "Y \<Turnstile>r\<Rightarrow> X \<equiv> Y ;; (L r) \<subseteq> X"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   473
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   474
definition
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   475
  "init_rhs CS X \<equiv>  
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   476
      if ([] \<in> X) then 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   477
          {Lam EMPTY} \<union> {Trn Y (CHAR c) | Y c. Y \<in> CS \<and> Y \<Turnstile>(CHAR c)\<Rightarrow> X}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   478
      else 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   479
          {Trn Y (CHAR c)| Y c. Y \<in> CS \<and> Y \<Turnstile>(CHAR c)\<Rightarrow> X}"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   480
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   481
text {*
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   482
  In the definition of @{text "init_rhs"}, the term 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   483
  @{text "{Trn Y (CHAR c)| Y c. Y \<in> CS \<and> Y ;; {[c]} \<subseteq> X}"} appearing on both branches
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   484
  describes the formation of strings in @{text "X"} out of transitions, while 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   485
  the term @{text "{Lam(EMPTY)}"} describes the empty string which is intrinsically contained in
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   486
  @{text "X"} rather than by transition. This @{text "{Lam(EMPTY)}"} corresponds to 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   487
  the $\lambda$ in \eqref{example_eqns}.
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   488
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   489
  With the help of @{text "init_rhs"}, the equitional system descrbing the formation of every
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   490
  equivalent class inside @{text "CS"} is given by the following @{text "eqs(CS)"}.
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   491
*}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   492
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   493
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   494
definition "eqs CS \<equiv> {(X, init_rhs CS X) | X.  X \<in> CS}"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   495
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   496
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   497
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   498
(************ arden's lemma variation ********************)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   499
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   500
text {* 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   501
  The following @{text "trns_of rhs X"} returns all @{text "X"}-items in @{text "rhs"}.
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   502
*}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   503
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   504
definition
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   505
  "trns_of rhs X \<equiv> {Trn X r | r. Trn X r \<in> rhs}"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   506
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   507
text {*
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   508
  The following @{text "attach_rexp rexp' itm"} attach 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   509
  the regular expression @{text "rexp'"} to
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   510
  the right of right hand side item @{text "itm"}.
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   511
*}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   512
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   513
fun 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   514
  attach_rexp :: "rexp \<Rightarrow> rhs_item \<Rightarrow> rhs_item"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   515
where
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   516
  "attach_rexp rexp' (Lam rexp)   = Lam (SEQ rexp rexp')"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   517
| "attach_rexp rexp' (Trn X rexp) = Trn X (SEQ rexp rexp')"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   518
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   519
text {* 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   520
  The following @{text "append_rhs_rexp rhs rexp"} attaches 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   521
  @{text "rexp"} to every item in @{text "rhs"}.
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   522
*}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   523
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   524
definition
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   525
  "append_rhs_rexp rhs rexp \<equiv> (attach_rexp rexp) ` rhs"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   526
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   527
text {*
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   528
  With the help of the two functions immediately above, Ardens'
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   529
  transformation on right hand side @{text "rhs"} is implemented
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   530
  by the following function @{text "arden_variate X rhs"}.
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   531
  After this transformation, the recursive occurence of @{text "X"}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   532
  in @{text "rhs"} will be eliminated, while the string set defined 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   533
  by @{text "rhs"} is kept unchanged.
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   534
*}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   535
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   536
definition 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   537
  "arden_variate X rhs \<equiv> 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   538
        append_rhs_rexp (rhs - trns_of rhs X) (STAR (\<Uplus> {r. Trn X r \<in> rhs}))"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   539
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   540
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   541
(*********** substitution of ES *************)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   542
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   543
text {* 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   544
  Suppose the equation defining @{text "X"} is $X = xrhs$,
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   545
  the purpose of @{text "rhs_subst"} is to substitute all occurences of @{text "X"} in
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   546
  @{text "rhs"} by @{text "xrhs"}.
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   547
  A litte thought may reveal that the final result
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   548
  should be: first append $(a_1 | a_2 | \ldots | a_n)$ to every item of @{text "xrhs"} and then
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   549
  union the result with all non-@{text "X"}-items of @{text "rhs"}.
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   550
 *}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   551
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   552
definition 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   553
  "rhs_subst rhs X xrhs \<equiv> 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   554
        (rhs - (trns_of rhs X)) \<union> (append_rhs_rexp xrhs (\<Uplus> {r. Trn X r \<in> rhs}))"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   555
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   556
text {*
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   557
  Suppose the equation defining @{text "X"} is $X = xrhs$, the follwing
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   558
  @{text "eqs_subst ES X xrhs"} substitute @{text "xrhs"} into every equation
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   559
  of the equational system @{text "ES"}.
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   560
  *}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   561
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   562
definition
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   563
  "eqs_subst ES X xrhs \<equiv> {(Y, rhs_subst yrhs X xrhs) | Y yrhs. (Y, yrhs) \<in> ES}"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   564
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   565
text {*
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   566
  The computation of regular expressions for equivalence classes is accomplished
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   567
  using a iteration principle given by the following lemma.
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   568
*}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   569
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   570
lemma wf_iter [rule_format]: 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   571
  fixes f
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   572
  assumes step: "\<And> e. \<lbrakk>P e; \<not> Q e\<rbrakk> \<Longrightarrow> (\<exists> e'. P e' \<and>  (f(e'), f(e)) \<in> less_than)"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   573
  shows pe:     "P e \<longrightarrow> (\<exists> e'. P e' \<and>  Q e')"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   574
proof(induct e rule: wf_induct 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   575
           [OF wf_inv_image[OF wf_less_than, where f = "f"]], clarify)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   576
  fix x 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   577
  assume h [rule_format]: 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   578
    "\<forall>y. (y, x) \<in> inv_image less_than f \<longrightarrow> P y \<longrightarrow> (\<exists>e'. P e' \<and> Q e')"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   579
    and px: "P x"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   580
  show "\<exists>e'. P e' \<and> Q e'"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   581
  proof(cases "Q x")
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   582
    assume "Q x" with px show ?thesis by blast
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   583
  next
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   584
    assume nq: "\<not> Q x"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   585
    from step [OF px nq]
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   586
    obtain e' where pe': "P e'" and ltf: "(f e', f x) \<in> less_than" by auto
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   587
    show ?thesis
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   588
    proof(rule h)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   589
      from ltf show "(e', x) \<in> inv_image less_than f" 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   590
	by (simp add:inv_image_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   591
    next
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   592
      from pe' show "P e'" .
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   593
    qed
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   594
  qed
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   595
qed
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   596
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   597
text {*
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   598
  The @{text "P"} in lemma @{text "wf_iter"} is an invariant kept throughout the iteration procedure.
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   599
  The particular invariant used to solve our problem is defined by function @{text "Inv(ES)"},
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   600
  an invariant over equal system @{text "ES"}.
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   601
  Every definition starting next till @{text "Inv"} stipulates a property to be satisfied by @{text "ES"}.
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   602
*}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   603
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   604
text {* 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   605
  Every variable is defined at most onece in @{text "ES"}.
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   606
  *}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   607
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   608
definition 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   609
  "distinct_equas ES \<equiv> 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   610
            \<forall> X rhs rhs'. (X, rhs) \<in> ES \<and> (X, rhs') \<in> ES \<longrightarrow> rhs = rhs'"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   611
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   612
text {* 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   613
  Every equation in @{text "ES"} (represented by @{text "(X, rhs)"}) is valid, i.e. @{text "(X = L rhs)"}.
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   614
  *}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   615
definition 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   616
  "valid_eqns ES \<equiv> \<forall> X rhs. (X, rhs) \<in> ES \<longrightarrow> (X = L rhs)"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   617
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   618
text {*
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   619
  The following @{text "rhs_nonempty rhs"} requires regular expressions occuring in transitional 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   620
  items of @{text "rhs"} does not contain empty string. This is necessary for
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   621
  the application of Arden's transformation to @{text "rhs"}.
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   622
  *}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   623
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   624
definition 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   625
  "rhs_nonempty rhs \<equiv> (\<forall> Y r. Trn Y r \<in> rhs \<longrightarrow> [] \<notin> L r)"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   626
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   627
text {*
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   628
  The following @{text "ardenable ES"} requires that Arden's transformation is applicable
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   629
  to every equation of equational system @{text "ES"}.
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   630
  *}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   631
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   632
definition 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   633
  "ardenable ES \<equiv> \<forall> X rhs. (X, rhs) \<in> ES \<longrightarrow> rhs_nonempty rhs"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   634
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   635
(* The following non_empty seems useless. *)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   636
definition 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   637
  "non_empty ES \<equiv> \<forall> X rhs. (X, rhs) \<in> ES \<longrightarrow> X \<noteq> {}"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   638
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   639
text {*
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   640
  The following @{text "finite_rhs ES"} requires every equation in @{text "rhs"} be finite.
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   641
  *}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   642
definition
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   643
  "finite_rhs ES \<equiv> \<forall> X rhs. (X, rhs) \<in> ES \<longrightarrow> finite rhs"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   644
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   645
text {*
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   646
  The following @{text "classes_of rhs"} returns all variables (or equivalent classes)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   647
  occuring in @{text "rhs"}.
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   648
  *}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   649
definition 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   650
  "classes_of rhs \<equiv> {X. \<exists> r. Trn X r \<in> rhs}"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   651
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   652
text {*
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   653
  The following @{text "lefts_of ES"} returns all variables 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   654
  defined by equational system @{text "ES"}.
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   655
  *}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   656
definition
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   657
  "lefts_of ES \<equiv> {Y | Y yrhs. (Y, yrhs) \<in> ES}"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   658
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   659
text {*
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   660
  The following @{text "self_contained ES"} requires that every
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   661
  variable occuring on the right hand side of equations is already defined by some
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   662
  equation in @{text "ES"}.
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   663
  *}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   664
definition 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   665
  "self_contained ES \<equiv> \<forall> (X, xrhs) \<in> ES. classes_of xrhs \<subseteq> lefts_of ES"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   666
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   667
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   668
text {*
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   669
  The invariant @{text "Inv(ES)"} is a conjunction of all the previously defined constaints.
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   670
  *}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   671
definition 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   672
  "Inv ES \<equiv> valid_eqns ES \<and> finite ES \<and> distinct_equas ES \<and> ardenable ES \<and> 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   673
                non_empty ES \<and> finite_rhs ES \<and> self_contained ES"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   674
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   675
subsection {* The proof of this direction *}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   676
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   677
subsubsection {* Basic properties *}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   678
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   679
text {*
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   680
  The following are some basic properties of the above definitions.
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   681
*}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   682
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   683
lemma L_rhs_union_distrib:
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   684
  fixes A B::"rhs_item set"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   685
  shows "L A \<union> L B = L (A \<union> B)"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   686
by simp
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   687
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   688
lemma finite_Trn:
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   689
  assumes fin: "finite rhs"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   690
  shows "finite {r. Trn Y r \<in> rhs}"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   691
proof -
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   692
  have "finite {Trn Y r | Y r. Trn Y r \<in> rhs}"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   693
    by (rule rev_finite_subset[OF fin]) (auto)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   694
  then have "finite ((\<lambda>(Y, r). Trn Y r) ` {(Y, r) | Y r. Trn Y r \<in> rhs})"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   695
    by (simp add: image_Collect)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   696
  then have "finite {(Y, r) | Y r. Trn Y r \<in> rhs}"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   697
    by (erule_tac finite_imageD) (simp add: inj_on_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   698
  then show "finite {r. Trn Y r \<in> rhs}"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   699
    by (erule_tac f="snd" in finite_surj) (auto simp add: image_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   700
qed
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   701
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   702
lemma finite_Lam:
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   703
  assumes fin:"finite rhs"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   704
  shows "finite {r. Lam r \<in> rhs}"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   705
proof -
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   706
  have "finite {Lam r | r. Lam r \<in> rhs}"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   707
    by (rule rev_finite_subset[OF fin]) (auto)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   708
  then show "finite {r. Lam r \<in> rhs}"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   709
    apply(simp add: image_Collect[symmetric])
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   710
    apply(erule finite_imageD)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   711
    apply(auto simp add: inj_on_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   712
    done
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   713
qed
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   714
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   715
lemma rexp_of_empty:
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   716
  assumes finite:"finite rhs"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   717
  and nonempty:"rhs_nonempty rhs"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   718
  shows "[] \<notin> L (\<Uplus> {r. Trn X r \<in> rhs})"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   719
using finite nonempty rhs_nonempty_def
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   720
using finite_Trn[OF finite]
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   721
by (auto)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   722
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   723
lemma [intro!]:
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   724
  "P (Trn X r) \<Longrightarrow> (\<exists>a. (\<exists>r. a = Trn X r \<and> P a))" by auto
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   725
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   726
lemma lang_of_rexp_of:
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   727
  assumes finite:"finite rhs"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   728
  shows "L ({Trn X r| r. Trn X r \<in> rhs}) = X ;; (L (\<Uplus>{r. Trn X r \<in> rhs}))"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   729
proof -
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   730
  have "finite {r. Trn X r \<in> rhs}" 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   731
    by (rule finite_Trn[OF finite]) 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   732
  then show ?thesis
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   733
    apply(auto simp add: Seq_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   734
    apply(rule_tac x = "s\<^isub>1" in exI, rule_tac x = "s\<^isub>2" in exI, auto)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   735
    apply(rule_tac x= "Trn X xa" in exI)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   736
    apply(auto simp: Seq_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   737
    done
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   738
qed
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   739
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   740
lemma rexp_of_lam_eq_lam_set:
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   741
  assumes fin: "finite rhs"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   742
  shows "L (\<Uplus>{r. Lam r \<in> rhs}) = L ({Lam r | r. Lam r \<in> rhs})"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   743
proof -
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   744
  have "finite ({r. Lam r \<in> rhs})" using fin by (rule finite_Lam)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   745
  then show ?thesis by auto
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   746
qed
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   747
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   748
lemma [simp]:
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   749
  "L (attach_rexp r xb) = L xb ;; L r"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   750
apply (cases xb, auto simp: Seq_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   751
apply(rule_tac x = "s\<^isub>1 @ s\<^isub>1'" in exI, rule_tac x = "s\<^isub>2'" in exI)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   752
apply(auto simp: Seq_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   753
done
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   754
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   755
lemma lang_of_append_rhs:
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   756
  "L (append_rhs_rexp rhs r) = L rhs ;; L r"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   757
apply (auto simp:append_rhs_rexp_def image_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   758
apply (auto simp:Seq_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   759
apply (rule_tac x = "L xb ;; L r" in exI, auto simp add:Seq_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   760
by (rule_tac x = "attach_rexp r xb" in exI, auto simp:Seq_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   761
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   762
lemma classes_of_union_distrib:
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   763
  "classes_of A \<union> classes_of B = classes_of (A \<union> B)"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   764
by (auto simp add:classes_of_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   765
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   766
lemma lefts_of_union_distrib:
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   767
  "lefts_of A \<union> lefts_of B = lefts_of (A \<union> B)"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   768
by (auto simp:lefts_of_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   769
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   770
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   771
subsubsection {* Intialization *}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   772
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   773
text {*
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   774
  The following several lemmas until @{text "init_ES_satisfy_Inv"} shows that
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   775
  the initial equational system satisfies invariant @{text "Inv"}.
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   776
*}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   777
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   778
lemma defined_by_str:
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   779
  "\<lbrakk>s \<in> X; X \<in> UNIV // (\<approx>Lang)\<rbrakk> \<Longrightarrow> X = (\<approx>Lang) `` {s}"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   780
by (auto simp:quotient_def Image_def str_eq_rel_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   781
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   782
lemma every_eqclass_has_transition:
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   783
  assumes has_str: "s @ [c] \<in> X"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   784
  and     in_CS:   "X \<in> UNIV // (\<approx>Lang)"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   785
  obtains Y where "Y \<in> UNIV // (\<approx>Lang)" and "Y ;; {[c]} \<subseteq> X" and "s \<in> Y"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   786
proof -
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   787
  def Y \<equiv> "(\<approx>Lang) `` {s}"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   788
  have "Y \<in> UNIV // (\<approx>Lang)" 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   789
    unfolding Y_def quotient_def by auto
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   790
  moreover
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   791
  have "X = (\<approx>Lang) `` {s @ [c]}" 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   792
    using has_str in_CS defined_by_str by blast
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   793
  then have "Y ;; {[c]} \<subseteq> X" 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   794
    unfolding Y_def Image_def Seq_def
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   795
    unfolding str_eq_rel_def
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   796
    by clarsimp
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   797
  moreover
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   798
  have "s \<in> Y" unfolding Y_def 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   799
    unfolding Image_def str_eq_rel_def by simp
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   800
  ultimately show thesis by (blast intro: that)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   801
qed
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   802
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   803
lemma l_eq_r_in_eqs:
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   804
  assumes X_in_eqs: "(X, xrhs) \<in> (eqs (UNIV // (\<approx>Lang)))"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   805
  shows "X = L xrhs"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   806
proof 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   807
  show "X \<subseteq> L xrhs"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   808
  proof
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   809
    fix x
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   810
    assume "(1)": "x \<in> X"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   811
    show "x \<in> L xrhs"          
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   812
    proof (cases "x = []")
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   813
      assume empty: "x = []"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   814
      thus ?thesis using X_in_eqs "(1)"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   815
        by (auto simp:eqs_def init_rhs_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   816
    next
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   817
      assume not_empty: "x \<noteq> []"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   818
      then obtain clist c where decom: "x = clist @ [c]"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   819
        by (case_tac x rule:rev_cases, auto)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   820
      have "X \<in> UNIV // (\<approx>Lang)" using X_in_eqs by (auto simp:eqs_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   821
      then obtain Y 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   822
        where "Y \<in> UNIV // (\<approx>Lang)" 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   823
        and "Y ;; {[c]} \<subseteq> X"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   824
        and "clist \<in> Y"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   825
        using decom "(1)" every_eqclass_has_transition by blast
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   826
      hence 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   827
        "x \<in> L {Trn Y (CHAR c)| Y c. Y \<in> UNIV // (\<approx>Lang) \<and> Y \<Turnstile>(CHAR c)\<Rightarrow> X}"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   828
        unfolding transition_def
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   829
	using "(1)" decom
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   830
        by (simp, rule_tac x = "Trn Y (CHAR c)" in exI, simp add:Seq_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   831
      thus ?thesis using X_in_eqs "(1)"	
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   832
        by (simp add: eqs_def init_rhs_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   833
    qed
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   834
  qed
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   835
next
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   836
  show "L xrhs \<subseteq> X" using X_in_eqs
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   837
    by (auto simp:eqs_def init_rhs_def transition_def) 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   838
qed
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   839
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   840
lemma finite_init_rhs: 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   841
  assumes finite: "finite CS"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   842
  shows "finite (init_rhs CS X)"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   843
proof-
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   844
  have "finite {Trn Y (CHAR c) |Y c. Y \<in> CS \<and> Y ;; {[c]} \<subseteq> X}" (is "finite ?A")
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   845
  proof -
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   846
    def S \<equiv> "{(Y, c)| Y c. Y \<in> CS \<and> Y ;; {[c]} \<subseteq> X}" 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   847
    def h \<equiv> "\<lambda> (Y, c). Trn Y (CHAR c)"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   848
    have "finite (CS \<times> (UNIV::char set))" using finite by auto
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   849
    hence "finite S" using S_def 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   850
      by (rule_tac B = "CS \<times> UNIV" in finite_subset, auto)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   851
    moreover have "?A = h ` S" by (auto simp: S_def h_def image_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   852
    ultimately show ?thesis 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   853
      by auto
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   854
  qed
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   855
  thus ?thesis by (simp add:init_rhs_def transition_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   856
qed
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   857
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   858
lemma init_ES_satisfy_Inv:
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   859
  assumes finite_CS: "finite (UNIV // (\<approx>Lang))"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   860
  shows "Inv (eqs (UNIV // (\<approx>Lang)))"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   861
proof -
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   862
  have "finite (eqs (UNIV // (\<approx>Lang)))" using finite_CS
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   863
    by (simp add:eqs_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   864
  moreover have "distinct_equas (eqs (UNIV // (\<approx>Lang)))"     
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   865
    by (simp add:distinct_equas_def eqs_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   866
  moreover have "ardenable (eqs (UNIV // (\<approx>Lang)))"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   867
    by (auto simp add:ardenable_def eqs_def init_rhs_def rhs_nonempty_def del:L_rhs.simps)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   868
  moreover have "valid_eqns (eqs (UNIV // (\<approx>Lang)))"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   869
    using l_eq_r_in_eqs by (simp add:valid_eqns_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   870
  moreover have "non_empty (eqs (UNIV // (\<approx>Lang)))"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   871
    by (auto simp:non_empty_def eqs_def quotient_def Image_def str_eq_rel_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   872
  moreover have "finite_rhs (eqs (UNIV // (\<approx>Lang)))"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   873
    using finite_init_rhs[OF finite_CS] 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   874
    by (auto simp:finite_rhs_def eqs_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   875
  moreover have "self_contained (eqs (UNIV // (\<approx>Lang)))"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   876
    by (auto simp:self_contained_def eqs_def init_rhs_def classes_of_def lefts_of_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   877
  ultimately show ?thesis by (simp add:Inv_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   878
qed
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   879
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   880
subsubsection {* 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   881
  Interation step
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   882
  *}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   883
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   884
text {*
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   885
  From this point until @{text "iteration_step"}, it is proved
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   886
  that there exists iteration steps which keep @{text "Inv(ES)"} while
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   887
  decreasing the size of @{text "ES"}.
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   888
*}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   889
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   890
lemma arden_variate_keeps_eq:
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   891
  assumes l_eq_r: "X = L rhs"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   892
  and not_empty: "[] \<notin> L (\<Uplus>{r. Trn X r \<in> rhs})"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   893
  and finite: "finite rhs"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   894
  shows "X = L (arden_variate X rhs)"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   895
proof -
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   896
  def A \<equiv> "L (\<Uplus>{r. Trn X r \<in> rhs})"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   897
  def b \<equiv> "rhs - trns_of rhs X"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   898
  def B \<equiv> "L b" 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   899
  have "X = B ;; A\<star>"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   900
  proof-
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   901
    have "L rhs = L(trns_of rhs X \<union> b)" by (auto simp: b_def trns_of_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   902
    also have "\<dots> = X ;; A \<union> B"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   903
      unfolding trns_of_def
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   904
      unfolding L_rhs_union_distrib[symmetric]
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   905
      by (simp only: lang_of_rexp_of finite B_def A_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   906
    finally show ?thesis
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   907
      using l_eq_r not_empty
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   908
      apply(rule_tac ardens_revised[THEN iffD1])
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   909
      apply(simp add: A_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   910
      apply(simp)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   911
      done
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   912
  qed
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   913
  moreover have "L (arden_variate X rhs) = (B ;; A\<star>)"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   914
    by (simp only:arden_variate_def L_rhs_union_distrib lang_of_append_rhs 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   915
                  B_def A_def b_def L_rexp.simps seq_union_distrib_left)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   916
   ultimately show ?thesis by simp
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   917
qed 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   918
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   919
lemma append_keeps_finite:
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   920
  "finite rhs \<Longrightarrow> finite (append_rhs_rexp rhs r)"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   921
by (auto simp:append_rhs_rexp_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   922
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   923
lemma arden_variate_keeps_finite:
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   924
  "finite rhs \<Longrightarrow> finite (arden_variate X rhs)"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   925
by (auto simp:arden_variate_def append_keeps_finite)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   926
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   927
lemma append_keeps_nonempty:
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   928
  "rhs_nonempty rhs \<Longrightarrow> rhs_nonempty (append_rhs_rexp rhs r)"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   929
apply (auto simp:rhs_nonempty_def append_rhs_rexp_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   930
by (case_tac x, auto simp:Seq_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   931
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   932
lemma nonempty_set_sub:
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   933
  "rhs_nonempty rhs \<Longrightarrow> rhs_nonempty (rhs - A)"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   934
by (auto simp:rhs_nonempty_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   935
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   936
lemma nonempty_set_union:
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   937
  "\<lbrakk>rhs_nonempty rhs; rhs_nonempty rhs'\<rbrakk> \<Longrightarrow> rhs_nonempty (rhs \<union> rhs')"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   938
by (auto simp:rhs_nonempty_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   939
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   940
lemma arden_variate_keeps_nonempty:
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   941
  "rhs_nonempty rhs \<Longrightarrow> rhs_nonempty (arden_variate X rhs)"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   942
by (simp only:arden_variate_def append_keeps_nonempty nonempty_set_sub)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   943
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   944
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   945
lemma rhs_subst_keeps_nonempty:
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   946
  "\<lbrakk>rhs_nonempty rhs; rhs_nonempty xrhs\<rbrakk> \<Longrightarrow> rhs_nonempty (rhs_subst rhs X xrhs)"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   947
by (simp only:rhs_subst_def append_keeps_nonempty  nonempty_set_union nonempty_set_sub)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   948
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   949
lemma rhs_subst_keeps_eq:
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   950
  assumes substor: "X = L xrhs"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   951
  and finite: "finite rhs"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   952
  shows "L (rhs_subst rhs X xrhs) = L rhs" (is "?Left = ?Right")
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   953
proof-
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   954
  def A \<equiv> "L (rhs - trns_of rhs X)"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   955
  have "?Left = A \<union> L (append_rhs_rexp xrhs (\<Uplus>{r. Trn X r \<in> rhs}))"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   956
    unfolding rhs_subst_def
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   957
    unfolding L_rhs_union_distrib[symmetric]
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   958
    by (simp add: A_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   959
  moreover have "?Right = A \<union> L ({Trn X r | r. Trn X r \<in> rhs})"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   960
  proof-
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   961
    have "rhs = (rhs - trns_of rhs X) \<union> (trns_of rhs X)" by (auto simp add: trns_of_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   962
    thus ?thesis 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   963
      unfolding A_def
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   964
      unfolding L_rhs_union_distrib
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   965
      unfolding trns_of_def
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   966
      by simp
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   967
  qed
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   968
  moreover have "L (append_rhs_rexp xrhs (\<Uplus>{r. Trn X r \<in> rhs})) = L ({Trn X r | r. Trn X r \<in> rhs})" 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   969
    using finite substor  by (simp only:lang_of_append_rhs lang_of_rexp_of)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   970
  ultimately show ?thesis by simp
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   971
qed
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   972
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   973
lemma rhs_subst_keeps_finite_rhs:
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   974
  "\<lbrakk>finite rhs; finite yrhs\<rbrakk> \<Longrightarrow> finite (rhs_subst rhs Y yrhs)"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   975
by (auto simp:rhs_subst_def append_keeps_finite)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   976
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   977
lemma eqs_subst_keeps_finite:
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   978
  assumes finite:"finite (ES:: (string set \<times> rhs_item set) set)"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   979
  shows "finite (eqs_subst ES Y yrhs)"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   980
proof -
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   981
  have "finite {(Ya, rhs_subst yrhsa Y yrhs) |Ya yrhsa. (Ya, yrhsa) \<in> ES}" 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   982
                                                                  (is "finite ?A")
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   983
  proof-
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   984
    def eqns' \<equiv> "{((Ya::string set), yrhsa)| Ya yrhsa. (Ya, yrhsa) \<in> ES}"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   985
    def h \<equiv> "\<lambda> ((Ya::string set), yrhsa). (Ya, rhs_subst yrhsa Y yrhs)"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   986
    have "finite (h ` eqns')" using finite h_def eqns'_def by auto
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   987
    moreover have "?A = h ` eqns'" by (auto simp:h_def eqns'_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   988
    ultimately show ?thesis by auto      
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   989
  qed
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   990
  thus ?thesis by (simp add:eqs_subst_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   991
qed
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   992
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   993
lemma eqs_subst_keeps_finite_rhs:
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   994
  "\<lbrakk>finite_rhs ES; finite yrhs\<rbrakk> \<Longrightarrow> finite_rhs (eqs_subst ES Y yrhs)"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   995
by (auto intro:rhs_subst_keeps_finite_rhs simp add:eqs_subst_def finite_rhs_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   996
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   997
lemma append_rhs_keeps_cls:
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   998
  "classes_of (append_rhs_rexp rhs r) = classes_of rhs"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
   999
apply (auto simp:classes_of_def append_rhs_rexp_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1000
apply (case_tac xa, auto simp:image_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1001
by (rule_tac x = "SEQ ra r" in exI, rule_tac x = "Trn x ra" in bexI, simp+)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1002
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1003
lemma arden_variate_removes_cl:
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1004
  "classes_of (arden_variate Y yrhs) = classes_of yrhs - {Y}"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1005
apply (simp add:arden_variate_def append_rhs_keeps_cls trns_of_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1006
by (auto simp:classes_of_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1007
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1008
lemma lefts_of_keeps_cls:
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1009
  "lefts_of (eqs_subst ES Y yrhs) = lefts_of ES"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1010
by (auto simp:lefts_of_def eqs_subst_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1011
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1012
lemma rhs_subst_updates_cls:
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1013
  "X \<notin> classes_of xrhs \<Longrightarrow> 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1014
      classes_of (rhs_subst rhs X xrhs) = classes_of rhs \<union> classes_of xrhs - {X}"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1015
apply (simp only:rhs_subst_def append_rhs_keeps_cls 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1016
                              classes_of_union_distrib[THEN sym])
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1017
by (auto simp:classes_of_def trns_of_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1018
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1019
lemma eqs_subst_keeps_self_contained:
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1020
  fixes Y
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1021
  assumes sc: "self_contained (ES \<union> {(Y, yrhs)})" (is "self_contained ?A")
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1022
  shows "self_contained (eqs_subst ES Y (arden_variate Y yrhs))" 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1023
                                                   (is "self_contained ?B")
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1024
proof-
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1025
  { fix X xrhs'
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1026
    assume "(X, xrhs') \<in> ?B"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1027
    then obtain xrhs 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1028
      where xrhs_xrhs': "xrhs' = rhs_subst xrhs Y (arden_variate Y yrhs)"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1029
      and X_in: "(X, xrhs) \<in> ES" by (simp add:eqs_subst_def, blast)    
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1030
    have "classes_of xrhs' \<subseteq> lefts_of ?B"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1031
    proof-
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1032
      have "lefts_of ?B = lefts_of ES" by (auto simp add:lefts_of_def eqs_subst_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1033
      moreover have "classes_of xrhs' \<subseteq> lefts_of ES"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1034
      proof-
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1035
        have "classes_of xrhs' \<subseteq> 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1036
                        classes_of xrhs \<union> classes_of (arden_variate Y yrhs) - {Y}"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1037
        proof-
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1038
          have "Y \<notin> classes_of (arden_variate Y yrhs)" 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1039
            using arden_variate_removes_cl by simp
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1040
          thus ?thesis using xrhs_xrhs' by (auto simp:rhs_subst_updates_cls)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1041
        qed
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1042
        moreover have "classes_of xrhs \<subseteq> lefts_of ES \<union> {Y}" using X_in sc
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1043
          apply (simp only:self_contained_def lefts_of_union_distrib[THEN sym])
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1044
          by (drule_tac x = "(X, xrhs)" in bspec, auto simp:lefts_of_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1045
        moreover have "classes_of (arden_variate Y yrhs) \<subseteq> lefts_of ES \<union> {Y}" 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1046
          using sc 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1047
          by (auto simp add:arden_variate_removes_cl self_contained_def lefts_of_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1048
        ultimately show ?thesis by auto
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1049
      qed
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1050
      ultimately show ?thesis by simp
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1051
    qed
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1052
  } thus ?thesis by (auto simp only:eqs_subst_def self_contained_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1053
qed
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1054
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1055
lemma eqs_subst_satisfy_Inv:
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1056
  assumes Inv_ES: "Inv (ES \<union> {(Y, yrhs)})"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1057
  shows "Inv (eqs_subst ES Y (arden_variate Y yrhs))"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1058
proof -  
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1059
  have finite_yrhs: "finite yrhs" 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1060
    using Inv_ES by (auto simp:Inv_def finite_rhs_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1061
  have nonempty_yrhs: "rhs_nonempty yrhs" 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1062
    using Inv_ES by (auto simp:Inv_def ardenable_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1063
  have Y_eq_yrhs: "Y = L yrhs" 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1064
    using Inv_ES by (simp only:Inv_def valid_eqns_def, blast)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1065
  have "distinct_equas (eqs_subst ES Y (arden_variate Y yrhs))" 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1066
    using Inv_ES
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1067
    by (auto simp:distinct_equas_def eqs_subst_def Inv_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1068
  moreover have "finite (eqs_subst ES Y (arden_variate Y yrhs))" 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1069
    using Inv_ES by (simp add:Inv_def eqs_subst_keeps_finite)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1070
  moreover have "finite_rhs (eqs_subst ES Y (arden_variate Y yrhs))"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1071
  proof-
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1072
    have "finite_rhs ES" using Inv_ES 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1073
      by (simp add:Inv_def finite_rhs_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1074
    moreover have "finite (arden_variate Y yrhs)"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1075
    proof -
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1076
      have "finite yrhs" using Inv_ES 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1077
        by (auto simp:Inv_def finite_rhs_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1078
      thus ?thesis using arden_variate_keeps_finite by simp
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1079
    qed
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1080
    ultimately show ?thesis 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1081
      by (simp add:eqs_subst_keeps_finite_rhs)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1082
  qed
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1083
  moreover have "ardenable (eqs_subst ES Y (arden_variate Y yrhs))"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1084
  proof - 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1085
    { fix X rhs
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1086
      assume "(X, rhs) \<in> ES"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1087
      hence "rhs_nonempty rhs"  using prems Inv_ES  
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1088
        by (simp add:Inv_def ardenable_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1089
      with nonempty_yrhs 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1090
      have "rhs_nonempty (rhs_subst rhs Y (arden_variate Y yrhs))"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1091
        by (simp add:nonempty_yrhs 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1092
               rhs_subst_keeps_nonempty arden_variate_keeps_nonempty)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1093
    } thus ?thesis by (auto simp add:ardenable_def eqs_subst_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1094
  qed
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1095
  moreover have "valid_eqns (eqs_subst ES Y (arden_variate Y yrhs))"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1096
  proof-
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1097
    have "Y = L (arden_variate Y yrhs)" 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1098
      using Y_eq_yrhs Inv_ES finite_yrhs nonempty_yrhs      
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1099
      by (rule_tac arden_variate_keeps_eq, (simp add:rexp_of_empty)+)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1100
    thus ?thesis using Inv_ES 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1101
      by (clarsimp simp add:valid_eqns_def 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1102
              eqs_subst_def rhs_subst_keeps_eq Inv_def finite_rhs_def
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1103
                   simp del:L_rhs.simps)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1104
  qed
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1105
  moreover have 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1106
    non_empty_subst: "non_empty (eqs_subst ES Y (arden_variate Y yrhs))"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1107
    using Inv_ES by (auto simp:Inv_def non_empty_def eqs_subst_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1108
  moreover 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1109
  have self_subst: "self_contained (eqs_subst ES Y (arden_variate Y yrhs))"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1110
    using Inv_ES eqs_subst_keeps_self_contained by (simp add:Inv_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1111
  ultimately show ?thesis using Inv_ES by (simp add:Inv_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1112
qed
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1113
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1114
lemma eqs_subst_card_le: 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1115
  assumes finite: "finite (ES::(string set \<times> rhs_item set) set)"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1116
  shows "card (eqs_subst ES Y yrhs) <= card ES"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1117
proof-
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1118
  def f \<equiv> "\<lambda> x. ((fst x)::string set, rhs_subst (snd x) Y yrhs)"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1119
  have "eqs_subst ES Y yrhs = f ` ES" 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1120
    apply (auto simp:eqs_subst_def f_def image_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1121
    by (rule_tac x = "(Ya, yrhsa)" in bexI, simp+)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1122
  thus ?thesis using finite by (auto intro:card_image_le)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1123
qed
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1124
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1125
lemma eqs_subst_cls_remains: 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1126
  "(X, xrhs) \<in> ES \<Longrightarrow> \<exists> xrhs'. (X, xrhs') \<in> (eqs_subst ES Y yrhs)"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1127
by (auto simp:eqs_subst_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1128
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1129
lemma card_noteq_1_has_more:
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1130
  assumes card:"card S \<noteq> 1"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1131
  and e_in: "e \<in> S"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1132
  and finite: "finite S"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1133
  obtains e' where "e' \<in> S \<and> e \<noteq> e'" 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1134
proof-
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1135
  have "card (S - {e}) > 0"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1136
  proof -
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1137
    have "card S > 1" using card e_in finite  
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1138
      by (case_tac "card S", auto) 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1139
    thus ?thesis using finite e_in by auto
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1140
  qed
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1141
  hence "S - {e} \<noteq> {}" using finite by (rule_tac notI, simp)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1142
  thus "(\<And>e'. e' \<in> S \<and> e \<noteq> e' \<Longrightarrow> thesis) \<Longrightarrow> thesis" by auto
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1143
qed
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1144
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1145
lemma iteration_step: 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1146
  assumes Inv_ES: "Inv ES"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1147
  and    X_in_ES: "(X, xrhs) \<in> ES"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1148
  and    not_T: "card ES \<noteq> 1"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1149
  shows "\<exists> ES'. (Inv ES' \<and> (\<exists> xrhs'.(X, xrhs') \<in> ES')) \<and> 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1150
                (card ES', card ES) \<in> less_than" (is "\<exists> ES'. ?P ES'")
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1151
proof -
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1152
  have finite_ES: "finite ES" using Inv_ES by (simp add:Inv_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1153
  then obtain Y yrhs 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1154
    where Y_in_ES: "(Y, yrhs) \<in> ES" and not_eq: "(X, xrhs) \<noteq> (Y, yrhs)" 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1155
    using not_T X_in_ES by (drule_tac card_noteq_1_has_more, auto)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1156
  def ES' == "ES - {(Y, yrhs)}"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1157
  let ?ES'' = "eqs_subst ES' Y (arden_variate Y yrhs)"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1158
  have "?P ?ES''"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1159
  proof -
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1160
    have "Inv ?ES''" using Y_in_ES Inv_ES
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1161
      by (rule_tac eqs_subst_satisfy_Inv, simp add:ES'_def insert_absorb)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1162
    moreover have "\<exists>xrhs'. (X, xrhs') \<in> ?ES''"  using not_eq X_in_ES
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1163
      by (rule_tac ES = ES' in eqs_subst_cls_remains, auto simp add:ES'_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1164
    moreover have "(card ?ES'', card ES) \<in> less_than" 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1165
    proof -
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1166
      have "finite ES'" using finite_ES ES'_def by auto
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1167
      moreover have "card ES' < card ES" using finite_ES Y_in_ES
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1168
        by (auto simp:ES'_def card_gt_0_iff intro:diff_Suc_less)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1169
      ultimately show ?thesis 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1170
        by (auto dest:eqs_subst_card_le elim:le_less_trans)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1171
    qed
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1172
    ultimately show ?thesis by simp
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1173
  qed
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1174
  thus ?thesis by blast
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1175
qed
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1176
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1177
subsubsection {*
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1178
  Conclusion of the proof
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1179
  *}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1180
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1181
text {*
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1182
  From this point until @{text "hard_direction"}, the hard direction is proved
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1183
  through a simple application of the iteration principle.
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1184
*}
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1185
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1186
lemma iteration_conc: 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1187
  assumes history: "Inv ES"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1188
  and    X_in_ES: "\<exists> xrhs. (X, xrhs) \<in> ES"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1189
  shows 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1190
  "\<exists> ES'. (Inv ES' \<and> (\<exists> xrhs'. (X, xrhs') \<in> ES')) \<and> card ES' = 1" 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1191
                                                          (is "\<exists> ES'. ?P ES'")
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1192
proof (cases "card ES = 1")
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1193
  case True
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1194
  thus ?thesis using history X_in_ES
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1195
    by blast
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1196
next
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1197
  case False  
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1198
  thus ?thesis using history iteration_step X_in_ES
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1199
    by (rule_tac f = card in wf_iter, auto)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1200
qed
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1201
  
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1202
lemma last_cl_exists_rexp:
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1203
  assumes ES_single: "ES = {(X, xrhs)}" 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1204
  and Inv_ES: "Inv ES"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1205
  shows "\<exists> (r::rexp). L r = X" (is "\<exists> r. ?P r")
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1206
proof-
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1207
  def A \<equiv> "arden_variate X xrhs"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1208
  have "?P (\<Uplus>{r. Lam r \<in> A})"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1209
  proof -
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1210
    have "L (\<Uplus>{r. Lam r \<in> A}) = L ({Lam r | r. Lam r \<in>  A})"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1211
    proof(rule rexp_of_lam_eq_lam_set)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1212
      show "finite A" 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1213
	unfolding A_def
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1214
	using Inv_ES ES_single 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1215
        by (rule_tac arden_variate_keeps_finite) 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1216
           (auto simp add: Inv_def finite_rhs_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1217
    qed
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1218
    also have "\<dots> = L A"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1219
    proof-
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1220
      have "{Lam r | r. Lam r \<in> A} = A"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1221
      proof-
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1222
        have "classes_of A = {}" using Inv_ES ES_single
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1223
	  unfolding A_def
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1224
          by (simp add:arden_variate_removes_cl 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1225
                       self_contained_def Inv_def lefts_of_def) 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1226
        thus ?thesis
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1227
	  unfolding A_def
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1228
          by (auto simp only: classes_of_def, case_tac x, auto)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1229
      qed
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1230
      thus ?thesis by simp
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1231
    qed
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1232
    also have "\<dots> = X"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1233
    unfolding A_def
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1234
    proof(rule arden_variate_keeps_eq [THEN sym])
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1235
      show "X = L xrhs" using Inv_ES ES_single 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1236
        by (auto simp only:Inv_def valid_eqns_def)  
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1237
    next
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1238
      from Inv_ES ES_single show "[] \<notin> L (\<Uplus>{r. Trn X r \<in> xrhs})"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1239
        by(simp add:Inv_def ardenable_def rexp_of_empty finite_rhs_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1240
    next
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1241
      from Inv_ES ES_single show "finite xrhs" 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1242
        by (simp add:Inv_def finite_rhs_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1243
    qed
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1244
    finally show ?thesis by simp
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1245
  qed
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1246
  thus ?thesis by auto
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1247
qed
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1248
   
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1249
lemma every_eqcl_has_reg: 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1250
  assumes finite_CS: "finite (UNIV // (\<approx>Lang))"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1251
  and X_in_CS: "X \<in> (UNIV // (\<approx>Lang))"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1252
  shows "\<exists> (reg::rexp). L reg = X" (is "\<exists> r. ?E r")
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1253
proof -
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1254
  from X_in_CS have "\<exists> xrhs. (X, xrhs) \<in> (eqs (UNIV  // (\<approx>Lang)))"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1255
    by (auto simp:eqs_def init_rhs_def)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1256
  then obtain ES xrhs where Inv_ES: "Inv ES" 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1257
    and X_in_ES: "(X, xrhs) \<in> ES"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1258
    and card_ES: "card ES = 1"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1259
    using finite_CS X_in_CS init_ES_satisfy_Inv iteration_conc
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1260
    by blast
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1261
  hence ES_single_equa: "ES = {(X, xrhs)}" 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1262
    by (auto simp:Inv_def dest!:card_Suc_Diff1 simp:card_eq_0_iff) 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1263
  thus ?thesis using Inv_ES
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1264
    by (rule last_cl_exists_rexp)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1265
qed
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1266
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1267
theorem hard_direction: 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1268
  assumes finite_CS: "finite (UNIV // \<approx>A)"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1269
  shows   "\<exists>r::rexp. A = L r"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1270
proof -
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1271
  have "\<forall> X \<in> (UNIV // \<approx>A). \<exists>reg::rexp. X = L reg" 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1272
    using finite_CS every_eqcl_has_reg by blast
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1273
  then obtain f 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1274
    where f_prop: "\<forall> X \<in> (UNIV // \<approx>A). X = L ((f X)::rexp)"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1275
    by (auto dest: bchoice)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1276
  def rs \<equiv> "f ` (finals A)"  
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1277
  have "A = \<Union> (finals A)" using lang_is_union_of_finals by auto
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1278
  also have "\<dots> = L (\<Uplus>rs)" 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1279
  proof -
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1280
    have "finite rs"
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1281
    proof -
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1282
      have "finite (finals A)" 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1283
        using finite_CS finals_in_partitions[of "A"]   
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1284
        by (erule_tac finite_subset, simp)
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1285
      thus ?thesis using rs_def by auto
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1286
    qed
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1287
    thus ?thesis 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1288
      using f_prop rs_def finals_in_partitions[of "A"] by auto
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1289
  qed
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1290
  finally show ?thesis by blast
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1291
qed 
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1292
f41351709800 saved a copy of the current Myhill for reference
urbanc
parents:
diff changeset
  1293
end