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