Myhill_1.thy
author urbanc
Wed, 18 May 2011 19:54:43 +0000
changeset 162 e93760534354
parent 149 e122cb146ecc
child 166 7743d2ad71d1
permissions -rw-r--r--
added directory for journal version; took uptodate version of the theory files
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
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
     2
imports Main Folds Regular
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
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
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
     6
section {* Direction @{text "finite partition \<Rightarrow> regular language"} *}
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
     7
75
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
     8
lemma Pair_Collect[simp]:
48
61d9684a557a Myhill.thy and Myhill_1.thy changed.
zhang
parents: 46
diff changeset
     9
  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
    10
by simp
61d9684a557a Myhill.thy and Myhill_1.thy changed.
zhang
parents: 46
diff changeset
    11
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
    12
text {* Myhill-Nerode relation *}
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
    13
48
61d9684a557a Myhill.thy and Myhill_1.thy changed.
zhang
parents: 46
diff changeset
    14
definition
71
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
    15
  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
    16
where
70
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
    17
  "\<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
    18
61d9684a557a Myhill.thy and Myhill_1.thy changed.
zhang
parents: 46
diff changeset
    19
definition 
71
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
    20
  finals :: "lang \<Rightarrow> lang set"
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
    21
where
108
212bfa431fa5 filled details in one place
urbanc
parents: 106
diff changeset
    22
  "finals A \<equiv> {\<approx>A `` {s} | s . s \<in> A}"
48
61d9684a557a Myhill.thy and Myhill_1.thy changed.
zhang
parents: 46
diff changeset
    23
61d9684a557a Myhill.thy and Myhill_1.thy changed.
zhang
parents: 46
diff changeset
    24
lemma lang_is_union_of_finals: 
70
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
    25
  shows "A = \<Union> finals A"
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
    26
unfolding finals_def
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
    27
unfolding Image_def
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
    28
unfolding str_eq_rel_def
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
    29
by (auto) (metis append_Nil2)
70
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
    30
79
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
    31
lemma finals_in_partitions:
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
    32
  shows "finals A \<subseteq> (UNIV // \<approx>A)"
94
5b12cd0a3b3c latest on the paper
urbanc
parents: 92
diff changeset
    33
unfolding finals_def quotient_def
76
1589bf5c1ad8 added an abbreviation for folds ALT NULL
urbanc
parents: 75
diff changeset
    34
by auto
1589bf5c1ad8 added an abbreviation for folds ALT NULL
urbanc
parents: 75
diff changeset
    35
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
    36
section {* Equational systems *}
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
    37
89
42af13d194c9 a bit more on the paper
urbanc
parents: 88
diff changeset
    38
text {* The two kinds of terms in the rhs of equations. *}
42af13d194c9 a bit more on the paper
urbanc
parents: 88
diff changeset
    39
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
    40
datatype rhs_trm = 
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
    41
   Lam "rexp"            (* Lambda-marker *)
70
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
    42
 | Trn "lang" "rexp"     (* Transition *)
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
    43
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
    44
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
    45
overloading L_rhs_trm \<equiv> "L:: rhs_trm \<Rightarrow> lang"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
    46
begin
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
    47
  fun L_rhs_trm:: "rhs_trm \<Rightarrow> lang"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
    48
  where
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
    49
    "L_rhs_trm (Lam r) = L r" 
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
    50
  | "L_rhs_trm (Trn X r) = X ;; L r"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
    51
end
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
    52
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
    53
overloading L_rhs \<equiv> "L:: rhs_trm set \<Rightarrow> lang"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
    54
begin
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
    55
   fun L_rhs:: "rhs_trm set \<Rightarrow> lang"
70
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
    56
   where 
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
    57
     "L_rhs rhs = \<Union> (L ` rhs)"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
    58
end
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
    59
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
    60
lemma L_rhs_set:
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
    61
  shows "L {Trn X r | r. P r} = \<Union>{L (Trn X r) | r. P r}"
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
    62
by (auto simp del: L_rhs_trm.simps)
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
    63
96
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
    64
lemma L_rhs_union_distrib:
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
    65
  fixes A B::"rhs_trm set"
96
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
    66
  shows "L A \<union> L B = L (A \<union> B)"
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
    67
by simp
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
    68
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
    69
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
    70
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
    71
text {* Transitions between equivalence classes *}
71
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
    72
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
    73
definition 
92
a9ebc410a5c8 more on paper
urbanc
parents: 91
diff changeset
    74
  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
    75
where
92
a9ebc410a5c8 more on paper
urbanc
parents: 91
diff changeset
    76
  "Y \<Turnstile>c\<Rightarrow> X \<equiv> Y ;; {[c]} \<subseteq> X"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
    77
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
    78
text {* Initial equational system *}
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
    79
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
    80
definition
96
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
    81
  "Init_rhs CS X \<equiv>  
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
    82
      if ([] \<in> X) then 
92
a9ebc410a5c8 more on paper
urbanc
parents: 91
diff changeset
    83
          {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
    84
      else 
92
a9ebc410a5c8 more on paper
urbanc
parents: 91
diff changeset
    85
          {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
    86
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
    87
definition 
96
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
    88
  "Init CS \<equiv> {(X, Init_rhs CS X) | X.  X \<in> CS}"
75
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
    89
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
    90
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
    91
section {* Arden Operation on equations *}
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
    92
70
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
    93
fun 
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
    94
  Append_rexp :: "rexp \<Rightarrow> rhs_trm \<Rightarrow> rhs_trm"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
    95
where
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
    96
  "Append_rexp r (Lam rexp)   = Lam (SEQ rexp r)"
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
    97
| "Append_rexp r (Trn X rexp) = Trn X (SEQ rexp r)"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
    98
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
    99
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   100
definition
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   101
  "Append_rexp_rhs rhs rexp \<equiv> (Append_rexp rexp) ` rhs"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   102
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   103
definition 
94
5b12cd0a3b3c latest on the paper
urbanc
parents: 92
diff changeset
   104
  "Arden X rhs \<equiv> 
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   105
     Append_rexp_rhs (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
   106
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   107
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   108
section {* Substitution Operation on equations *}
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   109
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   110
definition 
94
5b12cd0a3b3c latest on the paper
urbanc
parents: 92
diff changeset
   111
  "Subst rhs X xrhs \<equiv> 
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   112
        (rhs - {Trn X r | r. Trn X r \<in> rhs}) \<union> (Append_rexp_rhs xrhs (\<Uplus> {r. Trn X r \<in> rhs}))"
97
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   113
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   114
definition
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   115
  Subst_all :: "(lang \<times> rhs_trm set) set \<Rightarrow> lang \<Rightarrow> rhs_trm set \<Rightarrow> (lang \<times> rhs_trm set) set"
97
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   116
where
94
5b12cd0a3b3c latest on the paper
urbanc
parents: 92
diff changeset
   117
  "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
   118
91
37ab56205097 added Xingyuan's changes with the while combinator
urbanc
parents: 89
diff changeset
   119
definition
96
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   120
  "Remove ES X xrhs \<equiv> 
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   121
      Subst_all  (ES - {(X, xrhs)}) X (Arden X xrhs)"
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   122
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   123
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   124
section {* While-combinator *}
91
37ab56205097 added Xingyuan's changes with the while combinator
urbanc
parents: 89
diff changeset
   125
37ab56205097 added Xingyuan's changes with the while combinator
urbanc
parents: 89
diff changeset
   126
definition 
96
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   127
  "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
   128
                in Remove ES Y yrhs)"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   129
97
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   130
lemma IterI2:
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   131
  assumes "(Y, yrhs) \<in> ES"
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   132
  and     "X \<noteq> Y"
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   133
  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
   134
  shows "Q (Iter X ES)"
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   135
unfolding Iter_def using assms
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   136
by (rule_tac a="(Y, yrhs)" in someI2) (auto)
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   137
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   138
abbreviation
101
d3fe0597080a updated paper
urbanc
parents: 100
diff changeset
   139
  "Cond ES \<equiv> card ES \<noteq> 1"
97
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   140
91
37ab56205097 added Xingyuan's changes with the while combinator
urbanc
parents: 89
diff changeset
   141
definition 
101
d3fe0597080a updated paper
urbanc
parents: 100
diff changeset
   142
  "Solve X ES \<equiv> while Cond (Iter X) ES"
97
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   143
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   144
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   145
section {* Invariants *}
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   146
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   147
definition 
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   148
  "distinctness ES \<equiv> 
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   149
     \<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
   150
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   151
definition 
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   152
  "soundness ES \<equiv> \<forall>(X, rhs) \<in> ES. X = L rhs"
70
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
   153
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   154
definition 
110
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   155
  "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
   156
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   157
definition 
110
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   158
  "ardenable_all ES \<equiv> \<forall>(X, rhs) \<in> ES. ardenable rhs"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   159
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   160
definition
103
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   161
  "finite_rhs ES \<equiv> \<forall>(X, rhs) \<in> ES. finite rhs"
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   162
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   163
lemma finite_rhs_def2:
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   164
  "finite_rhs ES = (\<forall> X rhs. (X, rhs) \<in> ES \<longrightarrow> finite rhs)"
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   165
unfolding finite_rhs_def by auto
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   166
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   167
definition 
104
5bd73aa805a7 updated paper
urbanc
parents: 103
diff changeset
   168
  "rhss rhs \<equiv> {X | X r. Trn X r \<in> rhs}"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   169
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   170
definition
103
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   171
  "lhss ES \<equiv> {Y | Y yrhs. (Y, yrhs) \<in> ES}"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   172
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   173
definition 
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   174
  "validity ES \<equiv> \<forall>(X, rhs) \<in> ES. rhss rhs \<subseteq> lhss ES"
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   175
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   176
lemma rhss_union_distrib:
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   177
  shows "rhss (A \<union> B) = rhss A \<union> rhss B"
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   178
by (auto simp add: rhss_def)
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   179
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   180
lemma lhss_union_distrib:
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   181
  shows "lhss (A \<union> B) = lhss A \<union> lhss B"
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   182
by (auto simp add: lhss_def)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   183
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   184
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   185
definition 
103
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   186
  "invariant ES \<equiv> finite ES
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   187
                \<and> finite_rhs ES
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   188
                \<and> soundness ES 
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   189
                \<and> distinctness ES 
110
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   190
                \<and> ardenable_all ES 
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   191
                \<and> validity ES"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   192
96
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   193
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   194
lemma invariantI:
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   195
  assumes "soundness ES" "finite ES" "distinctness ES" "ardenable_all ES" 
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   196
          "finite_rhs ES" "validity ES"
96
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   197
  shows "invariant ES"
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   198
using assms by (simp add: invariant_def)
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   199
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   200
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   201
subsection {* The proof of this direction *}
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   202
79
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   203
lemma finite_Trn:
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   204
  assumes fin: "finite rhs"
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   205
  shows "finite {r. Trn Y r \<in> rhs}"
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   206
proof -
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   207
  have "finite {Trn Y r | Y r. Trn Y r \<in> rhs}"
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   208
    by (rule rev_finite_subset[OF fin]) (auto)
81
dc879cb59c9c more direct definitions
urbanc
parents: 80
diff changeset
   209
  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
   210
    by (simp add: image_Collect)
dc879cb59c9c more direct definitions
urbanc
parents: 80
diff changeset
   211
  then have "finite {(Y, r) | Y r. Trn Y r \<in> rhs}"
dc879cb59c9c more direct definitions
urbanc
parents: 80
diff changeset
   212
    by (erule_tac finite_imageD) (simp add: inj_on_def)
79
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   213
  then show "finite {r. Trn Y r \<in> rhs}"
81
dc879cb59c9c more direct definitions
urbanc
parents: 80
diff changeset
   214
    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
   215
qed
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   216
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   217
lemma finite_Lam:
96
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   218
  assumes fin: "finite rhs"
79
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   219
  shows "finite {r. Lam r \<in> rhs}"
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   220
proof -
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   221
  have "finite {Lam r | r. Lam r \<in> rhs}"
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   222
    by (rule rev_finite_subset[OF fin]) (auto)
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   223
  then show "finite {r. Lam r \<in> rhs}"
81
dc879cb59c9c more direct definitions
urbanc
parents: 80
diff changeset
   224
    apply(simp add: image_Collect[symmetric])
dc879cb59c9c more direct definitions
urbanc
parents: 80
diff changeset
   225
    apply(erule finite_imageD)
dc879cb59c9c more direct definitions
urbanc
parents: 80
diff changeset
   226
    apply(auto simp add: inj_on_def)
79
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   227
    done
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   228
qed
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   229
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   230
lemma rhs_trm_soundness:
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   231
  assumes finite:"finite rhs"
79
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   232
  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
   233
proof -
79
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   234
  have "finite {r. Trn X r \<in> rhs}" 
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   235
    by (rule finite_Trn[OF finite]) 
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   236
  then show "L ({Trn X r| r. Trn X r \<in> rhs}) = X ;; (L (\<Uplus>{r. Trn X r \<in> rhs}))"
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   237
    by (simp only: L_rhs_set L_rhs_trm.simps) (auto simp add: Seq_def)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   238
qed
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   239
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   240
lemma lang_of_append_rexp:
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   241
  "L (Append_rexp r rhs_trm) = L rhs_trm ;; L r"
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   242
by (induct rule: Append_rexp.induct)
96
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   243
   (auto simp add: seq_assoc)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   244
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   245
lemma lang_of_append_rexp_rhs:
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   246
  "L (Append_rexp_rhs rhs r) = L rhs ;; L r"
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   247
unfolding Append_rexp_rhs_def
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   248
by (auto simp add: Seq_def lang_of_append_rexp)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   249
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   250
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   251
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   252
subsubsection {* Intialization *}
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   253
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   254
lemma defined_by_str:
100
2409827d8eb8 updated
urbanc
parents: 99
diff changeset
   255
  assumes "s \<in> X" "X \<in> UNIV // \<approx>A" 
2409827d8eb8 updated
urbanc
parents: 99
diff changeset
   256
  shows "X = \<approx>A `` {s}"
2409827d8eb8 updated
urbanc
parents: 99
diff changeset
   257
using assms
2409827d8eb8 updated
urbanc
parents: 99
diff changeset
   258
unfolding quotient_def Image_def str_eq_rel_def
2409827d8eb8 updated
urbanc
parents: 99
diff changeset
   259
by auto
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   260
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   261
lemma every_eqclass_has_transition:
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   262
  assumes has_str: "s @ [c] \<in> X"
100
2409827d8eb8 updated
urbanc
parents: 99
diff changeset
   263
  and     in_CS:   "X \<in> UNIV // \<approx>A"
2409827d8eb8 updated
urbanc
parents: 99
diff changeset
   264
  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
   265
proof -
100
2409827d8eb8 updated
urbanc
parents: 99
diff changeset
   266
  def Y \<equiv> "\<approx>A `` {s}"
2409827d8eb8 updated
urbanc
parents: 99
diff changeset
   267
  have "Y \<in> UNIV // \<approx>A" 
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   268
    unfolding Y_def quotient_def by auto
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   269
  moreover
100
2409827d8eb8 updated
urbanc
parents: 99
diff changeset
   270
  have "X = \<approx>A `` {s @ [c]}" 
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   271
    using has_str in_CS defined_by_str by blast
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   272
  then have "Y ;; {[c]} \<subseteq> X" 
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   273
    unfolding Y_def Image_def Seq_def
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   274
    unfolding str_eq_rel_def
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   275
    by clarsimp
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   276
  moreover
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   277
  have "s \<in> Y" unfolding Y_def 
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   278
    unfolding Image_def str_eq_rel_def by simp
100
2409827d8eb8 updated
urbanc
parents: 99
diff changeset
   279
  ultimately show thesis using that by blast
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   280
qed
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   281
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   282
lemma l_eq_r_in_eqs:
100
2409827d8eb8 updated
urbanc
parents: 99
diff changeset
   283
  assumes X_in_eqs: "(X, rhs) \<in> Init (UNIV // \<approx>A)"
2409827d8eb8 updated
urbanc
parents: 99
diff changeset
   284
  shows "X = L rhs"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   285
proof 
100
2409827d8eb8 updated
urbanc
parents: 99
diff changeset
   286
  show "X \<subseteq> L rhs"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   287
  proof
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   288
    fix x
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   289
    assume in_X: "x \<in> X"
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   290
    { assume empty: "x = []"
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   291
      then have "x \<in> L rhs" using X_in_eqs in_X
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   292
	unfolding Init_def Init_rhs_def
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   293
        by auto
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   294
    }
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   295
    moreover
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   296
    { assume not_empty: "x \<noteq> []"
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   297
      then obtain s c where decom: "x = s @ [c]"
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   298
	using rev_cases by blast
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   299
      have "X \<in> UNIV // \<approx>A" using X_in_eqs unfolding Init_def by auto
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   300
      then obtain Y where "Y \<in> UNIV // \<approx>A" "Y ;; {[c]} \<subseteq> X" "s \<in> Y"
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   301
        using decom in_X every_eqclass_has_transition by blast
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   302
      then have "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
   303
        unfolding transition_def
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   304
	using decom by (force simp add: Seq_def)
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   305
      then have "x \<in> L rhs" using X_in_eqs in_X
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   306
	unfolding Init_def Init_rhs_def by simp
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   307
    }
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   308
    ultimately show "x \<in> L rhs" by blast
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   309
  qed
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   310
next
100
2409827d8eb8 updated
urbanc
parents: 99
diff changeset
   311
  show "L rhs \<subseteq> X" using X_in_eqs
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   312
    unfolding Init_def Init_rhs_def transition_def
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   313
    by auto 
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   314
qed
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   315
100
2409827d8eb8 updated
urbanc
parents: 99
diff changeset
   316
lemma test:
2409827d8eb8 updated
urbanc
parents: 99
diff changeset
   317
  assumes X_in_eqs: "(X, rhs) \<in> Init (UNIV // \<approx>A)"
2409827d8eb8 updated
urbanc
parents: 99
diff changeset
   318
  shows "X = \<Union> (L `  rhs)"
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   319
using assms l_eq_r_in_eqs by (simp)
100
2409827d8eb8 updated
urbanc
parents: 99
diff changeset
   320
96
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   321
lemma finite_Init_rhs: 
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   322
  assumes finite: "finite CS"
96
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   323
  shows "finite (Init_rhs CS X)"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   324
proof-
105
ae6ad1363eb9 updated paper
urbanc
parents: 104
diff changeset
   325
  def S \<equiv> "{(Y, c)| Y c. Y \<in> CS \<and> Y ;; {[c]} \<subseteq> X}" 
ae6ad1363eb9 updated paper
urbanc
parents: 104
diff changeset
   326
  def h \<equiv> "\<lambda> (Y, c). Trn Y (CHAR c)"
ae6ad1363eb9 updated paper
urbanc
parents: 104
diff changeset
   327
  have "finite (CS \<times> (UNIV::char set))" using finite by auto
ae6ad1363eb9 updated paper
urbanc
parents: 104
diff changeset
   328
  then have "finite S" using S_def 
ae6ad1363eb9 updated paper
urbanc
parents: 104
diff changeset
   329
    by (rule_tac B = "CS \<times> UNIV" in finite_subset) (auto)
ae6ad1363eb9 updated paper
urbanc
parents: 104
diff changeset
   330
  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
   331
    unfolding S_def h_def image_def by auto
ae6ad1363eb9 updated paper
urbanc
parents: 104
diff changeset
   332
  ultimately
ae6ad1363eb9 updated paper
urbanc
parents: 104
diff changeset
   333
  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
   334
  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
   335
qed
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   336
96
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   337
lemma Init_ES_satisfies_invariant:
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   338
  assumes finite_CS: "finite (UNIV // \<approx>A)"
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   339
  shows "invariant (Init (UNIV // \<approx>A))"
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   340
proof (rule invariantI)
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   341
  show "soundness (Init (UNIV // \<approx>A))"
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   342
    unfolding soundness_def 
97
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   343
    using l_eq_r_in_eqs by auto
96
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   344
  show "finite (Init (UNIV // \<approx>A))" using finite_CS
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   345
    unfolding Init_def by simp
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   346
  show "distinctness (Init (UNIV // \<approx>A))"     
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   347
    unfolding distinctness_def Init_def by simp
110
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   348
  show "ardenable_all (Init (UNIV // \<approx>A))"
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   349
    unfolding ardenable_all_def Init_def Init_rhs_def ardenable_def
103
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   350
   by auto 
96
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   351
  show "finite_rhs (Init (UNIV // \<approx>A))"
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   352
    using finite_Init_rhs[OF finite_CS]
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   353
    unfolding finite_rhs_def Init_def by auto
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   354
  show "validity (Init (UNIV // \<approx>A))"
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   355
    unfolding validity_def Init_def Init_rhs_def rhss_def lhss_def
96
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   356
    by auto
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   357
qed
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   358
91
37ab56205097 added Xingyuan's changes with the while combinator
urbanc
parents: 89
diff changeset
   359
subsubsection {* Interation step *}
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   360
94
5b12cd0a3b3c latest on the paper
urbanc
parents: 92
diff changeset
   361
lemma Arden_keeps_eq:
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   362
  assumes l_eq_r: "X = L rhs"
110
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   363
  and not_empty: "ardenable rhs"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   364
  and finite: "finite rhs"
94
5b12cd0a3b3c latest on the paper
urbanc
parents: 92
diff changeset
   365
  shows "X = L (Arden X rhs)"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   366
proof -
79
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   367
  def A \<equiv> "L (\<Uplus>{r. Trn X r \<in> rhs})"
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   368
  def b \<equiv> "{Trn X r | r. Trn X r \<in> rhs}"
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   369
  def B \<equiv> "L (rhs - b)"
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   370
  have not_empty2: "[] \<notin> A" 
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   371
    using finite_Trn[OF finite] not_empty
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   372
    unfolding A_def ardenable_def by simp
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   373
  have "X = L rhs" using l_eq_r by simp
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   374
  also have "\<dots> = L (b \<union> (rhs - b))" unfolding b_def by auto
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   375
  also have "\<dots> = L b \<union> B" unfolding B_def by (simp only: L_rhs_union_distrib)
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   376
  also have "\<dots> = X ;; A \<union> B"
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   377
    unfolding b_def
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   378
    unfolding rhs_trm_soundness[OF finite]
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   379
    unfolding A_def
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   380
    by blast
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   381
  finally have "X = X ;; A \<union> B" . 
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   382
  then have "X = B ;; A\<star>"
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   383
    by (simp add: arden[OF not_empty2])
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   384
  also have "\<dots> = L (Arden X rhs)"
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   385
    unfolding Arden_def A_def B_def b_def
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   386
    by (simp only: lang_of_append_rexp_rhs L_rexp.simps)
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   387
  finally show "X = L (Arden X rhs)" by simp
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   388
qed 
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   389
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   390
lemma Append_keeps_finite:
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   391
  "finite rhs \<Longrightarrow> finite (Append_rexp_rhs rhs r)"
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   392
by (auto simp:Append_rexp_rhs_def)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   393
94
5b12cd0a3b3c latest on the paper
urbanc
parents: 92
diff changeset
   394
lemma Arden_keeps_finite:
5b12cd0a3b3c latest on the paper
urbanc
parents: 92
diff changeset
   395
  "finite rhs \<Longrightarrow> finite (Arden X rhs)"
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   396
by (auto simp:Arden_def Append_keeps_finite)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   397
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   398
lemma Append_keeps_nonempty:
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   399
  "ardenable rhs \<Longrightarrow> ardenable (Append_rexp_rhs rhs r)"
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   400
apply (auto simp:ardenable_def Append_rexp_rhs_def)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   401
by (case_tac x, auto simp:Seq_def)
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   402
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   403
lemma nonempty_set_sub:
110
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   404
  "ardenable rhs \<Longrightarrow> ardenable (rhs - A)"
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   405
by (auto simp:ardenable_def)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   406
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   407
lemma nonempty_set_union:
110
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   408
  "\<lbrakk>ardenable rhs; ardenable rhs'\<rbrakk> \<Longrightarrow> ardenable (rhs \<union> rhs')"
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   409
by (auto simp:ardenable_def)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   410
94
5b12cd0a3b3c latest on the paper
urbanc
parents: 92
diff changeset
   411
lemma Arden_keeps_nonempty:
110
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   412
  "ardenable rhs \<Longrightarrow> ardenable (Arden X rhs)"
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   413
by (simp only:Arden_def Append_keeps_nonempty nonempty_set_sub)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   414
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   415
94
5b12cd0a3b3c latest on the paper
urbanc
parents: 92
diff changeset
   416
lemma Subst_keeps_nonempty:
110
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   417
  "\<lbrakk>ardenable rhs; ardenable xrhs\<rbrakk> \<Longrightarrow> ardenable (Subst rhs X xrhs)"
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   418
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
   419
94
5b12cd0a3b3c latest on the paper
urbanc
parents: 92
diff changeset
   420
lemma Subst_keeps_eq:
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   421
  assumes substor: "X = L xrhs"
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   422
  and finite: "finite rhs"
94
5b12cd0a3b3c latest on the paper
urbanc
parents: 92
diff changeset
   423
  shows "L (Subst rhs X xrhs) = L rhs" (is "?Left = ?Right")
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   424
proof-
94
5b12cd0a3b3c latest on the paper
urbanc
parents: 92
diff changeset
   425
  def A \<equiv> "L (rhs - {Trn X r | r. Trn X r \<in> rhs})"
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   426
  have "?Left = A \<union> L (Append_rexp_rhs xrhs (\<Uplus>{r. Trn X r \<in> rhs}))"
94
5b12cd0a3b3c latest on the paper
urbanc
parents: 92
diff changeset
   427
    unfolding Subst_def
79
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   428
    unfolding L_rhs_union_distrib[symmetric]
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   429
    by (simp add: A_def)
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   430
  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
   431
  proof-
94
5b12cd0a3b3c latest on the paper
urbanc
parents: 92
diff changeset
   432
    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
   433
    thus ?thesis 
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   434
      unfolding A_def
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   435
      unfolding L_rhs_union_distrib
bba9c80735f9 started to define things more directly
urbanc
parents: 76
diff changeset
   436
      by simp
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   437
  qed
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   438
  moreover have "L (Append_rexp_rhs xrhs (\<Uplus>{r. Trn X r \<in> rhs})) = L ({Trn X r | r. Trn X r \<in> rhs})" 
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   439
    using finite substor by (simp only: lang_of_append_rexp_rhs rhs_trm_soundness)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   440
  ultimately show ?thesis by simp
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   441
qed
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   442
94
5b12cd0a3b3c latest on the paper
urbanc
parents: 92
diff changeset
   443
lemma Subst_keeps_finite_rhs:
5b12cd0a3b3c latest on the paper
urbanc
parents: 92
diff changeset
   444
  "\<lbrakk>finite rhs; finite yrhs\<rbrakk> \<Longrightarrow> finite (Subst rhs Y yrhs)"
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   445
by (auto simp: Subst_def Append_keeps_finite)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   446
94
5b12cd0a3b3c latest on the paper
urbanc
parents: 92
diff changeset
   447
lemma Subst_all_keeps_finite:
110
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   448
  assumes finite: "finite ES"
94
5b12cd0a3b3c latest on the paper
urbanc
parents: 92
diff changeset
   449
  shows "finite (Subst_all ES Y yrhs)"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   450
proof -
110
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   451
  def eqns \<equiv> "{(X::lang, rhs) |X rhs. (X, rhs) \<in> ES}"
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   452
  def h \<equiv> "\<lambda>(X::lang, rhs). (X, Subst rhs Y yrhs)"
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   453
  have "finite (h ` eqns)" using finite h_def eqns_def by auto
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   454
  moreover 
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   455
  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
   456
  ultimately
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   457
  show "finite (Subst_all ES Y yrhs)" by simp
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   458
qed
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   459
94
5b12cd0a3b3c latest on the paper
urbanc
parents: 92
diff changeset
   460
lemma Subst_all_keeps_finite_rhs:
5b12cd0a3b3c latest on the paper
urbanc
parents: 92
diff changeset
   461
  "\<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
   462
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
   463
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   464
lemma append_rhs_keeps_cls:
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   465
  "rhss (Append_rexp_rhs rhs r) = rhss rhs"
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   466
apply (auto simp:rhss_def Append_rexp_rhs_def)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   467
apply (case_tac xa, auto simp:image_def)
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   468
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
   469
94
5b12cd0a3b3c latest on the paper
urbanc
parents: 92
diff changeset
   470
lemma Arden_removes_cl:
104
5bd73aa805a7 updated paper
urbanc
parents: 103
diff changeset
   471
  "rhss (Arden Y yrhs) = rhss yrhs - {Y}"
94
5b12cd0a3b3c latest on the paper
urbanc
parents: 92
diff changeset
   472
apply (simp add:Arden_def append_rhs_keeps_cls)
104
5bd73aa805a7 updated paper
urbanc
parents: 103
diff changeset
   473
by (auto simp:rhss_def)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   474
103
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   475
lemma lhss_keeps_cls:
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   476
  "lhss (Subst_all ES Y yrhs) = lhss ES"
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   477
by (auto simp:lhss_def Subst_all_def)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   478
94
5b12cd0a3b3c latest on the paper
urbanc
parents: 92
diff changeset
   479
lemma Subst_updates_cls:
104
5bd73aa805a7 updated paper
urbanc
parents: 103
diff changeset
   480
  "X \<notin> rhss xrhs \<Longrightarrow> 
5bd73aa805a7 updated paper
urbanc
parents: 103
diff changeset
   481
      rhss (Subst rhs X xrhs) = rhss rhs \<union> rhss xrhs - {X}"
5bd73aa805a7 updated paper
urbanc
parents: 103
diff changeset
   482
apply (simp only:Subst_def append_rhs_keeps_cls rhss_union_distrib)
5bd73aa805a7 updated paper
urbanc
parents: 103
diff changeset
   483
by (auto simp:rhss_def)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   484
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   485
lemma Subst_all_keeps_validity:
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   486
  assumes sc: "validity (ES \<union> {(Y, yrhs)})"        (is "validity ?A")
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   487
  shows "validity (Subst_all ES Y (Arden Y yrhs))"  (is "validity ?B")
110
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   488
proof -
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   489
  { fix X xrhs'
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   490
    assume "(X, xrhs') \<in> ?B"
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   491
    then obtain xrhs 
94
5b12cd0a3b3c latest on the paper
urbanc
parents: 92
diff changeset
   492
      where xrhs_xrhs': "xrhs' = Subst xrhs Y (Arden Y yrhs)"
5b12cd0a3b3c latest on the paper
urbanc
parents: 92
diff changeset
   493
      and X_in: "(X, xrhs) \<in> ES" by (simp add:Subst_all_def, blast)    
104
5bd73aa805a7 updated paper
urbanc
parents: 103
diff changeset
   494
    have "rhss xrhs' \<subseteq> lhss ?B"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   495
    proof-
103
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   496
      have "lhss ?B = lhss ES" by (auto simp add:lhss_def Subst_all_def)
104
5bd73aa805a7 updated paper
urbanc
parents: 103
diff changeset
   497
      moreover have "rhss xrhs' \<subseteq> lhss ES"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   498
      proof-
110
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   499
        have "rhss xrhs' \<subseteq>  rhss xrhs \<union> rhss (Arden Y yrhs) - {Y}"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   500
        proof-
104
5bd73aa805a7 updated paper
urbanc
parents: 103
diff changeset
   501
          have "Y \<notin> rhss (Arden Y yrhs)" 
94
5b12cd0a3b3c latest on the paper
urbanc
parents: 92
diff changeset
   502
            using Arden_removes_cl by simp
5b12cd0a3b3c latest on the paper
urbanc
parents: 92
diff changeset
   503
          thus ?thesis using xrhs_xrhs' by (auto simp:Subst_updates_cls)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   504
        qed
104
5bd73aa805a7 updated paper
urbanc
parents: 103
diff changeset
   505
        moreover have "rhss xrhs \<subseteq> lhss ES \<union> {Y}" using X_in sc
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   506
          apply (simp only:validity_def lhss_union_distrib)
103
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   507
          by (drule_tac x = "(X, xrhs)" in bspec, auto simp:lhss_def)
104
5bd73aa805a7 updated paper
urbanc
parents: 103
diff changeset
   508
        moreover have "rhss (Arden Y yrhs) \<subseteq> lhss ES \<union> {Y}" 
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   509
          using sc 
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   510
          by (auto simp add:Arden_removes_cl validity_def lhss_def)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   511
        ultimately show ?thesis by auto
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   512
      qed
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   513
      ultimately show ?thesis by simp
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   514
    qed
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   515
  } thus ?thesis by (auto simp only:Subst_all_def validity_def)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   516
qed
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   517
96
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   518
lemma Subst_all_satisfies_invariant:
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   519
  assumes invariant_ES: "invariant (ES \<union> {(Y, yrhs)})"
94
5b12cd0a3b3c latest on the paper
urbanc
parents: 92
diff changeset
   520
  shows "invariant (Subst_all ES Y (Arden Y yrhs))"
96
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   521
proof (rule invariantI)
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   522
  have Y_eq_yrhs: "Y = L yrhs" 
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   523
    using invariant_ES by (simp only:invariant_def soundness_def, blast)
96
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   524
   have finite_yrhs: "finite yrhs" 
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   525
    using invariant_ES by (auto simp:invariant_def finite_rhs_def)
110
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   526
  have nonempty_yrhs: "ardenable yrhs" 
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   527
    using invariant_ES by (auto simp:invariant_def ardenable_all_def)
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   528
  show "soundness (Subst_all ES Y (Arden Y yrhs))"
110
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   529
  proof -
96
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   530
    have "Y = L (Arden Y yrhs)" 
103
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   531
      using Y_eq_yrhs invariant_ES finite_yrhs
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   532
      using finite_Trn[OF finite_yrhs]
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   533
      apply(rule_tac Arden_keeps_eq)
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   534
      apply(simp_all)
110
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   535
      unfolding invariant_def ardenable_all_def ardenable_def
103
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   536
      apply(auto)
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   537
      done
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   538
    thus ?thesis using invariant_ES
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   539
      unfolding invariant_def finite_rhs_def2 soundness_def Subst_all_def
103
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   540
      by (auto simp add: Subst_keeps_eq simp del: L_rhs.simps)
96
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   541
  qed
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   542
  show "finite (Subst_all ES Y (Arden Y yrhs))" 
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   543
    using invariant_ES by (simp add:invariant_def Subst_all_keeps_finite)
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   544
  show "distinctness (Subst_all ES Y (Arden Y yrhs))" 
110
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   545
    using invariant_ES 
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   546
    unfolding distinctness_def Subst_all_def invariant_def by auto
110
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   547
  show "ardenable_all (Subst_all ES Y (Arden Y yrhs))"
96
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   548
  proof - 
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   549
    { fix X rhs
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   550
      assume "(X, rhs) \<in> ES"
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   551
      hence "ardenable rhs"  using invariant_ES  
110
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   552
        by (auto simp add:invariant_def ardenable_all_def)
96
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   553
      with nonempty_yrhs 
110
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   554
      have "ardenable (Subst rhs Y (Arden Y yrhs))"
96
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   555
        by (simp add:nonempty_yrhs 
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   556
               Subst_keeps_nonempty Arden_keeps_nonempty)
110
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   557
    } thus ?thesis by (auto simp add:ardenable_all_def Subst_all_def)
96
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   558
  qed
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   559
  show "finite_rhs (Subst_all ES Y (Arden Y yrhs))"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   560
  proof-
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   561
    have "finite_rhs ES" using invariant_ES 
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   562
      by (simp add:invariant_def finite_rhs_def)
94
5b12cd0a3b3c latest on the paper
urbanc
parents: 92
diff changeset
   563
    moreover have "finite (Arden Y yrhs)"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   564
    proof -
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   565
      have "finite yrhs" using invariant_ES 
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 81
diff changeset
   566
        by (auto simp:invariant_def finite_rhs_def)
94
5b12cd0a3b3c latest on the paper
urbanc
parents: 92
diff changeset
   567
      thus ?thesis using Arden_keeps_finite by simp
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   568
    qed
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   569
    ultimately show ?thesis 
94
5b12cd0a3b3c latest on the paper
urbanc
parents: 92
diff changeset
   570
      by (simp add:Subst_all_keeps_finite_rhs)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   571
  qed
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   572
  show "validity (Subst_all ES Y (Arden Y yrhs))"
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   573
    using invariant_ES Subst_all_keeps_validity by (simp add:invariant_def)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   574
qed
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   575
97
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   576
lemma Remove_in_card_measure:
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   577
  assumes finite: "finite ES"
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   578
  and     in_ES: "(X, rhs) \<in> ES"
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   579
  shows "(Remove ES X rhs, ES) \<in> measure card"
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   580
proof -
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   581
  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
   582
  def ES' \<equiv> "ES - {(X, rhs)}"
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   583
  have "Subst_all ES' X (Arden X rhs) = f ` ES'" 
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   584
    apply (auto simp: Subst_all_def f_def image_def)
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   585
    by (rule_tac x = "(Y, yrhs)" in bexI, simp+)
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   586
  then have "card (Subst_all ES' X (Arden X rhs)) \<le> card ES'"
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   587
    unfolding ES'_def using finite by (auto intro: card_image_le)
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   588
  also have "\<dots> < card ES" unfolding ES'_def 
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   589
    using in_ES finite by (rule_tac card_Diff1_less)
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   590
  finally show "(Remove ES X rhs, ES) \<in> measure card" 
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   591
    unfolding Remove_def ES'_def by simp
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   592
qed
97
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   593
    
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   594
94
5b12cd0a3b3c latest on the paper
urbanc
parents: 92
diff changeset
   595
lemma Subst_all_cls_remains: 
5b12cd0a3b3c latest on the paper
urbanc
parents: 92
diff changeset
   596
  "(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
   597
by (auto simp: Subst_all_def)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   598
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   599
lemma card_noteq_1_has_more:
103
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   600
  assumes card:"Cond ES"
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   601
  and e_in: "(X, xrhs) \<in> ES"
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   602
  and finite: "finite ES"
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   603
  shows "\<exists>(Y, yrhs) \<in> ES. (X, xrhs) \<noteq> (Y, yrhs)"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   604
proof-
103
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   605
  have "card ES > 1" using card e_in finite 
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   606
    by (cases "card ES") (auto) 
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   607
  then have "card (ES - {(X, xrhs)}) > 0"
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   608
    using finite e_in by auto
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   609
  then have "(ES - {(X, xrhs)}) \<noteq> {}" using finite by (rule_tac notI, simp)
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   610
  then show "\<exists>(Y, yrhs) \<in> ES. (X, xrhs) \<noteq> (Y, yrhs)"
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   611
    by auto
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   612
qed
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   613
97
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   614
lemma iteration_step_measure:
91
37ab56205097 added Xingyuan's changes with the while combinator
urbanc
parents: 89
diff changeset
   615
  assumes Inv_ES: "invariant ES"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   616
  and    X_in_ES: "(X, xrhs) \<in> ES"
105
ae6ad1363eb9 updated paper
urbanc
parents: 104
diff changeset
   617
  and    Cnd:     "Cond ES "
97
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   618
  shows "(Iter X ES, ES) \<in> measure card"
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   619
proof -
105
ae6ad1363eb9 updated paper
urbanc
parents: 104
diff changeset
   620
  have fin: "finite ES" using Inv_ES unfolding invariant_def by simp
97
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   621
  then obtain Y yrhs 
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   622
    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
   623
    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
   624
  then have "(Y, yrhs) \<in> ES " "X \<noteq> Y"  
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   625
    using X_in_ES Inv_ES unfolding invariant_def distinctness_def
103
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   626
    by auto
97
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   627
  then show "(Iter X ES, ES) \<in> measure card" 
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   628
  apply(rule IterI2)
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   629
  apply(rule Remove_in_card_measure)
105
ae6ad1363eb9 updated paper
urbanc
parents: 104
diff changeset
   630
  apply(simp_all add: fin)
97
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   631
  done
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   632
qed
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   633
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   634
lemma iteration_step_invariant:
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   635
  assumes Inv_ES: "invariant ES"
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   636
  and    X_in_ES: "(X, xrhs) \<in> ES"
105
ae6ad1363eb9 updated paper
urbanc
parents: 104
diff changeset
   637
  and    Cnd: "Cond ES"
97
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   638
  shows "invariant (Iter X ES)"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   639
proof -
91
37ab56205097 added Xingyuan's changes with the while combinator
urbanc
parents: 89
diff changeset
   640
  have finite_ES: "finite ES" using Inv_ES by (simp add: invariant_def)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   641
  then obtain Y yrhs 
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   642
    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
   643
    using Cnd X_in_ES by (drule_tac card_noteq_1_has_more) (auto)
103
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   644
  then have "(Y, yrhs) \<in> ES" "X \<noteq> Y" 
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   645
    using X_in_ES Inv_ES unfolding invariant_def distinctness_def
103
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   646
    by auto
97
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   647
  then show "invariant (Iter X ES)" 
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   648
  proof(rule IterI2)
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   649
    fix Y yrhs
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   650
    assume h: "(Y, yrhs) \<in> ES" "X \<noteq> Y"
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   651
    then have "ES - {(Y, yrhs)} \<union> {(Y, yrhs)} = ES" by auto
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   652
    then show "invariant (Remove ES Y yrhs)" unfolding Remove_def
110
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   653
      using Inv_ES
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   654
      by (rule_tac Subst_all_satisfies_invariant) (simp) 
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   655
  qed
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   656
qed
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   657
97
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   658
lemma iteration_step_ex:
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   659
  assumes Inv_ES: "invariant ES"
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   660
  and    X_in_ES: "(X, xrhs) \<in> ES"
105
ae6ad1363eb9 updated paper
urbanc
parents: 104
diff changeset
   661
  and    Cnd: "Cond ES"
97
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   662
  shows "\<exists>xrhs'. (X, xrhs') \<in> (Iter X ES)"
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   663
proof -
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   664
  have finite_ES: "finite ES" using Inv_ES by (simp add: invariant_def)
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   665
  then obtain Y yrhs 
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   666
    where "(Y, yrhs) \<in> ES" "(X, xrhs) \<noteq> (Y, yrhs)" 
105
ae6ad1363eb9 updated paper
urbanc
parents: 104
diff changeset
   667
    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
   668
  then have "(Y, yrhs) \<in> ES " "X \<noteq> Y"  
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   669
    using X_in_ES Inv_ES unfolding invariant_def distinctness_def
103
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   670
    by auto
97
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   671
  then show "\<exists>xrhs'. (X, xrhs') \<in> (Iter X ES)" 
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   672
  apply(rule IterI2)
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   673
  unfolding Remove_def
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   674
  apply(rule Subst_all_cls_remains)
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   675
  using X_in_ES
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   676
  apply(auto)
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   677
  done
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   678
qed
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   679
91
37ab56205097 added Xingyuan's changes with the while combinator
urbanc
parents: 89
diff changeset
   680
37ab56205097 added Xingyuan's changes with the while combinator
urbanc
parents: 89
diff changeset
   681
subsubsection {* Conclusion of the proof *}
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   682
103
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   683
lemma Solve:
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   684
  assumes fin: "finite (UNIV // \<approx>A)"
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   685
  and     X_in: "X \<in> (UNIV // \<approx>A)"
104
5bd73aa805a7 updated paper
urbanc
parents: 103
diff changeset
   686
  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
   687
proof -
104
5bd73aa805a7 updated paper
urbanc
parents: 103
diff changeset
   688
  def Inv \<equiv> "\<lambda>ES. invariant ES \<and> (\<exists>rhs. (X, rhs) \<in> ES)"
103
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   689
  have "Inv (Init (UNIV // \<approx>A))" unfolding Inv_def
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   690
      using fin X_in by (simp add: Init_ES_satisfies_invariant, simp add: Init_def)
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   691
  moreover
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   692
  { fix ES
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   693
    assume inv: "Inv ES" and crd: "Cond ES"
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   694
    then have "Inv (Iter X ES)"
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   695
      unfolding Inv_def
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   696
      by (auto simp add: iteration_step_invariant iteration_step_ex) }
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   697
  moreover
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   698
  { fix ES
110
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   699
    assume inv: "Inv ES" and not_crd: "\<not>Cond ES"
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   700
    from inv obtain rhs where "(X, rhs) \<in> ES" unfolding Inv_def by auto
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   701
    moreover
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   702
    from not_crd have "card ES = 1" by simp
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   703
    ultimately 
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   704
    have "ES = {(X, rhs)}" by (auto simp add: card_Suc_eq) 
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   705
    then have "\<exists>rhs'. ES = {(X, rhs')} \<and> invariant {(X, rhs')}" using inv
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   706
      unfolding Inv_def by auto }
103
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   707
  moreover
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   708
    have "wf (measure card)" by simp
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   709
  moreover
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   710
  { fix ES
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   711
    assume inv: "Inv ES" and crd: "Cond ES"
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   712
    then have "(Iter X ES, ES) \<in> measure card"
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   713
      unfolding Inv_def
97
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   714
      apply(clarify)
103
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   715
      apply(rule_tac iteration_step_measure)
97
70485955c934 slightly streamlined the proof
urbanc
parents: 96
diff changeset
   716
      apply(auto)
103
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   717
      done }
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   718
  ultimately 
104
5bd73aa805a7 updated paper
urbanc
parents: 103
diff changeset
   719
  show "\<exists>rhs. Solve X (Init (UNIV // \<approx>A)) = {(X, rhs)} \<and> invariant {(X, rhs)}" 
103
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   720
    unfolding Solve_def by (rule while_rule)
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   721
qed
91
37ab56205097 added Xingyuan's changes with the while combinator
urbanc
parents: 89
diff changeset
   722
106
91dc591de63f updated paper
urbanc
parents: 105
diff changeset
   723
lemma every_eqcl_has_reg:
91dc591de63f updated paper
urbanc
parents: 105
diff changeset
   724
  assumes finite_CS: "finite (UNIV // \<approx>A)"
91dc591de63f updated paper
urbanc
parents: 105
diff changeset
   725
  and X_in_CS: "X \<in> (UNIV // \<approx>A)"
91dc591de63f updated paper
urbanc
parents: 105
diff changeset
   726
  shows "\<exists>r::rexp. X = L r" 
91dc591de63f updated paper
urbanc
parents: 105
diff changeset
   727
proof -
91dc591de63f updated paper
urbanc
parents: 105
diff changeset
   728
  from finite_CS X_in_CS 
91dc591de63f updated paper
urbanc
parents: 105
diff changeset
   729
  obtain xrhs where Inv_ES: "invariant {(X, xrhs)}"
91dc591de63f updated paper
urbanc
parents: 105
diff changeset
   730
    using Solve by metis
91dc591de63f updated paper
urbanc
parents: 105
diff changeset
   731
94
5b12cd0a3b3c latest on the paper
urbanc
parents: 92
diff changeset
   732
  def A \<equiv> "Arden X xrhs"
105
ae6ad1363eb9 updated paper
urbanc
parents: 104
diff changeset
   733
  have "rhss xrhs \<subseteq> {X}" using Inv_ES 
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   734
    unfolding validity_def invariant_def rhss_def lhss_def
105
ae6ad1363eb9 updated paper
urbanc
parents: 104
diff changeset
   735
    by auto
ae6ad1363eb9 updated paper
urbanc
parents: 104
diff changeset
   736
  then have "rhss A = {}" unfolding A_def 
ae6ad1363eb9 updated paper
urbanc
parents: 104
diff changeset
   737
    by (simp add: Arden_removes_cl)
ae6ad1363eb9 updated paper
urbanc
parents: 104
diff changeset
   738
  then have eq: "{Lam r | r. Lam r \<in> A} = A" unfolding rhss_def
ae6ad1363eb9 updated paper
urbanc
parents: 104
diff changeset
   739
    by (auto, case_tac x, auto)
ae6ad1363eb9 updated paper
urbanc
parents: 104
diff changeset
   740
  
96
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   741
  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
   742
    using Arden_keeps_finite by auto
105
ae6ad1363eb9 updated paper
urbanc
parents: 104
diff changeset
   743
  then have fin: "finite {r. Lam r \<in> A}" by (rule finite_Lam)
ae6ad1363eb9 updated paper
urbanc
parents: 104
diff changeset
   744
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 149
diff changeset
   745
  have "X = L xrhs" using Inv_ES unfolding invariant_def soundness_def
105
ae6ad1363eb9 updated paper
urbanc
parents: 104
diff changeset
   746
    by simp
ae6ad1363eb9 updated paper
urbanc
parents: 104
diff changeset
   747
  then have "X = L A" using Inv_ES 
110
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   748
    unfolding A_def invariant_def ardenable_all_def finite_rhs_def 
105
ae6ad1363eb9 updated paper
urbanc
parents: 104
diff changeset
   749
    by (rule_tac Arden_keeps_eq) (simp_all add: finite_Trn)
ae6ad1363eb9 updated paper
urbanc
parents: 104
diff changeset
   750
  then have "X = L {Lam r | r. Lam r \<in> A}" using eq by simp
ae6ad1363eb9 updated paper
urbanc
parents: 104
diff changeset
   751
  then have "X = L (\<Uplus>{r. Lam r \<in> A})" using fin by auto
106
91dc591de63f updated paper
urbanc
parents: 105
diff changeset
   752
  then show "\<exists>r::rexp. X = L r" by blast
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   753
qed
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   754
96
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   755
lemma bchoice_finite_set:
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   756
  assumes a: "\<forall>x \<in> S. \<exists>y. x = f y" 
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   757
  and     b: "finite S"
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   758
  shows "\<exists>ys. (\<Union> S) = \<Union>(f ` ys) \<and> finite ys"
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   759
using bchoice[OF a] b
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   760
apply(erule_tac exE)
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   761
apply(rule_tac x="fa ` S" in exI)
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   762
apply(auto)
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   763
done
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   764
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   765
theorem Myhill_Nerode1:
70
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
   766
  assumes finite_CS: "finite (UNIV // \<approx>A)"
8ab3a06577cf slightly more on the paper
urbanc
parents: 66
diff changeset
   767
  shows   "\<exists>r::rexp. A = L r"
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   768
proof -
105
ae6ad1363eb9 updated paper
urbanc
parents: 104
diff changeset
   769
  have fin: "finite (finals A)" 
96
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   770
    using finals_in_partitions finite_CS by (rule finite_subset)
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   771
  have "\<forall>X \<in> (UNIV // \<approx>A). \<exists>r::rexp. X = L r" 
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   772
    using finite_CS every_eqcl_has_reg by blast
96
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   773
  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
   774
    using finals_in_partitions by auto
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   775
  then obtain rs::"rexp set" where "\<Union> (finals A) = \<Union>(L ` rs)" "finite rs"
105
ae6ad1363eb9 updated paper
urbanc
parents: 104
diff changeset
   776
    using fin by (auto dest: bchoice_finite_set)
96
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   777
  then have "A = L (\<Uplus>rs)" 
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   778
    unfolding lang_is_union_of_finals[symmetric] by simp
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   779
  then show "\<exists>r::rexp. A = L r" by blast
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   780
qed 
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   781
96
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   782
42
f809cb54de4e Trying to solve the confict
zhang
parents:
diff changeset
   783
end