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