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