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