MyhillNerode.thy
author urbanc
Thu, 21 Apr 2011 12:07:11 +0000
changeset 156 fd39492b187c
parent 23 e31b733ace44
permissions -rw-r--r--
a few more changes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
     1
theory MyhillNerode
23
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
     2
  imports "Main" "List_Prefix"
6
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
     3
begin
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
     4
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
     5
text {* sequential composition of languages *}
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
     6
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
     7
definition
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
     8
  lang_seq :: "string set \<Rightarrow> string set \<Rightarrow> string set" ("_ ; _" [100,100] 100)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
     9
where 
7
86167563a1ed deleted the matcher ate the beginning; made it to work with stable Isabelle and the development version
urbanc
parents: 6
diff changeset
    10
  "L1 ; L2 = {s1 @ s2 | s1 s2. s1 \<in> L1 \<and> s2 \<in> L2}"
6
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    11
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    12
lemma lang_seq_empty:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    13
  shows "{[]} ; L = L"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    14
  and   "L ; {[]} = L"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    15
unfolding lang_seq_def by auto
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    16
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    17
lemma lang_seq_null:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    18
  shows "{} ; L = {}"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    19
  and   "L ; {} = {}"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    20
unfolding lang_seq_def by auto
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    21
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    22
lemma lang_seq_append:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    23
  assumes a: "s1 \<in> L1"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    24
  and     b: "s2 \<in> L2"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    25
  shows "s1@s2 \<in> L1 ; L2"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    26
unfolding lang_seq_def
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    27
using a b by auto 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    28
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    29
lemma lang_seq_union:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    30
  shows "(L1 \<union> L2); L3 = (L1; L3) \<union> (L2; L3)"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    31
  and   "L1; (L2 \<union> L3) = (L1; L2) \<union> (L1; L3)"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    32
unfolding lang_seq_def by auto
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    33
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    34
lemma lang_seq_assoc:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    35
  shows "(L1 ; L2) ; L3 = L1 ; (L2 ; L3)"
7
86167563a1ed deleted the matcher ate the beginning; made it to work with stable Isabelle and the development version
urbanc
parents: 6
diff changeset
    36
unfolding lang_seq_def
86167563a1ed deleted the matcher ate the beginning; made it to work with stable Isabelle and the development version
urbanc
parents: 6
diff changeset
    37
apply(auto)
86167563a1ed deleted the matcher ate the beginning; made it to work with stable Isabelle and the development version
urbanc
parents: 6
diff changeset
    38
apply(metis)
86167563a1ed deleted the matcher ate the beginning; made it to work with stable Isabelle and the development version
urbanc
parents: 6
diff changeset
    39
by (metis append_assoc)
6
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    40
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    41
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    42
section {* Kleene star for languages defined as least fixed point *}
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    43
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    44
inductive_set
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    45
  Star :: "string set \<Rightarrow> string set" ("_\<star>" [101] 102)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    46
  for L :: "string set"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    47
where
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    48
  start[intro]: "[] \<in> L\<star>"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    49
| step[intro]:  "\<lbrakk>s1 \<in> L; s2 \<in> L\<star>\<rbrakk> \<Longrightarrow> s1@s2 \<in> L\<star>"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    50
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    51
lemma lang_star_empty:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    52
  shows "{}\<star> = {[]}"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    53
by (auto elim: Star.cases)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    54
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    55
lemma lang_star_cases:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    56
  shows "L\<star> =  {[]} \<union> L ; L\<star>"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    57
proof
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    58
  { fix x
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    59
    have "x \<in> L\<star> \<Longrightarrow> x \<in> {[]} \<union> L ; L\<star>"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    60
      unfolding lang_seq_def
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    61
    by (induct rule: Star.induct) (auto)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    62
  }
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    63
  then show "L\<star> \<subseteq> {[]} \<union> L ; L\<star>" by auto
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    64
next
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    65
  show "{[]} \<union> L ; L\<star> \<subseteq> L\<star>" 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    66
    unfolding lang_seq_def by auto
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    67
qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    68
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    69
lemma lang_star_cases':
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    70
  shows "L\<star> =  {[]} \<union> L\<star> ; L"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    71
proof
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    72
  { fix x
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    73
    have "x \<in> L\<star> \<Longrightarrow> x \<in> {[]} \<union> L\<star> ; L"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    74
      unfolding lang_seq_def
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    75
    apply (induct rule: Star.induct)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    76
    apply simp
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    77
    apply simp
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    78
    apply (erule disjE)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    79
    apply (auto)[1]
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    80
    apply (erule exE | erule conjE)+
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    81
    apply (rule disjI2)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    82
    apply (rule_tac x = "s1 @ s1a" in exI)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    83
    by auto
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    84
  }
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    85
  then show "L\<star> \<subseteq> {[]} \<union> L\<star> ; L" by auto
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    86
next
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    87
  show "{[]} \<union> L\<star> ; L \<subseteq> L\<star>" 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    88
    unfolding lang_seq_def
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    89
    apply auto
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    90
    apply (erule Star.induct)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    91
    apply auto
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    92
    apply (drule step[of _ _ "[]"])
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    93
    by (auto intro:start)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    94
qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    95
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    96
lemma lang_star_simple:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    97
  shows "L \<subseteq> L\<star>"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    98
by (subst lang_star_cases)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    99
   (auto simp only: lang_seq_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   100
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   101
lemma lang_star_prop0_aux:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   102
  "s2 \<in> L\<star> \<Longrightarrow> \<forall> s1. s1 \<in> L \<longrightarrow> (\<exists> s3 s4. s3 \<in> L\<star> \<and> s4 \<in> L \<and> s1 @ s2 = s3 @ s4)" 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   103
apply (erule Star.induct)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   104
apply (clarify, rule_tac x = "[]" in exI, rule_tac x = s1 in exI, simp add:start)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   105
apply (clarify, drule_tac x = s1 in spec)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   106
apply (drule mp, simp, clarify)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   107
apply (rule_tac x = "s1a @ s3" in exI, rule_tac x = s4 in exI)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   108
by auto
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   109
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   110
lemma lang_star_prop0:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   111
  "\<lbrakk>s1 \<in> L; s2 \<in> L\<star>\<rbrakk> \<Longrightarrow> \<exists> s3 s4. s3 \<in> L\<star> \<and> s4 \<in> L \<and> s1 @ s2 = s3 @ s4" 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   112
by (auto dest:lang_star_prop0_aux)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   113
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   114
lemma lang_star_prop1:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   115
  assumes asm: "L1; L2 \<subseteq> L2" 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   116
  shows "L1\<star>; L2 \<subseteq> L2"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   117
proof -
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   118
  { fix s1 s2
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   119
    assume minor: "s2 \<in> L2"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   120
    assume major: "s1 \<in> L1\<star>"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   121
    then have "s1@s2 \<in> L2"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   122
    proof(induct rule: Star.induct)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   123
      case start
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   124
      show "[]@s2 \<in> L2" using minor by simp
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   125
    next
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   126
      case (step s1 s1')
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   127
      have "s1 \<in> L1" by fact
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   128
      moreover
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   129
      have "s1'@s2 \<in> L2" by fact
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   130
      ultimately have "s1@(s1'@s2) \<in> L1; L2" by (auto simp add: lang_seq_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   131
      with asm have "s1@(s1'@s2) \<in> L2" by auto
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   132
      then show "(s1@s1')@s2 \<in> L2" by simp
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   133
    qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   134
  } 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   135
  then show "L1\<star>; L2 \<subseteq> L2" by (auto simp add: lang_seq_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   136
qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   137
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   138
lemma lang_star_prop2_aux:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   139
  "s2 \<in> L2\<star> \<Longrightarrow> \<forall> s1. s1 \<in> L1 \<and> L1 ; L2 \<subseteq> L1 \<longrightarrow> s1 @ s2 \<in> L1"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   140
apply (erule Star.induct, simp)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   141
apply (clarify, drule_tac x = "s1a @ s1" in spec)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   142
by (auto simp:lang_seq_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   143
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   144
lemma lang_star_prop2:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   145
  "L1; L2 \<subseteq> L1 \<Longrightarrow> L1 ; L2\<star> \<subseteq> L1"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   146
by (auto dest!:lang_star_prop2_aux simp:lang_seq_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   147
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   148
lemma lang_star_seq_subseteq: 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   149
  shows "L ; L\<star> \<subseteq> L\<star>"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   150
using lang_star_cases by blast
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   151
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   152
lemma lang_star_double:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   153
  shows "L\<star>; L\<star> = L\<star>"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   154
proof
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   155
  show "L\<star> ; L\<star> \<subseteq> L\<star>" 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   156
    using lang_star_prop1 lang_star_seq_subseteq by blast
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   157
next
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   158
  have "L\<star> \<subseteq> L\<star> \<union> L\<star>; (L; L\<star>)" by auto
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   159
  also have "\<dots> = L\<star>;{[]} \<union> L\<star>; (L; L\<star>)" by (simp add: lang_seq_empty)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   160
  also have "\<dots> = L\<star>; ({[]} \<union> L; L\<star>)" by (simp only: lang_seq_union)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   161
  also have "\<dots> = L\<star>; L\<star>" using lang_star_cases by simp 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   162
  finally show "L\<star> \<subseteq> L\<star> ; L\<star>" by simp
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   163
qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   164
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   165
lemma lang_star_seq_subseteq': 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   166
  shows "L\<star>; L \<subseteq> L\<star>"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   167
proof -
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   168
  have "L \<subseteq> L\<star>" by (rule lang_star_simple)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   169
  then have "L\<star>; L \<subseteq> L\<star>; L\<star>" by (auto simp add: lang_seq_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   170
  then show "L\<star>; L \<subseteq> L\<star>" using lang_star_double by blast
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   171
qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   172
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   173
lemma
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   174
  shows "L\<star> \<subseteq> L\<star>\<star>"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   175
by (rule lang_star_simple)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   176
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   177
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   178
section {* regular expressions *}
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   179
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   180
datatype rexp =
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   181
  NULL
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   182
| EMPTY
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   183
| CHAR char
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   184
| SEQ rexp rexp
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   185
| ALT rexp rexp
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   186
| STAR rexp
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   187
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   188
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   189
consts L:: "'a \<Rightarrow> string set"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   190
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   191
overloading L_rexp \<equiv> "L::  rexp \<Rightarrow> string set"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   192
begin
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   193
fun
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   194
  L_rexp :: "rexp \<Rightarrow> string set"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   195
where
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   196
    "L_rexp (NULL) = {}"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   197
  | "L_rexp (EMPTY) = {[]}"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   198
  | "L_rexp (CHAR c) = {[c]}"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   199
  | "L_rexp (SEQ r1 r2) = (L_rexp r1) ; (L_rexp r2)"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   200
  | "L_rexp (ALT r1 r2) = (L_rexp r1) \<union> (L_rexp r2)"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   201
  | "L_rexp (STAR r) = (L_rexp r)\<star>"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   202
end
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   203
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   204
8
1f8fe5bfd381 tried at the end to prove the other direction (failed at the moment)
urbanc
parents: 7
diff changeset
   205
text{* ************ now is the codes writen by chunhan ************************************* *}
6
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   206
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   207
section {* Arden's Lemma revised *}
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   208
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   209
lemma arden_aux1:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   210
  assumes a: "X \<subseteq> X ; A \<union> B"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   211
  and     b: "[] \<notin> A"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   212
  shows      "x \<in> X \<Longrightarrow> x \<in> B ; A\<star>"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   213
apply (induct x taking:length rule:measure_induct)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   214
apply (subgoal_tac "x \<in> X ; A \<union> B")
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   215
defer
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   216
using a
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   217
apply (auto)[1]
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   218
apply simp
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   219
apply (erule disjE)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   220
defer
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   221
apply (auto simp add:lang_seq_def) [1]
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   222
apply (subgoal_tac "\<exists> x1 x2. x = x1 @ x2 \<and> x1 \<in> X \<and> x2 \<in> A")
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   223
defer
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   224
apply (auto simp add:lang_seq_def) [1]
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   225
apply (erule exE | erule conjE)+
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   226
apply simp
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   227
apply (drule_tac x = x1 in spec)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   228
apply (simp)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   229
using b
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   230
apply -
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   231
apply (auto)[1]
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   232
apply (subgoal_tac "x1 @ x2 \<in> (B ; A\<star>) ; A")
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   233
defer
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   234
apply (auto simp add:lang_seq_def)[1]
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   235
by (metis Un_absorb1 lang_seq_assoc lang_seq_union(2) lang_star_double lang_star_simple mem_def sup1CI)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   236
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   237
theorem ardens_revised:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   238
  assumes nemp: "[] \<notin> A"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   239
  shows "(X = X ; A \<union> B) \<longleftrightarrow> (X = B ; A\<star>)"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   240
apply(rule iffI)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   241
defer
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   242
apply(simp)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   243
apply(subst lang_star_cases')
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   244
apply(subst lang_seq_union)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   245
apply(simp add: lang_seq_empty)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   246
apply(simp add: lang_seq_assoc)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   247
apply(auto)[1]
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   248
proof -
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   249
  assume "X = X ; A \<union> B"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   250
  then have as1: "X ; A \<union> B \<subseteq> X" and as2: "X \<subseteq> X ; A \<union> B" by simp_all
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   251
  from as1 have a: "X ; A \<subseteq> X" and b: "B \<subseteq> X" by simp_all
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   252
  from b have "B; A\<star> \<subseteq> X ; A\<star>" by (auto simp add: lang_seq_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   253
  moreover
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   254
  from a have "X ; A\<star> \<subseteq> X" 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   255
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   256
by (rule lang_star_prop2)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   257
  ultimately have f1: "B ; A\<star> \<subseteq> X" by simp
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   258
  from as2 nemp
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   259
  have f2: "X \<subseteq> B; A\<star>" using arden_aux1 by auto
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   260
  from f1 f2 show "X = B; A\<star>" by auto
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   261
qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   262
11
475dd40cd734 deleted two unnecessary lemmas
urbanc
parents: 8
diff changeset
   263
475dd40cd734 deleted two unnecessary lemmas
urbanc
parents: 8
diff changeset
   264
6
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   265
section {* equiv class' definition *}
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   266
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   267
definition 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   268
  equiv_str :: "string \<Rightarrow> string set \<Rightarrow> string \<Rightarrow> bool" ("_ \<equiv>_\<equiv> _" [100, 100, 100] 100)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   269
where
8
1f8fe5bfd381 tried at the end to prove the other direction (failed at the moment)
urbanc
parents: 7
diff changeset
   270
  "x \<equiv>Lang\<equiv> y \<longleftrightarrow> (\<forall>z. x @ z \<in> Lang \<longleftrightarrow> y @ z \<in> Lang)"
6
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   271
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   272
definition
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   273
  equiv_class :: "string \<Rightarrow> (string set) \<Rightarrow> string set" ("\<lbrakk>_\<rbrakk>_" [100, 100] 100)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   274
where
8
1f8fe5bfd381 tried at the end to prove the other direction (failed at the moment)
urbanc
parents: 7
diff changeset
   275
  "\<lbrakk>x\<rbrakk>Lang \<equiv> {y. x \<equiv>Lang\<equiv> y}"
6
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   276
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   277
text {* Chunhan modifies Q to Quo *}
8
1f8fe5bfd381 tried at the end to prove the other direction (failed at the moment)
urbanc
parents: 7
diff changeset
   278
6
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   279
definition  
8
1f8fe5bfd381 tried at the end to prove the other direction (failed at the moment)
urbanc
parents: 7
diff changeset
   280
  quot :: "string set \<Rightarrow> string set \<Rightarrow> (string set) set" ("_ Quo _" [100, 100] 100)
6
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   281
where
8
1f8fe5bfd381 tried at the end to prove the other direction (failed at the moment)
urbanc
parents: 7
diff changeset
   282
  "L1 Quo L2 \<equiv> { \<lbrakk>x\<rbrakk>L2 | x. x \<in> L1}" 
1f8fe5bfd381 tried at the end to prove the other direction (failed at the moment)
urbanc
parents: 7
diff changeset
   283
23
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
   284
6
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   285
lemma lang_eqs_union_of_eqcls: 
23
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
   286
  "Lang = \<Union> {X. X \<in> (UNIV Quo Lang) \<and> (\<forall> x \<in> X. x \<in> Lang)}"
6
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   287
proof
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   288
  show "Lang \<subseteq> \<Union>{X \<in> UNIV Quo Lang. \<forall>x\<in>X. x \<in> Lang}"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   289
  proof
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   290
    fix x
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   291
    assume "x \<in> Lang"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   292
    thus "x \<in> \<Union>{X \<in> UNIV Quo Lang. \<forall>x\<in>X. x \<in> Lang}"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   293
    proof (simp add:quot_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   294
      assume "(1)": "x \<in> Lang"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   295
      show "\<exists>xa. (\<exists>x. xa = \<lbrakk>x\<rbrakk>Lang) \<and> (\<forall>x\<in>xa. x \<in> Lang) \<and> x \<in> xa" (is "\<exists>xa.?P xa")
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   296
      proof -
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   297
        have "?P (\<lbrakk>x\<rbrakk>Lang)" using "(1)"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   298
          by (auto simp:equiv_class_def equiv_str_def dest: spec[where  x = "[]"])
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   299
        thus ?thesis by blast
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   300
      qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   301
    qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   302
  qed   
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   303
next
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   304
  show "\<Union>{X \<in> UNIV Quo Lang. \<forall>x\<in>X. x \<in> Lang} \<subseteq> Lang"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   305
    by auto
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   306
qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   307
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   308
lemma empty_notin_CS: "{} \<notin> UNIV Quo Lang"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   309
apply (clarsimp simp:quot_def equiv_class_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   310
by (rule_tac x = x in exI, auto simp:equiv_str_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   311
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   312
lemma no_two_cls_inters:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   313
  "\<lbrakk>X \<in> UNIV Quo Lang; Y \<in> UNIV Quo Lang; X \<noteq> Y\<rbrakk> \<Longrightarrow> X \<inter> Y = {}"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   314
by (auto simp:quot_def equiv_class_def equiv_str_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   315
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   316
text {* equiv_class transition *}
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   317
definition 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   318
  CT :: "string set \<Rightarrow> char \<Rightarrow> string set \<Rightarrow> bool" ("_-_\<rightarrow>_" [99,99]99)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   319
where
23
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
   320
  "X-c\<rightarrow>Y \<equiv> ((X;{[c]}) \<subseteq> Y)"
6
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   321
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   322
types t_equa_rhs = "(string set \<times> rexp) set"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   323
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   324
types t_equa = "(string set \<times> t_equa_rhs)"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   325
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   326
types t_equas = "t_equa set"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   327
8
1f8fe5bfd381 tried at the end to prove the other direction (failed at the moment)
urbanc
parents: 7
diff changeset
   328
text {* 
1f8fe5bfd381 tried at the end to prove the other direction (failed at the moment)
urbanc
parents: 7
diff changeset
   329
  "empty_rhs" generates "\<lambda>" for init-state, just like "\<lambda>" for final states 
1f8fe5bfd381 tried at the end to prove the other direction (failed at the moment)
urbanc
parents: 7
diff changeset
   330
  in Brzozowski method. But if the init-state is "{[]}" ("\<lambda>" itself) then 
1f8fe5bfd381 tried at the end to prove the other direction (failed at the moment)
urbanc
parents: 7
diff changeset
   331
  empty set is returned, see definition of "equation_rhs" 
1f8fe5bfd381 tried at the end to prove the other direction (failed at the moment)
urbanc
parents: 7
diff changeset
   332
*} 
1f8fe5bfd381 tried at the end to prove the other direction (failed at the moment)
urbanc
parents: 7
diff changeset
   333
6
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   334
definition 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   335
  empty_rhs :: "string set \<Rightarrow> t_equa_rhs"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   336
where
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   337
  "empty_rhs X \<equiv> if ([] \<in> X) then {({[]}, EMPTY)} else {}"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   338
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   339
definition 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   340
  folds :: "('a \<Rightarrow> 'b \<Rightarrow> 'b) \<Rightarrow> 'b \<Rightarrow> 'a set \<Rightarrow> 'b"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   341
where
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   342
  "folds f z S \<equiv> SOME x. fold_graph f z S x"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   343
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   344
definition 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   345
  equation_rhs :: "(string set) set \<Rightarrow> string set \<Rightarrow> t_equa_rhs"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   346
where
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   347
  "equation_rhs CS X \<equiv> if (X = {[]}) then {({[]}, EMPTY)}
23
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
   348
                         else {(S, folds ALT NULL {CHAR c| c. S-c\<rightarrow>X} )| S. S \<in> CS} \<union> empty_rhs X"
6
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   349
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   350
definition 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   351
  equations :: "(string set) set \<Rightarrow> t_equas"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   352
where
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   353
  "equations CS \<equiv> {(X, equation_rhs CS X) | X. X \<in> CS}"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   354
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   355
overloading L_rhs \<equiv> "L:: t_equa_rhs \<Rightarrow> string set"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   356
begin
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   357
fun L_rhs:: "t_equa_rhs \<Rightarrow> string set"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   358
where
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   359
  "L_rhs rhs = {x. \<exists> X r. (X, r) \<in> rhs \<and> x \<in> X;(L r)}"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   360
end
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   361
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   362
definition 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   363
  distinct_rhs :: "t_equa_rhs \<Rightarrow> bool"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   364
where
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   365
  "distinct_rhs rhs \<equiv> \<forall> X reg\<^isub>1 reg\<^isub>2. (X, reg\<^isub>1) \<in> rhs \<and> (X, reg\<^isub>2) \<in> rhs \<longrightarrow> reg\<^isub>1 = reg\<^isub>2"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   366
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   367
definition
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   368
  distinct_equas_rhs :: "t_equas \<Rightarrow> bool"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   369
where
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   370
  "distinct_equas_rhs equas \<equiv> \<forall> X rhs. (X, rhs) \<in> equas \<longrightarrow> distinct_rhs rhs"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   371
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   372
definition 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   373
  distinct_equas :: "t_equas \<Rightarrow> bool"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   374
where
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   375
  "distinct_equas equas \<equiv> \<forall> X rhs rhs'. (X, rhs) \<in> equas \<and> (X, rhs') \<in> equas \<longrightarrow> rhs = rhs'"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   376
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   377
definition 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   378
  seq_rhs_r :: "t_equa_rhs \<Rightarrow> rexp \<Rightarrow> t_equa_rhs"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   379
where
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   380
  "seq_rhs_r rhs r \<equiv> (\<lambda>(X, reg). (X, SEQ reg r)) ` rhs"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   381
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   382
definition 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   383
  del_x_paired :: "('a \<times> 'b) set \<Rightarrow> 'a \<Rightarrow> ('a \<times> 'b) set"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   384
where
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   385
  "del_x_paired S x \<equiv> S - {X. X \<in> S \<and> fst X = x}"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   386
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   387
definition
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   388
  arden_variate :: "string set \<Rightarrow> rexp \<Rightarrow> t_equa_rhs \<Rightarrow> t_equa_rhs"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   389
where
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   390
  "arden_variate X r rhs \<equiv> seq_rhs_r (del_x_paired rhs X) (STAR r)"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   391
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   392
definition
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   393
  no_EMPTY_rhs :: "t_equa_rhs \<Rightarrow> bool"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   394
where
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   395
  "no_EMPTY_rhs rhs \<equiv> \<forall> X r. (X, r) \<in> rhs \<and> X \<noteq> {[]} \<longrightarrow> [] \<notin> L r"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   396
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   397
definition 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   398
  no_EMPTY_equas :: "t_equas \<Rightarrow> bool"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   399
where
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   400
  "no_EMPTY_equas equas \<equiv> \<forall> X rhs. (X, rhs) \<in> equas \<longrightarrow> no_EMPTY_rhs rhs"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   401
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   402
lemma fold_alt_null_eqs:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   403
  "finite rS \<Longrightarrow> x \<in> L (folds ALT NULL rS) = (\<exists> r \<in> rS. x \<in> L r)"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   404
apply (simp add:folds_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   405
apply (rule someI2_ex)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   406
apply (erule finite_imp_fold_graph)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   407
apply (erule fold_graph.induct)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   408
by auto (*??? how do this be in Isar ?? *)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   409
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   410
lemma seq_rhs_r_prop1:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   411
  "L (seq_rhs_r rhs r) = (L rhs);(L r)"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   412
apply (auto simp:seq_rhs_r_def image_def lang_seq_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   413
apply (rule_tac x = "s1 @ s1a" in exI, rule_tac x = "s2a" in exI, simp)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   414
apply (rule_tac x = a in exI, rule_tac x = b in exI, simp)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   415
apply (rule_tac x = s1 in exI, rule_tac x = s1a in exI, simp)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   416
apply (rule_tac x = X in exI, rule_tac x  = "SEQ ra r" in exI, simp)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   417
apply (rule conjI)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   418
apply (rule_tac x = "(X, ra)" in bexI, simp+) 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   419
apply (rule_tac x = s1a in exI, rule_tac x = "s2a @ s2" in exI, simp)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   420
apply (simp add:lang_seq_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   421
by (rule_tac x = s2a in exI, rule_tac x = s2 in exI, simp)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   422
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   423
lemma del_x_paired_prop1:  
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   424
  "\<lbrakk>distinct_rhs rhs; (X, r) \<in> rhs\<rbrakk> \<Longrightarrow> X ; L r \<union> L (del_x_paired rhs X) = L rhs"
7
86167563a1ed deleted the matcher ate the beginning; made it to work with stable Isabelle and the development version
urbanc
parents: 6
diff changeset
   425
  apply (simp add:del_x_paired_def)
86167563a1ed deleted the matcher ate the beginning; made it to work with stable Isabelle and the development version
urbanc
parents: 6
diff changeset
   426
  apply (simp add: distinct_rhs_def)
86167563a1ed deleted the matcher ate the beginning; made it to work with stable Isabelle and the development version
urbanc
parents: 6
diff changeset
   427
  apply(auto simp add: lang_seq_def)
86167563a1ed deleted the matcher ate the beginning; made it to work with stable Isabelle and the development version
urbanc
parents: 6
diff changeset
   428
  apply(metis)
86167563a1ed deleted the matcher ate the beginning; made it to work with stable Isabelle and the development version
urbanc
parents: 6
diff changeset
   429
  done
6
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   430
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   431
lemma arden_variate_prop:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   432
  assumes "(X, rx) \<in> rhs"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   433
  shows "(\<forall> Y. Y \<noteq> X \<longrightarrow> (\<exists> r. (Y, r) \<in> rhs) = (\<exists> r. (Y, r) \<in> (arden_variate X rx rhs)))"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   434
proof (rule allI, rule impI)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   435
  fix Y
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   436
  assume "(1)": "Y \<noteq> X"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   437
  show "(\<exists>r. (Y, r) \<in> rhs) = (\<exists>r. (Y, r) \<in> arden_variate X rx rhs)"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   438
  proof
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   439
    assume "(1_1)": "\<exists>r. (Y, r) \<in> rhs"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   440
    show "\<exists>r. (Y, r) \<in> arden_variate X rx rhs" (is "\<exists>r. ?P r")
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   441
    proof -
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   442
      from "(1_1)" obtain r where "(Y, r) \<in> rhs" ..
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   443
      hence "?P (SEQ r (STAR rx))"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   444
      proof (simp add:arden_variate_def image_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   445
        have "(Y, r) \<in> rhs \<Longrightarrow> (Y, r) \<in> del_x_paired rhs X"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   446
          by (auto simp:del_x_paired_def "(1)")
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   447
        thus "(Y, r) \<in> rhs \<Longrightarrow> (Y, SEQ r (STAR rx)) \<in> seq_rhs_r (del_x_paired rhs X) (STAR rx)"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   448
          by (auto simp:seq_rhs_r_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   449
      qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   450
      thus ?thesis by blast
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   451
    qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   452
  next
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   453
    assume "(2_1)": "\<exists>r. (Y, r) \<in> arden_variate X rx rhs"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   454
    thus "\<exists>r. (Y, r) \<in> rhs" (is "\<exists> r. ?P r")
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   455
      by (auto simp:arden_variate_def del_x_paired_def seq_rhs_r_def image_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   456
  qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   457
qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   458
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   459
text {*
11
475dd40cd734 deleted two unnecessary lemmas
urbanc
parents: 8
diff changeset
   460
  arden_variate_valid:  proves variation from 
475dd40cd734 deleted two unnecessary lemmas
urbanc
parents: 8
diff changeset
   461
  
475dd40cd734 deleted two unnecessary lemmas
urbanc
parents: 8
diff changeset
   462
   "X = X;r + Y;ry + \<dots>" to "X = Y;(SEQ ry (STAR r)) + \<dots>" 
475dd40cd734 deleted two unnecessary lemmas
urbanc
parents: 8
diff changeset
   463
475dd40cd734 deleted two unnecessary lemmas
urbanc
parents: 8
diff changeset
   464
  holds the law of "language of left equiv language of right" 
6
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   465
*}
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   466
lemma arden_variate_valid:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   467
  assumes X_not_empty: "X \<noteq> {[]}"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   468
  and     l_eq_r:   "X = L rhs"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   469
  and     dist: "distinct_rhs rhs"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   470
  and     no_empty: "no_EMPTY_rhs rhs"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   471
  and     self_contained: "(X, r) \<in> rhs"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   472
  shows   "X = L (arden_variate X r rhs)" 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   473
proof -
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   474
  have "[] \<notin> L r" using no_empty X_not_empty self_contained
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   475
    by (auto simp:no_EMPTY_rhs_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   476
  hence ardens: "X = X;(L r) \<union> (L (del_x_paired rhs X)) \<longleftrightarrow> X = (L (del_x_paired rhs X)) ; (L r)\<star>" 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   477
    by (rule ardens_revised)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   478
  have del_x: "X = X ; L r \<union> L (del_x_paired rhs X) \<longleftrightarrow> X = L rhs" using dist l_eq_r self_contained
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   479
    by (auto dest!:del_x_paired_prop1)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   480
  show ?thesis
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   481
  proof
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   482
    show "X \<subseteq> L (arden_variate X r rhs)"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   483
    proof
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   484
      fix x
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   485
      assume "(1_1)": "x \<in> X" with l_eq_r ardens del_x
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   486
      show "x \<in> L (arden_variate X r rhs)" 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   487
        by (simp add:arden_variate_def seq_rhs_r_prop1 del:L_rhs.simps)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   488
    qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   489
  next
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   490
    show "L (arden_variate X r rhs) \<subseteq> X"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   491
    proof
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   492
      fix x
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   493
      assume "(2_1)": "x \<in> L (arden_variate X r rhs)" with ardens del_x l_eq_r
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   494
      show "x \<in> X" 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   495
        by (simp add:arden_variate_def seq_rhs_r_prop1 del:L_rhs.simps)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   496
    qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   497
  qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   498
qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   499
11
475dd40cd734 deleted two unnecessary lemmas
urbanc
parents: 8
diff changeset
   500
text {* 
23
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
   501
  merge_rhs {(x1, r1), (x2, r2}, (x4, r4), \<dots>} {(x1, r1'), (x3, r3'), \<dots>} = 
11
475dd40cd734 deleted two unnecessary lemmas
urbanc
parents: 8
diff changeset
   502
     {(x1, ALT r1 r1'}, (x2, r2), (x3, r3'), (x4, r4), \<dots>} *}  
6
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   503
definition 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   504
  merge_rhs :: "t_equa_rhs \<Rightarrow> t_equa_rhs \<Rightarrow> t_equa_rhs"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   505
where
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   506
  "merge_rhs rhs rhs' \<equiv> {(X, r). (\<exists> r1 r2. ((X,r1) \<in> rhs \<and> (X, r2) \<in> rhs') \<and> r = ALT r1 r2)  \<or>
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   507
                                 (\<exists> r1. (X, r1) \<in> rhs \<and> (\<not> (\<exists> r2. (X, r2) \<in> rhs')) \<and> r = r1) \<or>
23
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
   508
                                 (\<exists> r2. (X, r2) \<in> rhs' \<and> (\<not> (\<exists> r1. (X, r1) \<in> rhs)) \<and> r = r2)    }"                                  
6
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   509
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   510
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   511
text {* rhs_subst rhs X=xrhs r: substitude all occurence of X in rhs((X,r) \<in> rhs) with xrhs *}
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   512
definition 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   513
  rhs_subst :: "t_equa_rhs \<Rightarrow> string set \<Rightarrow> t_equa_rhs \<Rightarrow> rexp \<Rightarrow> t_equa_rhs"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   514
where
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   515
  "rhs_subst rhs X xrhs r \<equiv> merge_rhs (del_x_paired rhs X) (seq_rhs_r xrhs r)"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   516
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   517
definition 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   518
  equas_subst_f :: "string set \<Rightarrow> t_equa_rhs \<Rightarrow> t_equa \<Rightarrow> t_equa"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   519
where
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   520
  "equas_subst_f X xrhs equa \<equiv> let (Y, rhs) = equa in
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   521
                                 if (\<exists> r. (X, r) \<in> rhs)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   522
                                 then (Y, rhs_subst rhs X xrhs (SOME r. (X, r) \<in> rhs))
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   523
                                 else equa"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   524
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   525
definition
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   526
  equas_subst :: "t_equas \<Rightarrow> string set \<Rightarrow> t_equa_rhs \<Rightarrow> t_equas"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   527
where
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   528
  "equas_subst ES X xrhs \<equiv> del_x_paired (equas_subst_f X xrhs ` ES) X"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   529
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   530
lemma lang_seq_prop1:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   531
 "x \<in> X ; L r \<Longrightarrow> x \<in> X ; (L r \<union> L r')"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   532
by (auto simp:lang_seq_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   533
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   534
lemma lang_seq_prop1':
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   535
  "x \<in> X; L r \<Longrightarrow> x \<in> X ; (L r' \<union> L r)"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   536
by (auto simp:lang_seq_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   537
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   538
lemma lang_seq_prop2:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   539
  "x \<in> X; (L r \<union> L r') \<Longrightarrow> x \<in> X;L r \<or> x \<in> X;L r'"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   540
by (auto simp:lang_seq_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   541
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   542
lemma merge_rhs_prop1:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   543
  shows "L (merge_rhs rhs rhs') = L rhs \<union> L rhs' "
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   544
apply (auto simp add:merge_rhs_def dest!:lang_seq_prop2 intro:lang_seq_prop1)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   545
apply (rule_tac x = X in exI, rule_tac x = r1 in exI, simp)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   546
apply (case_tac "\<exists> r2. (X, r2) \<in> rhs'")
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   547
apply (clarify, rule_tac x = X in exI, rule_tac x = "ALT r r2" in exI, simp add:lang_seq_prop1)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   548
apply (rule_tac x = X in exI, rule_tac x = r in exI, simp)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   549
apply (case_tac "\<exists> r1. (X, r1) \<in> rhs")
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   550
apply (clarify, rule_tac x = X in exI, rule_tac x = "ALT r1 r" in exI, simp add:lang_seq_prop1')
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   551
apply (rule_tac x = X in exI, rule_tac x = r in exI, simp)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   552
done
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   553
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   554
lemma no_EMPTY_rhss_imp_merge_no_EMPTY:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   555
  "\<lbrakk>no_EMPTY_rhs rhs; no_EMPTY_rhs rhs'\<rbrakk> \<Longrightarrow> no_EMPTY_rhs (merge_rhs rhs rhs')"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   556
apply (simp add:no_EMPTY_rhs_def merge_rhs_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   557
apply (clarify, (erule conjE | erule exE | erule disjE)+)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   558
by auto
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   559
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   560
lemma distinct_rhs_prop:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   561
  "\<lbrakk>distinct_rhs rhs; (X, r1) \<in> rhs; (X, r2) \<in> rhs\<rbrakk> \<Longrightarrow> r1 = r2"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   562
by (auto simp:distinct_rhs_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   563
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   564
lemma merge_rhs_prop2:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   565
  assumes dist_rhs: "distinct_rhs rhs"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   566
  and     dist_rhs':"distinct_rhs rhs'"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   567
  shows "distinct_rhs (merge_rhs rhs rhs')"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   568
apply (auto simp:merge_rhs_def distinct_rhs_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   569
using dist_rhs
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   570
apply (drule distinct_rhs_prop, simp+)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   571
using dist_rhs'
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   572
apply (drule distinct_rhs_prop, simp+)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   573
using dist_rhs
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   574
apply (drule distinct_rhs_prop, simp+)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   575
using dist_rhs'
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   576
apply (drule distinct_rhs_prop, simp+)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   577
done
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   578
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   579
lemma seq_rhs_r_holds_distinct: 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   580
  "distinct_rhs rhs \<Longrightarrow> distinct_rhs (seq_rhs_r rhs r)"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   581
by (auto simp:distinct_rhs_def seq_rhs_r_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   582
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   583
lemma seq_rhs_r_prop0:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   584
  assumes l_eq_r: "X = L xrhs"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   585
  shows "L (seq_rhs_r xrhs r) = X ; L r "
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   586
using l_eq_r
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   587
by (auto simp only:seq_rhs_r_prop1)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   588
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   589
lemma rhs_subst_prop1:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   590
  assumes l_eq_r: "X = L xrhs"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   591
  and     dist:  "distinct_rhs rhs"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   592
  shows "(X, r) \<in> rhs \<Longrightarrow> L rhs = L (rhs_subst rhs X xrhs r)"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   593
apply (simp add:rhs_subst_def merge_rhs_prop1 del:L_rhs.simps)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   594
using l_eq_r 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   595
apply (drule_tac r = r in seq_rhs_r_prop0, simp del:L_rhs.simps)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   596
using dist
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   597
by (auto dest!:del_x_paired_prop1 simp del:L_rhs.simps)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   598
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   599
lemma del_x_paired_holds_distinct_rhs:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   600
  "distinct_rhs rhs \<Longrightarrow> distinct_rhs (del_x_paired rhs x)"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   601
by (auto simp:distinct_rhs_def del_x_paired_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   602
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   603
lemma rhs_subst_holds_distinct_rhs:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   604
  "\<lbrakk>distinct_rhs rhs; distinct_rhs xrhs\<rbrakk> \<Longrightarrow> distinct_rhs (rhs_subst rhs X xrhs r)"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   605
apply (drule_tac r = r and rhs = xrhs in seq_rhs_r_holds_distinct)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   606
apply (drule_tac x = X in del_x_paired_holds_distinct_rhs)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   607
by (auto dest:merge_rhs_prop2[where rhs = "del_x_paired rhs X"] simp:rhs_subst_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   608
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   609
section {* myhill-nerode theorem *}
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   610
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   611
definition left_eq_cls :: "t_equas \<Rightarrow> (string set) set"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   612
where
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   613
  "left_eq_cls ES \<equiv> {X. \<exists> rhs. (X, rhs) \<in> ES} "
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   614
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   615
definition right_eq_cls :: "t_equas \<Rightarrow> (string set) set"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   616
where
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   617
  "right_eq_cls ES \<equiv> {Y. \<exists> X rhs r. (X, rhs) \<in> ES \<and> (Y, r) \<in> rhs }"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   618
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   619
definition rhs_eq_cls :: "t_equa_rhs \<Rightarrow> (string set) set"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   620
where
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   621
  "rhs_eq_cls rhs \<equiv> {Y. \<exists> r. (Y, r) \<in> rhs}"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   622
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   623
definition ardenable :: "t_equa \<Rightarrow> bool"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   624
where
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   625
  "ardenable equa \<equiv> let (X, rhs) = equa in 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   626
                      distinct_rhs rhs \<and> no_EMPTY_rhs rhs \<and> X = L rhs"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   627
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   628
text {*
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   629
  Inv: Invairance of the equation-system, during the decrease of the equation-system, Inv holds.
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   630
*}
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   631
definition Inv :: "string set \<Rightarrow> t_equas \<Rightarrow> bool"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   632
where
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   633
  "Inv X ES \<equiv> finite ES \<and> (\<exists> rhs. (X, rhs) \<in> ES) \<and> distinct_equas ES \<and> 
23
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
   634
            (\<forall> X xrhs. (X, xrhs) \<in> ES \<longrightarrow> ardenable (X, xrhs) \<and> X \<noteq> {} \<and> rhs_eq_cls xrhs \<subseteq> insert {[]} (left_eq_cls ES))"
6
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   635
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   636
text {*
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   637
  TCon: Termination Condition of the equation-system decreasion.
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   638
*}
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   639
definition TCon:: "'a set \<Rightarrow> bool"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   640
where
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   641
  "TCon ES \<equiv> card ES = 1"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   642
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   643
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   644
text {* 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   645
  The following is a iteration principle, and is the main framework for the proof:
23
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
   646
   1: We can form the initial equation-system using "equations" defined above, and prove it has invariance Inv by lemma "init_ES_satisfy_Inv";
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
   647
   2: We can decrease the number of the equation-system using ardens_lemma_revised and substitution ("equas_subst", defined above), 
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
   648
        and prove it holds the property "step" in "wf_iter" by lemma "iteration_step"
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
   649
   and finally using property Inv and TCon to prove the myhill-nerode theorem
6
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   650
  
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   651
*}
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   652
lemma wf_iter [rule_format]: 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   653
  fixes f
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   654
  assumes step: "\<And> e. \<lbrakk>P e; \<not> Q e\<rbrakk> \<Longrightarrow> (\<exists> e'. P e' \<and>  (f(e'), f(e)) \<in> less_than)"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   655
  shows pe:     "P e \<longrightarrow> (\<exists> e'. P e' \<and>  Q e')"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   656
proof(induct e rule: wf_induct 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   657
           [OF wf_inv_image[OF wf_less_than, where f = "f"]], clarify)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   658
  fix x 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   659
  assume h [rule_format]: 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   660
    "\<forall>y. (y, x) \<in> inv_image less_than f \<longrightarrow> P y \<longrightarrow> (\<exists>e'. P e' \<and> Q e')"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   661
    and px: "P x"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   662
  show "\<exists>e'. P e' \<and> Q e'"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   663
  proof(cases "Q x")
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   664
    assume "Q x" with px show ?thesis by blast
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   665
  next
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   666
    assume nq: "\<not> Q x"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   667
    from step [OF px nq]
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   668
    obtain e' where pe': "P e'" and ltf: "(f e', f x) \<in> less_than" by auto
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   669
    show ?thesis
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   670
    proof(rule h)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   671
      from ltf show "(e', x) \<in> inv_image less_than f" 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   672
	by (simp add:inv_image_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   673
    next
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   674
      from pe' show "P e'" .
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   675
    qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   676
  qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   677
qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   678
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   679
11
475dd40cd734 deleted two unnecessary lemmas
urbanc
parents: 8
diff changeset
   680
text {* ******BEGIN: proving the initial equation-system satisfies Inv ****** *}
6
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   681
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   682
lemma distinct_rhs_equations:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   683
  "(X, xrhs) \<in> equations (UNIV Quo Lang) \<Longrightarrow> distinct_rhs xrhs"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   684
by (auto simp: equations_def equation_rhs_def distinct_rhs_def empty_rhs_def dest:no_two_cls_inters)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   685
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   686
lemma every_nonempty_eqclass_has_strings:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   687
  "\<lbrakk>X \<in> (UNIV Quo Lang); X \<noteq> {[]}\<rbrakk> \<Longrightarrow> \<exists> clist. clist \<in> X \<and> clist \<noteq> []"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   688
by (auto simp:quot_def equiv_class_def equiv_str_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   689
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   690
lemma every_eqclass_is_derived_from_empty:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   691
  assumes not_empty: "X \<noteq> {[]}"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   692
  shows "X \<in> (UNIV Quo Lang) \<Longrightarrow> \<exists> clist. {[]};{clist} \<subseteq> X \<and> clist \<noteq> []"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   693
using not_empty
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   694
apply (drule_tac every_nonempty_eqclass_has_strings, simp)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   695
by (auto intro:exI[where x = clist] simp:lang_seq_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   696
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   697
lemma equiv_str_in_CS:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   698
  "\<lbrakk>clist\<rbrakk>Lang \<in> (UNIV Quo Lang)"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   699
by (auto simp:quot_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   700
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   701
lemma has_str_imp_defined_by_str:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   702
  "\<lbrakk>str \<in> X; X \<in> UNIV Quo Lang\<rbrakk> \<Longrightarrow> X = \<lbrakk>str\<rbrakk>Lang"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   703
by (auto simp:quot_def equiv_class_def equiv_str_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   704
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   705
lemma every_eqclass_has_ascendent:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   706
  assumes has_str: "clist @ [c] \<in> X"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   707
  and     in_CS:   "X \<in> UNIV Quo Lang"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   708
  shows "\<exists> Y. Y \<in> UNIV Quo Lang \<and> Y-c\<rightarrow>X \<and> clist \<in> Y" (is "\<exists> Y. ?P Y")
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   709
proof -
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   710
  have "?P (\<lbrakk>clist\<rbrakk>Lang)" 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   711
  proof -
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   712
    have "\<lbrakk>clist\<rbrakk>Lang \<in> UNIV Quo Lang"       
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   713
      by (simp add:quot_def, rule_tac x = clist in exI, simp)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   714
    moreover have "\<lbrakk>clist\<rbrakk>Lang-c\<rightarrow>X" 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   715
    proof -
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   716
      have "X = \<lbrakk>(clist @ [c])\<rbrakk>Lang" using has_str in_CS
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   717
        by (auto intro!:has_str_imp_defined_by_str)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   718
      moreover have "\<forall> sl. sl \<in> \<lbrakk>clist\<rbrakk>Lang \<longrightarrow> sl @ [c] \<in> \<lbrakk>(clist @ [c])\<rbrakk>Lang"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   719
        by (auto simp:equiv_class_def equiv_str_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   720
      ultimately show ?thesis unfolding CT_def lang_seq_def
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   721
        by auto
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   722
    qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   723
    moreover have "clist \<in> \<lbrakk>clist\<rbrakk>Lang" 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   724
      by (auto simp:equiv_str_def equiv_class_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   725
    ultimately show "?P (\<lbrakk>clist\<rbrakk>Lang)" by simp
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   726
  qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   727
  thus ?thesis by blast
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   728
qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   729
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   730
lemma finite_charset_rS:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   731
  "finite {CHAR c |c. Y-c\<rightarrow>X}"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   732
by (rule_tac A = UNIV and f = CHAR in finite_surj, auto)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   733
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   734
lemma l_eq_r_in_equations:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   735
  assumes X_in_equas: "(X, xrhs) \<in> equations (UNIV Quo Lang)"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   736
  shows "X = L xrhs"    
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   737
proof (cases "X = {[]}")
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   738
  case True
18
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
   739
  thus ?thesis using X_in_equas 
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
   740
    by (simp add:equations_def equation_rhs_def lang_seq_def)
6
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   741
next
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   742
  case False 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   743
  show ?thesis
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   744
  proof 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   745
    show "X \<subseteq> L xrhs"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   746
    proof
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   747
      fix x
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   748
      assume "(1)": "x \<in> X"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   749
      show "x \<in> L xrhs"          
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   750
      proof (cases "x = []")
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   751
        assume empty: "x = []"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   752
        hence "x \<in> L (empty_rhs X)" using "(1)"
18
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
   753
          by (auto simp:empty_rhs_def lang_seq_def)
6
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   754
        thus ?thesis using X_in_equas False empty "(1)" 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   755
          unfolding equations_def equation_rhs_def by auto
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   756
      next
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   757
        assume not_empty: "x \<noteq> []"
18
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
   758
        hence "\<exists> clist c. x = clist @ [c]" by (case_tac x rule:rev_cases, auto)
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
   759
        then obtain clist c where decom: "x = clist @ [c]" by blast
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
   760
        moreover have "\<And> Y. \<lbrakk>Y \<in> UNIV Quo Lang; Y-c\<rightarrow>X; clist \<in> Y\<rbrakk>
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
   761
          \<Longrightarrow> [c] \<in> L (folds ALT NULL {CHAR c |c. Y-c\<rightarrow>X})"
6
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   762
        proof -
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   763
          fix Y
18
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
   764
          assume Y_is_eq_cl: "Y \<in> UNIV Quo Lang"
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
   765
            and Y_CT_X: "Y-c\<rightarrow>X"
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
   766
            and clist_in_Y: "clist \<in> Y"
6
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   767
          with finite_charset_rS 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   768
          show "[c] \<in> L (folds ALT NULL {CHAR c |c. Y-c\<rightarrow>X})"
18
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
   769
            by (auto simp :fold_alt_null_eqs)
6
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   770
        qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   771
        hence "\<exists>Xa. Xa \<in> UNIV Quo Lang \<and> clist @ [c] \<in> Xa ; L (folds ALT NULL {CHAR c |c. Xa-c\<rightarrow>X})" 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   772
          using X_in_equas False not_empty "(1)" decom
18
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
   773
          by (auto dest!:every_eqclass_has_ascendent simp:equations_def equation_rhs_def lang_seq_def)
11
475dd40cd734 deleted two unnecessary lemmas
urbanc
parents: 8
diff changeset
   774
        then obtain Xa where 
18
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
   775
          "Xa \<in> UNIV Quo Lang \<and> clist @ [c] \<in> Xa ; L (folds ALT NULL {CHAR c |c. Xa-c\<rightarrow>X})" by blast
11
475dd40cd734 deleted two unnecessary lemmas
urbanc
parents: 8
diff changeset
   776
        hence "x \<in> L {(S, folds ALT NULL {CHAR c |c. S-c\<rightarrow>X}) |S. S \<in> UNIV Quo Lang}" 
475dd40cd734 deleted two unnecessary lemmas
urbanc
parents: 8
diff changeset
   777
          using X_in_equas "(1)" decom
6
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   778
          by (auto simp add:equations_def equation_rhs_def intro!:exI[where x = Xa])
18
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
   779
        thus "x \<in> L xrhs" using X_in_equas False not_empty unfolding equations_def equation_rhs_def
6
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   780
          by auto
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   781
      qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   782
    qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   783
  next
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   784
    show "L xrhs \<subseteq> X"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   785
    proof
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   786
      fix x 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   787
      assume "(2)": "x \<in> L xrhs"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   788
      have "(2_1)": "\<And> s1 s2 r Xa. \<lbrakk>s1 \<in> Xa; s2 \<in> L (folds ALT NULL {CHAR c |c. Xa-c\<rightarrow>X})\<rbrakk> \<Longrightarrow> s1 @ s2 \<in> X"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   789
        using finite_charset_rS
18
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
   790
        by (auto simp:CT_def lang_seq_def fold_alt_null_eqs)
6
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   791
      have "(2_2)": "\<And> s1 s2 Xa r.\<lbrakk>s1 \<in> Xa; s2 \<in> L r; (Xa, r) \<in> empty_rhs X\<rbrakk> \<Longrightarrow> s1 @ s2 \<in> X"
18
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
   792
        by (simp add:empty_rhs_def split:if_splits)
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
   793
      show "x \<in> X" using X_in_equas False "(2)"         
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
   794
        by (auto intro:"(2_1)" "(2_2)" simp:equations_def equation_rhs_def lang_seq_def)
6
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   795
    qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   796
  qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   797
qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   798
11
475dd40cd734 deleted two unnecessary lemmas
urbanc
parents: 8
diff changeset
   799
6
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   800
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   801
lemma no_EMPTY_equations:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   802
  "(X, xrhs) \<in> equations CS \<Longrightarrow> no_EMPTY_rhs xrhs"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   803
apply (clarsimp simp add:equations_def equation_rhs_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   804
apply (simp add:no_EMPTY_rhs_def empty_rhs_def, auto)
23
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
   805
apply (subgoal_tac "finite {CHAR c |c. Xa-c\<rightarrow>X}", drule_tac x = "[]" in fold_alt_null_eqs, clarsimp, rule finite_charset_rS)+
6
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   806
done
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   807
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   808
lemma init_ES_satisfy_ardenable:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   809
  "(X, xrhs) \<in> equations (UNIV Quo Lang)  \<Longrightarrow> ardenable (X, xrhs)"  
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   810
  unfolding ardenable_def
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   811
  by (auto intro:distinct_rhs_equations no_EMPTY_equations simp:l_eq_r_in_equations simp del:L_rhs.simps)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   812
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   813
lemma init_ES_satisfy_Inv:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   814
  assumes finite_CS: "finite (UNIV Quo Lang)"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   815
  and X_in_eq_cls: "X \<in> UNIV Quo Lang"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   816
  shows "Inv X (equations (UNIV Quo Lang))"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   817
proof -
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   818
  have "finite (equations (UNIV Quo Lang))" using finite_CS
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   819
    by (auto simp:equations_def)    
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   820
  moreover have "\<exists>rhs. (X, rhs) \<in> equations (UNIV Quo Lang)" using X_in_eq_cls 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   821
    by (simp add:equations_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   822
  moreover have "distinct_equas (equations (UNIV Quo Lang))" 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   823
    by (auto simp:distinct_equas_def equations_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   824
  moreover have "\<forall>X xrhs. (X, xrhs) \<in> equations (UNIV Quo Lang) \<longrightarrow>
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   825
                 rhs_eq_cls xrhs \<subseteq> insert {[]} (left_eq_cls (equations (UNIV Quo Lang)))" 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   826
    apply (simp add:left_eq_cls_def equations_def rhs_eq_cls_def equation_rhs_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   827
    by (auto simp:empty_rhs_def split:if_splits)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   828
  moreover have "\<forall>X xrhs. (X, xrhs) \<in> equations (UNIV Quo Lang) \<longrightarrow> X \<noteq> {}"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   829
    by (clarsimp simp:equations_def empty_notin_CS intro:classical)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   830
  moreover have "\<forall>X xrhs. (X, xrhs) \<in> equations (UNIV Quo Lang) \<longrightarrow> ardenable (X, xrhs)"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   831
    by (auto intro!:init_ES_satisfy_ardenable)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   832
  ultimately show ?thesis by (simp add:Inv_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   833
qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   834
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   835
11
475dd40cd734 deleted two unnecessary lemmas
urbanc
parents: 8
diff changeset
   836
text {* *********** END: proving the initial equation-system satisfies Inv ******* *}
6
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   837
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   838
11
475dd40cd734 deleted two unnecessary lemmas
urbanc
parents: 8
diff changeset
   839
text {* ****** BEGIN: proving every equation-system's iteration step satisfies Inv ***** *}
6
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   840
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   841
lemma not_T_aux: "\<lbrakk>\<not> TCon (insert a A); x = a\<rbrakk>
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   842
       \<Longrightarrow> \<exists>y. x \<noteq> y \<and> y \<in> insert a A "
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   843
apply (case_tac "insert a A = {a}")
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   844
by (auto simp:TCon_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   845
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   846
lemma not_T_atleast_2[rule_format]:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   847
  "finite S \<Longrightarrow> \<forall> x. x \<in> S \<and> (\<not> TCon S)\<longrightarrow> (\<exists> y. x \<noteq> y \<and> y \<in> S)"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   848
apply (erule finite.induct, simp)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   849
apply (clarify, case_tac "x = a")
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   850
by (erule not_T_aux, auto)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   851
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   852
lemma exist_another_equa: 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   853
  "\<lbrakk>\<not> TCon ES; finite ES; distinct_equas ES; (X, rhl) \<in> ES\<rbrakk> \<Longrightarrow> \<exists> Y yrhl. (Y, yrhl) \<in> ES \<and> X \<noteq> Y"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   854
apply (drule not_T_atleast_2, simp)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   855
apply (clarsimp simp:distinct_equas_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   856
apply (drule_tac x= X in spec, drule_tac x = rhl in spec, drule_tac x = b in spec)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   857
by auto
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   858
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   859
lemma Inv_mono_with_lambda:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   860
  assumes Inv_ES: "Inv X ES"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   861
  and X_noteq_Y:  "X \<noteq> {[]}"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   862
  shows "Inv X (ES - {({[]}, yrhs)})"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   863
proof -
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   864
  have "finite (ES - {({[]}, yrhs)})" using Inv_ES
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   865
    by (simp add:Inv_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   866
  moreover have "\<exists>rhs. (X, rhs) \<in> ES - {({[]}, yrhs)}" using Inv_ES X_noteq_Y
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   867
    by (simp add:Inv_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   868
  moreover have "distinct_equas (ES - {({[]}, yrhs)})" using Inv_ES X_noteq_Y
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   869
    apply (clarsimp simp:Inv_def distinct_equas_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   870
    by (drule_tac x = Xa in spec, simp)    
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   871
  moreover have "\<forall>X xrhs.(X, xrhs) \<in> ES - {({[]}, yrhs)} \<longrightarrow>
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   872
                          ardenable (X, xrhs) \<and> X \<noteq> {}" using Inv_ES
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   873
    by (clarify, simp add:Inv_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   874
  moreover 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   875
  have "insert {[]} (left_eq_cls (ES - {({[]}, yrhs)})) = insert {[]} (left_eq_cls ES)"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   876
    by (auto simp:left_eq_cls_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   877
  hence "\<forall>X xrhs.(X, xrhs) \<in> ES - {({[]}, yrhs)} \<longrightarrow>
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   878
                          rhs_eq_cls xrhs \<subseteq> insert {[]} (left_eq_cls (ES - {({[]}, yrhs)}))"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   879
    using Inv_ES by (auto simp:Inv_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   880
  ultimately show ?thesis by (simp add:Inv_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   881
qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   882
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   883
lemma non_empty_card_prop:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   884
  "finite ES \<Longrightarrow> \<forall>e. e \<in> ES \<longrightarrow> card ES - Suc 0 < card ES"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   885
apply (erule finite.induct, simp)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   886
apply (case_tac[!] "a \<in> A")
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   887
by (auto simp:insert_absorb)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   888
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   889
lemma ardenable_prop:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   890
  assumes not_lambda: "Y \<noteq> {[]}"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   891
  and ardable: "ardenable (Y, yrhs)"
23
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
   892
  shows "\<exists> yrhs'. Y = L yrhs' \<and> distinct_rhs yrhs' \<and> rhs_eq_cls yrhs' = rhs_eq_cls yrhs - {Y}" (is "\<exists> yrhs'. ?P yrhs'")
6
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   893
proof (cases "(\<exists> reg. (Y, reg) \<in> yrhs)")
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   894
  case True
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   895
  thus ?thesis 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   896
  proof 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   897
    fix reg
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   898
    assume self_contained: "(Y, reg) \<in> yrhs"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   899
    show ?thesis 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   900
    proof -
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   901
      have "?P (arden_variate Y reg yrhs)"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   902
      proof -
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   903
        have "Y = L (arden_variate Y reg yrhs)" 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   904
          using self_contained not_lambda ardable
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   905
          by (rule_tac arden_variate_valid, simp_all add:ardenable_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   906
        moreover have "distinct_rhs (arden_variate Y reg yrhs)" 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   907
          using ardable 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   908
          by (auto simp:distinct_rhs_def arden_variate_def seq_rhs_r_def del_x_paired_def ardenable_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   909
        moreover have "rhs_eq_cls (arden_variate Y reg yrhs) = rhs_eq_cls yrhs - {Y}"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   910
        proof -
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   911
          have "\<And> rhs r. rhs_eq_cls (seq_rhs_r rhs r) = rhs_eq_cls rhs"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   912
            apply (auto simp:rhs_eq_cls_def seq_rhs_r_def image_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   913
            by (rule_tac x = "SEQ ra r" in exI, rule_tac x = "(x, ra)" in bexI, simp+)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   914
          moreover have "\<And> rhs X. rhs_eq_cls (del_x_paired rhs X) = rhs_eq_cls rhs - {X}"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   915
            by (auto simp:rhs_eq_cls_def del_x_paired_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   916
          ultimately show ?thesis by (simp add:arden_variate_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   917
        qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   918
        ultimately show ?thesis by simp
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   919
      qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   920
      thus ?thesis by (rule_tac x= "arden_variate Y reg yrhs" in exI, simp)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   921
    qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   922
  qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   923
next
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   924
  case False
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   925
  hence "(2)": "rhs_eq_cls yrhs - {Y} = rhs_eq_cls yrhs"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   926
    by (auto simp:rhs_eq_cls_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   927
  show ?thesis 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   928
  proof -
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   929
    have "?P yrhs" using False ardable "(2)" 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   930
      by (simp add:ardenable_def)      
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   931
    thus ?thesis by blast
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   932
  qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   933
qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   934
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   935
lemma equas_subst_f_del_no_other:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   936
  assumes self_contained: "(Y, rhs) \<in> ES"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   937
  shows "\<exists> rhs'. (Y, rhs') \<in> (equas_subst_f X xrhs ` ES)" (is "\<exists> rhs'. ?P rhs'")
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   938
proof -
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   939
  have "\<exists> rhs'. equas_subst_f X xrhs (Y, rhs) = (Y, rhs')"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   940
    by (auto simp:equas_subst_f_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   941
  then obtain rhs' where "equas_subst_f X xrhs (Y, rhs) = (Y, rhs')" by blast
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   942
  hence "?P rhs'" unfolding image_def using self_contained
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   943
    by (auto intro:bexI[where x = "(Y, rhs)"])
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   944
  thus ?thesis by blast
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   945
qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   946
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   947
lemma del_x_paired_del_only_x: 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   948
  "\<lbrakk>X \<noteq> Y; (X, rhs) \<in> ES\<rbrakk> \<Longrightarrow> (X, rhs) \<in> del_x_paired ES Y"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   949
by (auto simp:del_x_paired_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   950
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   951
lemma equas_subst_del_no_other:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   952
 "\<lbrakk>(X, rhs) \<in> ES; X \<noteq> Y\<rbrakk> \<Longrightarrow> (\<exists>rhs. (X, rhs) \<in> equas_subst ES Y rhs')"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   953
unfolding equas_subst_def
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   954
apply (drule_tac X = Y and xrhs = rhs' in equas_subst_f_del_no_other)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   955
by (erule exE, drule del_x_paired_del_only_x, auto)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   956
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   957
lemma equas_subst_holds_distinct:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   958
  "distinct_equas ES \<Longrightarrow> distinct_equas (equas_subst ES Y rhs')"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   959
apply (clarsimp simp add:equas_subst_def distinct_equas_def del_x_paired_def equas_subst_f_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   960
by (auto split:if_splits)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   961
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   962
lemma del_x_paired_dels: 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   963
  "(X, rhs) \<in> ES \<Longrightarrow> {Y. Y \<in> ES \<and> fst Y = X} \<inter> ES \<noteq> {}"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   964
by (auto)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   965
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   966
lemma del_x_paired_subset:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   967
  "(X, rhs) \<in> ES \<Longrightarrow> ES - {Y. Y \<in> ES \<and> fst Y = X} \<subset> ES"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   968
apply (drule del_x_paired_dels)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   969
by auto
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   970
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   971
lemma del_x_paired_card_less: 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   972
  "\<lbrakk>finite ES; (X, rhs) \<in> ES\<rbrakk> \<Longrightarrow> card (del_x_paired ES X) < card ES"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   973
apply (simp add:del_x_paired_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   974
apply (drule del_x_paired_subset)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   975
by (auto intro:psubset_card_mono)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   976
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   977
lemma equas_subst_card_less:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   978
  "\<lbrakk>finite ES; (Y, yrhs) \<in> ES\<rbrakk> \<Longrightarrow> card (equas_subst ES Y rhs') < card ES"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   979
apply (simp add:equas_subst_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   980
apply (frule_tac h = "equas_subst_f Y rhs'" in finite_imageI)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   981
apply (drule_tac f = "equas_subst_f Y rhs'" in Finite_Set.card_image_le)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   982
apply (drule_tac X = Y and xrhs = rhs' in equas_subst_f_del_no_other,erule exE)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   983
by (drule del_x_paired_card_less, auto)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   984
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   985
lemma equas_subst_holds_distinct_rhs:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   986
  assumes   dist': "distinct_rhs yrhs'"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   987
  and     history: "\<forall>X xrhs. (X, xrhs) \<in> ES \<longrightarrow> ardenable (X, xrhs)"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   988
  and     X_in :  "(X, xrhs) \<in> equas_subst ES Y yrhs'"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   989
  shows "distinct_rhs xrhs"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   990
using X_in history
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   991
apply (clarsimp simp:equas_subst_def del_x_paired_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   992
apply (drule_tac x = a in spec, drule_tac x = b in spec)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   993
apply (simp add:ardenable_def equas_subst_f_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   994
by (auto intro:rhs_subst_holds_distinct_rhs simp:dist' split:if_splits)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   995
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   996
lemma r_no_EMPTY_imp_seq_rhs_r_no_EMPTY:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   997
  "[] \<notin> L r \<Longrightarrow> no_EMPTY_rhs (seq_rhs_r rhs r)"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   998
by (auto simp:no_EMPTY_rhs_def seq_rhs_r_def lang_seq_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   999
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1000
lemma del_x_paired_holds_no_EMPTY:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1001
  "no_EMPTY_rhs yrhs \<Longrightarrow> no_EMPTY_rhs (del_x_paired yrhs Y)"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1002
by (auto simp:no_EMPTY_rhs_def del_x_paired_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1003
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1004
lemma rhs_subst_holds_no_EMPTY:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1005
  "\<lbrakk>no_EMPTY_rhs yrhs; (Y, r) \<in> yrhs; Y \<noteq> {[]}\<rbrakk> \<Longrightarrow> no_EMPTY_rhs (rhs_subst yrhs Y rhs' r)"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1006
apply (auto simp:rhs_subst_def intro!:no_EMPTY_rhss_imp_merge_no_EMPTY r_no_EMPTY_imp_seq_rhs_r_no_EMPTY del_x_paired_holds_no_EMPTY)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1007
by (auto simp:no_EMPTY_rhs_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1008
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1009
lemma equas_subst_holds_no_EMPTY:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1010
  assumes substor: "Y \<noteq> {[]}"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1011
  and history: "\<forall>X xrhs. (X, xrhs) \<in> ES \<longrightarrow> ardenable (X, xrhs)"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1012
  and X_in:"(X, xrhs) \<in> equas_subst ES Y yrhs'"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1013
  shows "no_EMPTY_rhs xrhs"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1014
proof-
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1015
  from X_in have "\<exists> (Z, zrhs) \<in> ES. (X, xrhs) = equas_subst_f Y yrhs' (Z, zrhs)"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1016
    by (auto simp add:equas_subst_def del_x_paired_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1017
  then obtain Z zrhs where Z_in: "(Z, zrhs) \<in> ES"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1018
                       and X_Z: "(X, xrhs) = equas_subst_f Y yrhs' (Z, zrhs)" by blast
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1019
  hence dist_zrhs: "distinct_rhs zrhs" using history
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1020
    by (auto simp:ardenable_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1021
  show ?thesis
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1022
  proof (cases "\<exists> r. (Y, r) \<in> zrhs")
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1023
    case True
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1024
    then obtain r where Y_in_zrhs: "(Y, r) \<in> zrhs" ..
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1025
    hence some: "(SOME r. (Y, r) \<in> zrhs) = r" using Z_in dist_zrhs
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1026
      by (auto simp:distinct_rhs_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1027
    hence "no_EMPTY_rhs (rhs_subst zrhs Y yrhs' r)"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1028
      using substor Y_in_zrhs history Z_in
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1029
      by (rule_tac rhs_subst_holds_no_EMPTY, auto simp:ardenable_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1030
    thus ?thesis using X_Z True some
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1031
      by (simp add:equas_subst_def equas_subst_f_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1032
  next
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1033
    case False
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1034
    hence "(X, xrhs) = (Z, zrhs)" using Z_in X_Z
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1035
      by (simp add:equas_subst_f_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1036
    thus ?thesis using history Z_in
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1037
      by (auto simp:ardenable_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1038
  qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1039
qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1040
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1041
lemma equas_subst_f_holds_left_eq_right:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1042
  assumes substor: "Y = L rhs'"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1043
  and     history: "\<forall>X xrhs. (X, xrhs) \<in> ES \<longrightarrow> distinct_rhs xrhs \<and> X = L xrhs"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1044
  and       subst: "(X, xrhs) = equas_subst_f Y rhs' (Z, zrhs)"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1045
  and     self_contained: "(Z, zrhs) \<in> ES"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1046
  shows "X = L xrhs"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1047
proof (cases "\<exists> r. (Y, r) \<in> zrhs")
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1048
  case True
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1049
  from True obtain r where "(1)":"(Y, r) \<in> zrhs" ..
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1050
  show ?thesis
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1051
  proof -
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1052
    from history self_contained
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1053
    have dist: "distinct_rhs zrhs" by auto
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1054
    hence "(SOME r. (Y, r) \<in> zrhs) = r" using self_contained "(1)"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1055
      using distinct_rhs_def by (auto intro:some_equality)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1056
    moreover have "L zrhs = L (rhs_subst zrhs Y rhs' r)" using substor dist "(1)" self_contained
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1057
      by (rule_tac rhs_subst_prop1, auto simp:distinct_equas_rhs_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1058
    ultimately show ?thesis using subst history self_contained
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1059
      by (auto simp:equas_subst_f_def split:if_splits)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1060
  qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1061
next
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1062
  case False
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1063
  thus ?thesis using history subst self_contained
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1064
    by (auto simp:equas_subst_f_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1065
qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1066
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1067
lemma equas_subst_holds_left_eq_right:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1068
  assumes history: "\<forall>X xrhs. (X, xrhs) \<in> ES \<longrightarrow> ardenable (X, xrhs)"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1069
  and     substor: "Y = L rhs'"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1070
  and     X_in :  "(X, xrhs) \<in> equas_subst ES Y yrhs'"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1071
  shows "\<forall>X xrhs. (X, xrhs) \<in> equas_subst ES Y rhs' \<longrightarrow> X = L xrhs"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1072
apply (clarsimp simp add:equas_subst_def del_x_paired_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1073
using substor
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1074
apply (drule_tac equas_subst_f_holds_left_eq_right)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1075
using history
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1076
by (auto simp:ardenable_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1077
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1078
lemma equas_subst_holds_ardenable:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1079
  assumes substor: "Y = L yrhs'"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1080
  and history: "\<forall>X xrhs. (X, xrhs) \<in> ES \<longrightarrow> ardenable (X, xrhs)"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1081
  and X_in:"(X, xrhs) \<in> equas_subst ES Y yrhs'"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1082
  and dist': "distinct_rhs yrhs'"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1083
  and not_lambda: "Y \<noteq> {[]}"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1084
  shows "ardenable (X, xrhs)"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1085
proof -
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1086
  have "distinct_rhs xrhs" using history X_in dist' 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1087
    by (auto dest:equas_subst_holds_distinct_rhs)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1088
  moreover have "no_EMPTY_rhs xrhs" using history X_in not_lambda
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1089
    by (auto intro:equas_subst_holds_no_EMPTY)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1090
  moreover have "X = L xrhs" using history substor X_in
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1091
  by (auto dest: equas_subst_holds_left_eq_right simp del:L_rhs.simps)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1092
  ultimately show ?thesis using ardenable_def by simp
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1093
qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1094
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1095
lemma equas_subst_holds_cls_defined:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1096
  assumes         X_in: "(X, xrhs) \<in> equas_subst ES Y yrhs'"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1097
  and           Inv_ES: "Inv X' ES"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1098
  and            subst: "(Y, yrhs) \<in> ES"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1099
  and  cls_holds_but_Y: "rhs_eq_cls yrhs' = rhs_eq_cls yrhs - {Y}"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1100
  shows "rhs_eq_cls xrhs \<subseteq> insert {[]} (left_eq_cls (equas_subst ES Y yrhs'))"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1101
proof-
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1102
  have tac: "\<lbrakk> A \<subseteq> B; C \<subseteq> D; E \<subseteq> A \<union> B\<rbrakk> \<Longrightarrow> E \<subseteq> B \<union> D" by auto
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1103
  from X_in have "\<exists> (Z, zrhs) \<in> ES. (X, xrhs) = equas_subst_f Y yrhs' (Z, zrhs)"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1104
    by (auto simp add:equas_subst_def del_x_paired_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1105
  then obtain Z zrhs where Z_in: "(Z, zrhs) \<in> ES"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1106
                       and X_Z: "(X, xrhs) = equas_subst_f Y yrhs' (Z, zrhs)" by blast
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1107
  hence "rhs_eq_cls zrhs \<subseteq> insert {[]} (left_eq_cls ES)" using Inv_ES
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1108
    by (auto simp:Inv_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1109
  moreover have "rhs_eq_cls yrhs' \<subseteq> insert {[]} (left_eq_cls ES) - {Y}" 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1110
    using Inv_ES subst cls_holds_but_Y
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1111
    by (auto simp:Inv_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1112
  moreover have "rhs_eq_cls xrhs \<subseteq> rhs_eq_cls zrhs \<union> rhs_eq_cls yrhs' - {Y}"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1113
    using X_Z cls_holds_but_Y
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1114
    apply (clarsimp simp add:equas_subst_f_def rhs_subst_def split:if_splits)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1115
    by (auto simp:rhs_eq_cls_def merge_rhs_def del_x_paired_def seq_rhs_r_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1116
  moreover have "left_eq_cls (equas_subst ES Y yrhs') = left_eq_cls ES - {Y}" using subst
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1117
    by (auto simp: left_eq_cls_def equas_subst_def del_x_paired_def equas_subst_f_def
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1118
             dest: equas_subst_f_del_no_other
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1119
             split: if_splits)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1120
  ultimately show ?thesis by blast
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1121
qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1122
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1123
lemma iteration_step: 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1124
  assumes Inv_ES: "Inv X ES"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1125
  and    not_T: "\<not> TCon ES"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1126
  shows "(\<exists> ES'. Inv X ES' \<and> (card ES', card ES) \<in> less_than)" 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1127
proof -
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1128
  from Inv_ES not_T have another: "\<exists>Y yrhs. (Y, yrhs) \<in> ES \<and> X \<noteq> Y" unfolding Inv_def
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1129
    by (clarify, rule_tac exist_another_equa[where X = X], auto)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1130
  then obtain Y yrhs where subst: "(Y, yrhs) \<in> ES" and not_X: " X \<noteq> Y" by blast
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1131
  show ?thesis (is "\<exists> ES'. ?P ES'")
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1132
  proof (cases "Y = {[]}") 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1133
    case True
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1134
      --"in this situation, we pick a \"\<lambda>\" equation, thus directly remove it from the equation-system"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1135
    have "?P (ES - {(Y, yrhs)})" 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1136
    proof 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1137
      show "Inv X (ES - {(Y, yrhs)})" using True not_X
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1138
        by (simp add:Inv_ES Inv_mono_with_lambda)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1139
    next 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1140
      show "(card (ES - {(Y, yrhs)}), card ES) \<in> less_than" using Inv_ES subst
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1141
        by (auto elim:non_empty_card_prop[rule_format] simp:Inv_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1142
    qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1143
    thus ?thesis by blast
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1144
  next
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1145
    case False
11
475dd40cd734 deleted two unnecessary lemmas
urbanc
parents: 8
diff changeset
  1146
      --"in this situation, we pick a equation and using ardenable to get a 
475dd40cd734 deleted two unnecessary lemmas
urbanc
parents: 8
diff changeset
  1147
        rhs without itself in it, then use equas_subst to form a new equation-system"
475dd40cd734 deleted two unnecessary lemmas
urbanc
parents: 8
diff changeset
  1148
    hence "\<exists> yrhs'. Y = L yrhs' \<and> distinct_rhs yrhs' \<and> rhs_eq_cls yrhs' = rhs_eq_cls yrhs - {Y}" 
475dd40cd734 deleted two unnecessary lemmas
urbanc
parents: 8
diff changeset
  1149
      using subst Inv_ES
6
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1150
      by (auto intro:ardenable_prop simp add:Inv_def simp del:L_rhs.simps)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1151
    then obtain yrhs' where Y'_l_eq_r: "Y = L yrhs'"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1152
      and dist_Y': "distinct_rhs yrhs'"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1153
      and cls_holds_but_Y: "rhs_eq_cls yrhs' = rhs_eq_cls yrhs - {Y}" by blast
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1154
    hence "?P (equas_subst ES Y yrhs')"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1155
    proof -
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1156
      have finite_del: "\<And> S x. finite S \<Longrightarrow> finite (del_x_paired S x)" 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1157
        apply (rule_tac A = "del_x_paired S x" in finite_subset)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1158
        by (auto simp:del_x_paired_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1159
      have "finite (equas_subst ES Y yrhs')" using Inv_ES 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1160
        by (auto intro!:finite_del simp:equas_subst_def Inv_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1161
      moreover have "\<exists>rhs. (X, rhs) \<in> equas_subst ES Y yrhs'" using Inv_ES not_X
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1162
        by (auto intro:equas_subst_del_no_other simp:Inv_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1163
      moreover have "distinct_equas (equas_subst ES Y yrhs')" using Inv_ES
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1164
        by (auto intro:equas_subst_holds_distinct simp:Inv_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1165
      moreover have "\<forall>X xrhs. (X, xrhs) \<in> equas_subst ES Y yrhs' \<longrightarrow> ardenable (X, xrhs)"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1166
        using Inv_ES dist_Y' False Y'_l_eq_r
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1167
        apply (clarsimp simp:Inv_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1168
        by (rule equas_subst_holds_ardenable, simp_all)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1169
      moreover have "\<forall>X xrhs. (X, xrhs) \<in> equas_subst ES Y yrhs' \<longrightarrow> X \<noteq> {}" using Inv_ES
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1170
        by (clarsimp simp:equas_subst_def Inv_def del_x_paired_def equas_subst_f_def split:if_splits, auto)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1171
      moreover have "\<forall>X xrhs. (X, xrhs) \<in> equas_subst ES Y yrhs' \<longrightarrow>
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1172
                               rhs_eq_cls xrhs \<subseteq> insert {[]} (left_eq_cls (equas_subst ES Y yrhs'))"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1173
        using Inv_ES subst cls_holds_but_Y
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1174
        apply (rule_tac impI | rule_tac allI)+
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1175
        by (erule equas_subst_holds_cls_defined, auto)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1176
      moreover have "(card (equas_subst ES Y yrhs'), card ES) \<in> less_than"using Inv_ES subst
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1177
        by (simp add:equas_subst_card_less Inv_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1178
      ultimately show "?P (equas_subst ES Y yrhs')" by (auto simp:Inv_def)      
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1179
    qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1180
    thus ?thesis by blast
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1181
  qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1182
qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1183
11
475dd40cd734 deleted two unnecessary lemmas
urbanc
parents: 8
diff changeset
  1184
text {* ***** END: proving every equation-system's iteration step satisfies Inv ************** *}
6
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1185
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1186
lemma iteration_conc: 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1187
  assumes history: "Inv X ES"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1188
  shows "\<exists> ES'. Inv X ES' \<and> TCon ES'" (is "\<exists> ES'. ?P ES'")
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1189
proof (cases "TCon ES")
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1190
  case True
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1191
  hence "?P ES" using history by simp
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1192
  thus ?thesis by blast
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1193
next
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1194
  case False  
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1195
  thus ?thesis using history iteration_step
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1196
    by (rule_tac f = card in wf_iter, simp_all)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1197
qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1198
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1199
lemma eqset_imp_iff': "A = B \<Longrightarrow> \<forall> x. x \<in> A \<longleftrightarrow> x \<in> B"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1200
apply (auto simp:mem_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1201
done
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1202
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1203
lemma set_cases2:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1204
  "\<lbrakk>(A = {} \<Longrightarrow> R A); \<And> x. (A = {x}) \<Longrightarrow> R A; \<And> x y. \<lbrakk>x \<noteq> y; x \<in> A; y \<in> A\<rbrakk> \<Longrightarrow> R A\<rbrakk> \<Longrightarrow> R A"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1205
apply (case_tac "A = {}", simp)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1206
by (case_tac "\<exists> x. A = {x}", clarsimp, blast)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1207
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1208
lemma rhs_aux:"\<lbrakk>distinct_rhs rhs; {Y. \<exists>r. (Y, r) \<in> rhs} = {X}\<rbrakk> \<Longrightarrow> (\<exists>r. rhs = {(X, r)})"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1209
apply (rule_tac A = rhs in set_cases2, simp)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1210
apply (drule_tac x = X in eqset_imp_iff, clarsimp)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1211
apply (drule eqset_imp_iff',clarsimp)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1212
apply (frule_tac x = a in spec, drule_tac x = aa in spec)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1213
by (auto simp:distinct_rhs_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1214
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1215
lemma every_eqcl_has_reg: 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1216
  assumes finite_CS: "finite (UNIV Quo Lang)"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1217
  and X_in_CS: "X \<in> (UNIV Quo Lang)"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1218
  shows "\<exists> (reg::rexp). L reg = X" (is "\<exists> r. ?E r")
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1219
proof-
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1220
  have "\<exists>ES'. Inv X ES' \<and> TCon ES'" using finite_CS X_in_CS
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1221
    by (auto intro:init_ES_satisfy_Inv iteration_conc)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1222
  then obtain ES' where Inv_ES': "Inv X ES'" 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1223
                   and  TCon_ES': "TCon ES'" by blast
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1224
  from Inv_ES' TCon_ES' 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1225
  have "\<exists> rhs. ES' = {(X, rhs)}"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1226
    apply (clarsimp simp:Inv_def TCon_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1227
    apply (rule_tac x = rhs in exI)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1228
    by (auto dest!:card_Suc_Diff1 simp:card_eq_0_iff)  
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1229
  then obtain rhs where ES'_single_equa: "ES' = {(X, rhs)}" ..
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1230
  hence X_ardenable: "ardenable (X, rhs)" using Inv_ES'
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1231
    by (simp add:Inv_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1232
  
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1233
  from X_ardenable have X_l_eq_r: "X = L rhs"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1234
    by (simp add:ardenable_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1235
  hence rhs_not_empty: "rhs \<noteq> {}" using Inv_ES' ES'_single_equa
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1236
    by (auto simp:Inv_def ardenable_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1237
  have rhs_eq_cls: "rhs_eq_cls rhs \<subseteq> {X, {[]}}"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1238
    using Inv_ES' ES'_single_equa
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1239
    by (auto simp:Inv_def ardenable_def left_eq_cls_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1240
  have X_not_empty: "X \<noteq> {}" using Inv_ES' ES'_single_equa
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1241
    by (auto simp:Inv_def)    
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1242
  show ?thesis
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1243
  proof (cases "X = {[]}")
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1244
    case True
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1245
    hence "?E EMPTY" by (simp)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1246
    thus ?thesis by blast
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1247
  next
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1248
    case False with  X_ardenable
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1249
    have "\<exists> rhs'. X = L rhs' \<and> rhs_eq_cls rhs' = rhs_eq_cls rhs - {X} \<and> distinct_rhs rhs'"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1250
      by (drule_tac ardenable_prop, auto)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1251
    then obtain rhs' where X_eq_rhs': "X = L rhs'"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1252
      and rhs'_eq_cls: "rhs_eq_cls rhs' = rhs_eq_cls rhs - {X}" 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1253
      and rhs'_dist : "distinct_rhs rhs'" by blast
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1254
    have "rhs_eq_cls rhs' \<subseteq> {{[]}}" using rhs_eq_cls False rhs'_eq_cls rhs_not_empty 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1255
      by blast
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1256
    hence "rhs_eq_cls rhs' = {{[]}}" using X_not_empty X_eq_rhs'
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1257
      by (auto simp:rhs_eq_cls_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1258
    hence "\<exists> r. rhs' = {({[]}, r)}" using rhs'_dist
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1259
      by (auto intro:rhs_aux simp:rhs_eq_cls_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1260
    then obtain r where "rhs' = {({[]}, r)}" ..
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1261
    hence "?E r" using X_eq_rhs' by (auto simp add:lang_seq_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1262
    thus ?thesis by blast     
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1263
  qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1264
qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1265
11
475dd40cd734 deleted two unnecessary lemmas
urbanc
parents: 8
diff changeset
  1266
text {* definition of a regular language *}
475dd40cd734 deleted two unnecessary lemmas
urbanc
parents: 8
diff changeset
  1267
475dd40cd734 deleted two unnecessary lemmas
urbanc
parents: 8
diff changeset
  1268
abbreviation
475dd40cd734 deleted two unnecessary lemmas
urbanc
parents: 8
diff changeset
  1269
  reg :: "string set => bool"
475dd40cd734 deleted two unnecessary lemmas
urbanc
parents: 8
diff changeset
  1270
where
475dd40cd734 deleted two unnecessary lemmas
urbanc
parents: 8
diff changeset
  1271
  "reg L1 \<equiv> (\<exists>r::rexp. L r = L1)"
475dd40cd734 deleted two unnecessary lemmas
urbanc
parents: 8
diff changeset
  1272
6
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1273
theorem myhill_nerode: 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1274
  assumes finite_CS: "finite (UNIV Quo Lang)"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1275
  shows   "\<exists> (reg::rexp). Lang = L reg" (is "\<exists> r. ?P r")
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1276
proof -
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1277
  have has_r_each: "\<forall>C\<in>{X \<in> UNIV Quo Lang. \<forall>x\<in>X. x \<in> Lang}. \<exists>(r::rexp). C = L r" using finite_CS
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1278
    by (auto dest:every_eqcl_has_reg)  
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1279
  have "\<exists> (rS::rexp set). finite rS \<and> 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1280
                          (\<forall> C \<in> {X \<in> UNIV Quo Lang. \<forall>x\<in>X. x \<in> Lang}. \<exists> r \<in> rS. C = L r) \<and> 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1281
                          (\<forall> r \<in> rS. \<exists> C \<in> {X \<in> UNIV Quo Lang. \<forall>x\<in>X. x \<in> Lang}. C = L r)" 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1282
       (is "\<exists> rS. ?Q rS")
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1283
  proof-
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1284
    have "\<And> C. C \<in> {X \<in> UNIV Quo Lang. \<forall>x\<in>X. x \<in> Lang} \<Longrightarrow> C = L (SOME (ra::rexp). C = L ra)"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1285
      using has_r_each
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1286
      apply (erule_tac x = C in ballE, erule_tac exE)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1287
      by (rule_tac a = r in someI2, simp+)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1288
    hence "?Q ((\<lambda> C. SOME r. C = L r) ` {X \<in> UNIV Quo Lang. \<forall>x\<in>X. x \<in> Lang})" using has_r_each
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1289
      using finite_CS by auto
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1290
    thus ?thesis by blast    
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1291
  qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1292
  then obtain rS where finite_rS : "finite rS"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1293
    and has_r_each': "\<forall> C \<in> {X \<in> UNIV Quo Lang. \<forall>x\<in>X. x \<in> Lang}. \<exists> r \<in> (rS::rexp set). C = L r"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1294
    and has_cl_each: "\<forall> r \<in> (rS::rexp set). \<exists> C \<in> {X \<in> UNIV Quo Lang. \<forall>x\<in>X. x \<in> Lang}. C = L r" by blast
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1295
  have "?P (folds ALT NULL rS)"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1296
  proof
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1297
    show "Lang \<subseteq> L (folds ALT NULL rS)" using finite_rS lang_eqs_union_of_eqcls[of Lang] has_r_each'
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1298
      apply (clarsimp simp:fold_alt_null_eqs) by blast
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1299
  next 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1300
    show "L (folds ALT NULL rS) \<subseteq> Lang" using finite_rS lang_eqs_union_of_eqcls[of Lang] has_cl_each
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1301
      by (clarsimp simp:fold_alt_null_eqs)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1302
  qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1303
  thus ?thesis by blast
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1304
qed 
8
1f8fe5bfd381 tried at the end to prove the other direction (failed at the moment)
urbanc
parents: 7
diff changeset
  1305
1f8fe5bfd381 tried at the end to prove the other direction (failed at the moment)
urbanc
parents: 7
diff changeset
  1306
1f8fe5bfd381 tried at the end to prove the other direction (failed at the moment)
urbanc
parents: 7
diff changeset
  1307
text {* tests by Christian *}
1f8fe5bfd381 tried at the end to prove the other direction (failed at the moment)
urbanc
parents: 7
diff changeset
  1308
23
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1309
(* Alternative definition for Quo *)
11
475dd40cd734 deleted two unnecessary lemmas
urbanc
parents: 8
diff changeset
  1310
definition 
475dd40cd734 deleted two unnecessary lemmas
urbanc
parents: 8
diff changeset
  1311
  QUOT :: "string set \<Rightarrow> (string set) set"  
8
1f8fe5bfd381 tried at the end to prove the other direction (failed at the moment)
urbanc
parents: 7
diff changeset
  1312
where
11
475dd40cd734 deleted two unnecessary lemmas
urbanc
parents: 8
diff changeset
  1313
  "QUOT Lang \<equiv> (\<Union>x. {\<lbrakk>x\<rbrakk>Lang})"
475dd40cd734 deleted two unnecessary lemmas
urbanc
parents: 8
diff changeset
  1314
23
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1315
lemma test: 
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1316
  "UNIV Quo Lang = QUOT Lang"
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1317
by (auto simp add: quot_def QUOT_def)
13
a761b8ac8488 a few more experiments, but no proof for the ALT-case
urbanc
parents: 12
diff changeset
  1318
23
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1319
lemma test1:
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1320
  assumes finite_CS: "finite (QUOT Lang)"
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1321
  shows "reg Lang"
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1322
using finite_CS
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1323
unfolding test[symmetric]
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1324
by (auto dest: myhill_nerode)
18
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1325
23
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1326
lemma cons_one: "x @ y \<in> {z} \<Longrightarrow> x @ y = z"
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1327
by simp
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1328
12
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1329
lemma quot_lambda: "QUOT {[]} = {{[]}, UNIV - {[]}}"
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1330
proof 
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1331
  show "QUOT {[]} \<subseteq> {{[]}, UNIV - {[]}}"
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1332
  proof 
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1333
    fix x 
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1334
    assume in_quot: "x \<in> QUOT {[]}"
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1335
    show "x \<in> {{[]}, UNIV - {[]}}"
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1336
    proof -
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1337
      from in_quot 
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1338
      have "x = {[]} \<or> x = UNIV - {[]}"
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1339
        unfolding QUOT_def equiv_class_def
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1340
      proof 
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1341
        fix xa
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1342
        assume in_univ: "xa \<in> UNIV"
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1343
           and in_eqiv: "x \<in> {{y. xa \<equiv>{[]}\<equiv> y}}"
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1344
        show "x = {[]} \<or> x = UNIV - {[]}"
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1345
        proof(cases "xa = []")
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1346
          case True
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1347
          hence "{y. xa \<equiv>{[]}\<equiv> y} = {[]}" using in_eqiv
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1348
            by (auto simp add:equiv_str_def)
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1349
          thus ?thesis using in_eqiv by (rule_tac disjI1, simp)
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1350
        next
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1351
          case False
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1352
          hence "{y. xa \<equiv>{[]}\<equiv> y} = UNIV - {[]}" using in_eqiv
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1353
            by (auto simp:equiv_str_def)
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1354
          thus ?thesis using in_eqiv by (rule_tac disjI2, simp)
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1355
        qed
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1356
      qed
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1357
      thus ?thesis by simp
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1358
    qed
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1359
  qed
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1360
next
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1361
  show "{{[]}, UNIV - {[]}} \<subseteq> QUOT {[]}"
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1362
  proof
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1363
    fix x
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1364
    assume in_res: "x \<in> {{[]}, (UNIV::string set) - {[]}}"
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1365
    show "x \<in> (QUOT {[]})"
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1366
    proof -
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1367
      have "x = {[]} \<Longrightarrow> x \<in> QUOT {[]}"
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1368
        apply (simp add:QUOT_def equiv_class_def equiv_str_def)
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1369
        by (rule_tac x = "[]" in exI, auto)
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1370
      moreover have "x = UNIV - {[]} \<Longrightarrow> x \<in> QUOT {[]}"
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1371
        apply (simp add:QUOT_def equiv_class_def equiv_str_def)
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1372
        by (rule_tac x = "''a''" in exI, auto)
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1373
      ultimately show ?thesis using in_res by blast
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1374
    qed
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1375
  qed
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1376
qed
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1377
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1378
lemma quot_single_aux: "\<lbrakk>x \<noteq> []; x \<noteq> [c]\<rbrakk> \<Longrightarrow> x @ z \<noteq> [c]"
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1379
by (induct x, auto)
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1380
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1381
lemma quot_single: "\<And> (c::char). QUOT {[c]} = {{[]}, {[c]}, UNIV - {[], [c]}}"
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1382
proof - 
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1383
  fix c::"char" 
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1384
  have exist_another: "\<exists> a. a \<noteq> c" 
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1385
    apply (case_tac "c = CHR ''a''")
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1386
    apply (rule_tac x = "CHR ''b''" in exI, simp)
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1387
    by (rule_tac x = "CHR ''a''" in exI, simp)  
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1388
  show "QUOT {[c]} = {{[]}, {[c]}, UNIV - {[], [c]}}"
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1389
  proof
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1390
    show "QUOT {[c]} \<subseteq> {{[]},{[c]}, UNIV - {[], [c]}}"
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1391
    proof 
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1392
      fix x 
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1393
      assume in_quot: "x \<in> QUOT {[c]}"
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1394
      show "x \<in> {{[]}, {[c]}, UNIV - {[],[c]}}"
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1395
      proof -
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1396
        from in_quot 
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1397
        have "x = {[]} \<or> x = {[c]} \<or> x = UNIV - {[],[c]}"
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1398
          unfolding QUOT_def equiv_class_def
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1399
        proof 
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1400
          fix xa
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1401
          assume in_eqiv: "x \<in> {{y. xa \<equiv>{[c]}\<equiv> y}}"
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1402
          show "x = {[]} \<or> x = {[c]} \<or> x = UNIV - {[], [c]}"
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1403
          proof-
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1404
            have "xa = [] \<Longrightarrow> x = {[]}" using in_eqiv 
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1405
              by (auto simp add:equiv_str_def)
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1406
            moreover have "xa = [c] \<Longrightarrow> x = {[c]}"
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1407
            proof -
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1408
              have "xa = [c] \<Longrightarrow> {y. xa \<equiv>{[c]}\<equiv> y} = {[c]}" using in_eqiv
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1409
                apply (simp add:equiv_str_def)
23
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1410
                apply (rule set_ext, rule iffI, simp)
12
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1411
                apply (drule_tac x = "[]" in spec, auto)
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1412
                done   
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1413
              thus "xa = [c] \<Longrightarrow> x = {[c]}" using in_eqiv by simp 
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1414
            qed
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1415
            moreover have "\<lbrakk>xa \<noteq> []; xa \<noteq> [c]\<rbrakk> \<Longrightarrow> x = UNIV - {[],[c]}"
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1416
            proof -
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1417
              have "\<lbrakk>xa \<noteq> []; xa \<noteq> [c]\<rbrakk> \<Longrightarrow> {y. xa \<equiv>{[c]}\<equiv> y} = UNIV - {[],[c]}" 
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1418
                apply (clarsimp simp add:equiv_str_def)
23
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1419
                apply (rule set_ext, rule iffI, simp)
12
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1420
                apply (rule conjI)
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1421
                apply (drule_tac x = "[c]" in spec, simp)
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1422
                apply (drule_tac x = "[]" in spec, simp)
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1423
                by (auto dest:quot_single_aux)
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1424
              thus "\<lbrakk>xa \<noteq> []; xa \<noteq> [c]\<rbrakk> \<Longrightarrow> x = UNIV - {[],[c]}" using in_eqiv by simp
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1425
            qed
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1426
            ultimately show ?thesis by blast
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1427
          qed
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1428
        qed
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1429
        thus ?thesis by simp
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1430
      qed
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1431
    qed
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1432
  next
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1433
    show "{{[]}, {[c]}, UNIV - {[],[c]}} \<subseteq> QUOT {[c]}"
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1434
    proof
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1435
      fix x
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1436
      assume in_res: "x \<in> {{[]},{[c]}, (UNIV::string set) - {[],[c]}}"
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1437
      show "x \<in> (QUOT {[c]})"
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1438
      proof -
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1439
        have "x = {[]} \<Longrightarrow> x \<in> QUOT {[c]}"
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1440
          apply (simp add:QUOT_def equiv_class_def equiv_str_def)
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1441
          by (rule_tac x = "[]" in exI, auto)
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1442
        moreover have "x = {[c]} \<Longrightarrow> x \<in> QUOT {[c]}"
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1443
          apply (simp add:QUOT_def equiv_class_def equiv_str_def)
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1444
          apply (rule_tac x = "[c]" in exI, simp)
23
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1445
          apply (rule set_ext, rule iffI, simp+)
12
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1446
          by (drule_tac x = "[]" in spec, simp)
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1447
        moreover have "x = UNIV - {[],[c]} \<Longrightarrow> x \<in> QUOT {[c]}"
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1448
          using exist_another
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1449
          apply (clarsimp simp add:QUOT_def equiv_class_def equiv_str_def)        
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1450
          apply (rule_tac x = "[a]" in exI, simp)
23
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1451
          apply (rule set_ext, rule iffI, simp)
12
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1452
          apply (clarsimp simp:quot_single_aux, simp)
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1453
          apply (rule conjI)
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1454
          apply (drule_tac x = "[c]" in spec, simp)
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1455
          by (drule_tac x = "[]" in spec, simp)     
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1456
        ultimately show ?thesis using in_res by blast
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1457
      qed
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1458
    qed
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1459
  qed
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1460
qed
440a01d100eb add some proofs about the other direction
wu
parents: 11
diff changeset
  1461
23
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1462
lemma eq_class_imp_eq_str:
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1463
  "\<lbrakk>x\<rbrakk>lang = \<lbrakk>y\<rbrakk>lang \<Longrightarrow> x \<equiv>lang\<equiv> y"
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1464
by (auto simp:equiv_class_def equiv_str_def)
18
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1465
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1466
lemma finite_tag_image: 
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1467
  "finite (range tag) \<Longrightarrow> finite (((op `) tag) ` S)"
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1468
apply (rule_tac B = "Pow (tag ` UNIV)" in finite_subset)
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1469
by (auto simp add:image_def Pow_def)
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1470
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1471
lemma str_inj_imps:
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1472
  assumes str_inj: "\<And> m n. tag m = tag (n::string) \<Longrightarrow> m \<equiv>lang\<equiv> n"
23
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1473
  shows "inj_on ((op `) tag) (QUOT lang)"
18
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1474
proof (clarsimp simp add:inj_on_def QUOT_def)
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1475
  fix x y
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1476
  assume eq_tag: "tag ` \<lbrakk>x\<rbrakk>lang = tag ` \<lbrakk>y\<rbrakk>lang"
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1477
  show "\<lbrakk>x\<rbrakk>lang = \<lbrakk>y\<rbrakk>lang"
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1478
  proof -
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1479
    have aux1:"\<And>a b. a \<in> (\<lbrakk>b\<rbrakk>lang) \<Longrightarrow> (a \<equiv>lang\<equiv> b)"
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1480
      by (simp add:equiv_class_def equiv_str_def)
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1481
    have aux2: "\<And> A B f. \<lbrakk>f ` A = f ` B; A \<noteq> {}\<rbrakk> \<Longrightarrow> \<exists> a b. a \<in> A \<and> b \<in> B \<and> f a = f b"
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1482
      by auto
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1483
    have aux3: "\<And> a l. \<lbrakk>a\<rbrakk>l \<noteq> {}" 
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1484
      by (auto simp:equiv_class_def equiv_str_def)
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1485
    show ?thesis using eq_tag
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1486
      apply (drule_tac aux2, simp add:aux3, clarsimp)
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1487
      apply (drule_tac str_inj, (drule_tac aux1)+)
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1488
      by (simp add:equiv_str_def equiv_class_def)
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1489
  qed
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1490
qed
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1491
23
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1492
definition tag_str_ALT :: "string set \<Rightarrow> string set \<Rightarrow> string \<Rightarrow> (string set \<times> string set)"
18
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1493
where
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1494
  "tag_str_ALT L\<^isub>1 L\<^isub>2 x \<equiv> (\<lbrakk>x\<rbrakk>L\<^isub>1, \<lbrakk>x\<rbrakk>L\<^isub>2)"
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1495
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1496
lemma tag_str_alt_range_finite:
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1497
  assumes finite1: "finite (QUOT L\<^isub>1)"
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1498
  and finite2: "finite (QUOT L\<^isub>2)"
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1499
  shows "finite (range (tag_str_ALT L\<^isub>1 L\<^isub>2))"
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1500
proof -
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1501
  have "{y. \<exists>x. y = (\<lbrakk>x\<rbrakk>L\<^isub>1, \<lbrakk>x\<rbrakk>L\<^isub>2)} \<subseteq> (QUOT L\<^isub>1) \<times> (QUOT L\<^isub>2)"
23
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1502
    by (auto simp:QUOT_def)
18
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1503
  thus ?thesis using finite1 finite2
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1504
    by (auto simp: image_def tag_str_ALT_def UNION_def 
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1505
            intro: finite_subset[where B = "(QUOT L\<^isub>1) \<times> (QUOT L\<^isub>2)"])
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1506
qed
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1507
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1508
lemma tag_str_alt_inj:
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1509
  "tag_str_ALT L\<^isub>1 L\<^isub>2 x = tag_str_ALT L\<^isub>1 L\<^isub>2 y \<Longrightarrow> x \<equiv>(L\<^isub>1 \<union> L\<^isub>2)\<equiv> y"
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1510
apply (simp add:tag_str_ALT_def equiv_class_def equiv_str_def)
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1511
by blast
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1512
  
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1513
lemma quot_alt:
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1514
  assumes finite1: "finite (QUOT L\<^isub>1)"
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1515
  and finite2: "finite (QUOT L\<^isub>2)"
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1516
  shows "finite (QUOT (L\<^isub>1 \<union> L\<^isub>2))"
23
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1517
proof (rule_tac f = "(op `) (tag_str_ALT L\<^isub>1 L\<^isub>2)" in finite_imageD)
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1518
  show "finite (op ` (tag_str_ALT L\<^isub>1 L\<^isub>2) ` QUOT (L\<^isub>1 \<union> L\<^isub>2))"
18
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1519
    using finite_tag_image tag_str_alt_range_finite finite1 finite2
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1520
    by auto
23
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1521
next
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1522
  show "inj_on (op ` (tag_str_ALT L\<^isub>1 L\<^isub>2)) (QUOT (L\<^isub>1 \<union> L\<^isub>2))"
18
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1523
    apply (rule_tac str_inj_imps)
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1524
    by (erule_tac tag_str_alt_inj)
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1525
qed
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1526
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1527
(* list_diff:: list substract, once different return tailer *)
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1528
fun list_diff :: "'a list \<Rightarrow> 'a list \<Rightarrow> 'a list" (infix "-" 51)
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1529
where
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1530
  "list_diff []  xs = []" |
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1531
  "list_diff (x#xs) [] = x#xs" |
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1532
  "list_diff (x#xs) (y#ys) = (if x = y then list_diff xs ys else (x#xs))"
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1533
23
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1534
lemma [simp]: "(x @ y) - x = y"
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1535
apply (induct x)
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1536
by (case_tac y, simp+)
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1537
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1538
lemma [simp]: "x - x = []"
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1539
by (induct x, auto)
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1540
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1541
lemma [simp]: "x = xa @ y \<Longrightarrow> x - xa = y "
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1542
by (induct x, auto)
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1543
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1544
lemma [simp]: "x - [] = x"
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1545
by (induct x, auto)
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1546
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1547
lemma [simp]: "xa \<le> x \<Longrightarrow> (x @ y) - xa = (x - xa) @ y"
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1548
by (auto elim:prefixE)
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1549
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1550
definition tag_str_SEQ:: "string set \<Rightarrow> string set \<Rightarrow> string \<Rightarrow> (string set \<times> string set set)"
18
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1551
where
23
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1552
  "tag_str_SEQ L\<^isub>1 L\<^isub>2 x \<equiv> if (\<exists> xa \<le> x. xa \<in> L\<^isub>1)
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1553
                         then (\<lbrakk>x\<rbrakk>L\<^isub>1, {\<lbrakk>(x - xa)\<rbrakk>L\<^isub>2 | xa.  xa \<le> x \<and> xa \<in> L\<^isub>1})
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1554
                         else (\<lbrakk>x\<rbrakk>L\<^isub>1, {})"
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1555
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1556
lemma tag_seq_eq_E:
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1557
  "tag_str_SEQ L\<^isub>1 L\<^isub>2 x = tag_str_SEQ L\<^isub>1 L\<^isub>2 y \<Longrightarrow>
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1558
   ((\<exists> xa \<le> x. xa \<in> L\<^isub>1) \<and> \<lbrakk>x\<rbrakk>L\<^isub>1 = \<lbrakk>y\<rbrakk>L\<^isub>1 \<and> 
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1559
    {\<lbrakk>(x - xa)\<rbrakk>L\<^isub>2 | xa. xa \<le> x \<and> xa \<in> L\<^isub>1} = {\<lbrakk>(y - ya)\<rbrakk>L\<^isub>2 | ya. ya \<le> y \<and> ya \<in> L\<^isub>1} ) \<or>
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1560
   ((\<forall> xa \<le> x. xa \<notin> L\<^isub>1) \<and> \<lbrakk>x\<rbrakk>L\<^isub>1 = \<lbrakk>y\<rbrakk>L\<^isub>1)"
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1561
by (simp add:tag_str_SEQ_def split:if_splits, blast)
18
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1562
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1563
lemma tag_str_seq_range_finite:
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1564
  assumes finite1: "finite (QUOT L\<^isub>1)"
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1565
  and finite2: "finite (QUOT L\<^isub>2)"
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1566
  shows "finite (range (tag_str_SEQ L\<^isub>1 L\<^isub>2))"
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1567
proof -
23
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1568
  have "(range (tag_str_SEQ L\<^isub>1 L\<^isub>2)) \<subseteq> (QUOT L\<^isub>1) \<times> (Pow (QUOT L\<^isub>2))"
18
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1569
    by (auto simp:image_def tag_str_SEQ_def QUOT_def)
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1570
  thus ?thesis using finite1 finite2 
23
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1571
    by (rule_tac B = "(QUOT L\<^isub>1) \<times> (Pow (QUOT L\<^isub>2))" in finite_subset, auto)
18
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1572
qed
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1573
  
23
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1574
lemma app_in_seq_decom[rule_format]:
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1575
  "\<forall> x. x @ z \<in> L\<^isub>1 ; L\<^isub>2 \<longrightarrow> (\<exists> xa \<le> x. xa \<in> L\<^isub>1 \<and> (x - xa) @ z \<in> L\<^isub>2) \<or> 
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1576
                            (\<exists> za \<le> z. (x @ za) \<in> L\<^isub>1 \<and> (z - za) \<in> L\<^isub>2)"
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1577
apply (induct z)
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1578
apply (simp, rule allI, rule impI, rule disjI1)
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1579
apply (clarsimp simp add:lang_seq_def)
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1580
apply (rule_tac x = s1 in exI, simp)
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1581
apply (rule allI | rule impI)+
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1582
apply (drule_tac x = "x @ [a]" in spec, simp)
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1583
apply (erule exE | erule conjE | erule disjE)+
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1584
apply (rule disjI2, rule_tac x = "[a]" in exI, simp)
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1585
apply (rule disjI1, rule_tac x = xa in exI, simp) 
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1586
apply (erule exE | erule conjE)+
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1587
apply (rule disjI2, rule_tac x = "a # za" in exI, simp)
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1588
done
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1589
18
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1590
lemma tag_str_seq_inj:
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1591
  assumes tag_eq: "tag_str_SEQ L\<^isub>1 L\<^isub>2 x = tag_str_SEQ L\<^isub>1 L\<^isub>2 y"
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1592
  shows "(x::string) \<equiv>(L\<^isub>1 ; L\<^isub>2)\<equiv> y"
23
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1593
proof -
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1594
  have aux: "\<And> x y z. \<lbrakk>tag_str_SEQ L\<^isub>1 L\<^isub>2 x = tag_str_SEQ L\<^isub>1 L\<^isub>2 y; x @ z \<in> L\<^isub>1 ; L\<^isub>2\<rbrakk> 
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1595
                       \<Longrightarrow> y @ z \<in> L\<^isub>1 ; L\<^isub>2"
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1596
  proof (drule app_in_seq_decom, erule disjE)
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1597
    fix x y z
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1598
    assume tag_eq: "tag_str_SEQ L\<^isub>1 L\<^isub>2 x = tag_str_SEQ L\<^isub>1 L\<^isub>2 y"
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1599
      and x_gets_l2: "\<exists>xa\<le>x. xa \<in> L\<^isub>1 \<and> (x - xa) @ z \<in> L\<^isub>2"
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1600
    from x_gets_l2 have "\<exists> xa \<le> x. xa \<in> L\<^isub>1" by blast
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1601
    hence xy_l2:"{\<lbrakk>(x - xa)\<rbrakk>L\<^isub>2 | xa. xa \<le> x \<and> xa \<in> L\<^isub>1} = {\<lbrakk>(y - ya)\<rbrakk>L\<^isub>2 | ya. ya \<le> y \<and> ya \<in> L\<^isub>1}"
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1602
      using tag_eq tag_seq_eq_E by blast
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1603
    from x_gets_l2 obtain xa where xa_le_x: "xa \<le> x"
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1604
                               and xa_in_l1: "xa \<in> L\<^isub>1"
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1605
                               and rest_in_l2: "(x - xa) @ z \<in> L\<^isub>2" by blast
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1606
    hence "\<exists> ya. \<lbrakk>(x - xa)\<rbrakk>L\<^isub>2 = \<lbrakk>(y - ya)\<rbrakk>L\<^isub>2 \<and> ya \<le> y \<and> ya \<in> L\<^isub>1" using xy_l2 by auto
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1607
    then obtain ya where ya_le_x: "ya \<le> y"
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1608
                     and ya_in_l1: "ya \<in> L\<^isub>1"
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1609
                     and rest_eq: "\<lbrakk>(x - xa)\<rbrakk>L\<^isub>2 = \<lbrakk>(y - ya)\<rbrakk>L\<^isub>2" by blast
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1610
    from rest_eq rest_in_l2 have "(y - ya) @ z \<in> L\<^isub>2" 
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1611
      by (auto simp:equiv_class_def equiv_str_def)
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1612
    hence "ya @ ((y - ya) @ z) \<in> L\<^isub>1 ; L\<^isub>2" using ya_in_l1
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1613
      by (auto simp:lang_seq_def)
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1614
    thus "y @ z \<in> L\<^isub>1 ; L\<^isub>2" using ya_le_x 
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1615
      by (erule_tac prefixE, simp)
18
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1616
  next
23
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1617
    fix x y z
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1618
    assume tag_eq: "tag_str_SEQ L\<^isub>1 L\<^isub>2 x = tag_str_SEQ L\<^isub>1 L\<^isub>2 y"
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1619
      and x_gets_l1: "\<exists>za\<le>z. x @ za \<in> L\<^isub>1 \<and> z - za \<in> L\<^isub>2"
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1620
    from tag_eq tag_seq_eq_E have x_y_eq: "\<lbrakk>x\<rbrakk>L\<^isub>1 = \<lbrakk>y\<rbrakk>L\<^isub>1" by blast
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1621
    from x_gets_l1 obtain za where za_le_z: "za \<le> z"
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1622
                               and x_za_in_l1: "(x @ za) \<in> L\<^isub>1"
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1623
                               and rest_in_l2: "z - za \<in> L\<^isub>2" by blast
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1624
    from x_y_eq x_za_in_l1 have y_za_in_l1: "y @ za \<in> L\<^isub>1"
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1625
      by (auto simp:equiv_class_def equiv_str_def)
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1626
    hence "(y @ za) @ (z - za) \<in> L\<^isub>1 ; L\<^isub>2" using rest_in_l2
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1627
      apply (simp add:lang_seq_def)
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1628
      by (rule_tac x = "y @ za" in exI, rule_tac x = "z - za" in exI, simp)
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1629
    thus "y @ z \<in> L\<^isub>1 ; L\<^isub>2" using za_le_z
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1630
      by (erule_tac prefixE, simp)
18
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1631
  qed
23
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1632
  show ?thesis using tag_eq
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1633
    apply (simp add:equiv_str_def)
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1634
    by (auto intro:aux)
18
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1635
qed
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1636
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1637
lemma quot_seq: 
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1638
  assumes finite1: "finite (QUOT L\<^isub>1)"
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1639
  and finite2: "finite (QUOT L\<^isub>2)"
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1640
  shows "finite (QUOT (L\<^isub>1;L\<^isub>2))"
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1641
proof (rule_tac f = "(op `) (tag_str_SEQ L\<^isub>1 L\<^isub>2)" in finite_imageD)
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1642
  show "finite (op ` (tag_str_SEQ L\<^isub>1 L\<^isub>2) ` QUOT (L\<^isub>1 ; L\<^isub>2))"
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1643
    using finite_tag_image tag_str_seq_range_finite finite1 finite2
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1644
    by auto
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1645
next
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1646
  show "inj_on (op ` (tag_str_SEQ L\<^isub>1 L\<^isub>2)) (QUOT (L\<^isub>1 ; L\<^isub>2))"
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1647
    apply (rule_tac str_inj_imps)
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1648
    by (erule_tac tag_str_seq_inj)
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1649
qed
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1650
23
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1651
(****************** the STAR case ************************)
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1652
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1653
lemma app_eq_elim[rule_format]:
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1654
  "\<And> a. \<forall> b x y. a @ b = x @ y \<longrightarrow> (\<exists> aa ab. a = aa @ ab \<and> x = aa \<and> y = ab @ b) \<or>
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1655
                                   (\<exists> ba bb. b = ba @ bb \<and> x = a @ ba \<and> y = bb \<and> ba \<noteq> [])"
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1656
  apply (induct_tac a rule:List.induct, simp)
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1657
  apply (rule allI | rule impI)+
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1658
  by (case_tac x, auto)
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1659
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1660
definition tag_str_STAR:: "string set \<Rightarrow> string \<Rightarrow> string set set"
18
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1661
where
23
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1662
  "tag_str_STAR L\<^isub>1 x \<equiv> if (x = []) 
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1663
                       then {}
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1664
                       else {\<lbrakk>x\<^isub>2\<rbrakk>L\<^isub>1 | x\<^isub>1 x\<^isub>2. x =  x\<^isub>1 @ x\<^isub>2 \<and> x\<^isub>1 \<in> L\<^isub>1\<star> \<and> x\<^isub>2 \<noteq> []}"
18
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1665
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1666
lemma tag_str_star_range_finite:
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1667
  assumes finite1: "finite (QUOT L\<^isub>1)"
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1668
  shows "finite (range (tag_str_STAR L\<^isub>1))"
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1669
proof -
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1670
  have "range (tag_str_STAR L\<^isub>1) \<subseteq> Pow (QUOT L\<^isub>1)"
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1671
    by (auto simp:image_def tag_str_STAR_def QUOT_def)
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1672
  thus ?thesis using finite1
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1673
    by (rule_tac B = "Pow (QUOT L\<^isub>1)" in finite_subset, auto)
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1674
qed
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1675
23
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1676
lemma star_prop[rule_format]: "x \<in> lang\<star> \<Longrightarrow> \<forall> y. y \<in> lang\<star> \<longrightarrow> x @ y \<in> lang\<star>"
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1677
by (erule Star.induct, auto)
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1678
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1679
lemma star_prop2: "y \<in> lang \<Longrightarrow> y \<in> lang\<star>"
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1680
by (drule step[of y lang "[]"], auto simp:start)
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1681
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1682
lemma star_prop3[rule_format]: "x \<in> lang\<star> \<Longrightarrow> \<forall>y . y \<in> lang \<longrightarrow> x @ y \<in> lang\<star>"
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1683
by (erule Star.induct, auto intro:star_prop2)
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1684
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1685
lemma postfix_prop: "y >>= (x @ y) \<Longrightarrow> x = []"
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1686
by (erule postfixE, induct x arbitrary:y, auto)
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1687
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1688
lemma inj_aux:
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1689
  "\<lbrakk>(m @ z) \<in> L\<^isub>1\<star>; m \<equiv>L\<^isub>1\<equiv> yb; xa @ m = x; xa \<in> L\<^isub>1\<star>; m \<noteq> [];
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1690
    \<forall> xa xb. x = xa @ xb \<and> xa \<in> L\<^isub>1\<star> \<and> xb \<noteq> [] \<and> xb @ z \<in> L\<^isub>1\<star> \<longrightarrow> xb >>= m\<rbrakk> 
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1691
  \<Longrightarrow> (yb @ z) \<in> L\<^isub>1\<star>"
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1692
proof- 
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1693
  have "\<And>s. s \<in> L\<^isub>1\<star> \<Longrightarrow> \<forall> m z yb. (s = m @ z \<and> m \<equiv>L\<^isub>1\<equiv> yb \<and> x = xa @ m \<and> xa \<in> L\<^isub>1\<star> \<and> m \<noteq> [] \<and>  
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1694
    (\<forall> xa xb. x = xa @ xb \<and> xa \<in> L\<^isub>1\<star> \<and> xb \<noteq> [] \<and> xb @ z \<in> L\<^isub>1\<star> \<longrightarrow> xb >>= m) \<longrightarrow> (yb @ z) \<in> L\<^isub>1\<star>)"    
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1695
    apply (erule Star.induct, simp)
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1696
    apply (rule allI | rule impI | erule conjE)+
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1697
    apply (drule app_eq_elim)
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1698
    apply (erule disjE | erule exE | erule conjE)+
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1699
    apply simp
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1700
    apply (simp (no_asm) only:append_assoc[THEN sym])
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1701
    apply (rule step) 
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1702
    apply (simp add:equiv_str_def)
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1703
    apply simp
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1704
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1705
    apply (erule exE | erule conjE)+    
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1706
    apply (rotate_tac 3)
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1707
    apply (frule_tac x = "xa @ s1" in spec)
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1708
    apply (rotate_tac 12)
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1709
    apply (drule_tac x = ba in spec)
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1710
    apply (erule impE)
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1711
    apply ( simp add:star_prop3)
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1712
    apply (simp)
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1713
    apply (drule postfix_prop)
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1714
    apply simp
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1715
    done
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1716
  thus "\<lbrakk>(m @ z) \<in> L\<^isub>1\<star>; m \<equiv>L\<^isub>1\<equiv> yb; xa @ m = x; xa \<in> L\<^isub>1\<star>; m \<noteq> [];
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1717
         \<forall> xa xb. x = xa @ xb \<and> xa \<in> L\<^isub>1\<star> \<and> xb \<noteq> [] \<and> xb @ z \<in> L\<^isub>1\<star> \<longrightarrow> xb >>= m\<rbrakk> 
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1718
        \<Longrightarrow> (yb @ z) \<in> L\<^isub>1\<star>" by blast
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1719
qed
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1720
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1721
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1722
lemma min_postfix_exists[rule_format]:
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1723
  "finite A \<Longrightarrow> A \<noteq> {} \<and> (\<forall> a \<in> A. \<forall> b \<in> A. ((b >>= a) \<or> (a >>= b))) 
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1724
                \<longrightarrow> (\<exists> min. (min \<in> A \<and> (\<forall> a \<in> A. a >>= min)))"
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1725
apply (erule finite.induct)
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1726
apply simp
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1727
apply simp
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1728
apply (case_tac "A = {}")
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1729
apply simp
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1730
apply clarsimp
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1731
apply (case_tac "a >>= min")
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1732
apply (rule_tac x = min in exI, simp)
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1733
apply (rule_tac x = a in exI, simp)
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1734
apply clarify
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1735
apply (rotate_tac 5)
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1736
apply (erule_tac x = aa in ballE) defer apply simp
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1737
apply (erule_tac ys = min in postfix_trans)
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1738
apply (erule_tac x = min in ballE) 
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1739
by simp+
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1740
18
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1741
lemma tag_str_star_inj:
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1742
  "tag_str_STAR L\<^isub>1 x = tag_str_STAR L\<^isub>1 (y::string) \<Longrightarrow> x \<equiv>L\<^isub>1\<star>\<equiv> y"
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1743
proof -
23
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1744
  have aux: "\<And> x y z. \<lbrakk>tag_str_STAR L\<^isub>1 x = tag_str_STAR L\<^isub>1 y; x @ z \<in> L\<^isub>1\<star>\<rbrakk> \<Longrightarrow> y @ z \<in> L\<^isub>1\<star>"
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1745
  proof-
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1746
    fix x y z
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1747
    assume tag_eq: "tag_str_STAR L\<^isub>1 x = tag_str_STAR L\<^isub>1 y"
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1748
      and x_z: "x @ z \<in> L\<^isub>1\<star>"
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1749
    show "y @ z \<in> L\<^isub>1\<star>"
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1750
    proof (cases "x = []")
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1751
      case True
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1752
      with tag_eq have "y = []" by (simp add:tag_str_STAR_def split:if_splits, blast)
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1753
      thus ?thesis using x_z True by simp
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1754
    next
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1755
      case False
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1756
      hence not_empty: "{xb. \<exists> xa. x = xa @ xb \<and> xa \<in> L\<^isub>1\<star> \<and> xb \<noteq> [] \<and> xb @ z \<in> L\<^isub>1\<star>} \<noteq> {}" using x_z
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1757
        by (simp, rule_tac x = x in exI, rule_tac x = "[]" in exI, simp add:start)
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1758
      have finite_set: "finite {xb. \<exists> xa. x = xa @ xb \<and> xa \<in> L\<^isub>1\<star> \<and> xb \<noteq> [] \<and> xb @ z \<in> L\<^isub>1\<star>}"
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1759
        apply (rule_tac B = "{xb. \<exists> xa. x = xa @ xb}" in finite_subset)
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1760
        apply auto
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1761
        apply (induct x, simp)
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1762
        apply (subgoal_tac "{xb. \<exists>xa. a # x = xa @ xb} = insert (a # x) {xb. \<exists>xa. x = xa @ xb}")
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1763
        apply auto
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1764
        by (case_tac xaa, simp+)
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1765
      have comparable: "\<forall> a \<in> {xb. \<exists> xa. x = xa @ xb \<and> xa \<in> L\<^isub>1\<star> \<and> xb \<noteq> [] \<and> xb @ z \<in> L\<^isub>1\<star>}. 
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1766
                        \<forall> b \<in> {xb. \<exists> xa. x = xa @ xb \<and> xa \<in> L\<^isub>1\<star> \<and> xb \<noteq> [] \<and> xb @ z \<in> L\<^isub>1\<star>}.
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1767
                          ((b >>= a) \<or> (a >>= b))"
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1768
        by (auto simp:postfix_def, drule app_eq_elim, blast)
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1769
      hence "\<exists> min. min \<in> {xb. \<exists> xa. x = xa @ xb \<and> xa \<in> L\<^isub>1\<star> \<and> xb \<noteq> [] \<and> xb @ z \<in> L\<^isub>1\<star>} 
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1770
                \<and> (\<forall> xa xb. x = xa @ xb \<and> xa \<in> L\<^isub>1\<star> \<and> xb \<noteq> [] \<and> xb @ z \<in> L\<^isub>1\<star> \<longrightarrow> xb >>= min)"
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1771
        using finite_set not_empty comparable
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1772
        apply (drule_tac min_postfix_exists, simp)
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1773
        by (erule exE, rule_tac x = min in exI, auto)
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1774
      then obtain min xa where x_decom: "x = xa @ min \<and> xa \<in> L\<^isub>1\<star>"
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1775
        and min_not_empty: "min \<noteq> []"
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1776
        and min_z_in_star: "min @ z \<in> L\<^isub>1\<star>"
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1777
        and is_min: "\<forall> xa xb. x = xa @ xb \<and> xa \<in> L\<^isub>1\<star> \<and> xb \<noteq> [] \<and> xb @ z \<in> L\<^isub>1\<star> \<longrightarrow> xb >>= min"  by blast
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1778
      from x_decom min_not_empty have "\<lbrakk>min\<rbrakk>L\<^isub>1 \<in> tag_str_STAR L\<^isub>1 x"  by (auto simp:tag_str_STAR_def)
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1779
      hence "\<exists> yb. \<lbrakk>yb\<rbrakk>L\<^isub>1 \<in> tag_str_STAR L\<^isub>1 y \<and> \<lbrakk>min\<rbrakk>L\<^isub>1 = \<lbrakk>yb\<rbrakk>L\<^isub>1" using tag_eq by auto
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1780
      hence "\<exists> ya yb. y = ya @ yb \<and> ya \<in> L\<^isub>1\<star> \<and> min \<equiv>L\<^isub>1\<equiv> yb \<and> yb \<noteq> [] " 
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1781
        by (simp add:tag_str_STAR_def equiv_class_def equiv_str_def split:if_splits, blast)        
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1782
      then obtain ya yb where y_decom: "y = ya @ yb"
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1783
                          and ya_in_star: "ya \<in> L\<^isub>1\<star>"
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1784
                          and yb_not_empty: "yb \<noteq> []"
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1785
                          and min_yb_eq: "min \<equiv>L\<^isub>1\<equiv> yb"  by blast
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1786
      from min_z_in_star min_yb_eq min_not_empty is_min x_decom
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1787
      have "yb @ z \<in> L\<^isub>1\<star>"
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1788
        by (rule_tac x = x and xa = xa in inj_aux, simp+)
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1789
      thus ?thesis using ya_in_star y_decom
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1790
        by (auto dest:star_prop)        
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1791
    qed
18
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1792
  qed
23
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1793
  show "tag_str_STAR L\<^isub>1 x = tag_str_STAR L\<^isub>1 (y::string) \<Longrightarrow> x \<equiv>L\<^isub>1\<star>\<equiv> y"
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1794
    by (auto intro:aux simp:equiv_str_def)
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1795
qed
18
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1796
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1797
lemma quot_star:  
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1798
  assumes finite1: "finite (QUOT L\<^isub>1)"
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1799
  shows "finite (QUOT (L\<^isub>1\<star>))"
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1800
proof (rule_tac f = "(op `) (tag_str_STAR L\<^isub>1)" in finite_imageD)
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1801
  show "finite (op ` (tag_str_STAR L\<^isub>1) ` QUOT (L\<^isub>1\<star>))"
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1802
    using finite_tag_image tag_str_star_range_finite finite1
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1803
    by auto
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1804
next
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1805
  show "inj_on (op ` (tag_str_STAR L\<^isub>1)) (QUOT (L\<^isub>1\<star>))"
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1806
    apply (rule_tac str_inj_imps)
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1807
    by (erule_tac tag_str_star_inj)
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1808
qed
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1809
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1810
lemma other_direction:
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1811
  "Lang = L (r::rexp) \<Longrightarrow> finite (QUOT Lang)"
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1812
apply (induct arbitrary:Lang rule:rexp.induct)
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1813
apply (simp add:QUOT_def equiv_class_def equiv_str_def)
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1814
by (simp_all add:quot_lambda quot_single quot_seq quot_alt quot_star)  
fbd62804f153 the ALT case is done;
wu
parents: 17
diff changeset
  1815
23
e31b733ace44 All cases of the Other direction finished
wu
parents: 19
diff changeset
  1816
end