MyhillNerode.thy
author urbanc
Thu, 21 Oct 2010 15:35:03 +0000
changeset 9 a53606765839
parent 8 1f8fe5bfd381
child 11 475dd40cd734
permissions -rw-r--r--
deleted the test
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
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
     2
  imports "Main" 
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
lemma lang_seq_minus:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    42
  shows "(L1; L2) - {[]} =
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    43
           (if [] \<in> L1 then L2 - {[]} else {}) \<union> 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    44
           (if [] \<in> L2 then L1 - {[]} else {}) \<union> ((L1 - {[]}); (L2 - {[]}))"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    45
apply(auto simp add: lang_seq_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    46
apply(metis mem_def self_append_conv)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    47
apply(metis mem_def self_append_conv2)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    48
apply(metis mem_def self_append_conv2)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    49
apply(metis mem_def self_append_conv)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    50
done
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    51
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    52
section {* Kleene star for languages defined as least fixed point *}
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    53
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    54
inductive_set
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    55
  Star :: "string set \<Rightarrow> string set" ("_\<star>" [101] 102)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    56
  for L :: "string set"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    57
where
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    58
  start[intro]: "[] \<in> L\<star>"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    59
| 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
    60
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    61
lemma lang_star_empty:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    62
  shows "{}\<star> = {[]}"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    63
by (auto elim: Star.cases)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    64
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    65
lemma lang_star_cases:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    66
  shows "L\<star> =  {[]} \<union> L ; L\<star>"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    67
proof
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    68
  { fix x
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    69
    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
    70
      unfolding lang_seq_def
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    71
    by (induct rule: Star.induct) (auto)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    72
  }
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    73
  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
    74
next
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    75
  show "{[]} \<union> L ; L\<star> \<subseteq> L\<star>" 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    76
    unfolding lang_seq_def by auto
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    77
qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    78
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    79
lemma lang_star_cases':
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    80
  shows "L\<star> =  {[]} \<union> L\<star> ; L"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    81
proof
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    82
  { fix x
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    83
    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
    84
      unfolding lang_seq_def
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    85
    apply (induct rule: Star.induct)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    86
    apply simp
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    87
    apply simp
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    88
    apply (erule disjE)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    89
    apply (auto)[1]
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    90
    apply (erule exE | erule conjE)+
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    91
    apply (rule disjI2)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    92
    apply (rule_tac x = "s1 @ s1a" in exI)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    93
    by auto
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    94
  }
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    95
  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
    96
next
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    97
  show "{[]} \<union> L\<star> ; L \<subseteq> L\<star>" 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    98
    unfolding lang_seq_def
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
    99
    apply auto
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   100
    apply (erule Star.induct)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   101
    apply auto
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   102
    apply (drule step[of _ _ "[]"])
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   103
    by (auto intro:start)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   104
qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   105
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   106
lemma lang_star_simple:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   107
  shows "L \<subseteq> L\<star>"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   108
by (subst lang_star_cases)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   109
   (auto simp only: lang_seq_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   110
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   111
lemma lang_star_prop0_aux:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   112
  "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
   113
apply (erule Star.induct)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   114
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
   115
apply (clarify, drule_tac x = s1 in spec)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   116
apply (drule mp, simp, clarify)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   117
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
   118
by auto
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   119
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   120
lemma lang_star_prop0:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   121
  "\<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
   122
by (auto dest:lang_star_prop0_aux)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   123
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   124
lemma lang_star_prop1:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   125
  assumes asm: "L1; L2 \<subseteq> L2" 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   126
  shows "L1\<star>; L2 \<subseteq> L2"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   127
proof -
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   128
  { fix s1 s2
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   129
    assume minor: "s2 \<in> L2"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   130
    assume major: "s1 \<in> L1\<star>"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   131
    then have "s1@s2 \<in> L2"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   132
    proof(induct rule: Star.induct)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   133
      case start
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   134
      show "[]@s2 \<in> L2" using minor by simp
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   135
    next
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   136
      case (step s1 s1')
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   137
      have "s1 \<in> L1" by fact
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   138
      moreover
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   139
      have "s1'@s2 \<in> L2" by fact
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   140
      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
   141
      with asm have "s1@(s1'@s2) \<in> L2" by auto
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   142
      then show "(s1@s1')@s2 \<in> L2" by simp
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   143
    qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   144
  } 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   145
  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
   146
qed
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_prop2_aux:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   149
  "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
   150
apply (erule Star.induct, simp)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   151
apply (clarify, drule_tac x = "s1a @ s1" in spec)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   152
by (auto simp:lang_seq_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   153
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   154
lemma lang_star_prop2:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   155
  "L1; L2 \<subseteq> L1 \<Longrightarrow> L1 ; L2\<star> \<subseteq> L1"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   156
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
   157
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   158
lemma lang_star_seq_subseteq: 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   159
  shows "L ; L\<star> \<subseteq> L\<star>"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   160
using lang_star_cases by blast
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   161
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   162
lemma lang_star_double:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   163
  shows "L\<star>; L\<star> = L\<star>"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   164
proof
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   165
  show "L\<star> ; L\<star> \<subseteq> L\<star>" 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   166
    using lang_star_prop1 lang_star_seq_subseteq by blast
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   167
next
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   168
  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
   169
  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
   170
  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
   171
  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
   172
  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
   173
qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   174
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   175
lemma lang_star_seq_subseteq': 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   176
  shows "L\<star>; L \<subseteq> L\<star>"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   177
proof -
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   178
  have "L \<subseteq> L\<star>" by (rule lang_star_simple)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   179
  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
   180
  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
   181
qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   182
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   183
lemma
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   184
  shows "L\<star> \<subseteq> L\<star>\<star>"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   185
by (rule lang_star_simple)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   186
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
section {* regular expressions *}
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   189
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   190
datatype rexp =
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   191
  NULL
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   192
| EMPTY
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   193
| CHAR char
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   194
| SEQ rexp rexp
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   195
| ALT rexp rexp
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   196
| STAR rexp
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   197
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   198
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   199
consts L:: "'a \<Rightarrow> string set"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   200
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   201
overloading L_rexp \<equiv> "L::  rexp \<Rightarrow> string set"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   202
begin
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   203
fun
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   204
  L_rexp :: "rexp \<Rightarrow> string set"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   205
where
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   206
    "L_rexp (NULL) = {}"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   207
  | "L_rexp (EMPTY) = {[]}"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   208
  | "L_rexp (CHAR c) = {[c]}"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   209
  | "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
   210
  | "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
   211
  | "L_rexp (STAR r) = (L_rexp r)\<star>"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   212
end
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   213
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   214
8
1f8fe5bfd381 tried at the end to prove the other direction (failed at the moment)
urbanc
parents: 7
diff changeset
   215
text{* ************ now is the codes writen by chunhan ************************************* *}
6
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   216
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   217
section {* Arden's Lemma revised *}
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   218
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   219
lemma arden_aux1:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   220
  assumes a: "X \<subseteq> X ; A \<union> B"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   221
  and     b: "[] \<notin> A"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   222
  shows      "x \<in> X \<Longrightarrow> x \<in> B ; A\<star>"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   223
apply (induct x taking:length rule:measure_induct)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   224
apply (subgoal_tac "x \<in> X ; A \<union> B")
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   225
defer
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   226
using a
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   227
apply (auto)[1]
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
apply (erule disjE)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   230
defer
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   231
apply (auto simp add:lang_seq_def) [1]
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   232
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
   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
apply (erule exE | erule conjE)+
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   236
apply simp
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   237
apply (drule_tac x = x1 in spec)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   238
apply (simp)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   239
using b
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   240
apply -
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   241
apply (auto)[1]
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   242
apply (subgoal_tac "x1 @ x2 \<in> (B ; A\<star>) ; A")
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   243
defer
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   244
apply (auto simp add:lang_seq_def)[1]
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   245
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
   246
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   247
theorem ardens_revised:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   248
  assumes nemp: "[] \<notin> A"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   249
  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
   250
apply(rule iffI)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   251
defer
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   252
apply(simp)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   253
apply(subst lang_star_cases')
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   254
apply(subst lang_seq_union)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   255
apply(simp add: lang_seq_empty)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   256
apply(simp add: lang_seq_assoc)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   257
apply(auto)[1]
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   258
proof -
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   259
  assume "X = X ; A \<union> B"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   260
  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
   261
  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
   262
  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
   263
  moreover
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   264
  from a have "X ; A\<star> \<subseteq> X" 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   265
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   266
by (rule lang_star_prop2)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   267
  ultimately have f1: "B ; A\<star> \<subseteq> X" by simp
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   268
  from as2 nemp
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   269
  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
   270
  from f1 f2 show "X = B; A\<star>" by auto
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   271
qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   272
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   273
section {* equiv class' definition *}
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   274
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   275
definition 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   276
  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
   277
where
8
1f8fe5bfd381 tried at the end to prove the other direction (failed at the moment)
urbanc
parents: 7
diff changeset
   278
  "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
   279
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   280
definition
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   281
  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
   282
where
8
1f8fe5bfd381 tried at the end to prove the other direction (failed at the moment)
urbanc
parents: 7
diff changeset
   283
  "\<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
   284
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   285
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
   286
6
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   287
definition  
8
1f8fe5bfd381 tried at the end to prove the other direction (failed at the moment)
urbanc
parents: 7
diff changeset
   288
  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
   289
where
8
1f8fe5bfd381 tried at the end to prove the other direction (failed at the moment)
urbanc
parents: 7
diff changeset
   290
  "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
   291
1f8fe5bfd381 tried at the end to prove the other direction (failed at the moment)
urbanc
parents: 7
diff changeset
   292
1f8fe5bfd381 tried at the end to prove the other direction (failed at the moment)
urbanc
parents: 7
diff changeset
   293
1f8fe5bfd381 tried at the end to prove the other direction (failed at the moment)
urbanc
parents: 7
diff changeset
   294
6
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   295
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   296
lemma lang_eqs_union_of_eqcls: 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   297
  "Lang = \<Union> {X. X \<in> (UNIV Quo Lang) \<and> (\<forall> x \<in> X. x \<in> Lang)}"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   298
proof
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   299
  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
   300
  proof
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   301
    fix x
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   302
    assume "x \<in> Lang"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   303
    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
   304
    proof (simp add:quot_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   305
      assume "(1)": "x \<in> Lang"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   306
      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
   307
      proof -
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   308
        have "?P (\<lbrakk>x\<rbrakk>Lang)" using "(1)"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   309
          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
   310
        thus ?thesis by blast
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   311
      qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   312
    qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   313
  qed   
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   314
next
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   315
  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
   316
    by auto
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   317
qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   318
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   319
lemma empty_notin_CS: "{} \<notin> UNIV Quo Lang"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   320
apply (clarsimp simp:quot_def equiv_class_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   321
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
   322
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   323
lemma no_two_cls_inters:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   324
  "\<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
   325
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
   326
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   327
text {* equiv_class transition *}
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   328
definition 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   329
  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
   330
where
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   331
  "X-c\<rightarrow>Y \<equiv> ((X;{[c]}) \<subseteq> Y)"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   332
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   333
types t_equa_rhs = "(string set \<times> rexp) set"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   334
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   335
types t_equa = "(string set \<times> t_equa_rhs)"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   336
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   337
types t_equas = "t_equa set"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   338
8
1f8fe5bfd381 tried at the end to prove the other direction (failed at the moment)
urbanc
parents: 7
diff changeset
   339
text {* 
1f8fe5bfd381 tried at the end to prove the other direction (failed at the moment)
urbanc
parents: 7
diff changeset
   340
  "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
   341
  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
   342
  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
   343
*} 
1f8fe5bfd381 tried at the end to prove the other direction (failed at the moment)
urbanc
parents: 7
diff changeset
   344
6
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   345
definition 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   346
  empty_rhs :: "string set \<Rightarrow> t_equa_rhs"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   347
where
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   348
  "empty_rhs X \<equiv> if ([] \<in> X) then {({[]}, EMPTY)} else {}"
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
  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
   352
where
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   353
  "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
   354
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   355
definition 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   356
  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
   357
where
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   358
  "equation_rhs CS X \<equiv> if (X = {[]}) then {({[]}, EMPTY)}
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   359
                         else {(S, folds ALT NULL {CHAR c| c. S-c\<rightarrow>X} )| S. S \<in> CS} \<union> empty_rhs X"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   360
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   361
definition 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   362
  equations :: "(string set) set \<Rightarrow> t_equas"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   363
where
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   364
  "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
   365
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   366
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
   367
begin
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   368
fun L_rhs:: "t_equa_rhs \<Rightarrow> string set"
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
  "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
   371
end
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   372
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   373
definition 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   374
  distinct_rhs :: "t_equa_rhs \<Rightarrow> bool"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   375
where
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   376
  "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
   377
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   378
definition
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   379
  distinct_equas_rhs :: "t_equas \<Rightarrow> bool"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   380
where
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   381
  "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
   382
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   383
definition 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   384
  distinct_equas :: "t_equas \<Rightarrow> bool"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   385
where
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   386
  "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
   387
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   388
definition 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   389
  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
   390
where
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   391
  "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
   392
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   393
definition 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   394
  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
   395
where
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   396
  "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
   397
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   398
definition
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   399
  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
   400
where
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   401
  "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
   402
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   403
definition
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   404
  no_EMPTY_rhs :: "t_equa_rhs \<Rightarrow> bool"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   405
where
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   406
  "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
   407
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   408
definition 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   409
  no_EMPTY_equas :: "t_equas \<Rightarrow> bool"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   410
where
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   411
  "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
   412
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   413
lemma fold_alt_null_eqs:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   414
  "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
   415
apply (simp add:folds_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   416
apply (rule someI2_ex)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   417
apply (erule finite_imp_fold_graph)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   418
apply (erule fold_graph.induct)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   419
by auto (*??? how do this be in Isar ?? *)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   420
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   421
lemma seq_rhs_r_prop1:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   422
  "L (seq_rhs_r rhs r) = (L rhs);(L r)"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   423
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
   424
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
   425
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
   426
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
   427
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
   428
apply (rule conjI)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   429
apply (rule_tac x = "(X, ra)" in bexI, simp+) 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   430
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
   431
apply (simp add:lang_seq_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   432
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
   433
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   434
lemma del_x_paired_prop1:  
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   435
  "\<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
   436
  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
   437
  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
   438
  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
   439
  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
   440
  done
6
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   441
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   442
lemma arden_variate_prop:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   443
  assumes "(X, rx) \<in> rhs"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   444
  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
   445
proof (rule allI, rule impI)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   446
  fix Y
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   447
  assume "(1)": "Y \<noteq> X"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   448
  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
   449
  proof
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   450
    assume "(1_1)": "\<exists>r. (Y, r) \<in> rhs"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   451
    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
   452
    proof -
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   453
      from "(1_1)" obtain r where "(Y, r) \<in> rhs" ..
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   454
      hence "?P (SEQ r (STAR rx))"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   455
      proof (simp add:arden_variate_def image_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   456
        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
   457
          by (auto simp:del_x_paired_def "(1)")
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   458
        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
   459
          by (auto simp:seq_rhs_r_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   460
      qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   461
      thus ?thesis by blast
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   462
    qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   463
  next
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   464
    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
   465
    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
   466
      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
   467
  qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   468
qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   469
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   470
text {*
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   471
  arden_variate_valid:  proves variation from "X = X;r + Y;ry + \<dots>" to "X = Y;(SEQ ry (STAR r)) + \<dots>" holds the law of "language of left equiv language of right" 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   472
*}
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   473
lemma arden_variate_valid:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   474
  assumes X_not_empty: "X \<noteq> {[]}"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   475
  and     l_eq_r:   "X = L rhs"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   476
  and     dist: "distinct_rhs rhs"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   477
  and     no_empty: "no_EMPTY_rhs rhs"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   478
  and     self_contained: "(X, r) \<in> rhs"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   479
  shows   "X = L (arden_variate X r rhs)" 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   480
proof -
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   481
  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
   482
    by (auto simp:no_EMPTY_rhs_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   483
  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
   484
    by (rule ardens_revised)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   485
  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
   486
    by (auto dest!:del_x_paired_prop1)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   487
  show ?thesis
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   488
  proof
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   489
    show "X \<subseteq> L (arden_variate X r rhs)"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   490
    proof
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   491
      fix x
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   492
      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
   493
      show "x \<in> L (arden_variate X r rhs)" 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   494
        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
   495
    qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   496
  next
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   497
    show "L (arden_variate X r rhs) \<subseteq> X"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   498
    proof
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   499
      fix x
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   500
      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
   501
      show "x \<in> X" 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   502
        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
   503
    qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   504
  qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   505
qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   506
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   507
text {* merge_rhs {(X1, r1), (x2, r2}, (x4, r4), \<dots>} {(x1, r1'), (x3, r3'), \<dots>} = {(x1, ALT r1 r1'}, (x2, r2), (x3, r3'), (x4, r4), \<dots>} *}  
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   508
definition 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   509
  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
   510
where
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   511
  "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
   512
                                 (\<exists> r1. (X, r1) \<in> rhs \<and> (\<not> (\<exists> r2. (X, r2) \<in> rhs')) \<and> r = r1) \<or>
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   513
                                 (\<exists> r2. (X, r2) \<in> rhs' \<and> (\<not> (\<exists> r1. (X, r1) \<in> rhs)) \<and> r = r2)    }"                                  
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   514
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   515
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   516
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
   517
definition 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   518
  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
   519
where
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   520
  "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
   521
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   522
definition 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   523
  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
   524
where
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   525
  "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
   526
                                 if (\<exists> r. (X, r) \<in> rhs)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   527
                                 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
   528
                                 else equa"
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
definition
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   531
  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
   532
where
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   533
  "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
   534
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   535
lemma lang_seq_prop1:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   536
 "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
   537
by (auto simp:lang_seq_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   538
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   539
lemma lang_seq_prop1':
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   540
  "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
   541
by (auto simp:lang_seq_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   542
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   543
lemma lang_seq_prop2:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   544
  "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
   545
by (auto simp:lang_seq_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   546
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   547
lemma merge_rhs_prop1:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   548
  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
   549
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
   550
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
   551
apply (case_tac "\<exists> r2. (X, r2) \<in> rhs'")
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   552
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
   553
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
   554
apply (case_tac "\<exists> r1. (X, r1) \<in> rhs")
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   555
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
   556
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
   557
done
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   558
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   559
lemma no_EMPTY_rhss_imp_merge_no_EMPTY:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   560
  "\<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
   561
apply (simp add:no_EMPTY_rhs_def merge_rhs_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   562
apply (clarify, (erule conjE | erule exE | erule disjE)+)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   563
by auto
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   564
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   565
lemma distinct_rhs_prop:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   566
  "\<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
   567
by (auto simp:distinct_rhs_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   568
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   569
lemma merge_rhs_prop2:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   570
  assumes dist_rhs: "distinct_rhs rhs"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   571
  and     dist_rhs':"distinct_rhs rhs'"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   572
  shows "distinct_rhs (merge_rhs rhs rhs')"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   573
apply (auto simp:merge_rhs_def distinct_rhs_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   574
using dist_rhs
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   575
apply (drule distinct_rhs_prop, simp+)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   576
using dist_rhs'
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   577
apply (drule distinct_rhs_prop, simp+)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   578
using dist_rhs
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   579
apply (drule distinct_rhs_prop, simp+)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   580
using dist_rhs'
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   581
apply (drule distinct_rhs_prop, simp+)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   582
done
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   583
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   584
lemma seq_rhs_r_holds_distinct: 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   585
  "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
   586
by (auto simp:distinct_rhs_def seq_rhs_r_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   587
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   588
lemma seq_rhs_r_prop0:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   589
  assumes l_eq_r: "X = L xrhs"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   590
  shows "L (seq_rhs_r xrhs r) = X ; L r "
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   591
using l_eq_r
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   592
by (auto simp only:seq_rhs_r_prop1)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   593
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   594
lemma rhs_subst_prop1:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   595
  assumes l_eq_r: "X = L xrhs"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   596
  and     dist:  "distinct_rhs rhs"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   597
  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
   598
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
   599
using l_eq_r 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   600
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
   601
using dist
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   602
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
   603
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   604
lemma del_x_paired_holds_distinct_rhs:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   605
  "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
   606
by (auto simp:distinct_rhs_def del_x_paired_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   607
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   608
lemma rhs_subst_holds_distinct_rhs:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   609
  "\<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
   610
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
   611
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
   612
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
   613
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   614
section {* myhill-nerode theorem *}
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   615
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   616
definition left_eq_cls :: "t_equas \<Rightarrow> (string set) set"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   617
where
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   618
  "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
   619
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   620
definition right_eq_cls :: "t_equas \<Rightarrow> (string set) set"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   621
where
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   622
  "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
   623
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   624
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
   625
where
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   626
  "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
   627
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   628
definition ardenable :: "t_equa \<Rightarrow> bool"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   629
where
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   630
  "ardenable equa \<equiv> let (X, rhs) = equa in 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   631
                      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
   632
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   633
text {*
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   634
  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
   635
*}
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   636
definition Inv :: "string set \<Rightarrow> t_equas \<Rightarrow> bool"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   637
where
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   638
  "Inv X ES \<equiv> finite ES \<and> (\<exists> rhs. (X, rhs) \<in> ES) \<and> distinct_equas ES \<and> 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   639
            (\<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))"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   640
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   641
text {*
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   642
  TCon: Termination Condition of the equation-system decreasion.
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
definition TCon:: "'a set \<Rightarrow> bool"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   645
where
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   646
  "TCon ES \<equiv> card ES = 1"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   647
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   648
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   649
text {* 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   650
  The following is a iteration principle, and is the main framework for the proof:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   651
   1: We can form the initial equation-system using "equations" defined above, and prove it has invariance Inv by lemma "init_ES_satisfy_Inv";
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   652
   2: We can decrease the number of the equation-system using ardens_lemma_revised and substitution ("equas_subst", defined above), 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   653
        and prove it holds the property "step" in "wf_iter" by lemma "iteration_step"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   654
   and finally using property Inv and TCon to prove the myhill-nerode theorem
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   655
  
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   656
*}
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   657
lemma wf_iter [rule_format]: 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   658
  fixes f
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   659
  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
   660
  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
   661
proof(induct e rule: wf_induct 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   662
           [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
   663
  fix x 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   664
  assume h [rule_format]: 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   665
    "\<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
   666
    and px: "P x"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   667
  show "\<exists>e'. P e' \<and> Q e'"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   668
  proof(cases "Q x")
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   669
    assume "Q x" with px show ?thesis by blast
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   670
  next
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   671
    assume nq: "\<not> Q x"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   672
    from step [OF px nq]
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   673
    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
   674
    show ?thesis
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   675
    proof(rule h)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   676
      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
   677
	by (simp add:inv_image_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   678
    next
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   679
      from pe' show "P e'" .
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   680
    qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   681
  qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   682
qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   683
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   684
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   685
(* ********************************* BEGIN: proving the initial equation-system satisfies Inv **************************************** *)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   686
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   687
lemma distinct_rhs_equations:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   688
  "(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
   689
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
   690
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   691
lemma every_nonempty_eqclass_has_strings:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   692
  "\<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
   693
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
   694
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   695
lemma every_eqclass_is_derived_from_empty:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   696
  assumes not_empty: "X \<noteq> {[]}"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   697
  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
   698
using not_empty
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   699
apply (drule_tac every_nonempty_eqclass_has_strings, simp)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   700
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
   701
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   702
lemma equiv_str_in_CS:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   703
  "\<lbrakk>clist\<rbrakk>Lang \<in> (UNIV Quo Lang)"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   704
by (auto simp:quot_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   705
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   706
lemma has_str_imp_defined_by_str:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   707
  "\<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
   708
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
   709
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   710
lemma every_eqclass_has_ascendent:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   711
  assumes has_str: "clist @ [c] \<in> X"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   712
  and     in_CS:   "X \<in> UNIV Quo Lang"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   713
  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
   714
proof -
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   715
  have "?P (\<lbrakk>clist\<rbrakk>Lang)" 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   716
  proof -
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   717
    have "\<lbrakk>clist\<rbrakk>Lang \<in> UNIV Quo Lang"       
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   718
      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
   719
    moreover have "\<lbrakk>clist\<rbrakk>Lang-c\<rightarrow>X" 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   720
    proof -
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   721
      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
   722
        by (auto intro!:has_str_imp_defined_by_str)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   723
      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
   724
        by (auto simp:equiv_class_def equiv_str_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   725
      ultimately show ?thesis unfolding CT_def lang_seq_def
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   726
        by auto
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   727
    qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   728
    moreover have "clist \<in> \<lbrakk>clist\<rbrakk>Lang" 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   729
      by (auto simp:equiv_str_def equiv_class_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   730
    ultimately show "?P (\<lbrakk>clist\<rbrakk>Lang)" by simp
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   731
  qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   732
  thus ?thesis by blast
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   733
qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   734
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   735
lemma finite_charset_rS:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   736
  "finite {CHAR c |c. Y-c\<rightarrow>X}"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   737
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
   738
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   739
lemma l_eq_r_in_equations:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   740
  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
   741
  shows "X = L xrhs"    
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   742
proof (cases "X = {[]}")
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   743
  case True
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   744
  thus ?thesis using X_in_equas 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   745
    by (simp add:equations_def equation_rhs_def lang_seq_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   746
next
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   747
  case False 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   748
  show ?thesis
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   749
  proof 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   750
    show "X \<subseteq> L xrhs"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   751
    proof
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   752
      fix x
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   753
      assume "(1)": "x \<in> X"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   754
      show "x \<in> L xrhs"          
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   755
      proof (cases "x = []")
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   756
        assume empty: "x = []"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   757
        hence "x \<in> L (empty_rhs X)" using "(1)"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   758
          by (auto simp:empty_rhs_def lang_seq_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   759
        thus ?thesis using X_in_equas False empty "(1)" 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   760
          unfolding equations_def equation_rhs_def by auto
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   761
      next
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   762
        assume not_empty: "x \<noteq> []"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   763
        hence "\<exists> clist c. x = clist @ [c]" by (case_tac x rule:rev_cases, auto)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   764
        then obtain clist c where decom: "x = clist @ [c]" by blast
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   765
        moreover have "\<And> Y. \<lbrakk>Y \<in> UNIV Quo Lang; Y-c\<rightarrow>X; clist \<in> Y\<rbrakk>\<Longrightarrow> [c] \<in> L (folds ALT NULL {CHAR c |c. Y-c\<rightarrow>X})"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   766
        proof -
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   767
          fix Y
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   768
          assume Y_is_eq_cl: "Y \<in> UNIV Quo Lang"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   769
            and Y_CT_X: "Y-c\<rightarrow>X"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   770
            and clist_in_Y: "clist \<in> Y"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   771
          with finite_charset_rS 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   772
          show "[c] \<in> L (folds ALT NULL {CHAR c |c. Y-c\<rightarrow>X})"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   773
            by (auto simp :fold_alt_null_eqs)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   774
        qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   775
        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
   776
          using X_in_equas False not_empty "(1)" decom
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   777
          by (auto dest!:every_eqclass_has_ascendent simp:equations_def equation_rhs_def lang_seq_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   778
        then obtain Xa where "Xa \<in> UNIV Quo Lang \<and> clist @ [c] \<in> Xa ; L (folds ALT NULL {CHAR c |c. Xa-c\<rightarrow>X})" by blast
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   779
        hence "x \<in> L {(S, folds ALT NULL {CHAR c |c. S-c\<rightarrow>X}) |S. S \<in> UNIV Quo Lang}" using X_in_equas "(1)" decom
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   780
          by (auto simp add:equations_def equation_rhs_def intro!:exI[where x = Xa])
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   781
        thus "x \<in> L xrhs" using X_in_equas False not_empty unfolding equations_def equation_rhs_def
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   782
          by auto
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   783
      qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   784
    qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   785
  next
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   786
    show "L xrhs \<subseteq> X"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   787
    proof
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   788
      fix x 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   789
      assume "(2)": "x \<in> L xrhs"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   790
      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
   791
        using finite_charset_rS
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   792
        by (auto simp:CT_def lang_seq_def fold_alt_null_eqs)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   793
      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"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   794
        by (simp add:empty_rhs_def split:if_splits)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   795
      show "x \<in> X" using X_in_equas False "(2)"         
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   796
        by (auto intro:"(2_1)" "(2_2)" simp:equations_def equation_rhs_def lang_seq_def)
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
  qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   799
qed
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 finite_CT_chars:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   802
  "finite {CHAR c |c. Xa-c\<rightarrow>X}"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   803
by (auto)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   804
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   805
lemma no_EMPTY_equations:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   806
  "(X, xrhs) \<in> equations CS \<Longrightarrow> no_EMPTY_rhs xrhs"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   807
apply (clarsimp simp add:equations_def equation_rhs_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   808
apply (simp add:no_EMPTY_rhs_def empty_rhs_def, auto)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   809
apply (subgoal_tac "finite {CHAR c |c. Xa-c\<rightarrow>X}", drule_tac x = "[]" in fold_alt_null_eqs, clarsimp, rule finite_CT_chars)+
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   810
done
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   811
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   812
lemma init_ES_satisfy_ardenable:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   813
  "(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
   814
  unfolding ardenable_def
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   815
  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
   816
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   817
lemma init_ES_satisfy_Inv:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   818
  assumes finite_CS: "finite (UNIV Quo Lang)"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   819
  and X_in_eq_cls: "X \<in> UNIV Quo Lang"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   820
  shows "Inv X (equations (UNIV Quo Lang))"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   821
proof -
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   822
  have "finite (equations (UNIV Quo Lang))" using finite_CS
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   823
    by (auto simp:equations_def)    
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   824
  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
   825
    by (simp add:equations_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   826
  moreover have "distinct_equas (equations (UNIV Quo Lang))" 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   827
    by (auto simp:distinct_equas_def equations_def)
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>
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   829
                 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
   830
    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
   831
    by (auto simp:empty_rhs_def split:if_splits)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   832
  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
   833
    by (clarsimp simp:equations_def empty_notin_CS intro:classical)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   834
  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
   835
    by (auto intro!:init_ES_satisfy_ardenable)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   836
  ultimately show ?thesis by (simp add:Inv_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   837
qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   838
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   839
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   840
(* ********************************* END: proving the initial equation-system satisfies Inv **************************************** *)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   841
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   842
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   843
(* ***************************** BEGIN: proving every equation-system's iteration step satisfies Inv ******************************* *)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   844
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   845
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
   846
       \<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
   847
apply (case_tac "insert a A = {a}")
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   848
by (auto simp:TCon_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   849
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   850
lemma not_T_atleast_2[rule_format]:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   851
  "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
   852
apply (erule finite.induct, simp)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   853
apply (clarify, case_tac "x = a")
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   854
by (erule not_T_aux, auto)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   855
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   856
lemma exist_another_equa: 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   857
  "\<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
   858
apply (drule not_T_atleast_2, simp)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   859
apply (clarsimp simp:distinct_equas_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   860
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
   861
by auto
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   862
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   863
lemma Inv_mono_with_lambda:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   864
  assumes Inv_ES: "Inv X ES"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   865
  and X_noteq_Y:  "X \<noteq> {[]}"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   866
  shows "Inv X (ES - {({[]}, yrhs)})"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   867
proof -
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   868
  have "finite (ES - {({[]}, yrhs)})" using Inv_ES
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   869
    by (simp add:Inv_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   870
  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
   871
    by (simp add:Inv_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   872
  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
   873
    apply (clarsimp simp:Inv_def distinct_equas_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   874
    by (drule_tac x = Xa in spec, simp)    
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   875
  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
   876
                          ardenable (X, xrhs) \<and> X \<noteq> {}" using Inv_ES
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   877
    by (clarify, simp add:Inv_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   878
  moreover 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   879
  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
   880
    by (auto simp:left_eq_cls_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   881
  hence "\<forall>X xrhs.(X, xrhs) \<in> ES - {({[]}, yrhs)} \<longrightarrow>
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   882
                          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
   883
    using Inv_ES by (auto simp:Inv_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   884
  ultimately show ?thesis by (simp add:Inv_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   885
qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   886
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   887
lemma non_empty_card_prop:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   888
  "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
   889
apply (erule finite.induct, simp)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   890
apply (case_tac[!] "a \<in> A")
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   891
by (auto simp:insert_absorb)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   892
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   893
lemma ardenable_prop:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   894
  assumes not_lambda: "Y \<noteq> {[]}"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   895
  and ardable: "ardenable (Y, yrhs)"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   896
  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'")
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   897
proof (cases "(\<exists> reg. (Y, reg) \<in> yrhs)")
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   898
  case True
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   899
  thus ?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
    fix reg
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   902
    assume self_contained: "(Y, reg) \<in> yrhs"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   903
    show ?thesis 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   904
    proof -
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   905
      have "?P (arden_variate Y reg yrhs)"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   906
      proof -
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   907
        have "Y = L (arden_variate Y reg yrhs)" 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   908
          using self_contained not_lambda ardable
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   909
          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
   910
        moreover have "distinct_rhs (arden_variate Y reg yrhs)" 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   911
          using ardable 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   912
          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
   913
        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
   914
        proof -
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   915
          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
   916
            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
   917
            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
   918
          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
   919
            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
   920
          ultimately show ?thesis by (simp add:arden_variate_def)
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
        ultimately show ?thesis by simp
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   923
      qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   924
      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
   925
    qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   926
  qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   927
next
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   928
  case False
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   929
  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
   930
    by (auto simp:rhs_eq_cls_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   931
  show ?thesis 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   932
  proof -
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   933
    have "?P yrhs" using False ardable "(2)" 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   934
      by (simp add:ardenable_def)      
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   935
    thus ?thesis by blast
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   936
  qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   937
qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   938
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   939
lemma equas_subst_f_del_no_other:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   940
  assumes self_contained: "(Y, rhs) \<in> ES"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   941
  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
   942
proof -
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   943
  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
   944
    by (auto simp:equas_subst_f_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   945
  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
   946
  hence "?P rhs'" unfolding image_def using self_contained
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   947
    by (auto intro:bexI[where x = "(Y, rhs)"])
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   948
  thus ?thesis by blast
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   949
qed
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 del_x_paired_del_only_x: 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   952
  "\<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
   953
by (auto simp:del_x_paired_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   954
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   955
lemma equas_subst_del_no_other:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   956
 "\<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
   957
unfolding equas_subst_def
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   958
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
   959
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
   960
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   961
lemma equas_subst_holds_distinct:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   962
  "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
   963
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
   964
by (auto split:if_splits)
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_dels: 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   967
  "(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
   968
by (auto)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   969
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   970
lemma del_x_paired_subset:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   971
  "(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
   972
apply (drule del_x_paired_dels)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   973
by auto
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   974
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   975
lemma del_x_paired_card_less: 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   976
  "\<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
   977
apply (simp add:del_x_paired_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   978
apply (drule del_x_paired_subset)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   979
by (auto intro:psubset_card_mono)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   980
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   981
lemma equas_subst_card_less:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   982
  "\<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
   983
apply (simp add:equas_subst_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   984
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
   985
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
   986
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
   987
by (drule del_x_paired_card_less, auto)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   988
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   989
lemma equas_subst_holds_distinct_rhs:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   990
  assumes   dist': "distinct_rhs yrhs'"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   991
  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
   992
  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
   993
  shows "distinct_rhs xrhs"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   994
using X_in history
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   995
apply (clarsimp simp:equas_subst_def del_x_paired_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   996
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
   997
apply (simp add:ardenable_def equas_subst_f_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
   998
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
   999
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1000
lemma r_no_EMPTY_imp_seq_rhs_r_no_EMPTY:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1001
  "[] \<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
  1002
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
  1003
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1004
lemma del_x_paired_holds_no_EMPTY:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1005
  "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
  1006
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
  1007
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1008
lemma rhs_subst_holds_no_EMPTY:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1009
  "\<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
  1010
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
  1011
by (auto simp:no_EMPTY_rhs_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1012
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1013
lemma equas_subst_holds_no_EMPTY:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1014
  assumes substor: "Y \<noteq> {[]}"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1015
  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
  1016
  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
  1017
  shows "no_EMPTY_rhs xrhs"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1018
proof-
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1019
  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
  1020
    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
  1021
  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
  1022
                       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
  1023
  hence dist_zrhs: "distinct_rhs zrhs" using history
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1024
    by (auto simp:ardenable_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1025
  show ?thesis
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1026
  proof (cases "\<exists> r. (Y, r) \<in> zrhs")
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1027
    case True
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1028
    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
  1029
    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
  1030
      by (auto simp:distinct_rhs_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1031
    hence "no_EMPTY_rhs (rhs_subst zrhs Y yrhs' r)"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1032
      using substor Y_in_zrhs history Z_in
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1033
      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
  1034
    thus ?thesis using X_Z True some
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1035
      by (simp add:equas_subst_def equas_subst_f_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1036
  next
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1037
    case False
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1038
    hence "(X, xrhs) = (Z, zrhs)" using Z_in X_Z
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1039
      by (simp add:equas_subst_f_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1040
    thus ?thesis using history Z_in
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1041
      by (auto simp:ardenable_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1042
  qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1043
qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1044
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1045
lemma equas_subst_f_holds_left_eq_right:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1046
  assumes substor: "Y = L rhs'"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1047
  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
  1048
  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
  1049
  and     self_contained: "(Z, zrhs) \<in> ES"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1050
  shows "X = L xrhs"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1051
proof (cases "\<exists> r. (Y, r) \<in> zrhs")
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1052
  case True
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1053
  from True obtain r where "(1)":"(Y, r) \<in> zrhs" ..
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1054
  show ?thesis
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1055
  proof -
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1056
    from history self_contained
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1057
    have dist: "distinct_rhs zrhs" by auto
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1058
    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
  1059
      using distinct_rhs_def by (auto intro:some_equality)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1060
    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
  1061
      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
  1062
    ultimately show ?thesis using subst history self_contained
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1063
      by (auto simp:equas_subst_f_def split:if_splits)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1064
  qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1065
next
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1066
  case False
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1067
  thus ?thesis using history subst self_contained
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1068
    by (auto simp:equas_subst_f_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1069
qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1070
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1071
lemma equas_subst_holds_left_eq_right:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1072
  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
  1073
  and     substor: "Y = L rhs'"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1074
  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
  1075
  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
  1076
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
  1077
using substor
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1078
apply (drule_tac equas_subst_f_holds_left_eq_right)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1079
using history
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1080
by (auto simp:ardenable_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1081
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1082
lemma equas_subst_holds_ardenable:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1083
  assumes substor: "Y = L yrhs'"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1084
  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
  1085
  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
  1086
  and dist': "distinct_rhs yrhs'"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1087
  and not_lambda: "Y \<noteq> {[]}"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1088
  shows "ardenable (X, xrhs)"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1089
proof -
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1090
  have "distinct_rhs xrhs" using history X_in dist' 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1091
    by (auto dest:equas_subst_holds_distinct_rhs)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1092
  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
  1093
    by (auto intro:equas_subst_holds_no_EMPTY)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1094
  moreover have "X = L xrhs" using history substor X_in
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1095
  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
  1096
  ultimately show ?thesis using ardenable_def by simp
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1097
qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1098
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1099
lemma equas_subst_holds_cls_defined:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1100
  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
  1101
  and           Inv_ES: "Inv X' ES"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1102
  and            subst: "(Y, yrhs) \<in> ES"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1103
  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
  1104
  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
  1105
proof-
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1106
  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
  1107
  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
  1108
    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
  1109
  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
  1110
                       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
  1111
  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
  1112
    by (auto simp:Inv_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1113
  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
  1114
    using Inv_ES subst cls_holds_but_Y
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1115
    by (auto simp:Inv_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1116
  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
  1117
    using X_Z cls_holds_but_Y
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1118
    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
  1119
    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
  1120
  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
  1121
    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
  1122
             dest: equas_subst_f_del_no_other
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1123
             split: if_splits)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1124
  ultimately show ?thesis by blast
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1125
qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1126
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1127
lemma iteration_step: 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1128
  assumes Inv_ES: "Inv X ES"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1129
  and    not_T: "\<not> TCon ES"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1130
  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
  1131
proof -
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1132
  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
  1133
    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
  1134
  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
  1135
  show ?thesis (is "\<exists> ES'. ?P ES'")
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1136
  proof (cases "Y = {[]}") 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1137
    case True
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1138
      --"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
  1139
    have "?P (ES - {(Y, yrhs)})" 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1140
    proof 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1141
      show "Inv X (ES - {(Y, yrhs)})" using True not_X
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1142
        by (simp add:Inv_ES Inv_mono_with_lambda)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1143
    next 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1144
      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
  1145
        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
  1146
    qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1147
    thus ?thesis by blast
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1148
  next
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1149
    case False
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1150
      --"in this situation, we pick a equation and using ardenable to get a rhs without itself in it, then use equas_subst to form a new equation-system"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1151
    hence "\<exists> yrhs'. Y = L yrhs' \<and> distinct_rhs yrhs' \<and> rhs_eq_cls yrhs' = rhs_eq_cls yrhs - {Y}" using subst Inv_ES
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1152
      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
  1153
    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
  1154
      and dist_Y': "distinct_rhs yrhs'"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1155
      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
  1156
    hence "?P (equas_subst ES Y yrhs')"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1157
    proof -
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1158
      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
  1159
        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
  1160
        by (auto simp:del_x_paired_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1161
      have "finite (equas_subst ES Y yrhs')" using Inv_ES 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1162
        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
  1163
      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
  1164
        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
  1165
      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
  1166
        by (auto intro:equas_subst_holds_distinct simp:Inv_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1167
      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
  1168
        using Inv_ES dist_Y' False Y'_l_eq_r
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1169
        apply (clarsimp simp:Inv_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1170
        by (rule equas_subst_holds_ardenable, simp_all)
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> X \<noteq> {}" using Inv_ES
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1172
        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
  1173
      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
  1174
                               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
  1175
        using Inv_ES subst cls_holds_but_Y
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1176
        apply (rule_tac impI | rule_tac allI)+
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1177
        by (erule equas_subst_holds_cls_defined, auto)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1178
      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
  1179
        by (simp add:equas_subst_card_less Inv_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1180
      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
  1181
    qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1182
    thus ?thesis by blast
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1183
  qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1184
qed
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
(* ****************************** END: proving every equation-system's iteration step satisfies Inv ******************************* *)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1187
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1188
lemma iteration_conc: 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1189
  assumes history: "Inv X ES"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1190
  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
  1191
proof (cases "TCon ES")
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1192
  case True
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1193
  hence "?P ES" using history by simp
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1194
  thus ?thesis by blast
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1195
next
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1196
  case False  
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1197
  thus ?thesis using history iteration_step
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1198
    by (rule_tac f = card in wf_iter, simp_all)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1199
qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1200
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1201
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
  1202
apply (auto simp:mem_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1203
done
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1204
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1205
lemma set_cases2:
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1206
  "\<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
  1207
apply (case_tac "A = {}", simp)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1208
by (case_tac "\<exists> x. A = {x}", clarsimp, blast)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1209
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1210
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
  1211
apply (rule_tac A = rhs in set_cases2, simp)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1212
apply (drule_tac x = X in eqset_imp_iff, clarsimp)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1213
apply (drule eqset_imp_iff',clarsimp)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1214
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
  1215
by (auto simp:distinct_rhs_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1216
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1217
lemma every_eqcl_has_reg: 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1218
  assumes finite_CS: "finite (UNIV Quo Lang)"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1219
  and X_in_CS: "X \<in> (UNIV Quo Lang)"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1220
  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
  1221
proof-
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1222
  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
  1223
    by (auto intro:init_ES_satisfy_Inv iteration_conc)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1224
  then obtain ES' where Inv_ES': "Inv X ES'" 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1225
                   and  TCon_ES': "TCon ES'" by blast
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1226
  from Inv_ES' TCon_ES' 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1227
  have "\<exists> rhs. ES' = {(X, rhs)}"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1228
    apply (clarsimp simp:Inv_def TCon_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1229
    apply (rule_tac x = rhs in exI)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1230
    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
  1231
  then obtain rhs where ES'_single_equa: "ES' = {(X, rhs)}" ..
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1232
  hence X_ardenable: "ardenable (X, rhs)" using Inv_ES'
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1233
    by (simp add:Inv_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1234
  
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1235
  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
  1236
    by (simp add:ardenable_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1237
  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
  1238
    by (auto simp:Inv_def ardenable_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1239
  have rhs_eq_cls: "rhs_eq_cls rhs \<subseteq> {X, {[]}}"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1240
    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 ardenable_def left_eq_cls_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1242
  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
  1243
    by (auto simp:Inv_def)    
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1244
  show ?thesis
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1245
  proof (cases "X = {[]}")
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1246
    case True
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1247
    hence "?E EMPTY" by (simp)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1248
    thus ?thesis by blast
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1249
  next
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1250
    case False with  X_ardenable
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1251
    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
  1252
      by (drule_tac ardenable_prop, auto)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1253
    then obtain rhs' where X_eq_rhs': "X = L rhs'"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1254
      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
  1255
      and rhs'_dist : "distinct_rhs rhs'" by blast
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1256
    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
  1257
      by blast
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1258
    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
  1259
      by (auto simp:rhs_eq_cls_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1260
    hence "\<exists> r. rhs' = {({[]}, r)}" using rhs'_dist
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1261
      by (auto intro:rhs_aux simp:rhs_eq_cls_def)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1262
    then obtain r where "rhs' = {({[]}, r)}" ..
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1263
    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
  1264
    thus ?thesis by blast     
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1265
  qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1266
qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1267
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1268
theorem myhill_nerode: 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1269
  assumes finite_CS: "finite (UNIV Quo Lang)"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1270
  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
  1271
proof -
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1272
  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
  1273
    by (auto dest:every_eqcl_has_reg)  
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1274
  have "\<exists> (rS::rexp set). finite rS \<and> 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1275
                          (\<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
  1276
                          (\<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
  1277
       (is "\<exists> rS. ?Q rS")
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1278
  proof-
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1279
    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
  1280
      using has_r_each
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1281
      apply (erule_tac x = C in ballE, erule_tac exE)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1282
      by (rule_tac a = r in someI2, simp+)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1283
    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
  1284
      using finite_CS by auto
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1285
    thus ?thesis by blast    
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1286
  qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1287
  then obtain rS where finite_rS : "finite rS"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1288
    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
  1289
    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
  1290
  have "?P (folds ALT NULL rS)"
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1291
  proof
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1292
    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
  1293
      apply (clarsimp simp:fold_alt_null_eqs) by blast
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1294
  next 
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1295
    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
  1296
      by (clarsimp simp:fold_alt_null_eqs)
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1297
  qed
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1298
  thus ?thesis by blast
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1299
qed 
8
1f8fe5bfd381 tried at the end to prove the other direction (failed at the moment)
urbanc
parents: 7
diff changeset
  1300
1f8fe5bfd381 tried at the end to prove the other direction (failed at the moment)
urbanc
parents: 7
diff changeset
  1301
1f8fe5bfd381 tried at the end to prove the other direction (failed at the moment)
urbanc
parents: 7
diff changeset
  1302
text {* tests by Christian *}
1f8fe5bfd381 tried at the end to prove the other direction (failed at the moment)
urbanc
parents: 7
diff changeset
  1303
1f8fe5bfd381 tried at the end to prove the other direction (failed at the moment)
urbanc
parents: 7
diff changeset
  1304
abbreviation
1f8fe5bfd381 tried at the end to prove the other direction (failed at the moment)
urbanc
parents: 7
diff changeset
  1305
  reg :: "string set => bool"
1f8fe5bfd381 tried at the end to prove the other direction (failed at the moment)
urbanc
parents: 7
diff changeset
  1306
where
1f8fe5bfd381 tried at the end to prove the other direction (failed at the moment)
urbanc
parents: 7
diff changeset
  1307
  "reg L1 \<equiv> (\<exists>r::rexp. L r = L1)"
1f8fe5bfd381 tried at the end to prove the other direction (failed at the moment)
urbanc
parents: 7
diff changeset
  1308
1f8fe5bfd381 tried at the end to prove the other direction (failed at the moment)
urbanc
parents: 7
diff changeset
  1309
lemma test1:
1f8fe5bfd381 tried at the end to prove the other direction (failed at the moment)
urbanc
parents: 7
diff changeset
  1310
  assumes finite_CS: "finite (UNIV Quo Lang)"
1f8fe5bfd381 tried at the end to prove the other direction (failed at the moment)
urbanc
parents: 7
diff changeset
  1311
  shows "reg Lang"
1f8fe5bfd381 tried at the end to prove the other direction (failed at the moment)
urbanc
parents: 7
diff changeset
  1312
using finite_CS
1f8fe5bfd381 tried at the end to prove the other direction (failed at the moment)
urbanc
parents: 7
diff changeset
  1313
by (auto dest: myhill_nerode)
1f8fe5bfd381 tried at the end to prove the other direction (failed at the moment)
urbanc
parents: 7
diff changeset
  1314
1f8fe5bfd381 tried at the end to prove the other direction (failed at the moment)
urbanc
parents: 7
diff changeset
  1315
lemma t1: "(UNIV Quo {}) = {UNIV}"
1f8fe5bfd381 tried at the end to prove the other direction (failed at the moment)
urbanc
parents: 7
diff changeset
  1316
apply(simp only: quot_def equiv_class_def equiv_str_def)
1f8fe5bfd381 tried at the end to prove the other direction (failed at the moment)
urbanc
parents: 7
diff changeset
  1317
apply(simp)
1f8fe5bfd381 tried at the end to prove the other direction (failed at the moment)
urbanc
parents: 7
diff changeset
  1318
done
1f8fe5bfd381 tried at the end to prove the other direction (failed at the moment)
urbanc
parents: 7
diff changeset
  1319
1f8fe5bfd381 tried at the end to prove the other direction (failed at the moment)
urbanc
parents: 7
diff changeset
  1320
lemma 
1f8fe5bfd381 tried at the end to prove the other direction (failed at the moment)
urbanc
parents: 7
diff changeset
  1321
  fixes r :: "rexp"
1f8fe5bfd381 tried at the end to prove the other direction (failed at the moment)
urbanc
parents: 7
diff changeset
  1322
  shows "finite (UNIV Quo (L r))"
1f8fe5bfd381 tried at the end to prove the other direction (failed at the moment)
urbanc
parents: 7
diff changeset
  1323
apply(induct r)
1f8fe5bfd381 tried at the end to prove the other direction (failed at the moment)
urbanc
parents: 7
diff changeset
  1324
apply(simp add: t1)
1f8fe5bfd381 tried at the end to prove the other direction (failed at the moment)
urbanc
parents: 7
diff changeset
  1325
oops
1f8fe5bfd381 tried at the end to prove the other direction (failed at the moment)
urbanc
parents: 7
diff changeset
  1326
1f8fe5bfd381 tried at the end to prove the other direction (failed at the moment)
urbanc
parents: 7
diff changeset
  1327
1f8fe5bfd381 tried at the end to prove the other direction (failed at the moment)
urbanc
parents: 7
diff changeset
  1328
6
779e1d9fbf3e former version has a ugly usage of "overloaded";
wu
parents: 2
diff changeset
  1329
end