Myhill.thy
author wu
Fri, 07 Jan 2011 14:25:23 +0000
changeset 29 c64241fa4dff
parent 28 cef2893f353b
child 30 f5db9e08effc
permissions -rw-r--r--
Beautifying of the Other Direction is finished.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
27
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
     1
theory MyhillNerode
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
     2
  imports "Main" "List_Prefix"
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
     3
begin
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
     4
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
     5
text {* sequential composition of languages *}
29
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
     6
definition Seq :: "string set \<Rightarrow> string set \<Rightarrow> string set" ("_ ;; _" [100,100] 100)
27
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
     7
where 
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
     8
  "L1 ;; L2 = {s1 @ s2 | s1 s2. s1 \<in> L1 \<and> s2 \<in> L2}"
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
     9
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    10
inductive_set
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    11
  Star :: "string set \<Rightarrow> string set" ("_\<star>" [101] 102)
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    12
  for L :: "string set"
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    13
where
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    14
  start[intro]: "[] \<in> L\<star>"
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    15
| step[intro]:  "\<lbrakk>s1 \<in> L; s2 \<in> L\<star>\<rbrakk> \<Longrightarrow> s1@s2 \<in> L\<star>" 
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    16
28
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
    17
lemma seq_union_distrib:
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
    18
  "(A \<union> B) ;; C = (A ;; C) \<union> (B ;; C)"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
    19
by (auto simp:Seq_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
    20
29
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
    21
lemma seq_intro:
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
    22
  "\<lbrakk>x \<in> A; y \<in> B\<rbrakk> \<Longrightarrow> x @ y \<in> A ;; B "
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
    23
by (auto simp:Seq_def)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
    24
28
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
    25
lemma seq_assoc:
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
    26
  "(A ;; B) ;; C = A ;; (B ;; C)"
29
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
    27
apply(auto simp:Seq_def)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
    28
apply blast
28
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
    29
by (metis append_assoc)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
    30
27
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    31
theorem ardens_revised:
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    32
  assumes nemp: "[] \<notin> A"
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    33
  shows "(X = X ;; A \<union> B) \<longleftrightarrow> (X = B ;; A\<star>)"
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    34
proof
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    35
  assume eq: "X = B ;; A\<star>"
29
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
    36
  have "A\<star> =  {[]} \<union> A\<star> ;; A" sorry 
27
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    37
  then have "B ;; A\<star> = B ;; ({[]} \<union> A\<star> ;; A)" unfolding Seq_def by simp
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    38
  also have "\<dots> = B \<union> B ;; (A\<star> ;; A)"  unfolding Seq_def by auto
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    39
  also have "\<dots> = B \<union> (B ;; A\<star>) ;; A"  unfolding Seq_def
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    40
    by (auto) (metis append_assoc)+
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    41
  finally show "X = X ;; A \<union> B" using eq by auto
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    42
next
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    43
  assume "X = X ;; A \<union> B"
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    44
  then have "B \<subseteq> X" "X ;; A \<subseteq> X" by auto
29
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
    45
  thus "X = B ;; A\<star>" sorry
27
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    46
qed
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    47
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    48
datatype rexp =
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    49
  NULL
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    50
| EMPTY
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    51
| CHAR char
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    52
| SEQ rexp rexp
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    53
| ALT rexp rexp
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    54
| STAR rexp
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    55
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    56
consts L:: "'a \<Rightarrow> string set"
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    57
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    58
overloading L_rexp \<equiv> "L::  rexp \<Rightarrow> string set"
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    59
begin
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    60
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    61
fun
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    62
  L_rexp :: "rexp \<Rightarrow> string set"
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    63
where
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    64
    "L_rexp (NULL) = {}"
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    65
  | "L_rexp (EMPTY) = {[]}"
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    66
  | "L_rexp (CHAR c) = {[c]}"
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    67
  | "L_rexp (SEQ r1 r2) = (L_rexp r1) ;; (L_rexp r2)"
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    68
  | "L_rexp (ALT r1 r2) = (L_rexp r1) \<union> (L_rexp r2)"
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    69
  | "L_rexp (STAR r) = (L_rexp r)\<star>"
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    70
end
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    71
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    72
definition 
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    73
  folds :: "('a \<Rightarrow> 'b \<Rightarrow> 'b) \<Rightarrow> 'b \<Rightarrow> 'a set \<Rightarrow> 'b"
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    74
where
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    75
  "folds f z S \<equiv> SOME x. fold_graph f z S x"
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    76
28
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
    77
lemma folds_alt_simp [simp]:
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
    78
  "finite rs \<Longrightarrow> L (folds ALT NULL rs) = \<Union> (L ` rs)"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
    79
apply (rule set_ext, simp add:folds_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
    80
apply (rule someI2_ex, erule finite_imp_fold_graph)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
    81
by (erule fold_graph.induct, auto)
27
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    82
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    83
lemma [simp]:
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    84
  shows "(x, y) \<in> {(x, y). P x y} \<longleftrightarrow> P x y"
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    85
by simp
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    86
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    87
definition
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    88
  str_eq ("_ \<approx>_ _")
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    89
where
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    90
  "x \<approx>Lang y \<equiv> (\<forall>z. x @ z \<in> Lang \<longleftrightarrow> y @ z \<in> Lang)"
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    91
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    92
definition
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    93
  str_eq_rel ("\<approx>_")
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    94
where
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    95
  "\<approx>Lang \<equiv> {(x, y). x \<approx>Lang y}"
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
    96
28
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
    97
definition
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
    98
  final :: "string set \<Rightarrow> string set \<Rightarrow> bool"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
    99
where
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   100
  "final X Lang \<equiv> (X \<in> UNIV // \<approx>Lang) \<and> (\<forall>s \<in> X. s \<in> Lang)"
27
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   101
28
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   102
lemma lang_is_union_of_finals: 
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   103
  "Lang = \<Union> {X. final X Lang}"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   104
proof 
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   105
  show "Lang \<subseteq> \<Union> {X. final X Lang}"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   106
  proof
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   107
    fix x
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   108
    assume "x \<in> Lang"   
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   109
    thus "x \<in> \<Union> {X. final X Lang}"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   110
      apply (simp, rule_tac x = "(\<approx>Lang) `` {x}" in exI)      
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   111
      apply (auto simp:final_def quotient_def Image_def str_eq_rel_def str_eq_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   112
      by (drule_tac x = "[]" in spec, simp)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   113
  qed
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   114
next
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   115
  show "\<Union>{X. final X Lang} \<subseteq> Lang"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   116
    by (auto simp:final_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   117
qed
27
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   118
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   119
section {* finite \<Rightarrow> regular *}
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   120
28
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   121
datatype rhs_item = 
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   122
   Lam "rexp"                           (* Lambda *)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   123
 | Trn "string set" "rexp"              (* Transition *)
27
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   124
28
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   125
fun the_Trn:: "rhs_item \<Rightarrow> (string set \<times> rexp)"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   126
where "the_Trn (Trn Y r) = (Y, r)"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   127
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   128
fun the_r :: "rhs_item \<Rightarrow> rexp"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   129
where "the_r (Lam r) = r"
27
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   130
28
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   131
overloading L_rhs_e \<equiv> "L:: rhs_item \<Rightarrow> string set"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   132
begin
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   133
fun L_rhs_e:: "rhs_item \<Rightarrow> string set"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   134
where
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   135
  "L_rhs_e (Lam r) = L r" |
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   136
  "L_rhs_e (Trn X r) = X ;; L r"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   137
end
27
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   138
28
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   139
overloading L_rhs \<equiv> "L:: rhs_item set \<Rightarrow> string set"
27
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   140
begin
28
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   141
fun L_rhs:: "rhs_item set \<Rightarrow> string set"
27
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   142
where
28
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   143
  "L_rhs rhs = \<Union> (L ` rhs)"
27
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   144
end
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   145
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   146
definition
28
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   147
  "init_rhs CS X \<equiv>  if ([] \<in> X)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   148
                    then {Lam EMPTY} \<union> {Trn Y (CHAR c)| Y c. Y \<in> CS \<and> Y ;; {[c]} \<subseteq> X}
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   149
                    else {Trn Y (CHAR c)| Y c. Y \<in> CS \<and> Y ;; {[c]} \<subseteq> X}"
27
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   150
28
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   151
definition
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   152
  "eqs CS \<equiv> {(X, init_rhs CS X)|X.  X \<in> CS}"
27
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   153
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   154
(************ arden's lemma variation ********************)
28
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   155
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   156
definition
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   157
  "items_of rhs X \<equiv> {Trn X r | r. (Trn X r) \<in> rhs}"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   158
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   159
definition
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   160
  "lam_of rhs \<equiv> {Lam r | r. Lam r \<in> rhs}"
27
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   161
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   162
definition 
28
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   163
  "rexp_of rhs X \<equiv> folds ALT NULL ((snd o the_Trn) ` items_of rhs X)"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   164
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   165
definition
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   166
  "rexp_of_lam rhs \<equiv> folds ALT NULL (the_r ` lam_of rhs)"
27
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   167
28
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   168
fun attach_rexp :: "rexp \<Rightarrow> rhs_item \<Rightarrow> rhs_item"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   169
where
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   170
  "attach_rexp r' (Lam r)   = Lam (SEQ r r')"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   171
| "attach_rexp r' (Trn X r) = Trn X (SEQ r r')"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   172
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   173
definition
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   174
  "append_rhs_rexp rhs r \<equiv> (attach_rexp r) ` rhs"
27
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   175
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   176
definition 
28
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   177
  "arden_variate X rhs \<equiv> append_rhs_rexp (rhs - items_of rhs X) (STAR (rexp_of rhs X))"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   178
27
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   179
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   180
(*********** substitution of ES *************)
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   181
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   182
text {* rhs_subst rhs X xrhs: substitude all occurence of X in rhs with xrhs *}
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   183
definition 
28
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   184
  "rhs_subst rhs X xrhs \<equiv> (rhs - (items_of rhs X)) \<union> (append_rhs_rexp xrhs (rexp_of rhs X))"
27
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   185
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   186
definition
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   187
  "eqs_subst ES X xrhs \<equiv> {(Y, rhs_subst yrhs X xrhs) | Y yrhs. (Y, yrhs) \<in> ES}"
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   188
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   189
text {*
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   190
  Inv: Invairance of the equation-system, during the decrease of the equation-system, Inv holds.
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   191
*}
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   192
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   193
definition 
28
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   194
  "distinct_equas ES \<equiv> \<forall> X rhs rhs'. (X, rhs) \<in> ES \<and> (X, rhs') \<in> ES \<longrightarrow> rhs = rhs'"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   195
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   196
definition 
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   197
  "valid_eqns ES \<equiv> \<forall> X rhs. (X, rhs) \<in> ES \<longrightarrow> (X = L rhs)"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   198
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   199
definition 
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   200
  "rhs_nonempty rhs \<equiv> (\<forall> Y r. Trn Y r \<in> rhs \<longrightarrow> [] \<notin> L r)"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   201
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   202
definition 
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   203
  "ardenable ES \<equiv> \<forall> X rhs. (X, rhs) \<in> ES \<longrightarrow> rhs_nonempty rhs"
27
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   204
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   205
definition 
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   206
  "non_empty ES \<equiv> \<forall> X rhs. (X, rhs) \<in> ES \<longrightarrow> X \<noteq> {}"
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   207
28
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   208
definition
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   209
  "finite_rhs ES \<equiv> \<forall> X rhs. (X, rhs) \<in> ES \<longrightarrow> finite rhs"
27
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   210
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   211
definition 
28
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   212
  "classes_of rhs \<equiv> {X. \<exists> r. Trn X r \<in> rhs}"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   213
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   214
definition
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   215
  "lefts_of ES \<equiv> {Y | Y yrhs. (Y, yrhs) \<in> ES}"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   216
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   217
definition 
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   218
  "self_contained ES \<equiv> \<forall> (X, xrhs) \<in> ES. classes_of xrhs \<subseteq> lefts_of ES"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   219
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   220
definition 
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   221
  "Inv ES \<equiv> valid_eqns ES \<and> finite ES \<and> distinct_equas ES \<and> ardenable ES \<and> 
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   222
            non_empty ES \<and> finite_rhs ES \<and> self_contained ES"
27
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   223
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   224
lemma wf_iter [rule_format]: 
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   225
  fixes f
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   226
  assumes step: "\<And> e. \<lbrakk>P e; \<not> Q e\<rbrakk> \<Longrightarrow> (\<exists> e'. P e' \<and>  (f(e'), f(e)) \<in> less_than)"
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   227
  shows pe:     "P e \<longrightarrow> (\<exists> e'. P e' \<and>  Q e')"
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   228
proof(induct e rule: wf_induct 
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   229
           [OF wf_inv_image[OF wf_less_than, where f = "f"]], clarify)
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   230
  fix x 
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   231
  assume h [rule_format]: 
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   232
    "\<forall>y. (y, x) \<in> inv_image less_than f \<longrightarrow> P y \<longrightarrow> (\<exists>e'. P e' \<and> Q e')"
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   233
    and px: "P x"
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   234
  show "\<exists>e'. P e' \<and> Q e'"
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   235
  proof(cases "Q x")
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   236
    assume "Q x" with px show ?thesis by blast
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   237
  next
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   238
    assume nq: "\<not> Q x"
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   239
    from step [OF px nq]
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   240
    obtain e' where pe': "P e'" and ltf: "(f e', f x) \<in> less_than" by auto
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   241
    show ?thesis
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   242
    proof(rule h)
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   243
      from ltf show "(e', x) \<in> inv_image less_than f" 
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   244
	by (simp add:inv_image_def)
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   245
    next
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   246
      from pe' show "P e'" .
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   247
    qed
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   248
  qed
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   249
qed
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   250
28
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   251
text {* ************* basic properties of definitions above ************************ *}
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   252
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   253
lemma L_rhs_union_distrib:
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   254
  " L (A::rhs_item set) \<union> L B = L (A \<union> B)"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   255
by simp
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   256
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   257
lemma finite_snd_Trn:
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   258
  assumes finite:"finite rhs"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   259
  shows "finite {r\<^isub>2. Trn Y r\<^isub>2 \<in> rhs}" (is "finite ?B")
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   260
proof-
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   261
  def rhs' \<equiv> "{e \<in> rhs. \<exists> r. e = Trn Y r}"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   262
  have "?B = (snd o the_Trn) ` rhs'" using rhs'_def by (auto simp:image_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   263
  moreover have "finite rhs'" using finite rhs'_def by auto
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   264
  ultimately show ?thesis by simp
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   265
qed
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   266
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   267
lemma rexp_of_empty:
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   268
  assumes finite:"finite rhs"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   269
  and nonempty:"rhs_nonempty rhs"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   270
  shows "[] \<notin> L (rexp_of rhs X)"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   271
using finite nonempty rhs_nonempty_def
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   272
by (drule_tac finite_snd_Trn[where Y = X], auto simp:rexp_of_def items_of_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   273
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   274
lemma [intro!]:
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   275
  "P (Trn X r) \<Longrightarrow> (\<exists>a. (\<exists>r. a = Trn X r \<and> P a))" by auto
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   276
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   277
lemma finite_items_of:
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   278
  "finite rhs \<Longrightarrow> finite (items_of rhs X)"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   279
by (auto simp:items_of_def intro:finite_subset)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   280
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   281
lemma lang_of_rexp_of:
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   282
  assumes finite:"finite rhs"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   283
  shows "L (items_of rhs X) = X ;; (L (rexp_of rhs X))"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   284
proof -
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   285
  have "finite ((snd \<circ> the_Trn) ` items_of rhs X)" using finite_items_of[OF finite] by auto
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   286
  thus ?thesis
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   287
    apply (auto simp:rexp_of_def Seq_def items_of_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   288
    apply (rule_tac x = s1 in exI, rule_tac x = s2 in exI, auto)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   289
    by (rule_tac x= "Trn X r" in exI, auto simp:Seq_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   290
qed
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   291
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   292
lemma rexp_of_lam_eq_lam_set:
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   293
  assumes finite: "finite rhs"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   294
  shows "L (rexp_of_lam rhs) = L (lam_of rhs)"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   295
proof -
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   296
  have "finite (the_r ` {Lam r |r. Lam r \<in> rhs})" using finite
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   297
    by (rule_tac finite_imageI, auto intro:finite_subset)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   298
  thus ?thesis by (auto simp:rexp_of_lam_def lam_of_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   299
qed
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   300
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   301
lemma [simp]:
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   302
  " L (attach_rexp r xb) = L xb ;; L r"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   303
apply (cases xb, auto simp:Seq_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   304
by (rule_tac x = "s1 @ s1a" in exI, rule_tac x = s2a in exI,auto simp:Seq_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   305
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   306
lemma lang_of_append_rhs:
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   307
  "L (append_rhs_rexp rhs r) = L rhs ;; L r"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   308
apply (auto simp:append_rhs_rexp_def image_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   309
apply (auto simp:Seq_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   310
apply (rule_tac x = "L xb ;; L r" in exI, auto simp add:Seq_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   311
by (rule_tac x = "attach_rexp r xb" in exI, auto simp:Seq_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   312
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   313
lemma classes_of_union_distrib:
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   314
  "classes_of A \<union> classes_of B = classes_of (A \<union> B)"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   315
by (auto simp add:classes_of_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   316
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   317
lemma lefts_of_union_distrib:
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   318
  "lefts_of A \<union> lefts_of B = lefts_of (A \<union> B)"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   319
by (auto simp:lefts_of_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   320
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   321
27
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   322
text {* ******BEGIN: proving the initial equation-system satisfies Inv ****** *}
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   323
28
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   324
lemma defined_by_str:
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   325
  "\<lbrakk>s \<in> X; X \<in> UNIV // (\<approx>Lang)\<rbrakk> \<Longrightarrow> X = (\<approx>Lang) `` {s}"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   326
by (auto simp:quotient_def Image_def str_eq_rel_def str_eq_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   327
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   328
lemma every_eqclass_has_transition:
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   329
  assumes has_str: "s @ [c] \<in> X"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   330
  and     in_CS:   "X \<in> UNIV // (\<approx>Lang)"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   331
  obtains Y where "Y \<in> UNIV // (\<approx>Lang)" and "Y ;; {[c]} \<subseteq> X" and "s \<in> Y"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   332
proof -
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   333
  def Y \<equiv> "(\<approx>Lang) `` {s}"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   334
  have "Y \<in> UNIV // (\<approx>Lang)" 
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   335
    unfolding Y_def quotient_def by auto
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   336
  moreover
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   337
  have "X = (\<approx>Lang) `` {s @ [c]}" 
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   338
    using has_str in_CS defined_by_str by blast
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   339
  then have "Y ;; {[c]} \<subseteq> X" 
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   340
    unfolding Y_def Image_def Seq_def
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   341
    unfolding str_eq_rel_def
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   342
    by (auto) (simp add: str_eq_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   343
  moreover
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   344
  have "s \<in> Y" unfolding Y_def 
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   345
    unfolding Image_def str_eq_rel_def str_eq_def by simp
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   346
  ultimately show thesis by (blast intro: that)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   347
qed
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   348
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   349
lemma l_eq_r_in_eqs:
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   350
  assumes X_in_eqs: "(X, xrhs) \<in> (eqs (UNIV // (\<approx>Lang)))"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   351
  shows "X = L xrhs"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   352
proof 
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   353
  show "X \<subseteq> L xrhs"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   354
  proof
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   355
    fix x
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   356
    assume "(1)": "x \<in> X"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   357
    show "x \<in> L xrhs"          
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   358
    proof (cases "x = []")
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   359
      assume empty: "x = []"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   360
      thus ?thesis using X_in_eqs "(1)"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   361
        by (auto simp:eqs_def init_rhs_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   362
    next
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   363
      assume not_empty: "x \<noteq> []"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   364
      then obtain clist c where decom: "x = clist @ [c]"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   365
        by (case_tac x rule:rev_cases, auto)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   366
      have "X \<in> UNIV // (\<approx>Lang)" using X_in_eqs by (auto simp:eqs_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   367
      then obtain Y 
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   368
        where "Y \<in> UNIV // (\<approx>Lang)" 
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   369
        and "Y ;; {[c]} \<subseteq> X"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   370
        and "clist \<in> Y"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   371
        using decom "(1)" every_eqclass_has_transition by blast
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   372
      hence "x \<in> L {Trn Y (CHAR c)| Y c. Y \<in> UNIV // (\<approx>Lang) \<and> Y ;; {[c]} \<subseteq> X}"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   373
        using "(1)" decom
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   374
        by (simp, rule_tac x = "Trn Y (CHAR c)" in exI, simp add:Seq_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   375
      thus ?thesis using X_in_eqs "(1)"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   376
        by (simp add:eqs_def init_rhs_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   377
    qed
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   378
  qed
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   379
next
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   380
  show "L xrhs \<subseteq> X" using X_in_eqs
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   381
    by (auto simp:eqs_def init_rhs_def) 
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   382
qed
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   383
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   384
lemma finite_init_rhs: 
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   385
  assumes finite: "finite CS"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   386
  shows "finite (init_rhs CS X)"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   387
proof-
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   388
  have "finite {Trn Y (CHAR c) |Y c. Y \<in> CS \<and> Y ;; {[c]} \<subseteq> X}" (is "finite ?A")
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   389
  proof -
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   390
    def S \<equiv> "{(Y, c)| Y c. Y \<in> CS \<and> Y ;; {[c]} \<subseteq> X}" 
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   391
    def h \<equiv> "\<lambda> (Y, c). Trn Y (CHAR c)"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   392
    have "finite (CS \<times> (UNIV::char set))" using finite by auto
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   393
    hence "finite S" using S_def 
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   394
      by (rule_tac B = "CS \<times> UNIV" in finite_subset, auto)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   395
    moreover have "?A = h ` S" by (auto simp: S_def h_def image_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   396
    ultimately show ?thesis 
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   397
      by auto
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   398
  qed
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   399
  thus ?thesis by (simp add:init_rhs_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   400
qed
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   401
27
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   402
lemma init_ES_satisfy_Inv:
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   403
  assumes finite_CS: "finite (UNIV // (\<approx>Lang))"
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   404
  shows "Inv (eqs (UNIV // (\<approx>Lang)))"
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   405
proof -
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   406
  have "finite (eqs (UNIV // (\<approx>Lang)))" using finite_CS
28
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   407
    by (simp add:eqs_def)
27
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   408
  moreover have "distinct_equas (eqs (UNIV // (\<approx>Lang)))"     
28
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   409
    by (simp add:distinct_equas_def eqs_def)
27
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   410
  moreover have "ardenable (eqs (UNIV // (\<approx>Lang)))"
28
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   411
    by (auto simp add:ardenable_def eqs_def init_rhs_def rhs_nonempty_def del:L_rhs.simps)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   412
  moreover have "valid_eqns (eqs (UNIV // (\<approx>Lang)))"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   413
    using l_eq_r_in_eqs by (simp add:valid_eqns_def)
27
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   414
  moreover have "non_empty (eqs (UNIV // (\<approx>Lang)))"
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   415
    by (auto simp:non_empty_def eqs_def quotient_def Image_def str_eq_rel_def str_eq_def)
28
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   416
  moreover have "finite_rhs (eqs (UNIV // (\<approx>Lang)))"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   417
    using finite_init_rhs[OF finite_CS] 
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   418
    by (auto simp:finite_rhs_def eqs_def)
27
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   419
  moreover have "self_contained (eqs (UNIV // (\<approx>Lang)))"
28
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   420
    by (auto simp:self_contained_def eqs_def init_rhs_def classes_of_def lefts_of_def)
27
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   421
  ultimately show ?thesis by (simp add:Inv_def)
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   422
qed
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   423
28
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   424
text {* ****** BEGIN: proving every equation-system's iteration step satisfies Inv ***** *}
27
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   425
28
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   426
lemma arden_variate_keeps_eq:
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   427
  assumes l_eq_r: "X = L rhs"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   428
  and not_empty: "[] \<notin> L (rexp_of rhs X)"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   429
  and finite: "finite rhs"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   430
  shows "X = L (arden_variate X rhs)"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   431
proof -
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   432
  def A \<equiv> "L (rexp_of rhs X)"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   433
  def b \<equiv> "rhs - items_of rhs X"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   434
  def B \<equiv> "L b" 
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   435
  have "X = B ;; A\<star>"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   436
  proof-
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   437
    have "rhs = items_of rhs X \<union> b" by (auto simp:b_def items_of_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   438
    hence "L rhs = L(items_of rhs X \<union> b)" by simp
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   439
    hence "L rhs = L(items_of rhs X) \<union> B" by (simp only:L_rhs_union_distrib B_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   440
    with lang_of_rexp_of
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   441
    have "L rhs = X ;; A \<union> B " using finite by (simp only:B_def b_def A_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   442
    thus ?thesis
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   443
      using l_eq_r not_empty
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   444
      apply (drule_tac B = B and X = X in ardens_revised)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   445
      by (auto simp:A_def simp del:L_rhs.simps)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   446
  qed
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   447
  moreover have "L (arden_variate X rhs) = (B ;; A\<star>)" (is "?L = ?R")
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   448
    by (simp only:arden_variate_def L_rhs_union_distrib lang_of_append_rhs 
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   449
                  B_def A_def b_def L_rexp.simps seq_union_distrib)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   450
   ultimately show ?thesis by simp
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   451
qed 
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   452
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   453
lemma append_keeps_finite:
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   454
  "finite rhs \<Longrightarrow> finite (append_rhs_rexp rhs r)"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   455
by (auto simp:append_rhs_rexp_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   456
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   457
lemma arden_variate_keeps_finite:
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   458
  "finite rhs \<Longrightarrow> finite (arden_variate X rhs)"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   459
by (auto simp:arden_variate_def append_keeps_finite)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   460
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   461
lemma append_keeps_nonempty:
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   462
  "rhs_nonempty rhs \<Longrightarrow> rhs_nonempty (append_rhs_rexp rhs r)"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   463
apply (auto simp:rhs_nonempty_def append_rhs_rexp_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   464
by (case_tac x, auto simp:Seq_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   465
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   466
lemma nonempty_set_sub:
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   467
  "rhs_nonempty rhs \<Longrightarrow> rhs_nonempty (rhs - A)"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   468
by (auto simp:rhs_nonempty_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   469
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   470
lemma nonempty_set_union:
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   471
  "\<lbrakk>rhs_nonempty rhs; rhs_nonempty rhs'\<rbrakk> \<Longrightarrow> rhs_nonempty (rhs \<union> rhs')"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   472
by (auto simp:rhs_nonempty_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   473
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   474
lemma arden_variate_keeps_nonempty:
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   475
  "rhs_nonempty rhs \<Longrightarrow> rhs_nonempty (arden_variate X rhs)"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   476
by (simp only:arden_variate_def append_keeps_nonempty nonempty_set_sub)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   477
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   478
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   479
lemma rhs_subst_keeps_nonempty:
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   480
  "\<lbrakk>rhs_nonempty rhs; rhs_nonempty xrhs\<rbrakk> \<Longrightarrow> rhs_nonempty (rhs_subst rhs X xrhs)"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   481
by (simp only:rhs_subst_def append_keeps_nonempty  nonempty_set_union nonempty_set_sub)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   482
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   483
lemma rhs_subst_keeps_eq:
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   484
  assumes substor: "X = L xrhs"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   485
  and finite: "finite rhs"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   486
  shows "L (rhs_subst rhs X xrhs) = L rhs" (is "?Left = ?Right")
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   487
proof-
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   488
  def A \<equiv> "L (rhs - items_of rhs X)"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   489
  have "?Left = A \<union> L (append_rhs_rexp xrhs (rexp_of rhs X))"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   490
    by (simp only:rhs_subst_def L_rhs_union_distrib A_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   491
  moreover have "?Right = A \<union> L (items_of rhs X)"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   492
  proof-
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   493
    have "rhs = (rhs - items_of rhs X) \<union> (items_of rhs X)" by (auto simp:items_of_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   494
    thus ?thesis by (simp only:L_rhs_union_distrib A_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   495
  qed
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   496
  moreover have "L (append_rhs_rexp xrhs (rexp_of rhs X)) = L (items_of rhs X)" 
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   497
    using finite substor  by (simp only:lang_of_append_rhs lang_of_rexp_of)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   498
  ultimately show ?thesis by simp
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   499
qed
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   500
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   501
lemma rhs_subst_keeps_finite_rhs:
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   502
  "\<lbrakk>finite rhs; finite yrhs\<rbrakk> \<Longrightarrow> finite (rhs_subst rhs Y yrhs)"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   503
by (auto simp:rhs_subst_def append_keeps_finite)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   504
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   505
lemma eqs_subst_keeps_finite:
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   506
  assumes finite:"finite (ES:: (string set \<times> rhs_item set) set)"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   507
  shows "finite (eqs_subst ES Y yrhs)"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   508
proof -
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   509
  have "finite {(Ya, rhs_subst yrhsa Y yrhs) |Ya yrhsa. (Ya, yrhsa) \<in> ES}" (is "finite ?A")
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   510
  proof-
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   511
    def eqns' \<equiv> "{((Ya::string set), yrhsa)| Ya yrhsa. (Ya, yrhsa) \<in> ES}"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   512
    def h \<equiv> "\<lambda> ((Ya::string set), yrhsa). (Ya, rhs_subst yrhsa Y yrhs)"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   513
    have "finite (h ` eqns')" using finite h_def eqns'_def by auto
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   514
    moreover have "?A = h ` eqns'" by (auto simp:h_def eqns'_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   515
    ultimately show ?thesis by auto      
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   516
  qed
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   517
  thus ?thesis by (simp add:eqs_subst_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   518
qed
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   519
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   520
lemma eqs_subst_keeps_finite_rhs:
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   521
  "\<lbrakk>finite_rhs ES; finite yrhs\<rbrakk> \<Longrightarrow> finite_rhs (eqs_subst ES Y yrhs)"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   522
by (auto intro:rhs_subst_keeps_finite_rhs simp add:eqs_subst_def finite_rhs_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   523
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   524
lemma append_rhs_keeps_cls:
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   525
  "classes_of (append_rhs_rexp rhs r) = classes_of rhs"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   526
apply (auto simp:classes_of_def append_rhs_rexp_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   527
apply (case_tac xa, auto simp:image_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   528
by (rule_tac x = "SEQ ra r" in exI, rule_tac x = "Trn x ra" in bexI, simp+)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   529
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   530
lemma arden_variate_removes_cl:
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   531
  "classes_of (arden_variate Y yrhs) = classes_of yrhs - {Y}"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   532
apply (simp add:arden_variate_def append_rhs_keeps_cls items_of_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   533
by (auto simp:classes_of_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   534
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   535
lemma lefts_of_keeps_cls:
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   536
  "lefts_of (eqs_subst ES Y yrhs) = lefts_of ES"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   537
by (auto simp:lefts_of_def eqs_subst_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   538
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   539
lemma rhs_subst_updates_cls:
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   540
  "X \<notin> classes_of xrhs \<Longrightarrow> classes_of (rhs_subst rhs X xrhs) = classes_of rhs \<union> classes_of xrhs - {X}"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   541
apply (simp only:rhs_subst_def append_rhs_keeps_cls classes_of_union_distrib[THEN sym])
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   542
by (auto simp:classes_of_def items_of_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   543
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   544
lemma eqs_subst_keeps_self_contained:
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   545
  fixes Y
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   546
  assumes sc: "self_contained (ES \<union> {(Y, yrhs)})" (is "self_contained ?A")
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   547
  shows "self_contained (eqs_subst ES Y (arden_variate Y yrhs))" (is "self_contained ?B")
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   548
proof-
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   549
  { fix X xrhs'
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   550
    assume "(X, xrhs') \<in> ?B"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   551
    then obtain xrhs 
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   552
      where xrhs_xrhs': "xrhs' = rhs_subst xrhs Y (arden_variate Y yrhs)"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   553
      and X_in: "(X, xrhs) \<in> ES" by (simp add:eqs_subst_def, blast)    
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   554
    have "classes_of xrhs' \<subseteq> lefts_of ?B"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   555
    proof-
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   556
      have "lefts_of ?B = lefts_of ES" by (auto simp add:lefts_of_def eqs_subst_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   557
      moreover have "classes_of xrhs' \<subseteq> lefts_of ES"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   558
      proof-
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   559
        have "classes_of xrhs' \<subseteq> classes_of xrhs \<union> classes_of (arden_variate Y yrhs) - {Y}"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   560
        proof-
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   561
          have "Y \<notin> classes_of (arden_variate Y yrhs)" using arden_variate_removes_cl by simp
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   562
          thus ?thesis using xrhs_xrhs' by (auto simp:rhs_subst_updates_cls)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   563
        qed
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   564
        moreover have "classes_of xrhs \<subseteq> lefts_of ES \<union> {Y}" using X_in sc
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   565
          apply (simp only:self_contained_def lefts_of_union_distrib[THEN sym])
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   566
          by (drule_tac x = "(X, xrhs)" in bspec, auto simp:lefts_of_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   567
        moreover have "classes_of (arden_variate Y yrhs) \<subseteq> lefts_of ES \<union> {Y}" using sc
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   568
          by (auto simp add:arden_variate_removes_cl self_contained_def lefts_of_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   569
        ultimately show ?thesis by auto
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   570
      qed
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   571
      ultimately show ?thesis by simp
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   572
    qed
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   573
  } thus ?thesis by (auto simp only:eqs_subst_def self_contained_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   574
qed
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   575
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   576
lemma eqs_subst_satisfy_Inv:
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   577
  assumes Inv_ES: "Inv (ES \<union> {(Y, yrhs)})"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   578
  shows "Inv (eqs_subst ES Y (arden_variate Y yrhs))"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   579
proof -  
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   580
  have finite_yrhs: "finite yrhs" using Inv_ES by (auto simp:Inv_def finite_rhs_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   581
  have nonempty_yrhs: "rhs_nonempty yrhs" using Inv_ES by (auto simp:Inv_def ardenable_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   582
  have Y_eq_yrhs: "Y = L yrhs" using Inv_ES by (simp only:Inv_def valid_eqns_def, blast)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   583
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   584
  have "distinct_equas (eqs_subst ES Y (arden_variate Y yrhs))" using Inv_ES
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   585
    by (auto simp:distinct_equas_def eqs_subst_def Inv_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   586
  moreover have "finite (eqs_subst ES Y (arden_variate Y yrhs))" using Inv_ES 
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   587
    by (simp add:Inv_def eqs_subst_keeps_finite)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   588
  moreover have "finite_rhs (eqs_subst ES Y (arden_variate Y yrhs))"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   589
  proof-
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   590
    have "finite_rhs ES" using Inv_ES by (simp add:Inv_def finite_rhs_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   591
    moreover have "finite (arden_variate Y yrhs)"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   592
    proof -
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   593
      have "finite yrhs" using Inv_ES by (auto simp:Inv_def finite_rhs_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   594
      thus ?thesis using arden_variate_keeps_finite by simp
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   595
    qed
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   596
    ultimately show ?thesis by (simp add:eqs_subst_keeps_finite_rhs)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   597
  qed
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   598
  moreover have "ardenable (eqs_subst ES Y (arden_variate Y yrhs))"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   599
  proof - 
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   600
    { fix X rhs
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   601
      assume "(X, rhs) \<in> ES"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   602
      hence "rhs_nonempty rhs"  using prems Inv_ES  by (simp add:Inv_def ardenable_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   603
      with nonempty_yrhs have "rhs_nonempty (rhs_subst rhs Y (arden_variate Y yrhs))"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   604
        by (simp add:nonempty_yrhs rhs_subst_keeps_nonempty arden_variate_keeps_nonempty)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   605
    } thus ?thesis by (auto simp add:ardenable_def eqs_subst_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   606
  qed
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   607
  moreover have "valid_eqns (eqs_subst ES Y (arden_variate Y yrhs))"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   608
  proof-
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   609
    have "Y = L (arden_variate Y yrhs)" using Y_eq_yrhs Inv_ES finite_yrhs nonempty_yrhs      
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   610
        by (rule_tac arden_variate_keeps_eq, (simp add:rexp_of_empty)+)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   611
    thus ?thesis using Inv_ES 
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   612
      by (clarsimp simp add:valid_eqns_def eqs_subst_def rhs_subst_keeps_eq Inv_def finite_rhs_def
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   613
                   simp del:L_rhs.simps)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   614
  qed
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   615
  moreover have non_empty_subst: "non_empty (eqs_subst ES Y (arden_variate Y yrhs))"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   616
    using Inv_ES by (auto simp:Inv_def non_empty_def eqs_subst_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   617
  moreover have self_subst: "self_contained (eqs_subst ES Y (arden_variate Y yrhs))"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   618
    using Inv_ES eqs_subst_keeps_self_contained by (simp add:Inv_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   619
  ultimately show ?thesis using Inv_ES by (simp add:Inv_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   620
qed
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   621
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   622
lemma eqs_subst_card_le: 
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   623
  assumes finite: "finite (ES::(string set \<times> rhs_item set) set)"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   624
  shows "card (eqs_subst ES Y yrhs) <= card ES"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   625
proof-
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   626
  def f \<equiv> "\<lambda> x. ((fst x)::string set, rhs_subst (snd x) Y yrhs)"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   627
  have "eqs_subst ES Y yrhs = f ` ES" 
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   628
    apply (auto simp:eqs_subst_def f_def image_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   629
    by (rule_tac x = "(Ya, yrhsa)" in bexI, simp+)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   630
  thus ?thesis using finite by (auto intro:card_image_le)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   631
qed
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   632
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   633
lemma eqs_subst_cls_remains: 
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   634
  "(X, xrhs) \<in> ES \<Longrightarrow> \<exists> xrhs'. (X, xrhs') \<in> (eqs_subst ES Y yrhs)"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   635
by (auto simp:eqs_subst_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   636
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   637
lemma card_noteq_1_has_more:
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   638
  assumes card:"card S \<noteq> 1"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   639
  and e_in: "e \<in> S"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   640
  and finite: "finite S"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   641
  obtains e' where "e' \<in> S \<and> e \<noteq> e'" 
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   642
proof-
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   643
  have "card (S - {e}) > 0"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   644
  proof -
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   645
    have "card S > 1" using card e_in finite  by (case_tac "card S", auto) 
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   646
    thus ?thesis using finite e_in by auto
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   647
  qed
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   648
  hence "S - {e} \<noteq> {}" using finite by (rule_tac notI, simp)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   649
  thus "(\<And>e'. e' \<in> S \<and> e \<noteq> e' \<Longrightarrow> thesis) \<Longrightarrow> thesis" by auto
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   650
qed
27
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   651
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   652
lemma iteration_step: 
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   653
  assumes Inv_ES: "Inv ES"
28
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   654
  and    X_in_ES: "(X, xrhs) \<in> ES"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   655
  and    not_T: "card ES \<noteq> 1"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   656
  shows "\<exists> ES'. (Inv ES' \<and> (\<exists> xrhs'.(X, xrhs') \<in> ES')) \<and> (card ES', card ES) \<in> less_than" (is "\<exists> ES'. ?P ES'")
27
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   657
proof -
28
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   658
  have finite_ES: "finite ES" using Inv_ES by (simp add:Inv_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   659
  then obtain Y yrhs where Y_in_ES: "(Y, yrhs) \<in> ES" and not_eq: "(X, xrhs) \<noteq> (Y, yrhs)" 
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   660
    using not_T X_in_ES by (drule_tac card_noteq_1_has_more, auto)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   661
  def ES' == "ES - {(Y, yrhs)}"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   662
  let ?ES'' = "eqs_subst ES' Y (arden_variate Y yrhs)"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   663
  have "?P ?ES''"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   664
  proof -
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   665
    have "Inv ?ES''" using Y_in_ES Inv_ES
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   666
      by (rule_tac eqs_subst_satisfy_Inv, simp add:ES'_def insert_absorb)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   667
    moreover have "\<exists>xrhs'. (X, xrhs') \<in> ?ES''"  using not_eq X_in_ES
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   668
      by (rule_tac ES = ES' in eqs_subst_cls_remains, auto simp add:ES'_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   669
    moreover have "(card ?ES'', card ES) \<in> less_than" 
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   670
    proof -
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   671
      have "finite ES'" using finite_ES ES'_def by auto
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   672
      moreover have "card ES' < card ES" using finite_ES Y_in_ES
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   673
        by (auto simp:ES'_def card_gt_0_iff intro:diff_Suc_less)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   674
      ultimately show ?thesis 
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   675
        by (auto dest:eqs_subst_card_le elim:le_less_trans)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   676
    qed
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   677
    ultimately show ?thesis by simp
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   678
  qed
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   679
  thus ?thesis by blast
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   680
qed
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   681
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   682
text {* ***** END: proving every equation-system's iteration step satisfies Inv ************** *}
27
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   683
28
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   684
lemma iteration_conc: 
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   685
  assumes history: "Inv ES"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   686
  and    X_in_ES: "\<exists> xrhs. (X, xrhs) \<in> ES"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   687
  shows "\<exists> ES'. (Inv ES' \<and> (\<exists> xrhs'. (X, xrhs') \<in> ES')) \<and> card ES' = 1" (is "\<exists> ES'. ?P ES'")
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   688
proof (cases "card ES = 1")
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   689
  case True
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   690
  thus ?thesis using history X_in_ES
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   691
    by blast
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   692
next
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   693
  case False  
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   694
  thus ?thesis using history iteration_step X_in_ES
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   695
    by (rule_tac f = card in wf_iter, auto)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   696
qed
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   697
  
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   698
lemma last_cl_exists_rexp:
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   699
  assumes ES_single: "ES = {(X, xrhs)}" 
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   700
  and Inv_ES: "Inv ES"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   701
  shows "\<exists> (r::rexp). L r = X" (is "\<exists> r. ?P r")
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   702
proof-
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   703
  let ?A = "arden_variate X xrhs"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   704
  have "?P (rexp_of_lam ?A)"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   705
  proof -
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   706
    have "L (rexp_of_lam ?A) = L (lam_of ?A)"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   707
    proof(rule rexp_of_lam_eq_lam_set)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   708
      show "finite (arden_variate X xrhs)" using Inv_ES ES_single 
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   709
        by (rule_tac arden_variate_keeps_finite, auto simp add:Inv_def finite_rhs_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   710
    qed
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   711
    also have "\<dots> = L ?A"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   712
    proof-
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   713
      have "lam_of ?A = ?A"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   714
      proof-
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   715
        have "classes_of ?A = {}" using Inv_ES ES_single
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   716
          by (simp add:arden_variate_removes_cl self_contained_def Inv_def lefts_of_def) 
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   717
        thus ?thesis by (auto simp only:lam_of_def classes_of_def, case_tac x, auto)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   718
      qed
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   719
      thus ?thesis by simp
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   720
    qed
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   721
    also have "\<dots> = X"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   722
    proof(rule arden_variate_keeps_eq [THEN sym])
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   723
      show "X = L xrhs" using Inv_ES ES_single by (auto simp only:Inv_def valid_eqns_def)  
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   724
    next
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   725
      from Inv_ES ES_single show "[] \<notin> L (rexp_of xrhs X)"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   726
        by(simp add:Inv_def ardenable_def rexp_of_empty finite_rhs_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   727
    next
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   728
      from Inv_ES ES_single show "finite xrhs" by (simp add:Inv_def finite_rhs_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   729
    qed
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   730
    finally show ?thesis by simp
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   731
  qed
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   732
  thus ?thesis by auto
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   733
qed
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   734
   
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   735
lemma every_eqcl_has_reg: 
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   736
  assumes finite_CS: "finite (UNIV // (\<approx>Lang))"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   737
  and X_in_CS: "X \<in> (UNIV // (\<approx>Lang))"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   738
  shows "\<exists> (reg::rexp). L reg = X" (is "\<exists> r. ?E r")
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   739
proof -
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   740
  from X_in_CS have "\<exists> xrhs. (X, xrhs) \<in> (eqs (UNIV  // (\<approx>Lang)))"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   741
    by (auto simp:eqs_def init_rhs_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   742
  then obtain ES xrhs where Inv_ES: "Inv ES" 
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   743
    and X_in_ES: "(X, xrhs) \<in> ES"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   744
    and card_ES: "card ES = 1"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   745
    using finite_CS X_in_CS init_ES_satisfy_Inv iteration_conc
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   746
    by blast
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   747
  hence ES_single_equa: "ES = {(X, xrhs)}" 
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   748
    by (auto simp:Inv_def dest!:card_Suc_Diff1 simp:card_eq_0_iff) 
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   749
  thus ?thesis using Inv_ES
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   750
    by (rule last_cl_exists_rexp)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   751
qed
27
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   752
28
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   753
theorem hard_direction: 
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   754
  assumes finite_CS: "finite (UNIV // (\<approx>Lang))"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   755
  shows   "\<exists> (reg::rexp). Lang = L reg"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   756
proof -
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   757
  have "\<forall> X \<in> (UNIV // (\<approx>Lang)). \<exists> (reg::rexp). X = L reg" 
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   758
    using finite_CS every_eqcl_has_reg by blast
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   759
  then obtain f where f_prop: "\<forall> X \<in> (UNIV // (\<approx>Lang)). X = L ((f X)::rexp)" 
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   760
    by (auto dest:bchoice)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   761
  def rs \<equiv> "f ` {X. final X Lang}"  
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   762
  have "Lang = \<Union> {X. final X Lang}" using lang_is_union_of_finals by simp
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   763
  also have "\<dots> = L (folds ALT NULL rs)" 
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   764
  proof -
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   765
    have "finite {X. final X Lang}" using finite_CS by (auto simp:final_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   766
    thus ?thesis  using f_prop by (auto simp:rs_def final_def)
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   767
  qed
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   768
  finally show ?thesis by blast
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   769
qed 
27
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   770
28
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   771
section {* regular \<Rightarrow> finite*}
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   772
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   773
lemma quot_empty_subset:
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   774
  "UNIV // (\<approx>{[]}) \<subseteq> {{[]}, UNIV - {[]}}"
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   775
proof
cef2893f353b Rewritten of hard direction once more. To make it looking better.
wu
parents: 27
diff changeset
   776
  fix x
29
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   777
  assume "x \<in> UNIV // \<approx>{[]}"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   778
  then obtain y where h: "x = {z. (y, z) \<in> \<approx>{[]}}" unfolding quotient_def Image_def by blast
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   779
  show "x \<in> {{[]}, UNIV - {[]}}" 
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   780
  proof (cases "y = []")
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   781
    case True with h
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   782
    have "x = {[]}" by (auto simp:str_eq_rel_def str_eq_def)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   783
    thus ?thesis by simp
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   784
  next
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   785
    case False with h
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   786
    have "x = UNIV - {[]}" by (auto simp:str_eq_rel_def str_eq_def)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   787
    thus ?thesis by simp
27
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   788
  qed
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   789
qed
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   790
29
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   791
lemma quot_char_subset:
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   792
  "UNIV // (\<approx>{[c]}) \<subseteq> {{[]},{[c]}, UNIV - {[], [c]}}"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   793
proof 
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   794
  fix x 
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   795
  assume "x \<in> UNIV // \<approx>{[c]}"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   796
  then obtain y where h: "x = {z. (y, z) \<in> \<approx>{[c]}}" unfolding quotient_def Image_def by blast
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   797
  show "x \<in> {{[]},{[c]}, UNIV - {[], [c]}}"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   798
  proof -
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   799
    { assume "y = []" hence "x = {[]}" using h by (auto simp:str_eq_rel_def str_eq_def)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   800
    } moreover {
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   801
      assume "y = [c]" hence "x = {[c]}" using h 
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   802
        by (auto dest!:spec[where x = "[]"] simp:str_eq_rel_def str_eq_def)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   803
    } moreover {
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   804
      assume "y \<noteq> []" and "y \<noteq> [c]"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   805
      hence "\<forall> z. (y @ z) \<noteq> [c]" by (case_tac y, auto)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   806
      moreover have "\<And> p. (p \<noteq> [] \<and> p \<noteq> [c]) = (\<forall> q. p @ q \<noteq> [c])" by (case_tac p, auto)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   807
      ultimately have "x = UNIV - {[],[c]}" using h
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   808
        by (auto simp add:str_eq_rel_def str_eq_def)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   809
    } ultimately show ?thesis by blast
27
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   810
  qed
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   811
qed
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   812
29
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   813
text {* *************** Some common lemmas for following ALT, SEQ & STAR cases ******************* *}
27
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   814
29
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   815
lemma finite_tag_imageI: 
27
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   816
  "finite (range tag) \<Longrightarrow> finite (((op `) tag) ` S)"
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   817
apply (rule_tac B = "Pow (tag ` UNIV)" in finite_subset)
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   818
by (auto simp add:image_def Pow_def)
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   819
29
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   820
lemma eq_class_equalI:
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   821
  "\<lbrakk>X \<in> UNIV // \<approx>lang; Y \<in> UNIV // \<approx>lang; x \<in> X; y \<in> Y; x \<approx>lang y\<rbrakk> \<Longrightarrow> X = Y"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   822
by (auto simp:quotient_def str_eq_rel_def str_eq_def)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   823
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   824
lemma tag_image_injI:
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   825
  assumes str_inj: "\<And> m n. tag m = tag (n::string) \<Longrightarrow> m \<approx>lang n"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   826
  shows "inj_on ((op `) tag) (UNIV // \<approx>lang)"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   827
proof-
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   828
  { fix X Y
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   829
    assume X_in: "X \<in> UNIV // \<approx>lang"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   830
      and  Y_in: "Y \<in> UNIV // \<approx>lang"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   831
      and  tag_eq: "tag ` X = tag ` Y"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   832
    then obtain x y where "x \<in> X" and "y \<in> Y" and "tag x = tag y"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   833
      unfolding quotient_def Image_def str_eq_rel_def str_eq_def image_def
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   834
      apply simp by blast
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   835
    with X_in Y_in str_inj
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   836
    have "X = Y" by (rule_tac eq_class_equalI, simp+)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   837
  }
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   838
  thus ?thesis unfolding inj_on_def by auto
27
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   839
qed
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   840
29
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   841
text {* **************** the SEQ case ************************ *}
27
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   842
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   843
(* list_diff:: list substract, once different return tailer *)
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   844
fun list_diff :: "'a list \<Rightarrow> 'a list \<Rightarrow> 'a list" (infix "-" 51)
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   845
where
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   846
  "list_diff []  xs = []" |
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   847
  "list_diff (x#xs) [] = x#xs" |
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   848
  "list_diff (x#xs) (y#ys) = (if x = y then list_diff xs ys else (x#xs))"
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   849
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   850
lemma [simp]: "(x @ y) - x = y"
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   851
apply (induct x)
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   852
by (case_tac y, simp+)
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   853
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   854
lemma [simp]: "x - x = []"
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   855
by (induct x, auto)
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   856
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   857
lemma [simp]: "x = xa @ y \<Longrightarrow> x - xa = y "
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   858
by (induct x, auto)
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   859
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   860
lemma [simp]: "x - [] = x"
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   861
by (induct x, auto)
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   862
29
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   863
lemma [simp]: "(x - y = []) \<Longrightarrow> (x \<le> y)"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   864
proof-   
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   865
  have "\<exists>xa. x = xa @ (x - y) \<and> xa \<le> y"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   866
    apply (rule list_diff.induct[of _ x y], simp+)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   867
    by (clarsimp, rule_tac x = "y # xa" in exI, simp+)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   868
  thus "(x - y = []) \<Longrightarrow> (x \<le> y)" by simp
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   869
qed
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   870
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   871
lemma diff_prefix:
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   872
  "\<lbrakk>c \<le> a - b; b \<le> a\<rbrakk> \<Longrightarrow> b @ c \<le> a"
27
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   873
by (auto elim:prefixE)
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   874
29
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   875
lemma diff_diff_appd: 
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   876
  "\<lbrakk>c < a - b; b < a\<rbrakk> \<Longrightarrow> (a - b) - c = a - (b @ c)"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   877
apply (clarsimp simp:strict_prefix_def)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   878
by (drule diff_prefix, auto elim:prefixE)
27
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   879
29
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   880
lemma app_eq_cases[rule_format]:
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   881
  "\<forall> x . x @ y = m @ n \<longrightarrow> (x \<le> m \<or> m \<le> x)"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   882
apply (induct y, simp)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   883
apply (clarify, drule_tac x = "x @ [a]" in spec)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   884
by (clarsimp, auto simp:prefix_def)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   885
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   886
lemma app_eq_dest:
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   887
  "x @ y = m @ n \<Longrightarrow> (x \<le> m \<and> (m - x) @ n = y) \<or> (m \<le> x \<and> (x - m) @ y = n)"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   888
by (frule_tac app_eq_cases, auto elim:prefixE)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   889
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   890
definition 
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   891
  "tag_str_SEQ L\<^isub>1 L\<^isub>2 x \<equiv> ((\<approx>L\<^isub>1) `` {x}, {(\<approx>L\<^isub>2) `` {x - xa}| xa.  xa \<le> x \<and> xa \<in> L\<^isub>1})"
27
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   892
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   893
lemma tag_str_seq_range_finite:
29
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   894
  "\<lbrakk>finite (UNIV // \<approx>L\<^isub>1); finite (UNIV // \<approx>L\<^isub>2)\<rbrakk> \<Longrightarrow> finite (range (tag_str_SEQ L\<^isub>1 L\<^isub>2))"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   895
apply (rule_tac B = "(UNIV // \<approx>L\<^isub>1) \<times> (Pow (UNIV // \<approx>L\<^isub>2))" in finite_subset)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   896
by (auto simp:tag_str_SEQ_def Image_def quotient_def split:if_splits)
27
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   897
29
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   898
lemma append_seq_elim:
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   899
  assumes "x @ y \<in> L\<^isub>1 ;; L\<^isub>2"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   900
  shows "(\<exists> xa \<le> x. xa \<in> L\<^isub>1 \<and> (x - xa) @ y \<in> L\<^isub>2) \<or> (\<exists> ya \<le> y. (x @ ya) \<in> L\<^isub>1 \<and> (y - ya) \<in> L\<^isub>2)"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   901
proof-
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   902
  from assms obtain s\<^isub>1 s\<^isub>2 where "x @ y = s\<^isub>1 @ s\<^isub>2" and in_seq: "s\<^isub>1 \<in> L\<^isub>1 \<and> s\<^isub>2 \<in> L\<^isub>2" 
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   903
    by (auto simp:Seq_def)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   904
  hence "(x \<le> s\<^isub>1 \<and> (s\<^isub>1 - x) @ s\<^isub>2 = y) \<or> (s\<^isub>1 \<le> x \<and> (x - s\<^isub>1) @ y = s\<^isub>2)"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   905
    using app_eq_dest by auto
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   906
  moreover have "\<lbrakk>x \<le> s\<^isub>1; (s\<^isub>1 - x) @ s\<^isub>2 = y\<rbrakk> \<Longrightarrow> \<exists> ya \<le> y. (x @ ya) \<in> L\<^isub>1 \<and> (y - ya) \<in> L\<^isub>2" using in_seq
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   907
    by (rule_tac x = "s\<^isub>1 - x" in exI, auto elim:prefixE)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   908
  moreover have "\<lbrakk>s\<^isub>1 \<le> x; (x - s\<^isub>1) @ y = s\<^isub>2\<rbrakk> \<Longrightarrow> \<exists> xa \<le> x. xa \<in> L\<^isub>1 \<and> (x - xa) @ y \<in> L\<^isub>2" using in_seq
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   909
    by (rule_tac x = s\<^isub>1 in exI, auto)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   910
  ultimately show ?thesis by blast
27
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   911
qed
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   912
29
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   913
lemma tag_str_SEQ_injI:
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   914
  "tag_str_SEQ L\<^isub>1 L\<^isub>2 m = tag_str_SEQ L\<^isub>1 L\<^isub>2 n \<Longrightarrow> m \<approx>(L\<^isub>1 ;; L\<^isub>2) n"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   915
proof-
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   916
  { fix x y z
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   917
    assume xz_in_seq: "x @ z \<in> L\<^isub>1 ;; L\<^isub>2"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   918
    and tag_xy: "tag_str_SEQ L\<^isub>1 L\<^isub>2 x = tag_str_SEQ L\<^isub>1 L\<^isub>2 y"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   919
    have"y @ z \<in> L\<^isub>1 ;; L\<^isub>2" 
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   920
    proof-
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   921
      have "(\<exists> xa \<le> x. xa \<in> L\<^isub>1 \<and> (x - xa) @ z \<in> L\<^isub>2) \<or> (\<exists> za \<le> z. (x @ za) \<in> L\<^isub>1 \<and> (z - za) \<in> L\<^isub>2)"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   922
        using xz_in_seq append_seq_elim by simp
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   923
      moreover {
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   924
        fix xa
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   925
        assume h1: "xa \<le> x" and h2: "xa \<in> L\<^isub>1" and h3: "(x - xa) @ z \<in> L\<^isub>2"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   926
        obtain ya where "ya \<le> y" and "ya \<in> L\<^isub>1" and "(y - ya) @ z \<in> L\<^isub>2" 
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   927
        proof -
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   928
          have "\<exists> ya.  ya \<le> y \<and> ya \<in> L\<^isub>1 \<and> (x - xa) \<approx>L\<^isub>2 (y - ya)"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   929
          proof -
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   930
            have "{\<approx>L\<^isub>2 `` {x - xa} |xa. xa \<le> x \<and> xa \<in> L\<^isub>1} = 
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   931
                  {\<approx>L\<^isub>2 `` {y - xa} |xa. xa \<le> y \<and> xa \<in> L\<^isub>1}" (is "?Left = ?Right") 
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   932
              using h1 tag_xy by (auto simp:tag_str_SEQ_def)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   933
            moreover have "\<approx>L\<^isub>2 `` {x - xa} \<in> ?Left" using h1 h2 by auto
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   934
            ultimately have "\<approx>L\<^isub>2 `` {x - xa} \<in> ?Right" by simp
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   935
            thus ?thesis by (auto simp:Image_def str_eq_rel_def str_eq_def)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   936
          qed
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   937
          with prems show ?thesis by (auto simp:str_eq_rel_def str_eq_def)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   938
        qed
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   939
        hence "y @ z \<in> L\<^isub>1 ;; L\<^isub>2" by (erule_tac prefixE, auto simp:Seq_def)          
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   940
      } moreover {
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   941
        fix za
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   942
        assume h1: "za \<le> z" and h2: "(x @ za) \<in> L\<^isub>1" and h3: "z - za \<in> L\<^isub>2"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   943
        hence "y @ za \<in> L\<^isub>1"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   944
        proof-
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   945
          have "\<approx>L\<^isub>1 `` {x} = \<approx>L\<^isub>1 `` {y}" using h1 tag_xy by (auto simp:tag_str_SEQ_def)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   946
          with h2 show ?thesis by (auto simp:Image_def str_eq_rel_def str_eq_def) 
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   947
        qed
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   948
        with h1 h3 have "y @ z \<in> L\<^isub>1 ;; L\<^isub>2" by (drule_tac A = L\<^isub>1 in seq_intro, auto elim:prefixE)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   949
      }
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   950
      ultimately show ?thesis by blast
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   951
    qed
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   952
  } thus "tag_str_SEQ L\<^isub>1 L\<^isub>2 m = tag_str_SEQ L\<^isub>1 L\<^isub>2 n \<Longrightarrow> m \<approx>(L\<^isub>1 ;; L\<^isub>2) n" 
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   953
    by (auto simp add: str_eq_def str_eq_rel_def)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   954
qed 
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   955
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   956
lemma quot_seq_finiteI:
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   957
  assumes finite1: "finite (UNIV // \<approx>(L\<^isub>1::string set))"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   958
  and finite2: "finite (UNIV // \<approx>L\<^isub>2)"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   959
  shows "finite (UNIV // \<approx>(L\<^isub>1 ;; L\<^isub>2))"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   960
proof(rule_tac f = "(op `) (tag_str_SEQ L\<^isub>1 L\<^isub>2)" in finite_imageD)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   961
  show "finite (op ` (tag_str_SEQ L\<^isub>1 L\<^isub>2) ` UNIV // \<approx>L\<^isub>1 ;; L\<^isub>2)" using finite1 finite2
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   962
    by (auto intro:finite_tag_imageI tag_str_seq_range_finite)
27
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   963
next
29
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   964
  show  "inj_on (op ` (tag_str_SEQ L\<^isub>1 L\<^isub>2)) (UNIV // \<approx>L\<^isub>1 ;; L\<^isub>2)"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   965
    apply (rule tag_image_injI)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   966
    apply (rule tag_str_SEQ_injI)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   967
    by (auto intro:tag_image_injI tag_str_SEQ_injI simp:)
27
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   968
qed
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   969
29
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   970
text {* **************** the ALT case ************************ *}
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   971
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   972
definition 
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   973
  "tag_str_ALT L\<^isub>1 L\<^isub>2 (x::string) \<equiv> ((\<approx>L\<^isub>1) `` {x}, (\<approx>L\<^isub>2) `` {x})"
27
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   974
29
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   975
lemma tag_str_alt_range_finite:
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   976
  "\<lbrakk>finite (UNIV // \<approx>L\<^isub>1); finite (UNIV // \<approx>L\<^isub>2)\<rbrakk> \<Longrightarrow> finite (range (tag_str_ALT L\<^isub>1 L\<^isub>2))"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   977
apply (rule_tac B = "(UNIV // \<approx>L\<^isub>1) \<times> (UNIV // \<approx>L\<^isub>2)" in finite_subset)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   978
by (auto simp:tag_str_ALT_def Image_def quotient_def)
27
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   979
29
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   980
lemma quot_union_finiteI:
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   981
  assumes finite1: "finite (UNIV // \<approx>(L\<^isub>1::string set))"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   982
  and finite2: "finite (UNIV // \<approx>L\<^isub>2)"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   983
  shows "finite (UNIV // \<approx>(L\<^isub>1 \<union> L\<^isub>2))"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   984
proof(rule_tac f = "(op `) (tag_str_ALT L\<^isub>1 L\<^isub>2)" in finite_imageD)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   985
  show "finite (op ` (tag_str_ALT L\<^isub>1 L\<^isub>2) ` UNIV // \<approx>L\<^isub>1 \<union> L\<^isub>2)" using finite1 finite2
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   986
    by (auto intro:finite_tag_imageI tag_str_alt_range_finite)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   987
next
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   988
  show "inj_on (op ` (tag_str_ALT L\<^isub>1 L\<^isub>2)) (UNIV // \<approx>L\<^isub>1 \<union> L\<^isub>2)"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   989
  proof-
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   990
    have "\<And>m n. tag_str_ALT L\<^isub>1 L\<^isub>2 m = tag_str_ALT L\<^isub>1 L\<^isub>2 n \<Longrightarrow> m \<approx>(L\<^isub>1 \<union> L\<^isub>2) n"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   991
      unfolding tag_str_ALT_def str_eq_def Image_def str_eq_rel_def by auto
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   992
    thus ?thesis by (auto intro:tag_image_injI)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   993
  qed
27
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   994
qed
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
   995
29
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   996
text {* **************** the Star case ****************** *}
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   997
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   998
lemma finite_set_has_max: "\<lbrakk>finite A; A \<noteq> {}\<rbrakk> \<Longrightarrow> (\<exists> max \<in> A. \<forall> a \<in> A. f a <= (f max :: nat))"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
   999
proof (induct rule:finite.induct)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1000
  case emptyI thus ?case by simp
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1001
next
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1002
  case (insertI A a)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1003
  show ?case
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1004
  proof (cases "A = {}")
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1005
    case True thus ?thesis by (rule_tac x = a in bexI, auto)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1006
  next
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1007
    case False
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1008
    with prems obtain max where h1: "max \<in> A" and h2: "\<forall>a\<in>A. f a \<le> f max" by blast
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1009
    show ?thesis
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1010
    proof (cases "f a \<le> f max")
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1011
      assume "f a \<le> f max"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1012
      with h1 h2 show ?thesis by (rule_tac x = max in bexI, auto)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1013
    next
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1014
      assume "\<not> (f a \<le> f max)"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1015
      thus ?thesis using h2 by (rule_tac x = a in bexI, auto)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1016
    qed
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1017
  qed
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1018
qed
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1019
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1020
lemma star_intro1[rule_format]: "x \<in> lang\<star> \<Longrightarrow> \<forall> y. y \<in> lang\<star> \<longrightarrow> x @ y \<in> lang\<star>"
27
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
  1021
by (erule Star.induct, auto)
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
  1022
29
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1023
lemma star_intro2: "y \<in> lang \<Longrightarrow> y \<in> lang\<star>"
27
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
  1024
by (drule step[of y lang "[]"], auto simp:start)
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
  1025
29
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1026
lemma star_intro3[rule_format]: "x \<in> lang\<star> \<Longrightarrow> \<forall>y . y \<in> lang \<longrightarrow> x @ y \<in> lang\<star>"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1027
by (erule Star.induct, auto intro:star_intro2)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1028
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1029
lemma star_decom: "\<lbrakk>x \<in> lang\<star>; x \<noteq> []\<rbrakk> \<Longrightarrow>(\<exists> a b. x = a @ b \<and> a \<noteq> [] \<and> a \<in> lang \<and> b \<in> lang\<star>)"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1030
by (induct x rule: Star.induct, simp, blast)
27
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
  1031
29
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1032
lemma finite_strict_prefix_set: "finite {xa. xa < (x::string)}"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1033
apply (induct x rule:rev_induct, simp)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1034
apply (subgoal_tac "{xa. xa < xs @ [x]} = {xa. xa < xs} \<union> {xs}")
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1035
by (auto simp:strict_prefix_def)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1036
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1037
definition 
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1038
  "tag_str_STAR L\<^isub>1 x \<equiv> {(\<approx>L\<^isub>1) `` {x - xa} | xa. xa < x \<and> xa \<in> L\<^isub>1\<star>}"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1039
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1040
lemma tag_str_star_range_finite:
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1041
  "finite (UNIV // \<approx>L\<^isub>1) \<Longrightarrow> finite (range (tag_str_STAR L\<^isub>1))"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1042
apply (rule_tac B = "Pow (UNIV // \<approx>L\<^isub>1)" in finite_subset)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1043
by (auto simp:tag_str_STAR_def Image_def quotient_def split:if_splits)
27
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
  1044
29
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1045
lemma tag_str_STAR_injI:
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1046
  "tag_str_STAR L\<^isub>1 m = tag_str_STAR L\<^isub>1 n \<Longrightarrow> m \<approx>(L\<^isub>1\<star>) n"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1047
proof-
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1048
  { fix x y z
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1049
    assume xz_in_star: "x @ z \<in> L\<^isub>1\<star>"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1050
    and tag_xy: "tag_str_STAR L\<^isub>1 x = tag_str_STAR L\<^isub>1 y"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1051
    have "y @ z \<in> L\<^isub>1\<star>"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1052
    proof(cases "x = []")
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1053
      case True
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1054
      with tag_xy have "y = []" by (auto simp:tag_str_STAR_def strict_prefix_def)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1055
      thus ?thesis using xz_in_star True by simp
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1056
    next
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1057
      case False
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1058
      obtain x_max where h1: "x_max < x" and h2: "x_max \<in> L\<^isub>1\<star>" and h3: "(x - x_max) @ z \<in> L\<^isub>1\<star>" 
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1059
        and h4:"\<forall> xa < x. xa \<in> L\<^isub>1\<star> \<and> (x - xa) @ z \<in> L\<^isub>1\<star> \<longrightarrow> length xa \<le> length x_max"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1060
      proof-
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1061
        let ?S = "{xa. xa < x \<and> xa \<in> L\<^isub>1\<star> \<and> (x - xa) @ z \<in> L\<^isub>1\<star>}"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1062
        have "finite ?S"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1063
          by (rule_tac B = "{xa. xa < x}" in finite_subset, auto simp:finite_strict_prefix_set)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1064
        moreover have "?S \<noteq> {}" using False xz_in_star
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1065
          by (simp, rule_tac x = "[]" in exI, auto simp:strict_prefix_def)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1066
        ultimately have "\<exists> max \<in> ?S. \<forall> a \<in> ?S. length a \<le> length max" using finite_set_has_max by blast
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1067
        with prems show ?thesis by blast
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1068
      qed
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1069
      obtain ya where h5: "ya < y" and h6: "ya \<in> L\<^isub>1\<star>" and h7: "(x - x_max) \<approx>L\<^isub>1 (y - ya)"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1070
      proof-
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1071
        from tag_xy have "{\<approx>L\<^isub>1 `` {x - xa} |xa. xa < x \<and> xa \<in> L\<^isub>1\<star>} = 
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1072
          {\<approx>L\<^isub>1 `` {y - xa} |xa. xa < y \<and> xa \<in> L\<^isub>1\<star>}" (is "?left = ?right")
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1073
          by (auto simp:tag_str_STAR_def)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1074
        moreover have "\<approx>L\<^isub>1 `` {x - x_max} \<in> ?left" using h1 h2 by auto
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1075
        ultimately have "\<approx>L\<^isub>1 `` {x - x_max} \<in> ?right" by simp
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1076
        with prems show ?thesis apply (simp add:Image_def str_eq_rel_def str_eq_def) by blast
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1077
      qed      
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1078
      have "(y - ya) @ z \<in> L\<^isub>1\<star>" 
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1079
      proof-
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1080
        from h3 h1 obtain a b where a_in: "a \<in> L\<^isub>1" and a_neq: "a \<noteq> []" and b_in: "b \<in> L\<^isub>1\<star>" 
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1081
          and ab_max: "(x - x_max) @ z = a @ b" 
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1082
          by (drule_tac star_decom, auto simp:strict_prefix_def elim:prefixE)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1083
        have "(x - x_max) \<le> a \<and> (a - (x - x_max)) @ b = z" 
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1084
        proof -
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1085
          have "((x - x_max) \<le> a \<and> (a - (x - x_max)) @ b = z) \<or> (a < (x - x_max) \<and> ((x - x_max) - a) @ z = b)" 
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1086
            using app_eq_dest[OF ab_max] by (auto simp:strict_prefix_def)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1087
          moreover { 
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1088
            assume np: "a < (x - x_max)" and b_eqs: " ((x - x_max) - a) @ z = b"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1089
            have "False"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1090
            proof -
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1091
              let ?x_max' = "x_max @ a"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1092
              have "?x_max' < x" using np h1 by (clarsimp simp:strict_prefix_def diff_prefix) 
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1093
              moreover have "?x_max' \<in> L\<^isub>1\<star>" using a_in h2 by (simp add:star_intro3) 
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1094
              moreover have "(x - ?x_max') @ z \<in> L\<^isub>1\<star>" using b_eqs b_in np h1 by (simp add:diff_diff_appd)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1095
              moreover have "\<not> (length ?x_max' \<le> length x_max)" using a_neq by simp
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1096
              ultimately show ?thesis using h4 by blast
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1097
            qed 
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1098
          } ultimately show ?thesis by blast
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1099
        qed
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1100
        then obtain za where z_decom: "z = za @ b" and x_za: "(x - x_max) @ za \<in> L\<^isub>1" 
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1101
          using a_in by (auto elim:prefixE)        
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1102
        from x_za h7 have "(y - ya) @ za \<in> L\<^isub>1" by (auto simp:str_eq_def)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1103
        with z_decom b_in show ?thesis by (auto dest!:step[of "(y - ya) @ za"])
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1104
      qed
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1105
      with h5 h6 show ?thesis by (drule_tac star_intro1, auto simp:strict_prefix_def elim:prefixE)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1106
    qed      
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1107
  } thus "tag_str_STAR L\<^isub>1 m = tag_str_STAR L\<^isub>1 n \<Longrightarrow> m \<approx>(L\<^isub>1\<star>) n"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1108
    by (auto simp add:str_eq_def str_eq_rel_def)
27
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
  1109
qed
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
  1110
29
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1111
lemma quot_star_finiteI:
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1112
  assumes finite: "finite (UNIV // \<approx>(L\<^isub>1::string set))"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1113
  shows "finite (UNIV // \<approx>(L\<^isub>1\<star>))"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1114
proof(rule_tac f = "(op `) (tag_str_STAR L\<^isub>1)" in finite_imageD)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1115
  show "finite (op ` (tag_str_STAR L\<^isub>1) ` UNIV // \<approx>L\<^isub>1\<star>)" using finite
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1116
    by (auto intro:finite_tag_imageI tag_str_star_range_finite)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1117
next
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1118
  show "inj_on (op ` (tag_str_STAR L\<^isub>1)) (UNIV // \<approx>L\<^isub>1\<star>)"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1119
    by (auto intro:tag_image_injI tag_str_STAR_injI)
27
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
  1120
qed
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
  1121
29
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1122
text {* **************** the Other Direction ************ *}
27
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
  1123
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
  1124
lemma other_direction:
29
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1125
  "Lang = L (r::rexp) \<Longrightarrow> finite (UNIV // (\<approx>Lang))"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1126
proof (induct arbitrary:Lang rule:rexp.induct)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1127
  case NULL
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1128
  have "UNIV // (\<approx>{}) \<subseteq> {UNIV} "
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1129
    by (auto simp:quotient_def str_eq_rel_def str_eq_def)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1130
  with prems show "?case" by (auto intro:finite_subset)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1131
next
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1132
  case EMPTY
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1133
  have "UNIV // (\<approx>{[]}) \<subseteq> {{[]}, UNIV - {[]}}" by (rule quot_empty_subset)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1134
  with prems show ?case by (auto intro:finite_subset)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1135
next
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1136
  case (CHAR c)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1137
  have "UNIV // (\<approx>{[c]}) \<subseteq> {{[]},{[c]}, UNIV - {[], [c]}}" by (rule quot_char_subset)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1138
  with prems show ?case by (auto intro:finite_subset)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1139
next
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1140
  case (SEQ r\<^isub>1 r\<^isub>2)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1141
  have "\<lbrakk>finite (UNIV // \<approx>(L r\<^isub>1)); finite (UNIV // \<approx>(L r\<^isub>2))\<rbrakk> \<Longrightarrow> finite (UNIV // \<approx>(L r\<^isub>1 ;; L r\<^isub>2))"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1142
    by (erule quot_seq_finiteI, simp)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1143
  with prems show ?case by simp
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1144
next
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1145
  case (ALT r\<^isub>1 r\<^isub>2)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1146
  have "\<lbrakk>finite (UNIV // \<approx>(L r\<^isub>1)); finite (UNIV // \<approx>(L r\<^isub>2))\<rbrakk> \<Longrightarrow> finite (UNIV // \<approx>(L r\<^isub>1 \<union> L r\<^isub>2))"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1147
    by (erule quot_union_finiteI, simp)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1148
  with prems show ?case by simp  
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1149
next
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1150
  case (STAR r)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1151
  have "finite (UNIV // \<approx>(L r)) \<Longrightarrow> finite (UNIV // \<approx>((L r)\<star>))"
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1152
    by (erule quot_star_finiteI)
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1153
  with prems show ?case by simp
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1154
qed 
27
90a57a533b0c Add new file for the new definition of the hard direction's simplification.
wu
parents:
diff changeset
  1155
29
c64241fa4dff Beautifying of the Other Direction is finished.
wu
parents: 28
diff changeset
  1156
end