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