My.thy
author urbanc
Wed, 10 Nov 2010 11:59:29 +0000
changeset 22 0792821035b6
child 24 f72c82bf59e5
permissions -rw-r--r--
added a test file
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
22
0792821035b6 added a test file
urbanc
parents:
diff changeset
     1
theory My
0792821035b6 added a test file
urbanc
parents:
diff changeset
     2
imports Main
0792821035b6 added a test file
urbanc
parents:
diff changeset
     3
begin
0792821035b6 added a test file
urbanc
parents:
diff changeset
     4
0792821035b6 added a test file
urbanc
parents:
diff changeset
     5
0792821035b6 added a test file
urbanc
parents:
diff changeset
     6
definition
0792821035b6 added a test file
urbanc
parents:
diff changeset
     7
  lang_seq :: "string set \<Rightarrow> string set \<Rightarrow> string set" ("_ ; _" [100,100] 100)
0792821035b6 added a test file
urbanc
parents:
diff changeset
     8
where 
0792821035b6 added a test file
urbanc
parents:
diff changeset
     9
  "L1 ; L2 = {s1 @ s2 | s1 s2. s1 \<in> L1 \<and> s2 \<in> L2}"
0792821035b6 added a test file
urbanc
parents:
diff changeset
    10
0792821035b6 added a test file
urbanc
parents:
diff changeset
    11
inductive_set
0792821035b6 added a test file
urbanc
parents:
diff changeset
    12
  Star :: "string set \<Rightarrow> string set" ("_\<star>" [101] 102)
0792821035b6 added a test file
urbanc
parents:
diff changeset
    13
  for L :: "string set"
0792821035b6 added a test file
urbanc
parents:
diff changeset
    14
where
0792821035b6 added a test file
urbanc
parents:
diff changeset
    15
  start[intro]: "[] \<in> L\<star>"
0792821035b6 added a test file
urbanc
parents:
diff changeset
    16
| step[intro]:  "\<lbrakk>s1 \<in> L; s2 \<in> L\<star>\<rbrakk> \<Longrightarrow> s1@s2 \<in> L\<star>"
0792821035b6 added a test file
urbanc
parents:
diff changeset
    17
0792821035b6 added a test file
urbanc
parents:
diff changeset
    18
0792821035b6 added a test file
urbanc
parents:
diff changeset
    19
datatype rexp =
0792821035b6 added a test file
urbanc
parents:
diff changeset
    20
  NULL
0792821035b6 added a test file
urbanc
parents:
diff changeset
    21
| EMPTY
0792821035b6 added a test file
urbanc
parents:
diff changeset
    22
| CHAR char
0792821035b6 added a test file
urbanc
parents:
diff changeset
    23
| SEQ rexp rexp
0792821035b6 added a test file
urbanc
parents:
diff changeset
    24
| ALT rexp rexp
0792821035b6 added a test file
urbanc
parents:
diff changeset
    25
| STAR rexp
0792821035b6 added a test file
urbanc
parents:
diff changeset
    26
0792821035b6 added a test file
urbanc
parents:
diff changeset
    27
fun
0792821035b6 added a test file
urbanc
parents:
diff changeset
    28
  L_rexp :: "rexp \<Rightarrow> string set"
0792821035b6 added a test file
urbanc
parents:
diff changeset
    29
where
0792821035b6 added a test file
urbanc
parents:
diff changeset
    30
    "L_rexp (NULL) = {}"
0792821035b6 added a test file
urbanc
parents:
diff changeset
    31
  | "L_rexp (EMPTY) = {[]}"
0792821035b6 added a test file
urbanc
parents:
diff changeset
    32
  | "L_rexp (CHAR c) = {[c]}"
0792821035b6 added a test file
urbanc
parents:
diff changeset
    33
  | "L_rexp (SEQ r1 r2) = (L_rexp r1) ; (L_rexp r2)"
0792821035b6 added a test file
urbanc
parents:
diff changeset
    34
  | "L_rexp (ALT r1 r2) = (L_rexp r1) \<union> (L_rexp r2)"
0792821035b6 added a test file
urbanc
parents:
diff changeset
    35
  | "L_rexp (STAR r) = (L_rexp r)\<star>"
0792821035b6 added a test file
urbanc
parents:
diff changeset
    36
0792821035b6 added a test file
urbanc
parents:
diff changeset
    37
definition 
0792821035b6 added a test file
urbanc
parents:
diff changeset
    38
  folds :: "('a \<Rightarrow> 'b \<Rightarrow> 'b) \<Rightarrow> 'b \<Rightarrow> 'a set \<Rightarrow> 'b"
0792821035b6 added a test file
urbanc
parents:
diff changeset
    39
where
0792821035b6 added a test file
urbanc
parents:
diff changeset
    40
  "folds f z S \<equiv> SOME x. fold_graph f z S x"
0792821035b6 added a test file
urbanc
parents:
diff changeset
    41
0792821035b6 added a test file
urbanc
parents:
diff changeset
    42
lemma folds_simp_null [simp]:
0792821035b6 added a test file
urbanc
parents:
diff changeset
    43
  "finite rs \<Longrightarrow> x \<in> L_rexp (folds ALT NULL rs) = (\<exists>r \<in> rs. x \<in> L_rexp r)"
0792821035b6 added a test file
urbanc
parents:
diff changeset
    44
apply (simp add: folds_def)
0792821035b6 added a test file
urbanc
parents:
diff changeset
    45
apply (rule someI2_ex)
0792821035b6 added a test file
urbanc
parents:
diff changeset
    46
apply (erule finite_imp_fold_graph)
0792821035b6 added a test file
urbanc
parents:
diff changeset
    47
apply (erule fold_graph.induct)
0792821035b6 added a test file
urbanc
parents:
diff changeset
    48
apply (auto)
0792821035b6 added a test file
urbanc
parents:
diff changeset
    49
done
0792821035b6 added a test file
urbanc
parents:
diff changeset
    50
0792821035b6 added a test file
urbanc
parents:
diff changeset
    51
lemma folds_simp_empty [simp]:
0792821035b6 added a test file
urbanc
parents:
diff changeset
    52
  "finite rs \<Longrightarrow> x \<in> L_rexp (folds ALT EMPTY rs) = ((\<exists>r \<in> rs. x \<in> L_rexp r) \<or> x = [])"
0792821035b6 added a test file
urbanc
parents:
diff changeset
    53
apply (simp add: folds_def)
0792821035b6 added a test file
urbanc
parents:
diff changeset
    54
apply (rule someI2_ex)
0792821035b6 added a test file
urbanc
parents:
diff changeset
    55
apply (erule finite_imp_fold_graph)
0792821035b6 added a test file
urbanc
parents:
diff changeset
    56
apply (erule fold_graph.induct)
0792821035b6 added a test file
urbanc
parents:
diff changeset
    57
apply (auto)
0792821035b6 added a test file
urbanc
parents:
diff changeset
    58
done
0792821035b6 added a test file
urbanc
parents:
diff changeset
    59
0792821035b6 added a test file
urbanc
parents:
diff changeset
    60
lemma [simp]:
0792821035b6 added a test file
urbanc
parents:
diff changeset
    61
  "(x, y) \<in> {(x, y). P x y} \<longleftrightarrow> P x y"
0792821035b6 added a test file
urbanc
parents:
diff changeset
    62
by simp
0792821035b6 added a test file
urbanc
parents:
diff changeset
    63
0792821035b6 added a test file
urbanc
parents:
diff changeset
    64
definition
0792821035b6 added a test file
urbanc
parents:
diff changeset
    65
  str_eq ("_ \<approx>_ _")
0792821035b6 added a test file
urbanc
parents:
diff changeset
    66
where
0792821035b6 added a test file
urbanc
parents:
diff changeset
    67
  "x \<approx>Lang y \<equiv> (\<forall>z. x @ z \<in> Lang \<longleftrightarrow> y @ z \<in> Lang)"
0792821035b6 added a test file
urbanc
parents:
diff changeset
    68
0792821035b6 added a test file
urbanc
parents:
diff changeset
    69
definition
0792821035b6 added a test file
urbanc
parents:
diff changeset
    70
  str_eq_rel ("\<approx>_")
0792821035b6 added a test file
urbanc
parents:
diff changeset
    71
where
0792821035b6 added a test file
urbanc
parents:
diff changeset
    72
  "\<approx>Lang \<equiv> {(x, y). x \<approx>Lang y}"
0792821035b6 added a test file
urbanc
parents:
diff changeset
    73
0792821035b6 added a test file
urbanc
parents:
diff changeset
    74
definition
0792821035b6 added a test file
urbanc
parents:
diff changeset
    75
  final :: "string set \<Rightarrow> string set \<Rightarrow> bool"
0792821035b6 added a test file
urbanc
parents:
diff changeset
    76
where
0792821035b6 added a test file
urbanc
parents:
diff changeset
    77
  "final X Lang \<equiv> (X \<in> UNIV // \<approx>Lang) \<and> (\<forall>s \<in> X. s \<in> Lang)"
0792821035b6 added a test file
urbanc
parents:
diff changeset
    78
0792821035b6 added a test file
urbanc
parents:
diff changeset
    79
lemma lang_is_union_of_finals: 
0792821035b6 added a test file
urbanc
parents:
diff changeset
    80
  "Lang = \<Union> {X. final X Lang}"
0792821035b6 added a test file
urbanc
parents:
diff changeset
    81
proof -
0792821035b6 added a test file
urbanc
parents:
diff changeset
    82
  have  "Lang \<subseteq> \<Union> {X. final X Lang}"
0792821035b6 added a test file
urbanc
parents:
diff changeset
    83
    unfolding final_def
0792821035b6 added a test file
urbanc
parents:
diff changeset
    84
    unfolding quotient_def Image_def
0792821035b6 added a test file
urbanc
parents:
diff changeset
    85
    unfolding str_eq_rel_def
0792821035b6 added a test file
urbanc
parents:
diff changeset
    86
    apply(simp)
0792821035b6 added a test file
urbanc
parents:
diff changeset
    87
    apply(auto)
0792821035b6 added a test file
urbanc
parents:
diff changeset
    88
    apply(rule_tac x="(\<approx>Lang) `` {x}" in exI)
0792821035b6 added a test file
urbanc
parents:
diff changeset
    89
    unfolding Image_def
0792821035b6 added a test file
urbanc
parents:
diff changeset
    90
    unfolding str_eq_rel_def
0792821035b6 added a test file
urbanc
parents:
diff changeset
    91
    apply(auto)
0792821035b6 added a test file
urbanc
parents:
diff changeset
    92
    unfolding str_eq_def
0792821035b6 added a test file
urbanc
parents:
diff changeset
    93
    apply(auto)
0792821035b6 added a test file
urbanc
parents:
diff changeset
    94
    apply(drule_tac x="[]" in spec)
0792821035b6 added a test file
urbanc
parents:
diff changeset
    95
    apply(simp)
0792821035b6 added a test file
urbanc
parents:
diff changeset
    96
    done
0792821035b6 added a test file
urbanc
parents:
diff changeset
    97
  moreover
0792821035b6 added a test file
urbanc
parents:
diff changeset
    98
  have "\<Union>{X. final X Lang} \<subseteq> Lang" 
0792821035b6 added a test file
urbanc
parents:
diff changeset
    99
    unfolding final_def by auto
0792821035b6 added a test file
urbanc
parents:
diff changeset
   100
  ultimately 
0792821035b6 added a test file
urbanc
parents:
diff changeset
   101
  show "Lang = \<Union> {X. final X Lang}"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   102
    by blast
0792821035b6 added a test file
urbanc
parents:
diff changeset
   103
qed
0792821035b6 added a test file
urbanc
parents:
diff changeset
   104
0792821035b6 added a test file
urbanc
parents:
diff changeset
   105
lemma all_rexp:
0792821035b6 added a test file
urbanc
parents:
diff changeset
   106
  "\<lbrakk>finite (UNIV // \<approx>Lang); X \<in> (UNIV // \<approx>Lang)\<rbrakk> \<Longrightarrow> \<exists>r. X = L_rexp r"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   107
sorry
0792821035b6 added a test file
urbanc
parents:
diff changeset
   108
0792821035b6 added a test file
urbanc
parents:
diff changeset
   109
lemma final_rexp:
0792821035b6 added a test file
urbanc
parents:
diff changeset
   110
  "\<lbrakk>finite (UNIV // (\<approx>Lang)); final X Lang\<rbrakk> \<Longrightarrow> \<exists>r. X = L_rexp r"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   111
unfolding final_def
0792821035b6 added a test file
urbanc
parents:
diff changeset
   112
using all_rexp by blast
0792821035b6 added a test file
urbanc
parents:
diff changeset
   113
0792821035b6 added a test file
urbanc
parents:
diff changeset
   114
lemma finite_f_one_to_one:
0792821035b6 added a test file
urbanc
parents:
diff changeset
   115
  assumes "finite B"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   116
  and "\<forall>x \<in> B. \<exists>y. f y = x"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   117
  shows "\<exists>rs. finite rs \<and> (B = {f y | y . y \<in> rs})"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   118
using assms
0792821035b6 added a test file
urbanc
parents:
diff changeset
   119
by (induct) (auto)
0792821035b6 added a test file
urbanc
parents:
diff changeset
   120
0792821035b6 added a test file
urbanc
parents:
diff changeset
   121
lemma finite_final:
0792821035b6 added a test file
urbanc
parents:
diff changeset
   122
  assumes "finite (UNIV // (\<approx>Lang))"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   123
  shows "finite {X. final X Lang}"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   124
using assms
0792821035b6 added a test file
urbanc
parents:
diff changeset
   125
proof -
0792821035b6 added a test file
urbanc
parents:
diff changeset
   126
  have "{X. final X Lang} \<subseteq> (UNIV // (\<approx>Lang))"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   127
    unfolding final_def by auto
0792821035b6 added a test file
urbanc
parents:
diff changeset
   128
  with assms show "finite {X. final X Lang}" 
0792821035b6 added a test file
urbanc
parents:
diff changeset
   129
    using finite_subset by auto
0792821035b6 added a test file
urbanc
parents:
diff changeset
   130
qed
0792821035b6 added a test file
urbanc
parents:
diff changeset
   131
0792821035b6 added a test file
urbanc
parents:
diff changeset
   132
lemma finite_regular_aux:
0792821035b6 added a test file
urbanc
parents:
diff changeset
   133
  fixes Lang :: "string set"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   134
  assumes "finite (UNIV // (\<approx>Lang))"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   135
  shows "\<exists>rs. Lang =  L_rexp (folds ALT NULL rs)"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   136
apply(subst lang_is_union_of_finals)
0792821035b6 added a test file
urbanc
parents:
diff changeset
   137
using assms
0792821035b6 added a test file
urbanc
parents:
diff changeset
   138
apply -
0792821035b6 added a test file
urbanc
parents:
diff changeset
   139
apply(drule finite_final)
0792821035b6 added a test file
urbanc
parents:
diff changeset
   140
apply(drule_tac f="L_rexp" in finite_f_one_to_one)
0792821035b6 added a test file
urbanc
parents:
diff changeset
   141
apply(clarify)
0792821035b6 added a test file
urbanc
parents:
diff changeset
   142
apply(drule final_rexp[OF assms])
0792821035b6 added a test file
urbanc
parents:
diff changeset
   143
apply(auto)[1]
0792821035b6 added a test file
urbanc
parents:
diff changeset
   144
apply(clarify)
0792821035b6 added a test file
urbanc
parents:
diff changeset
   145
apply(rule_tac x="rs" in exI)
0792821035b6 added a test file
urbanc
parents:
diff changeset
   146
apply(simp)
0792821035b6 added a test file
urbanc
parents:
diff changeset
   147
apply(rule set_eqI)
0792821035b6 added a test file
urbanc
parents:
diff changeset
   148
apply(auto)
0792821035b6 added a test file
urbanc
parents:
diff changeset
   149
done
0792821035b6 added a test file
urbanc
parents:
diff changeset
   150
0792821035b6 added a test file
urbanc
parents:
diff changeset
   151
lemma finite_regular:
0792821035b6 added a test file
urbanc
parents:
diff changeset
   152
  fixes Lang :: "string set"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   153
  assumes "finite (UNIV // (\<approx>Lang))"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   154
  shows "\<exists>r. Lang =  L_rexp r"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   155
using assms finite_regular_aux
0792821035b6 added a test file
urbanc
parents:
diff changeset
   156
by auto
0792821035b6 added a test file
urbanc
parents:
diff changeset
   157
0792821035b6 added a test file
urbanc
parents:
diff changeset
   158
0792821035b6 added a test file
urbanc
parents:
diff changeset
   159
0792821035b6 added a test file
urbanc
parents:
diff changeset
   160
section {* other direction *}
0792821035b6 added a test file
urbanc
parents:
diff changeset
   161
0792821035b6 added a test file
urbanc
parents:
diff changeset
   162
0792821035b6 added a test file
urbanc
parents:
diff changeset
   163
lemma inj_image_lang:
0792821035b6 added a test file
urbanc
parents:
diff changeset
   164
  fixes f::"string \<Rightarrow> 'a"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   165
  assumes str_inj: "\<And>x y. f x = f y \<Longrightarrow> x \<approx>Lang y"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   166
  shows "inj_on (image f) (UNIV // (\<approx>Lang))"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   167
proof - 
0792821035b6 added a test file
urbanc
parents:
diff changeset
   168
  { fix x y::string
0792821035b6 added a test file
urbanc
parents:
diff changeset
   169
    assume eq_tag: "f ` {z. x \<approx>Lang z} = f ` {z. y \<approx>Lang z}"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   170
    moreover
0792821035b6 added a test file
urbanc
parents:
diff changeset
   171
    have "{z. x \<approx>Lang z} \<noteq> {}" unfolding str_eq_def by auto
0792821035b6 added a test file
urbanc
parents:
diff changeset
   172
    ultimately obtain a b where "x \<approx>Lang a" "y \<approx>Lang b" "f a = f b" by blast
0792821035b6 added a test file
urbanc
parents:
diff changeset
   173
    then have "x \<approx>Lang a" "y \<approx>Lang b" "a \<approx>Lang b" using str_inj by auto
0792821035b6 added a test file
urbanc
parents:
diff changeset
   174
    then have "x \<approx>Lang y" unfolding str_eq_def by simp 
0792821035b6 added a test file
urbanc
parents:
diff changeset
   175
    then have "{z. x \<approx>Lang z} = {z. y \<approx>Lang z}" unfolding str_eq_def by simp
0792821035b6 added a test file
urbanc
parents:
diff changeset
   176
  }
0792821035b6 added a test file
urbanc
parents:
diff changeset
   177
  then have "\<forall>x\<in>UNIV // \<approx>Lang. \<forall>y\<in>UNIV // \<approx>Lang. f ` x = f ` y \<longrightarrow> x = y"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   178
    unfolding quotient_def Image_def str_eq_rel_def by simp
0792821035b6 added a test file
urbanc
parents:
diff changeset
   179
  then show "inj_on (image f) (UNIV // (\<approx>Lang))"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   180
    unfolding inj_on_def by simp
0792821035b6 added a test file
urbanc
parents:
diff changeset
   181
qed
0792821035b6 added a test file
urbanc
parents:
diff changeset
   182
0792821035b6 added a test file
urbanc
parents:
diff changeset
   183
0792821035b6 added a test file
urbanc
parents:
diff changeset
   184
lemma finite_range_image: 
0792821035b6 added a test file
urbanc
parents:
diff changeset
   185
  assumes fin: "finite (range f)"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   186
  shows "finite ((image f) ` X)"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   187
proof -
0792821035b6 added a test file
urbanc
parents:
diff changeset
   188
  from fin have "finite (Pow (f ` UNIV))" by auto
0792821035b6 added a test file
urbanc
parents:
diff changeset
   189
  moreover
0792821035b6 added a test file
urbanc
parents:
diff changeset
   190
  have "(image f) ` X \<subseteq> Pow (f ` UNIV)" by auto
0792821035b6 added a test file
urbanc
parents:
diff changeset
   191
  ultimately show "finite ((image f) ` X)" using finite_subset by auto
0792821035b6 added a test file
urbanc
parents:
diff changeset
   192
qed
0792821035b6 added a test file
urbanc
parents:
diff changeset
   193
0792821035b6 added a test file
urbanc
parents:
diff changeset
   194
definition 
0792821035b6 added a test file
urbanc
parents:
diff changeset
   195
  tag1 :: "string set \<Rightarrow> string set \<Rightarrow> string \<Rightarrow> (string set \<times> string set)"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   196
where
0792821035b6 added a test file
urbanc
parents:
diff changeset
   197
  "tag1 L\<^isub>1 L\<^isub>2 \<equiv> \<lambda>x. ((\<approx>L\<^isub>1) `` {x}, (\<approx>L\<^isub>2) `` {x})"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   198
0792821035b6 added a test file
urbanc
parents:
diff changeset
   199
lemma tag1_range_finite:
0792821035b6 added a test file
urbanc
parents:
diff changeset
   200
  assumes finite1: "finite (UNIV // \<approx>L\<^isub>1)"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   201
  and finite2: "finite (UNIV // \<approx>L\<^isub>2)"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   202
  shows "finite (range (tag1 L\<^isub>1 L\<^isub>2))"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   203
proof -
0792821035b6 added a test file
urbanc
parents:
diff changeset
   204
  have "finite (UNIV // \<approx>L\<^isub>1 \<times> UNIV // \<approx>L\<^isub>2)" using finite1 finite2 by auto
0792821035b6 added a test file
urbanc
parents:
diff changeset
   205
  moreover
0792821035b6 added a test file
urbanc
parents:
diff changeset
   206
  have "range (tag1 L\<^isub>1 L\<^isub>2) \<subseteq> (UNIV // \<approx>L\<^isub>1) \<times> (UNIV // \<approx>L\<^isub>2)"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   207
    unfolding tag1_def quotient_def by auto
0792821035b6 added a test file
urbanc
parents:
diff changeset
   208
  ultimately show "finite (range (tag1 L\<^isub>1 L\<^isub>2))" 
0792821035b6 added a test file
urbanc
parents:
diff changeset
   209
    using finite_subset by blast
0792821035b6 added a test file
urbanc
parents:
diff changeset
   210
qed
0792821035b6 added a test file
urbanc
parents:
diff changeset
   211
0792821035b6 added a test file
urbanc
parents:
diff changeset
   212
lemma tag1_inj:
0792821035b6 added a test file
urbanc
parents:
diff changeset
   213
  "tag1 L\<^isub>1 L\<^isub>2 x = tag1 L\<^isub>1 L\<^isub>2 y \<Longrightarrow> x \<approx>(L\<^isub>1 \<union> L\<^isub>2) y"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   214
unfolding tag1_def Image_def str_eq_rel_def str_eq_def
0792821035b6 added a test file
urbanc
parents:
diff changeset
   215
by auto
0792821035b6 added a test file
urbanc
parents:
diff changeset
   216
0792821035b6 added a test file
urbanc
parents:
diff changeset
   217
lemma quot_alt_cu:
0792821035b6 added a test file
urbanc
parents:
diff changeset
   218
  fixes L\<^isub>1 L\<^isub>2::"string set"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   219
  assumes fin1: "finite (UNIV // \<approx>L\<^isub>1)"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   220
  and fin2: "finite (UNIV // \<approx>L\<^isub>2)"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   221
  shows "finite (UNIV // \<approx>(L\<^isub>1 \<union> L\<^isub>2))"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   222
proof -
0792821035b6 added a test file
urbanc
parents:
diff changeset
   223
  have "finite (range (tag1 L\<^isub>1 L\<^isub>2))" 
0792821035b6 added a test file
urbanc
parents:
diff changeset
   224
    using fin1 fin2 tag1_range_finite by simp
0792821035b6 added a test file
urbanc
parents:
diff changeset
   225
  then have "finite (image (tag1 L\<^isub>1 L\<^isub>2) ` (UNIV // \<approx>(L\<^isub>1 \<union> L\<^isub>2)))" 
0792821035b6 added a test file
urbanc
parents:
diff changeset
   226
    using finite_range_image by blast
0792821035b6 added a test file
urbanc
parents:
diff changeset
   227
  moreover 
0792821035b6 added a test file
urbanc
parents:
diff changeset
   228
  have "\<And>x y. tag1 L\<^isub>1 L\<^isub>2 x = tag1 L\<^isub>1 L\<^isub>2 y \<Longrightarrow> x \<approx>(L\<^isub>1 \<union> L\<^isub>2) y" 
0792821035b6 added a test file
urbanc
parents:
diff changeset
   229
    using tag1_inj by simp
0792821035b6 added a test file
urbanc
parents:
diff changeset
   230
  then have "inj_on (image (tag1 L\<^isub>1 L\<^isub>2)) (UNIV // \<approx>(L\<^isub>1 \<union> L\<^isub>2))" 
0792821035b6 added a test file
urbanc
parents:
diff changeset
   231
    using inj_image_lang by blast
0792821035b6 added a test file
urbanc
parents:
diff changeset
   232
  ultimately 
0792821035b6 added a test file
urbanc
parents:
diff changeset
   233
  show "finite (UNIV // \<approx>(L\<^isub>1 \<union> L\<^isub>2))" by (rule finite_imageD)
0792821035b6 added a test file
urbanc
parents:
diff changeset
   234
qed
0792821035b6 added a test file
urbanc
parents:
diff changeset
   235
0792821035b6 added a test file
urbanc
parents:
diff changeset
   236
0792821035b6 added a test file
urbanc
parents:
diff changeset
   237
section {* finite \<Rightarrow> regular *}
0792821035b6 added a test file
urbanc
parents:
diff changeset
   238
0792821035b6 added a test file
urbanc
parents:
diff changeset
   239
definition
0792821035b6 added a test file
urbanc
parents:
diff changeset
   240
  transitions :: "string set \<Rightarrow> string set \<Rightarrow> rexp set" ("_\<Turnstile>\<Rightarrow>_")
0792821035b6 added a test file
urbanc
parents:
diff changeset
   241
where
0792821035b6 added a test file
urbanc
parents:
diff changeset
   242
  "Y \<Turnstile>\<Rightarrow> X \<equiv> {CHAR c | c. Y ; {[c]} \<subseteq> X}"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   243
0792821035b6 added a test file
urbanc
parents:
diff changeset
   244
definition
0792821035b6 added a test file
urbanc
parents:
diff changeset
   245
  transitions_rexp ("_ \<turnstile>\<rightarrow> _")
0792821035b6 added a test file
urbanc
parents:
diff changeset
   246
where
0792821035b6 added a test file
urbanc
parents:
diff changeset
   247
  "Y \<turnstile>\<rightarrow> X \<equiv> if [] \<in> X then folds ALT EMPTY (Y \<Turnstile>\<Rightarrow>X) else folds ALT NULL (Y \<Turnstile>\<Rightarrow>X)"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   248
0792821035b6 added a test file
urbanc
parents:
diff changeset
   249
definition
0792821035b6 added a test file
urbanc
parents:
diff changeset
   250
  "rhs CS X \<equiv> if X = {[]} then {({[]}, EMPTY)} else {(Y, Y \<turnstile>\<rightarrow>X) | Y. Y \<in> CS}"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   251
0792821035b6 added a test file
urbanc
parents:
diff changeset
   252
definition
0792821035b6 added a test file
urbanc
parents:
diff changeset
   253
  "rhs_sem CS X \<equiv> \<Union> {(Y; L_rexp r) | Y r . (Y, r) \<in> rhs CS X}"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   254
0792821035b6 added a test file
urbanc
parents:
diff changeset
   255
definition
0792821035b6 added a test file
urbanc
parents:
diff changeset
   256
  "eqs CS \<equiv> (\<Union>X \<in> CS. {(X, rhs CS X)})"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   257
0792821035b6 added a test file
urbanc
parents:
diff changeset
   258
definition
0792821035b6 added a test file
urbanc
parents:
diff changeset
   259
  "eqs_sem CS \<equiv> (\<Union>X \<in> CS. {(X, rhs_sem CS X)})"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   260
0792821035b6 added a test file
urbanc
parents:
diff changeset
   261
lemma [simp]:
0792821035b6 added a test file
urbanc
parents:
diff changeset
   262
  shows "finite (Y \<Turnstile>\<Rightarrow> X)"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   263
unfolding transitions_def
0792821035b6 added a test file
urbanc
parents:
diff changeset
   264
by auto
0792821035b6 added a test file
urbanc
parents:
diff changeset
   265
0792821035b6 added a test file
urbanc
parents:
diff changeset
   266
0792821035b6 added a test file
urbanc
parents:
diff changeset
   267
lemma defined_by_str:
0792821035b6 added a test file
urbanc
parents:
diff changeset
   268
  assumes "s \<in> X" 
0792821035b6 added a test file
urbanc
parents:
diff changeset
   269
  and "X \<in> UNIV // (\<approx>Lang)"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   270
  shows "X = (\<approx>Lang) `` {s}"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   271
using assms
0792821035b6 added a test file
urbanc
parents:
diff changeset
   272
unfolding quotient_def Image_def
0792821035b6 added a test file
urbanc
parents:
diff changeset
   273
unfolding str_eq_rel_def str_eq_def
0792821035b6 added a test file
urbanc
parents:
diff changeset
   274
by auto
0792821035b6 added a test file
urbanc
parents:
diff changeset
   275
0792821035b6 added a test file
urbanc
parents:
diff changeset
   276
lemma every_eqclass_has_transition:
0792821035b6 added a test file
urbanc
parents:
diff changeset
   277
  assumes has_str: "s @ [c] \<in> X"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   278
  and     in_CS:   "X \<in> UNIV // (\<approx>Lang)"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   279
  obtains Y where "Y \<in> UNIV // (\<approx>Lang)" and "Y ; {[c]} \<subseteq> X" and "s \<in> Y"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   280
proof -
0792821035b6 added a test file
urbanc
parents:
diff changeset
   281
  def Y \<equiv> "(\<approx>Lang) `` {s}"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   282
  have "Y \<in> UNIV // (\<approx>Lang)" 
0792821035b6 added a test file
urbanc
parents:
diff changeset
   283
    unfolding Y_def quotient_def by auto
0792821035b6 added a test file
urbanc
parents:
diff changeset
   284
  moreover
0792821035b6 added a test file
urbanc
parents:
diff changeset
   285
  have "X = (\<approx>Lang) `` {s @ [c]}" 
0792821035b6 added a test file
urbanc
parents:
diff changeset
   286
    using has_str in_CS defined_by_str by blast
0792821035b6 added a test file
urbanc
parents:
diff changeset
   287
  then have "Y ; {[c]} \<subseteq> X" 
0792821035b6 added a test file
urbanc
parents:
diff changeset
   288
    unfolding Y_def Image_def lang_seq_def
0792821035b6 added a test file
urbanc
parents:
diff changeset
   289
    unfolding str_eq_rel_def
0792821035b6 added a test file
urbanc
parents:
diff changeset
   290
    by (auto) (simp add: str_eq_def)
0792821035b6 added a test file
urbanc
parents:
diff changeset
   291
  moreover
0792821035b6 added a test file
urbanc
parents:
diff changeset
   292
  have "s \<in> Y" unfolding Y_def 
0792821035b6 added a test file
urbanc
parents:
diff changeset
   293
    unfolding Image_def str_eq_rel_def str_eq_def by simp
0792821035b6 added a test file
urbanc
parents:
diff changeset
   294
  moreover 
0792821035b6 added a test file
urbanc
parents:
diff changeset
   295
  have "True" by simp (* FIXME *)
0792821035b6 added a test file
urbanc
parents:
diff changeset
   296
  note that 
0792821035b6 added a test file
urbanc
parents:
diff changeset
   297
  ultimately show thesis by blast
0792821035b6 added a test file
urbanc
parents:
diff changeset
   298
qed
0792821035b6 added a test file
urbanc
parents:
diff changeset
   299
0792821035b6 added a test file
urbanc
parents:
diff changeset
   300
lemma test:
0792821035b6 added a test file
urbanc
parents:
diff changeset
   301
  assumes "[] \<in> X"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   302
  shows "[] \<in> L_rexp (Y \<turnstile>\<rightarrow> X)"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   303
using assms
0792821035b6 added a test file
urbanc
parents:
diff changeset
   304
by (simp add: transitions_rexp_def)
0792821035b6 added a test file
urbanc
parents:
diff changeset
   305
0792821035b6 added a test file
urbanc
parents:
diff changeset
   306
lemma rhs_sem:
0792821035b6 added a test file
urbanc
parents:
diff changeset
   307
  assumes "X \<in> (UNIV // (\<approx>Lang))"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   308
  shows "X \<subseteq> rhs_sem (UNIV // (\<approx>Lang)) X"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   309
apply(case_tac "X = {[]}")
0792821035b6 added a test file
urbanc
parents:
diff changeset
   310
apply(simp)
0792821035b6 added a test file
urbanc
parents:
diff changeset
   311
apply(simp add: rhs_sem_def rhs_def lang_seq_def)
0792821035b6 added a test file
urbanc
parents:
diff changeset
   312
apply(rule subsetI)
0792821035b6 added a test file
urbanc
parents:
diff changeset
   313
apply(case_tac "x = []")
0792821035b6 added a test file
urbanc
parents:
diff changeset
   314
apply(simp add: rhs_sem_def rhs_def)
0792821035b6 added a test file
urbanc
parents:
diff changeset
   315
apply(rule_tac x = "X" in exI)
0792821035b6 added a test file
urbanc
parents:
diff changeset
   316
apply(simp)
0792821035b6 added a test file
urbanc
parents:
diff changeset
   317
apply(rule_tac x = "X" in exI)
0792821035b6 added a test file
urbanc
parents:
diff changeset
   318
apply(simp add: assms)
0792821035b6 added a test file
urbanc
parents:
diff changeset
   319
apply(simp add: transitions_rexp_def)
0792821035b6 added a test file
urbanc
parents:
diff changeset
   320
oops