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