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