Myhill_1.thy
author urbanc
Wed, 09 Feb 2011 06:09:46 +0000
changeset 88 1436fc451bb9
parent 87 6a0efaabde19
child 89 42af13d194c9
permissions -rw-r--r--
added something about Setalt and folds
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
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
     2
imports Main Folds
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
section {* Preliminary definitions *}
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
     6
43
cb4403fabda7 added my changes again
urbanc
parents: 42
diff changeset
     7
types lang = "string set"
cb4403fabda7 added my changes again
urbanc
parents: 42
diff changeset
     8
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
     9
70
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
    10
text {*  Sequential composition of two languages *}
43
cb4403fabda7 added my changes again
urbanc
parents: 42
diff changeset
    11
60
fb08f41ca33d a bit more tuning on the introduction
urbanc
parents: 56
diff changeset
    12
definition 
fb08f41ca33d a bit more tuning on the introduction
urbanc
parents: 56
diff changeset
    13
  Seq :: "lang \<Rightarrow> lang \<Rightarrow> lang" (infixr ";;" 100)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
    14
where 
54
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 50
diff changeset
    15
  "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
    16
70
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
    17
56
b3898315e687 removed the inductive definition of Star and replaced it by a definition in terms of pow
urbanc
parents: 54
diff changeset
    18
text {* Some properties of operator @{text ";;"}. *}
50
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
    19
56
b3898315e687 removed the inductive definition of Star and replaced it by a definition in terms of pow
urbanc
parents: 54
diff changeset
    20
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
    21
  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
    22
  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
    23
using a by simp
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
    24
50
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
    25
lemma seq_union_distrib_right:
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
    26
  shows "(A \<union> B) ;; C = (A ;; C) \<union> (B ;; C)"
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
    27
unfolding Seq_def by auto
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
    28
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
    29
lemma seq_union_distrib_left:
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
    30
  shows "C ;; (A \<union> B) = (C ;; A) \<union> (C ;; B)"
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
    31
unfolding Seq_def by  auto
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
    32
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
    33
lemma seq_intro:
70
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
    34
  assumes a: "x \<in> A" "y \<in> B"
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
    35
  shows "x @ y \<in> A ;; B "
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
    36
using a by (auto simp: Seq_def)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
    37
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
    38
lemma seq_assoc:
50
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
    39
  shows "(A ;; B) ;; C = A ;; (B ;; C)"
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
    40
unfolding Seq_def
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
    41
apply(auto)
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
    42
apply(blast)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
    43
by (metis append_assoc)
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
    44
50
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
    45
lemma seq_empty [simp]:
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
    46
  shows "A ;; {[]} = A"
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
    47
  and   "{[]} ;; A = A"
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
    48
by (simp_all add: Seq_def)
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
    49
70
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
    50
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
    51
text {* Power and Star of a language *}
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
    52
56
b3898315e687 removed the inductive definition of Star and replaced it by a definition in terms of pow
urbanc
parents: 54
diff changeset
    53
fun 
b3898315e687 removed the inductive definition of Star and replaced it by a definition in terms of pow
urbanc
parents: 54
diff changeset
    54
  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
    55
where
b3898315e687 removed the inductive definition of Star and replaced it by a definition in terms of pow
urbanc
parents: 54
diff changeset
    56
  "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
    57
| "A \<up> (Suc n) =  A ;; (A \<up> n)" 
50
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
    58
56
b3898315e687 removed the inductive definition of Star and replaced it by a definition in terms of pow
urbanc
parents: 54
diff changeset
    59
definition
b3898315e687 removed the inductive definition of Star and replaced it by a definition in terms of pow
urbanc
parents: 54
diff changeset
    60
  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
    61
where
b3898315e687 removed the inductive definition of Star and replaced it by a definition in terms of pow
urbanc
parents: 54
diff changeset
    62
  "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
    63
70
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
    64
56
b3898315e687 removed the inductive definition of Star and replaced it by a definition in terms of pow
urbanc
parents: 54
diff changeset
    65
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
    66
  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
    67
proof -
b3898315e687 removed the inductive definition of Star and replaced it by a definition in terms of pow
urbanc
parents: 54
diff changeset
    68
  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
    69
  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
    70
qed
b3898315e687 removed the inductive definition of Star and replaced it by a definition in terms of pow
urbanc
parents: 54
diff changeset
    71
b3898315e687 removed the inductive definition of Star and replaced it by a definition in terms of pow
urbanc
parents: 54
diff changeset
    72
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
    73
  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
    74
  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
    75
  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
    76
proof -
b3898315e687 removed the inductive definition of Star and replaced it by a definition in terms of pow
urbanc
parents: 54
diff changeset
    77
  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
    78
  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
    79
  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
    80
qed
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
    81
56
b3898315e687 removed the inductive definition of Star and replaced it by a definition in terms of pow
urbanc
parents: 54
diff changeset
    82
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
    83
  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
    84
  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
    85
  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
    86
  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
    87
proof -
b3898315e687 removed the inductive definition of Star and replaced it by a definition in terms of pow
urbanc
parents: 54
diff changeset
    88
  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
    89
  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
    90
    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
    91
       (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
    92
qed
b3898315e687 removed the inductive definition of Star and replaced it by a definition in terms of pow
urbanc
parents: 54
diff changeset
    93
    
b3898315e687 removed the inductive definition of Star and replaced it by a definition in terms of pow
urbanc
parents: 54
diff changeset
    94
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
    95
  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
    96
  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
    97
  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
    98
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
    99
by (induct rule: star_induct) (auto)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   100
56
b3898315e687 removed the inductive definition of Star and replaced it by a definition in terms of pow
urbanc
parents: 54
diff changeset
   101
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
   102
  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
   103
  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
   104
proof -
b3898315e687 removed the inductive definition of Star and replaced it by a definition in terms of pow
urbanc
parents: 54
diff changeset
   105
  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
   106
  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
   107
qed
b3898315e687 removed the inductive definition of Star and replaced it by a definition in terms of pow
urbanc
parents: 54
diff changeset
   108
b3898315e687 removed the inductive definition of Star and replaced it by a definition in terms of pow
urbanc
parents: 54
diff changeset
   109
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
   110
  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
   111
  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
   112
  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
   113
using a b by (blast intro: star_intro1 star_intro2)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   114
71
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   115
lemma star_cases:
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   116
  shows "A\<star> =  {[]} \<union> A ;; A\<star>"
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   117
proof
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   118
  { fix x
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   119
    have "x \<in> A\<star> \<Longrightarrow> x \<in> {[]} \<union> A ;; A\<star>"
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   120
      unfolding Seq_def
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   121
    by (induct rule: star_induct) (auto)
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   122
  }
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   123
  then show "A\<star> \<subseteq> {[]} \<union> A ;; A\<star>" by auto
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   124
next
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   125
  show "{[]} \<union> A ;; A\<star> \<subseteq> A\<star>"
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   126
    unfolding Seq_def by auto
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   127
qed
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   128
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   129
lemma star_decom: 
71
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   130
  assumes a: "x \<in> A\<star>" "x \<noteq> []"
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   131
  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
   132
using a
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   133
by (induct rule: star_induct) (blast)+
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   134
50
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   135
lemma
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   136
  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
   137
  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
   138
unfolding Seq_def by auto
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   139
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   140
lemma seq_pow_comm:
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   141
  shows "A ;; (A \<up> n) = (A \<up> n) ;; A"
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   142
by (induct n) (simp_all add: seq_assoc[symmetric])
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   143
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   144
lemma seq_star_comm:
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   145
  shows "A ;; A\<star> = A\<star> ;; A"
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   146
unfolding Star_def seq_Union_left
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   147
unfolding seq_pow_comm seq_Union_right 
50
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   148
by simp
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   149
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   150
50
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   151
text {* Two lemmas about the length of strings in @{text "A \<up> n"} *}
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   152
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   153
lemma pow_length:
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   154
  assumes a: "[] \<notin> A"
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   155
  and     b: "s \<in> A \<up> Suc n"
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   156
  shows "n < length s"
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   157
using b
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   158
proof (induct n arbitrary: s)
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   159
  case 0
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   160
  have "s \<in> A \<up> Suc 0" by fact
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   161
  with a have "s \<noteq> []" by auto
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   162
  then show "0 < length s" by auto
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   163
next
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   164
  case (Suc n)
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   165
  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
   166
  have "s \<in> A \<up> Suc (Suc n)" by fact
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   167
  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
   168
    by (auto simp add: Seq_def)
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   169
  from ih ** have "n < length s2" by simp
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   170
  moreover have "0 < length s1" using * a by auto
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   171
  ultimately show "Suc n < length s" unfolding eq 
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   172
    by (simp only: length_append)
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   173
qed
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   174
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   175
lemma seq_pow_length:
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   176
  assumes a: "[] \<notin> A"
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   177
  and     b: "s \<in> B ;; (A \<up> Suc n)"
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   178
  shows "n < length s"
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   179
proof -
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   180
  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
   181
    unfolding Seq_def by auto
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   182
  from * have " n < length s2" by (rule pow_length[OF a])
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   183
  then show "n < length s" using eq by simp
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   184
qed
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   185
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   186
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   187
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   188
section {* A modified version of Arden's lemma *}
50
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   189
70
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
   190
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
   191
text {*  A helper lemma for Arden *}
50
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   192
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   193
lemma arden_helper:
50
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   194
  assumes eq: "X = X ;; A \<union> B"
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   195
  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
   196
proof (induct n)
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   197
  case 0 
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   198
  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
   199
    using eq by simp
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   200
next
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   201
  case (Suc n)
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   202
  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
   203
  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
   204
  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
   205
    by (simp add: seq_union_distrib_right seq_assoc)
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   206
  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
   207
    by (auto simp add: le_Suc_eq)
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   208
  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
   209
qed
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   210
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   211
theorem arden:
50
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   212
  assumes nemp: "[] \<notin> A"
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   213
  shows "X = X ;; A \<union> B \<longleftrightarrow> X = B ;; A\<star>"
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   214
proof
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   215
  assume eq: "X = B ;; A\<star>"
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   216
  have "A\<star> = {[]} \<union> A\<star> ;; A" 
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   217
    unfolding seq_star_comm[symmetric]
71
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   218
    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
   219
  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
   220
    by (rule seq_add_left)
50
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   221
  also have "\<dots> = B \<union> B ;; (A\<star> ;; A)"
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   222
    unfolding seq_union_distrib_left by simp
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   223
  also have "\<dots> = B \<union> (B ;; A\<star>) ;; A" 
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   224
    by (simp only: seq_assoc)
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   225
  finally show "X = X ;; A \<union> B" 
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   226
    using eq by blast 
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   227
next
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   228
  assume eq: "X = X ;; A \<union> B"
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   229
  { fix n::nat
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   230
    have "B ;; (A \<up> n) \<subseteq> X" using arden_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
   231
  then have "B ;; A\<star> \<subseteq> X" 
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   232
    unfolding Seq_def Star_def UNION_def by auto
50
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   233
  moreover
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   234
  { fix s::string
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   235
    obtain k where "k = length s" by auto
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   236
    then have not_in: "s \<notin> X ;; (A \<up> Suc k)" 
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   237
      using seq_pow_length[OF nemp] by blast
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   238
    assume "s \<in> X"
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   239
    then have "s \<in> X ;; (A \<up> Suc k) \<union> (\<Union>m\<in>{0..k}. B ;; (A \<up> m))"
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   240
      using arden_helper[OF eq, of "k"] by auto
50
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   241
    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
   242
    moreover
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   243
    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
   244
    ultimately 
56
b3898315e687 removed the inductive definition of Star and replaced it by a definition in terms of pow
urbanc
parents: 54
diff changeset
   245
    have "s \<in> B ;; A\<star>" 
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   246
      unfolding seq_Union_left Star_def by auto }
50
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   247
  then have "X \<subseteq> B ;; A\<star>" by auto
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   248
  ultimately 
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   249
  show "X = B ;; A\<star>" by simp
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   250
qed
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   251
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   252
70
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
   253
section {* Regular Expressions *}
48
61d9684a557a Myhill.thy and Myhill_1.thy changed.
zhang
parents: 46
diff changeset
   254
61d9684a557a Myhill.thy and Myhill_1.thy changed.
zhang
parents: 46
diff changeset
   255
datatype rexp =
61d9684a557a Myhill.thy and Myhill_1.thy changed.
zhang
parents: 46
diff changeset
   256
  NULL
61d9684a557a Myhill.thy and Myhill_1.thy changed.
zhang
parents: 46
diff changeset
   257
| EMPTY
61d9684a557a Myhill.thy and Myhill_1.thy changed.
zhang
parents: 46
diff changeset
   258
| CHAR char
61d9684a557a Myhill.thy and Myhill_1.thy changed.
zhang
parents: 46
diff changeset
   259
| SEQ rexp rexp
61d9684a557a Myhill.thy and Myhill_1.thy changed.
zhang
parents: 46
diff changeset
   260
| ALT rexp rexp
61d9684a557a Myhill.thy and Myhill_1.thy changed.
zhang
parents: 46
diff changeset
   261
| STAR rexp
61d9684a557a Myhill.thy and Myhill_1.thy changed.
zhang
parents: 46
diff changeset
   262
61d9684a557a Myhill.thy and Myhill_1.thy changed.
zhang
parents: 46
diff changeset
   263
61d9684a557a Myhill.thy and Myhill_1.thy changed.
zhang
parents: 46
diff changeset
   264
text {* 
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   265
  The function @{text L} is overloaded, with the idea that @{text "L x"} 
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   266
  evaluates to the language represented by the object @{text x}.
48
61d9684a557a Myhill.thy and Myhill_1.thy changed.
zhang
parents: 46
diff changeset
   267
*}
61d9684a557a Myhill.thy and Myhill_1.thy changed.
zhang
parents: 46
diff changeset
   268
70
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
   269
consts L:: "'a \<Rightarrow> lang"
48
61d9684a557a Myhill.thy and Myhill_1.thy changed.
zhang
parents: 46
diff changeset
   270
70
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
   271
overloading L_rexp \<equiv> "L::  rexp \<Rightarrow> lang"
48
61d9684a557a Myhill.thy and Myhill_1.thy changed.
zhang
parents: 46
diff changeset
   272
begin
61d9684a557a Myhill.thy and Myhill_1.thy changed.
zhang
parents: 46
diff changeset
   273
fun
88
1436fc451bb9 added something about Setalt and folds
urbanc
parents: 87
diff changeset
   274
  L_rexp :: "rexp \<Rightarrow> lang"
48
61d9684a557a Myhill.thy and Myhill_1.thy changed.
zhang
parents: 46
diff changeset
   275
where
61d9684a557a Myhill.thy and Myhill_1.thy changed.
zhang
parents: 46
diff changeset
   276
    "L_rexp (NULL) = {}"
61d9684a557a Myhill.thy and Myhill_1.thy changed.
zhang
parents: 46
diff changeset
   277
  | "L_rexp (EMPTY) = {[]}"
61d9684a557a Myhill.thy and Myhill_1.thy changed.
zhang
parents: 46
diff changeset
   278
  | "L_rexp (CHAR c) = {[c]}"
61d9684a557a Myhill.thy and Myhill_1.thy changed.
zhang
parents: 46
diff changeset
   279
  | "L_rexp (SEQ r1 r2) = (L_rexp r1) ;; (L_rexp r2)"
61d9684a557a Myhill.thy and Myhill_1.thy changed.
zhang
parents: 46
diff changeset
   280
  | "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
   281
  | "L_rexp (STAR r) = (L_rexp r)\<star>"
61d9684a557a Myhill.thy and Myhill_1.thy changed.
zhang
parents: 46
diff changeset
   282
end
61d9684a557a Myhill.thy and Myhill_1.thy changed.
zhang
parents: 46
diff changeset
   283
88
1436fc451bb9 added something about Setalt and folds
urbanc
parents: 87
diff changeset
   284
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   285
text {* ALT-combination of a set or regulare expressions *}
50
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   286
76
1589bf5c1ad8 added an abbreviation for folds ALT NULL
urbanc
parents: 75
diff changeset
   287
abbreviation
1589bf5c1ad8 added an abbreviation for folds ALT NULL
urbanc
parents: 75
diff changeset
   288
  Setalt  ("\<Uplus>_" [1000] 999) 
1589bf5c1ad8 added an abbreviation for folds ALT NULL
urbanc
parents: 75
diff changeset
   289
where
1589bf5c1ad8 added an abbreviation for folds ALT NULL
urbanc
parents: 75
diff changeset
   290
  "\<Uplus>A == folds ALT NULL A"
1589bf5c1ad8 added an abbreviation for folds ALT NULL
urbanc
parents: 75
diff changeset
   291
50
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   292
text {* 
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   293
  For finite sets, @{term Setalt} is preserved under @{term L}.
79
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   294
*}
70
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
   295
50
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   296
lemma folds_alt_simp [simp]:
88
1436fc451bb9 added something about Setalt and folds
urbanc
parents: 87
diff changeset
   297
  fixes rs::"rexp set"
70
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
   298
  assumes a: "finite rs"
76
1589bf5c1ad8 added an abbreviation for folds ALT NULL
urbanc
parents: 75
diff changeset
   299
  shows "L (\<Uplus>rs) = \<Union> (L ` rs)"
75
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   300
apply(rule set_eqI)
70
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
   301
apply(simp add: folds_def)
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
   302
apply(rule someI2_ex)
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
   303
apply(rule_tac finite_imp_fold_graph[OF a])
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
   304
apply(erule fold_graph.induct)
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
   305
apply(auto)
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
   306
done
50
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   307
70
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
   308
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   309
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   310
section {* Direction @{text "finite partition \<Rightarrow> regular language"} *}
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   311
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   312
70
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
   313
text {* Just a technical lemma for collections and pairs *}
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
   314
75
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   315
lemma Pair_Collect[simp]:
48
61d9684a557a Myhill.thy and Myhill_1.thy changed.
zhang
parents: 46
diff changeset
   316
  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
   317
by simp
61d9684a557a Myhill.thy and Myhill_1.thy changed.
zhang
parents: 46
diff changeset
   318
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   319
text {* Myhill-Nerode relation *}
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   320
48
61d9684a557a Myhill.thy and Myhill_1.thy changed.
zhang
parents: 46
diff changeset
   321
definition
71
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   322
  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
   323
where
70
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
   324
  "\<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
   325
61d9684a557a Myhill.thy and Myhill_1.thy changed.
zhang
parents: 46
diff changeset
   326
text {* 
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   327
  Among the equivalence clases of @{text "\<approx>A"}, the set @{text "finals A"} 
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   328
  singles out those which contains the strings from @{text A}.
48
61d9684a557a Myhill.thy and Myhill_1.thy changed.
zhang
parents: 46
diff changeset
   329
*}
61d9684a557a Myhill.thy and Myhill_1.thy changed.
zhang
parents: 46
diff changeset
   330
61d9684a557a Myhill.thy and Myhill_1.thy changed.
zhang
parents: 46
diff changeset
   331
definition 
71
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   332
  finals :: "lang \<Rightarrow> lang set"
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   333
where
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   334
  "finals A \<equiv> {\<approx>A `` {x} | x . x \<in> A}"
48
61d9684a557a Myhill.thy and Myhill_1.thy changed.
zhang
parents: 46
diff changeset
   335
70
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
   336
48
61d9684a557a Myhill.thy and Myhill_1.thy changed.
zhang
parents: 46
diff changeset
   337
lemma lang_is_union_of_finals: 
70
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
   338
  shows "A = \<Union> finals A"
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
   339
unfolding finals_def
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
   340
unfolding Image_def
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
   341
unfolding str_eq_rel_def
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
   342
apply(auto)
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
   343
apply(drule_tac x = "[]" in spec)
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
   344
apply(auto)
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
   345
done
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
   346
79
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   347
lemma finals_in_partitions:
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   348
  shows "finals A \<subseteq> (UNIV // \<approx>A)"
76
1589bf5c1ad8 added an abbreviation for folds ALT NULL
urbanc
parents: 75
diff changeset
   349
unfolding finals_def
1589bf5c1ad8 added an abbreviation for folds ALT NULL
urbanc
parents: 75
diff changeset
   350
unfolding quotient_def
1589bf5c1ad8 added an abbreviation for folds ALT NULL
urbanc
parents: 75
diff changeset
   351
by auto
1589bf5c1ad8 added an abbreviation for folds ALT NULL
urbanc
parents: 75
diff changeset
   352
48
61d9684a557a Myhill.thy and Myhill_1.thy changed.
zhang
parents: 46
diff changeset
   353
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   354
section {* Equational systems *}
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   355
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   356
datatype rhs_item = 
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   357
   Lam "rexp"            (* Lambda-marker *)
70
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
   358
 | Trn "lang" "rexp"     (* Transition *)
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
   359
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   360
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   361
overloading L_rhs_item \<equiv> "L:: rhs_item \<Rightarrow> lang"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   362
begin
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   363
  fun L_rhs_item:: "rhs_item \<Rightarrow> lang"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   364
  where
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   365
    "L_rhs_item (Lam r) = L r" 
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   366
  | "L_rhs_item (Trn X r) = X ;; L r"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   367
end
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   368
70
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
   369
overloading L_rhs \<equiv> "L:: rhs_item set \<Rightarrow> lang"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   370
begin
70
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
   371
   fun L_rhs:: "rhs_item set \<Rightarrow> lang"
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
   372
   where 
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
   373
     "L_rhs rhs = \<Union> (L ` rhs)"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   374
end
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   375
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   376
definition
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   377
  "trns_of rhs X \<equiv> {Trn X r | r. Trn X r \<in> rhs}"
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   378
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   379
text {* Transitions between equivalence classes *}
71
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   380
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   381
definition 
75
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   382
  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
   383
where
75
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   384
  "Y \<Turnstile>r\<Rightarrow> X \<equiv> Y ;; (L r) \<subseteq> X"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   385
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   386
text {* Initial equational system *}
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   387
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   388
definition
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   389
  "init_rhs CS X \<equiv>  
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   390
      if ([] \<in> X) then 
75
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   391
          {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
   392
      else 
75
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   393
          {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
   394
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   395
definition 
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   396
  "eqs CS \<equiv> {(X, init_rhs CS X) | X.  X \<in> CS}"
75
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   397
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   398
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   399
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   400
section {* Arden Operation on equations *}
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   401
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   402
text {*
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   403
  The function @{text "attach_rexp r item"} SEQ-composes @{text r} to the
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   404
  right of every rhs-item.
75
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   405
*}
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   406
70
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
   407
fun 
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
   408
  attach_rexp :: "rexp \<Rightarrow> rhs_item \<Rightarrow> rhs_item"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   409
where
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   410
  "attach_rexp r (Lam rexp)   = Lam (SEQ rexp r)"
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   411
| "attach_rexp r (Trn X rexp) = Trn X (SEQ rexp r)"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   412
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   413
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   414
definition
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   415
  "append_rhs_rexp rhs rexp \<equiv> (attach_rexp rexp) ` rhs"
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   416
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   417
definition 
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   418
  "arden_op X rhs \<equiv> 
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   419
     append_rhs_rexp (rhs - trns_of rhs X) (STAR (\<Uplus> {r. Trn X r \<in> rhs}))"
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   420
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   421
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   422
section {* Substitution Operation on equations *}
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   423
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   424
text {* 
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   425
  Suppose and equation @{text "X = xrhs"}, @{text "subst_op"} substitutes 
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   426
  all occurences of @{text "X"} in @{text "rhs"} by @{text "xrhs"}.
71
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   427
*}
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   428
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   429
definition 
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   430
  "subst_op rhs X xrhs \<equiv> 
79
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   431
        (rhs - (trns_of rhs X)) \<union> (append_rhs_rexp xrhs (\<Uplus> {r. Trn X r \<in> rhs}))"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   432
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   433
text {*
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   434
  @{text "eqs_subst ES X xrhs"} substitutes @{text xrhs} into every 
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   435
  equation of the equational system @{text ES}.
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   436
*}
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   437
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   438
definition
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   439
  "subst_op_all ES X xrhs \<equiv> {(Y, subst_op yrhs X xrhs) | Y yrhs. (Y, yrhs) \<in> ES}"
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   440
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   441
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   442
section {* Well-founded iteration *}
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   443
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   444
text {*
71
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   445
  The computation of regular expressions for equivalence classes is accomplished
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   446
  using a iteration principle given by the following lemma.
71
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   447
*}
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   448
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   449
lemma wf_iter [rule_format]: 
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   450
  fixes f
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   451
  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
   452
  shows pe:     "P e \<longrightarrow> (\<exists> e'. P e' \<and>  Q e')"
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   453
proof(induct e rule: wf_induct 
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   454
           [OF wf_inv_image[OF wf_less_than, where f = "f"]], clarify)
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   455
  fix x 
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   456
  assume h [rule_format]: 
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   457
    "\<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
   458
    and px: "P x"
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   459
  show "\<exists>e'. P e' \<and> Q e'"
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   460
  proof(cases "Q x")
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   461
    assume "Q x" with px show ?thesis by blast
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   462
  next
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   463
    assume nq: "\<not> Q x"
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   464
    from step [OF px nq]
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   465
    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
   466
    show ?thesis
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   467
    proof(rule h)
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   468
      from ltf show "(e', x) \<in> inv_image less_than f" 
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   469
	by (simp add:inv_image_def)
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   470
    next
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   471
      from pe' show "P e'" .
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   472
    qed
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   473
  qed
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   474
qed
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   475
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   476
text {*
75
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   477
  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
   478
  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
   479
  an invariant over equal system @{text "ES"}.
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   480
  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
   481
*}
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   482
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   483
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   484
section {* Invariants *}
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   485
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   486
text {* Every variable is defined at most onece in @{text ES}. *}
75
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   487
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   488
definition 
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   489
  "distinct_equas ES \<equiv> 
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   490
     \<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
   491
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   492
text {* 
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   493
  Every equation in @{text ES} (represented by @{text "(X, rhs)"}) 
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   494
  is valid, i.e. @{text "(X = L rhs)"}.
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   495
*}
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   496
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   497
definition 
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   498
  "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
   499
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   500
text {*
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   501
  @{text "rhs_nonempty rhs"} requires regular expressions occuring in 
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   502
  transitional items of @{text "rhs"} do not contain empty string. This is 
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   503
  necessary for the application of Arden's transformation to @{text "rhs"}.
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   504
*}
70
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
   505
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   506
definition 
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   507
  "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
   508
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   509
text {*
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   510
  The following @{text "ardenable ES"} requires that Arden's transformation 
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   511
  is applicable to every equation of equational system @{text "ES"}.
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   512
*}
70
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
   513
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   514
definition 
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   515
  "ardenable ES \<equiv> \<forall> X rhs. (X, rhs) \<in> ES \<longrightarrow> rhs_nonempty rhs"
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   516
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   517
text {* 
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   518
  @{text "finite_rhs ES"} requires every equation in @{text "rhs"} 
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   519
  be finite.
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   520
*}
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   521
definition
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   522
  "finite_rhs ES \<equiv> \<forall> X rhs. (X, rhs) \<in> ES \<longrightarrow> finite rhs"
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   523
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   524
text {*
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   525
  @{text "classes_of rhs"} returns all variables (or equivalent classes)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   526
  occuring in @{text "rhs"}.
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   527
  *}
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   528
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   529
definition 
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   530
  "classes_of rhs \<equiv> {X. \<exists> r. Trn X r \<in> rhs}"
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   531
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   532
text {*
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   533
  @{text "lefts_of ES"} returns all variables defined by an 
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   534
  equational system @{text "ES"}.
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   535
*}
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   536
definition
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   537
  "lefts_of ES \<equiv> {Y | Y yrhs. (Y, yrhs) \<in> ES}"
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   538
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   539
text {*
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   540
  The following @{text "self_contained ES"} requires that every variable occuring 
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   541
  on the right hand side of equations is already defined by some equation in @{text "ES"}.
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   542
*}
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   543
definition 
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   544
  "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
   545
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   546
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   547
text {*
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   548
  The invariant @{text "invariant(ES)"} is a conjunction of all the previously defined constaints.
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   549
  *}
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   550
definition 
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   551
  "invariant ES \<equiv> valid_eqns ES \<and> finite ES \<and> distinct_equas ES \<and> ardenable ES \<and> 
87
6a0efaabde19 deleted the non_empty invariant
urbanc
parents: 86
diff changeset
   552
                  finite_rhs ES \<and> self_contained ES"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   553
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   554
subsection {* The proof of this direction *}
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   555
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   556
subsubsection {* Basic properties *}
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   557
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   558
text {*
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   559
  The following are some basic properties of the above definitions.
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   560
*}
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   561
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   562
lemma L_rhs_union_distrib:
70
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
   563
  fixes A B::"rhs_item set"
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
   564
  shows "L A \<union> L B = L (A \<union> B)"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   565
by simp
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   566
79
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   567
lemma finite_Trn:
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   568
  assumes fin: "finite rhs"
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   569
  shows "finite {r. Trn Y r \<in> rhs}"
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   570
proof -
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   571
  have "finite {Trn Y r | Y r. Trn Y r \<in> rhs}"
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   572
    by (rule rev_finite_subset[OF fin]) (auto)
81
dc879cb59c9c more direct definitions
urbanc
parents: 80
diff changeset
   573
  then have "finite ((\<lambda>(Y, r). Trn Y r) ` {(Y, r) | Y r. Trn Y r \<in> rhs})"
dc879cb59c9c more direct definitions
urbanc
parents: 80
diff changeset
   574
    by (simp add: image_Collect)
dc879cb59c9c more direct definitions
urbanc
parents: 80
diff changeset
   575
  then have "finite {(Y, r) | Y r. Trn Y r \<in> rhs}"
dc879cb59c9c more direct definitions
urbanc
parents: 80
diff changeset
   576
    by (erule_tac finite_imageD) (simp add: inj_on_def)
79
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   577
  then show "finite {r. Trn Y r \<in> rhs}"
81
dc879cb59c9c more direct definitions
urbanc
parents: 80
diff changeset
   578
    by (erule_tac f="snd" in finite_surj) (auto simp add: image_def)
79
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   579
qed
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   580
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   581
lemma finite_Lam:
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   582
  assumes fin:"finite rhs"
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   583
  shows "finite {r. Lam r \<in> rhs}"
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   584
proof -
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   585
  have "finite {Lam r | r. Lam r \<in> rhs}"
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   586
    by (rule rev_finite_subset[OF fin]) (auto)
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   587
  then show "finite {r. Lam r \<in> rhs}"
81
dc879cb59c9c more direct definitions
urbanc
parents: 80
diff changeset
   588
    apply(simp add: image_Collect[symmetric])
dc879cb59c9c more direct definitions
urbanc
parents: 80
diff changeset
   589
    apply(erule finite_imageD)
dc879cb59c9c more direct definitions
urbanc
parents: 80
diff changeset
   590
    apply(auto simp add: inj_on_def)
79
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   591
    done
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   592
qed
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   593
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   594
lemma rexp_of_empty:
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   595
  assumes finite:"finite rhs"
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   596
  and nonempty:"rhs_nonempty rhs"
79
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   597
  shows "[] \<notin> L (\<Uplus> {r. Trn X r \<in> rhs})"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   598
using finite nonempty rhs_nonempty_def
79
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   599
using finite_Trn[OF finite]
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   600
by (auto)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   601
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   602
lemma [intro!]:
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   603
  "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
   604
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   605
lemma lang_of_rexp_of:
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   606
  assumes finite:"finite rhs"
79
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   607
  shows "L ({Trn X r| r. Trn X r \<in> rhs}) = X ;; (L (\<Uplus>{r. Trn X r \<in> rhs}))"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   608
proof -
79
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   609
  have "finite {r. Trn X r \<in> rhs}" 
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   610
    by (rule finite_Trn[OF finite]) 
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   611
  then show ?thesis
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   612
    apply(auto simp add: Seq_def)
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   613
    apply(rule_tac x = "s\<^isub>1" in exI, rule_tac x = "s\<^isub>2" in exI, auto)
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   614
    apply(rule_tac x= "Trn X xa" in exI)
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   615
    apply(auto simp: Seq_def)
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   616
    done
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   617
qed
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   618
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   619
lemma rexp_of_lam_eq_lam_set:
79
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   620
  assumes fin: "finite rhs"
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   621
  shows "L (\<Uplus>{r. Lam r \<in> rhs}) = L ({Lam r | r. Lam r \<in> rhs})"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   622
proof -
79
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   623
  have "finite ({r. Lam r \<in> rhs})" using fin by (rule finite_Lam)
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   624
  then show ?thesis by auto
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   625
qed
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   626
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   627
lemma [simp]:
70
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
   628
  "L (attach_rexp r xb) = L xb ;; L r"
79
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   629
apply (cases xb, auto simp: Seq_def)
54
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 50
diff changeset
   630
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
   631
apply(auto simp: Seq_def)
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 50
diff changeset
   632
done
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   633
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   634
lemma lang_of_append_rhs:
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   635
  "L (append_rhs_rexp rhs r) = L rhs ;; L r"
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   636
apply (auto simp:append_rhs_rexp_def image_def)
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   637
apply (auto simp:Seq_def)
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   638
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
   639
by (rule_tac x = "attach_rexp r xb" in exI, auto simp:Seq_def)
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   640
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   641
lemma classes_of_union_distrib:
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   642
  "classes_of A \<union> classes_of B = classes_of (A \<union> B)"
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   643
by (auto simp add:classes_of_def)
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   644
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   645
lemma lefts_of_union_distrib:
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   646
  "lefts_of A \<union> lefts_of B = lefts_of (A \<union> B)"
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   647
by (auto simp:lefts_of_def)
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   648
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   649
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   650
subsubsection {* Intialization *}
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   651
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   652
text {*
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   653
  The following several lemmas until @{text "init_ES_satisfy_invariant"} shows that
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   654
  the initial equational system satisfies invariant @{text "invariant"}.
71
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   655
*}
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   656
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   657
lemma defined_by_str:
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   658
  "\<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
   659
by (auto simp:quotient_def Image_def str_eq_rel_def)
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   660
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   661
lemma every_eqclass_has_transition:
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   662
  assumes has_str: "s @ [c] \<in> X"
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   663
  and     in_CS:   "X \<in> UNIV // (\<approx>Lang)"
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   664
  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
   665
proof -
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   666
  def Y \<equiv> "(\<approx>Lang) `` {s}"
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   667
  have "Y \<in> UNIV // (\<approx>Lang)" 
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   668
    unfolding Y_def quotient_def by auto
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   669
  moreover
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   670
  have "X = (\<approx>Lang) `` {s @ [c]}" 
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   671
    using has_str in_CS defined_by_str by blast
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   672
  then have "Y ;; {[c]} \<subseteq> X" 
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   673
    unfolding Y_def Image_def Seq_def
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   674
    unfolding str_eq_rel_def
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   675
    by clarsimp
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   676
  moreover
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   677
  have "s \<in> Y" unfolding Y_def 
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   678
    unfolding Image_def str_eq_rel_def by simp
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   679
  ultimately show thesis by (blast intro: that)
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   680
qed
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   681
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   682
lemma l_eq_r_in_eqs:
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   683
  assumes X_in_eqs: "(X, xrhs) \<in> (eqs (UNIV // (\<approx>Lang)))"
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   684
  shows "X = L xrhs"
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   685
proof 
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   686
  show "X \<subseteq> L xrhs"
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   687
  proof
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   688
    fix x
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   689
    assume "(1)": "x \<in> X"
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   690
    show "x \<in> L xrhs"          
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   691
    proof (cases "x = []")
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   692
      assume empty: "x = []"
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   693
      thus ?thesis using X_in_eqs "(1)"
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   694
        by (auto simp:eqs_def init_rhs_def)
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   695
    next
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   696
      assume not_empty: "x \<noteq> []"
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   697
      then obtain clist c where decom: "x = clist @ [c]"
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   698
        by (case_tac x rule:rev_cases, auto)
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   699
      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
   700
      then obtain Y 
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   701
        where "Y \<in> UNIV // (\<approx>Lang)" 
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   702
        and "Y ;; {[c]} \<subseteq> X"
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   703
        and "clist \<in> Y"
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   704
        using decom "(1)" every_eqclass_has_transition by blast
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   705
      hence 
75
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   706
        "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
   707
        unfolding transition_def
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   708
	using "(1)" decom
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   709
        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
   710
      thus ?thesis using X_in_eqs "(1)"	
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   711
        by (simp add: eqs_def init_rhs_def)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   712
    qed
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   713
  qed
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   714
next
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   715
  show "L xrhs \<subseteq> X" using X_in_eqs
71
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   716
    by (auto simp:eqs_def init_rhs_def transition_def) 
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   717
qed
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   718
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   719
lemma finite_init_rhs: 
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   720
  assumes finite: "finite CS"
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   721
  shows "finite (init_rhs CS X)"
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   722
proof-
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   723
  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
   724
  proof -
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   725
    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
   726
    def h \<equiv> "\<lambda> (Y, c). Trn Y (CHAR c)"
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   727
    have "finite (CS \<times> (UNIV::char set))" using finite by auto
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   728
    hence "finite S" using S_def 
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   729
      by (rule_tac B = "CS \<times> UNIV" in finite_subset, auto)
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   730
    moreover have "?A = h ` S" by (auto simp: S_def h_def image_def)
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   731
    ultimately show ?thesis 
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   732
      by auto
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   733
  qed
71
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   734
  thus ?thesis by (simp add:init_rhs_def transition_def)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   735
qed
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   736
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   737
lemma init_ES_satisfy_invariant:
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   738
  assumes finite_CS: "finite (UNIV // (\<approx>Lang))"
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   739
  shows "invariant (eqs (UNIV // (\<approx>Lang)))"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   740
proof -
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   741
  have "finite (eqs (UNIV // (\<approx>Lang)))" using finite_CS
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   742
    by (simp add:eqs_def)
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   743
  moreover have "distinct_equas (eqs (UNIV // (\<approx>Lang)))"     
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   744
    by (simp add:distinct_equas_def eqs_def)
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   745
  moreover have "ardenable (eqs (UNIV // (\<approx>Lang)))"
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   746
    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
   747
  moreover have "valid_eqns (eqs (UNIV // (\<approx>Lang)))"
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   748
    using l_eq_r_in_eqs by (simp add:valid_eqns_def)
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   749
  moreover have "finite_rhs (eqs (UNIV // (\<approx>Lang)))"
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   750
    using finite_init_rhs[OF finite_CS] 
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   751
    by (auto simp:finite_rhs_def eqs_def)
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   752
  moreover have "self_contained (eqs (UNIV // (\<approx>Lang)))"
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   753
    by (auto simp:self_contained_def eqs_def init_rhs_def classes_of_def lefts_of_def)
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   754
  ultimately show ?thesis by (simp add:invariant_def)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   755
qed
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   756
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   757
subsubsection {* 
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   758
  Interation step
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   759
  *}
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   760
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   761
text {*
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   762
  From this point until @{text "iteration_step"}, it is proved
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   763
  that there exists iteration steps which keep @{text "invariant(ES)"} while
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   764
  decreasing the size of @{text "ES"}.
71
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   765
*}
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   766
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   767
lemma arden_op_keeps_eq:
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   768
  assumes l_eq_r: "X = L rhs"
79
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   769
  and not_empty: "[] \<notin> L (\<Uplus>{r. Trn X r \<in> rhs})"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   770
  and finite: "finite rhs"
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   771
  shows "X = L (arden_op X rhs)"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   772
proof -
79
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   773
  def A \<equiv> "L (\<Uplus>{r. Trn X r \<in> rhs})"
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   774
  def b \<equiv> "rhs - trns_of rhs X"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   775
  def B \<equiv> "L b" 
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   776
  have "X = B ;; A\<star>"
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   777
  proof-
79
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   778
    have "L rhs = L(trns_of rhs X \<union> b)" by (auto simp: b_def trns_of_def)
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   779
    also have "\<dots> = X ;; A \<union> B"
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   780
      unfolding trns_of_def
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   781
      unfolding L_rhs_union_distrib[symmetric]
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   782
      by (simp only: lang_of_rexp_of finite B_def A_def)
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   783
    finally show ?thesis
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   784
      using l_eq_r not_empty
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   785
      apply(rule_tac arden[THEN iffD1])
79
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   786
      apply(simp add: A_def)
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   787
      apply(simp)
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   788
      done
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   789
  qed
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   790
  moreover have "L (arden_op X rhs) = (B ;; A\<star>)"
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   791
    by (simp only:arden_op_def L_rhs_union_distrib lang_of_append_rhs 
50
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 48
diff changeset
   792
                  B_def A_def b_def L_rexp.simps seq_union_distrib_left)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   793
   ultimately show ?thesis by simp
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   794
qed 
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   795
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   796
lemma append_keeps_finite:
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   797
  "finite rhs \<Longrightarrow> finite (append_rhs_rexp rhs r)"
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   798
by (auto simp:append_rhs_rexp_def)
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   799
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   800
lemma arden_op_keeps_finite:
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   801
  "finite rhs \<Longrightarrow> finite (arden_op X rhs)"
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   802
by (auto simp:arden_op_def append_keeps_finite)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   803
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   804
lemma append_keeps_nonempty:
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   805
  "rhs_nonempty rhs \<Longrightarrow> rhs_nonempty (append_rhs_rexp rhs r)"
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   806
apply (auto simp:rhs_nonempty_def append_rhs_rexp_def)
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   807
by (case_tac x, auto simp:Seq_def)
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   808
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   809
lemma nonempty_set_sub:
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   810
  "rhs_nonempty rhs \<Longrightarrow> rhs_nonempty (rhs - A)"
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   811
by (auto simp:rhs_nonempty_def)
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   812
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   813
lemma nonempty_set_union:
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   814
  "\<lbrakk>rhs_nonempty rhs; rhs_nonempty rhs'\<rbrakk> \<Longrightarrow> rhs_nonempty (rhs \<union> rhs')"
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   815
by (auto simp:rhs_nonempty_def)
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   816
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   817
lemma arden_op_keeps_nonempty:
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   818
  "rhs_nonempty rhs \<Longrightarrow> rhs_nonempty (arden_op X rhs)"
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   819
by (simp only:arden_op_def append_keeps_nonempty nonempty_set_sub)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   820
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   821
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   822
lemma subst_op_keeps_nonempty:
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   823
  "\<lbrakk>rhs_nonempty rhs; rhs_nonempty xrhs\<rbrakk> \<Longrightarrow> rhs_nonempty (subst_op rhs X xrhs)"
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   824
by (simp only:subst_op_def append_keeps_nonempty  nonempty_set_union nonempty_set_sub)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   825
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   826
lemma subst_op_keeps_eq:
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   827
  assumes substor: "X = L xrhs"
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   828
  and finite: "finite rhs"
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   829
  shows "L (subst_op rhs X xrhs) = L rhs" (is "?Left = ?Right")
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   830
proof-
79
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   831
  def A \<equiv> "L (rhs - trns_of rhs X)"
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   832
  have "?Left = A \<union> L (append_rhs_rexp xrhs (\<Uplus>{r. Trn X r \<in> rhs}))"
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   833
    unfolding subst_op_def
79
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   834
    unfolding L_rhs_union_distrib[symmetric]
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   835
    by (simp add: A_def)
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   836
  moreover have "?Right = A \<union> L ({Trn X r | r. Trn X r \<in> rhs})"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   837
  proof-
79
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   838
    have "rhs = (rhs - trns_of rhs X) \<union> (trns_of rhs X)" by (auto simp add: trns_of_def)
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   839
    thus ?thesis 
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   840
      unfolding A_def
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   841
      unfolding L_rhs_union_distrib
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   842
      unfolding trns_of_def
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   843
      by simp
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   844
  qed
79
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   845
  moreover have "L (append_rhs_rexp xrhs (\<Uplus>{r. Trn X r \<in> rhs})) = L ({Trn X r | r. Trn X r \<in> rhs})" 
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   846
    using finite substor  by (simp only:lang_of_append_rhs lang_of_rexp_of)
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   847
  ultimately show ?thesis by simp
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   848
qed
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   849
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   850
lemma subst_op_keeps_finite_rhs:
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   851
  "\<lbrakk>finite rhs; finite yrhs\<rbrakk> \<Longrightarrow> finite (subst_op rhs Y yrhs)"
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   852
by (auto simp:subst_op_def append_keeps_finite)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   853
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   854
lemma subst_op_all_keeps_finite:
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   855
  assumes finite:"finite (ES:: (string set \<times> rhs_item set) set)"
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   856
  shows "finite (subst_op_all ES Y yrhs)"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   857
proof -
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   858
  have "finite {(Ya, subst_op yrhsa Y yrhs) |Ya yrhsa. (Ya, yrhsa) \<in> ES}" 
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   859
                                                                  (is "finite ?A")
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   860
  proof-
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   861
    def eqns' \<equiv> "{((Ya::string set), yrhsa)| Ya yrhsa. (Ya, yrhsa) \<in> ES}"
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   862
    def h \<equiv> "\<lambda> ((Ya::string set), yrhsa). (Ya, subst_op yrhsa Y yrhs)"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   863
    have "finite (h ` eqns')" using finite h_def eqns'_def by auto
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   864
    moreover have "?A = h ` eqns'" by (auto simp:h_def eqns'_def)
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   865
    ultimately show ?thesis by auto      
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   866
  qed
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   867
  thus ?thesis by (simp add:subst_op_all_def)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   868
qed
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   869
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   870
lemma subst_op_all_keeps_finite_rhs:
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   871
  "\<lbrakk>finite_rhs ES; finite yrhs\<rbrakk> \<Longrightarrow> finite_rhs (subst_op_all ES Y yrhs)"
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   872
by (auto intro:subst_op_keeps_finite_rhs simp add:subst_op_all_def finite_rhs_def)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   873
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   874
lemma append_rhs_keeps_cls:
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   875
  "classes_of (append_rhs_rexp rhs r) = classes_of rhs"
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   876
apply (auto simp:classes_of_def append_rhs_rexp_def)
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   877
apply (case_tac xa, auto simp:image_def)
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   878
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
   879
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   880
lemma arden_op_removes_cl:
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   881
  "classes_of (arden_op Y yrhs) = classes_of yrhs - {Y}"
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   882
apply (simp add:arden_op_def append_rhs_keeps_cls trns_of_def)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   883
by (auto simp:classes_of_def)
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   884
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   885
lemma lefts_of_keeps_cls:
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   886
  "lefts_of (subst_op_all ES Y yrhs) = lefts_of ES"
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   887
by (auto simp:lefts_of_def subst_op_all_def)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   888
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   889
lemma subst_op_updates_cls:
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   890
  "X \<notin> classes_of xrhs \<Longrightarrow> 
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   891
      classes_of (subst_op rhs X xrhs) = classes_of rhs \<union> classes_of xrhs - {X}"
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   892
apply (simp only:subst_op_def append_rhs_keeps_cls 
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   893
                              classes_of_union_distrib[THEN sym])
79
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   894
by (auto simp:classes_of_def trns_of_def)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   895
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   896
lemma subst_op_all_keeps_self_contained:
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   897
  fixes Y
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   898
  assumes sc: "self_contained (ES \<union> {(Y, yrhs)})" (is "self_contained ?A")
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   899
  shows "self_contained (subst_op_all ES Y (arden_op Y yrhs))" 
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   900
                                                   (is "self_contained ?B")
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   901
proof-
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   902
  { fix X xrhs'
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   903
    assume "(X, xrhs') \<in> ?B"
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   904
    then obtain xrhs 
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   905
      where xrhs_xrhs': "xrhs' = subst_op xrhs Y (arden_op Y yrhs)"
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   906
      and X_in: "(X, xrhs) \<in> ES" by (simp add:subst_op_all_def, blast)    
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   907
    have "classes_of xrhs' \<subseteq> lefts_of ?B"
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   908
    proof-
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   909
      have "lefts_of ?B = lefts_of ES" by (auto simp add:lefts_of_def subst_op_all_def)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   910
      moreover have "classes_of xrhs' \<subseteq> lefts_of ES"
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   911
      proof-
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   912
        have "classes_of xrhs' \<subseteq> 
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   913
                        classes_of xrhs \<union> classes_of (arden_op Y yrhs) - {Y}"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   914
        proof-
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   915
          have "Y \<notin> classes_of (arden_op Y yrhs)" 
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   916
            using arden_op_removes_cl by simp
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   917
          thus ?thesis using xrhs_xrhs' by (auto simp:subst_op_updates_cls)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   918
        qed
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   919
        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
   920
          apply (simp only:self_contained_def lefts_of_union_distrib[THEN sym])
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   921
          by (drule_tac x = "(X, xrhs)" in bspec, auto simp:lefts_of_def)
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   922
        moreover have "classes_of (arden_op Y yrhs) \<subseteq> lefts_of ES \<union> {Y}" 
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   923
          using sc 
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   924
          by (auto simp add:arden_op_removes_cl self_contained_def lefts_of_def)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   925
        ultimately show ?thesis by auto
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   926
      qed
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   927
      ultimately show ?thesis by simp
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   928
    qed
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   929
  } thus ?thesis by (auto simp only:subst_op_all_def self_contained_def)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   930
qed
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   931
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   932
lemma subst_op_all_satisfy_invariant:
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   933
  assumes invariant_ES: "invariant (ES \<union> {(Y, yrhs)})"
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   934
  shows "invariant (subst_op_all ES Y (arden_op Y yrhs))"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   935
proof -  
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   936
  have finite_yrhs: "finite yrhs" 
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   937
    using invariant_ES by (auto simp:invariant_def finite_rhs_def)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   938
  have nonempty_yrhs: "rhs_nonempty yrhs" 
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   939
    using invariant_ES by (auto simp:invariant_def ardenable_def)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   940
  have Y_eq_yrhs: "Y = L yrhs" 
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   941
    using invariant_ES by (simp only:invariant_def valid_eqns_def, blast)
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   942
  have "distinct_equas (subst_op_all ES Y (arden_op Y yrhs))" 
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   943
    using invariant_ES
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   944
    by (auto simp:distinct_equas_def subst_op_all_def invariant_def)
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   945
  moreover have "finite (subst_op_all ES Y (arden_op Y yrhs))" 
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   946
    using invariant_ES by (simp add:invariant_def subst_op_all_keeps_finite)
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   947
  moreover have "finite_rhs (subst_op_all ES Y (arden_op Y yrhs))"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   948
  proof-
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   949
    have "finite_rhs ES" using invariant_ES 
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   950
      by (simp add:invariant_def finite_rhs_def)
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   951
    moreover have "finite (arden_op Y yrhs)"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   952
    proof -
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   953
      have "finite yrhs" using invariant_ES 
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   954
        by (auto simp:invariant_def finite_rhs_def)
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   955
      thus ?thesis using arden_op_keeps_finite by simp
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   956
    qed
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   957
    ultimately show ?thesis 
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   958
      by (simp add:subst_op_all_keeps_finite_rhs)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   959
  qed
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   960
  moreover have "ardenable (subst_op_all ES Y (arden_op Y yrhs))"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   961
  proof - 
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   962
    { fix X rhs
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   963
      assume "(X, rhs) \<in> ES"
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   964
      hence "rhs_nonempty rhs"  using prems invariant_ES  
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   965
        by (simp add:invariant_def ardenable_def)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   966
      with nonempty_yrhs 
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   967
      have "rhs_nonempty (subst_op rhs Y (arden_op Y yrhs))"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   968
        by (simp add:nonempty_yrhs 
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   969
               subst_op_keeps_nonempty arden_op_keeps_nonempty)
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   970
    } thus ?thesis by (auto simp add:ardenable_def subst_op_all_def)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   971
  qed
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   972
  moreover have "valid_eqns (subst_op_all ES Y (arden_op Y yrhs))"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   973
  proof-
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   974
    have "Y = L (arden_op Y yrhs)" 
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   975
      using Y_eq_yrhs invariant_ES finite_yrhs nonempty_yrhs      
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   976
      by (rule_tac arden_op_keeps_eq, (simp add:rexp_of_empty)+)
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   977
    thus ?thesis using invariant_ES 
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   978
      by (clarsimp simp add:valid_eqns_def 
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   979
              subst_op_all_def subst_op_keeps_eq invariant_def finite_rhs_def
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   980
                   simp del:L_rhs.simps)
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   981
  qed
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   982
  moreover 
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   983
  have self_subst: "self_contained (subst_op_all ES Y (arden_op Y yrhs))"
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   984
    using invariant_ES subst_op_all_keeps_self_contained by (simp add:invariant_def)
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   985
  ultimately show ?thesis using invariant_ES by (simp add:invariant_def)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   986
qed
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   987
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   988
lemma subst_op_all_card_le: 
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   989
  assumes finite: "finite (ES::(string set \<times> rhs_item set) set)"
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   990
  shows "card (subst_op_all ES Y yrhs) <= card ES"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   991
proof-
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   992
  def f \<equiv> "\<lambda> x. ((fst x)::string set, subst_op (snd x) Y yrhs)"
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   993
  have "subst_op_all ES Y yrhs = f ` ES" 
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   994
    apply (auto simp:subst_op_all_def f_def image_def)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   995
    by (rule_tac x = "(Ya, yrhsa)" in bexI, simp+)
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   996
  thus ?thesis using finite by (auto intro:card_image_le)
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   997
qed
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   998
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   999
lemma subst_op_all_cls_remains: 
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
  1000
  "(X, xrhs) \<in> ES \<Longrightarrow> \<exists> xrhs'. (X, xrhs') \<in> (subst_op_all ES Y yrhs)"
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
  1001
by (auto simp:subst_op_all_def)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1002
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1003
lemma card_noteq_1_has_more:
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1004
  assumes card:"card S \<noteq> 1"
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1005
  and e_in: "e \<in> S"
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1006
  and finite: "finite S"
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1007
  obtains e' where "e' \<in> S \<and> e \<noteq> e'" 
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1008
proof-
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1009
  have "card (S - {e}) > 0"
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1010
  proof -
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1011
    have "card S > 1" using card e_in finite  
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1012
      by (case_tac "card S", auto) 
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1013
    thus ?thesis using finite e_in by auto
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1014
  qed
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1015
  hence "S - {e} \<noteq> {}" using finite by (rule_tac notI, simp)
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1016
  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
  1017
qed
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1018
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1019
lemma iteration_step: 
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
  1020
  assumes invariant_ES: "invariant ES"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1021
  and    X_in_ES: "(X, xrhs) \<in> ES"
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1022
  and    not_T: "card ES \<noteq> 1"
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
  1023
  shows "\<exists> ES'. (invariant ES' \<and> (\<exists> xrhs'.(X, xrhs') \<in> ES')) \<and> 
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1024
                (card ES', card ES) \<in> less_than" (is "\<exists> ES'. ?P ES'")
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1025
proof -
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
  1026
  have finite_ES: "finite ES" using invariant_ES by (simp add:invariant_def)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1027
  then obtain Y yrhs 
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1028
    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
  1029
    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
  1030
  def ES' == "ES - {(Y, yrhs)}"
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
  1031
  let ?ES'' = "subst_op_all ES' Y (arden_op Y yrhs)"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1032
  have "?P ?ES''"
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1033
  proof -
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
  1034
    have "invariant ?ES''" using Y_in_ES invariant_ES
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
  1035
      by (rule_tac subst_op_all_satisfy_invariant, simp add:ES'_def insert_absorb)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1036
    moreover have "\<exists>xrhs'. (X, xrhs') \<in> ?ES''"  using not_eq X_in_ES
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
  1037
      by (rule_tac ES = ES' in subst_op_all_cls_remains, auto simp add:ES'_def)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1038
    moreover have "(card ?ES'', card ES) \<in> less_than" 
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1039
    proof -
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1040
      have "finite ES'" using finite_ES ES'_def by auto
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1041
      moreover have "card ES' < card ES" using finite_ES Y_in_ES
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1042
        by (auto simp:ES'_def card_gt_0_iff intro:diff_Suc_less)
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1043
      ultimately show ?thesis 
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
  1044
        by (auto dest:subst_op_all_card_le elim:le_less_trans)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1045
    qed
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1046
    ultimately show ?thesis by simp
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1047
  qed
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1048
  thus ?thesis by blast
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1049
qed
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1050
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1051
subsubsection {*
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1052
  Conclusion of the proof
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1053
  *}
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1054
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1055
text {*
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1056
  From this point until @{text "hard_direction"}, the hard direction is proved
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1057
  through a simple application of the iteration principle.
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1058
*}
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1059
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1060
lemma iteration_conc: 
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
  1061
  assumes history: "invariant ES"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1062
  and    X_in_ES: "\<exists> xrhs. (X, xrhs) \<in> ES"
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1063
  shows 
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
  1064
  "\<exists> ES'. (invariant ES' \<and> (\<exists> xrhs'. (X, xrhs') \<in> ES')) \<and> card ES' = 1" 
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1065
                                                          (is "\<exists> ES'. ?P ES'")
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1066
proof (cases "card ES = 1")
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1067
  case True
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1068
  thus ?thesis using history X_in_ES
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1069
    by blast
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1070
next
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1071
  case False  
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1072
  thus ?thesis using history iteration_step X_in_ES
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1073
    by (rule_tac f = card in wf_iter, auto)
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1074
qed
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1075
  
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1076
lemma last_cl_exists_rexp:
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1077
  assumes ES_single: "ES = {(X, xrhs)}" 
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
  1078
  and invariant_ES: "invariant ES"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1079
  shows "\<exists> (r::rexp). L r = X" (is "\<exists> r. ?P r")
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1080
proof-
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
  1081
  def A \<equiv> "arden_op X xrhs"
81
dc879cb59c9c more direct definitions
urbanc
parents: 80
diff changeset
  1082
  have "?P (\<Uplus>{r. Lam r \<in> A})"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1083
  proof -
79
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
  1084
    have "L (\<Uplus>{r. Lam r \<in> A}) = L ({Lam r | r. Lam r \<in>  A})"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1085
    proof(rule rexp_of_lam_eq_lam_set)
79
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
  1086
      show "finite A" 
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
  1087
	unfolding A_def
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
  1088
	using invariant_ES ES_single 
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
  1089
        by (rule_tac arden_op_keeps_finite) 
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
  1090
           (auto simp add: invariant_def finite_rhs_def)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1091
    qed
79
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
  1092
    also have "\<dots> = L A"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1093
    proof-
80
f901a26bf1ac deleted lam_of
urbanc
parents: 79
diff changeset
  1094
      have "{Lam r | r. Lam r \<in> A} = A"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1095
      proof-
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
  1096
        have "classes_of A = {}" using invariant_ES ES_single
79
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
  1097
	  unfolding A_def
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
  1098
          by (simp add:arden_op_removes_cl 
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
  1099
                       self_contained_def invariant_def lefts_of_def) 
79
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
  1100
        thus ?thesis
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
  1101
	  unfolding A_def
80
f901a26bf1ac deleted lam_of
urbanc
parents: 79
diff changeset
  1102
          by (auto simp only: classes_of_def, case_tac x, auto)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1103
      qed
80
f901a26bf1ac deleted lam_of
urbanc
parents: 79
diff changeset
  1104
      thus ?thesis by simp
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1105
    qed
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1106
    also have "\<dots> = X"
79
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
  1107
    unfolding A_def
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
  1108
    proof(rule arden_op_keeps_eq [THEN sym])
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
  1109
      show "X = L xrhs" using invariant_ES ES_single 
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
  1110
        by (auto simp only:invariant_def valid_eqns_def)  
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1111
    next
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
  1112
      from invariant_ES ES_single show "[] \<notin> L (\<Uplus>{r. Trn X r \<in> xrhs})"
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
  1113
        by(simp add:invariant_def ardenable_def rexp_of_empty finite_rhs_def)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1114
    next
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
  1115
      from invariant_ES ES_single show "finite xrhs" 
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
  1116
        by (simp add:invariant_def finite_rhs_def)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1117
    qed
81
dc879cb59c9c more direct definitions
urbanc
parents: 80
diff changeset
  1118
    finally show ?thesis by simp
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1119
  qed
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1120
  thus ?thesis by auto
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1121
qed
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1122
   
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1123
lemma every_eqcl_has_reg: 
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1124
  assumes finite_CS: "finite (UNIV // (\<approx>Lang))"
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1125
  and X_in_CS: "X \<in> (UNIV // (\<approx>Lang))"
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1126
  shows "\<exists> (reg::rexp). L reg = X" (is "\<exists> r. ?E r")
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1127
proof -
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1128
  from X_in_CS have "\<exists> xrhs. (X, xrhs) \<in> (eqs (UNIV  // (\<approx>Lang)))"
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1129
    by (auto simp:eqs_def init_rhs_def)
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
  1130
  then obtain ES xrhs where invariant_ES: "invariant ES" 
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1131
    and X_in_ES: "(X, xrhs) \<in> ES"
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1132
    and card_ES: "card ES = 1"
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
  1133
    using finite_CS X_in_CS init_ES_satisfy_invariant iteration_conc
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1134
    by blast
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1135
  hence ES_single_equa: "ES = {(X, xrhs)}" 
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
  1136
    by (auto simp:invariant_def dest!:card_Suc_Diff1 simp:card_eq_0_iff) 
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
  1137
  thus ?thesis using invariant_ES
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1138
    by (rule last_cl_exists_rexp)
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1139
qed
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1140
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1141
theorem hard_direction: 
70
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
  1142
  assumes finite_CS: "finite (UNIV // \<approx>A)"
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
  1143
  shows   "\<exists>r::rexp. A = L r"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1144
proof -
70
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
  1145
  have "\<forall> X \<in> (UNIV // \<approx>A). \<exists>reg::rexp. X = L reg" 
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1146
    using finite_CS every_eqcl_has_reg by blast
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1147
  then obtain f 
70
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
  1148
    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
  1149
    by (auto dest: bchoice)
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
  1150
  def rs \<equiv> "f ` (finals A)"  
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
  1151
  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
  1152
  also have "\<dots> = L (\<Uplus>rs)" 
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1153
  proof -
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1154
    have "finite rs"
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1155
    proof -
70
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
  1156
      have "finite (finals A)" 
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
  1157
        using finite_CS finals_in_partitions[of "A"]   
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1158
        by (erule_tac finite_subset, simp)
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1159
      thus ?thesis using rs_def by auto
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1160
    qed
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1161
    thus ?thesis 
70
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
  1162
      using f_prop rs_def finals_in_partitions[of "A"] by auto
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1163
  qed
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1164
  finally show ?thesis by blast
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1165
qed 
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1166
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
  1167
end