My.thy
author urbanc
Sun, 30 Jan 2011 17:24:37 +0000
changeset 53 da85feadb8e3
parent 24 f72c82bf59e5
permissions -rw-r--r--
small typo
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
22
0792821035b6 added a test file
urbanc
parents:
diff changeset
     1
theory My
24
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
     2
imports Main Infinite_Set
22
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
24
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
     7
  Seq :: "string set \<Rightarrow> string set \<Rightarrow> string set" ("_ ;; _" [100,100] 100)
22
0792821035b6 added a test file
urbanc
parents:
diff changeset
     8
where 
24
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
     9
  "L1 ;; L2 = {s1 @ s2 | s1 s2. s1 \<in> L1 \<and> s2 \<in> L2}"
22
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
24
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
    18
lemma lang_star_cases:
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
    19
  shows "L\<star> =  {[]} \<union> L ;; L\<star>"
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
    20
unfolding Seq_def
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
    21
by (auto) (metis Star.simps)
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
    22
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
    23
lemma lang_star_cases2:
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
    24
  shows "L ;; L\<star>  = L\<star> ;; L"
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
    25
sorry
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
    26
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
    27
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
    28
theorem ardens_revised:
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
    29
  assumes nemp: "[] \<notin> A"
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
    30
  shows "(X = X ;; A \<union> B) \<longleftrightarrow> (X = B ;; A\<star>)"
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
    31
proof
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
    32
  assume eq: "X = B ;; A\<star>"
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
    33
  have "A\<star> =  {[]} \<union> A\<star> ;; A" sorry
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
    34
  then have "B ;; A\<star> = B ;; ({[]} \<union> A\<star> ;; A)" unfolding Seq_def by simp
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
    35
  also have "\<dots> = B \<union> B ;; (A\<star> ;; A)"  unfolding Seq_def by auto
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
    36
  also have "\<dots> = B \<union> (B ;; A\<star>) ;; A"  unfolding Seq_def
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
    37
    by (auto) (metis append_assoc)+
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
    38
  finally show "X = X ;; A \<union> B" using eq by auto
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
    39
next
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
    40
  assume "X = X ;; A \<union> B"
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
    41
  then have "B \<subseteq> X" "X ;; A \<subseteq> X" by auto
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
    42
  show "X = B ;; A\<star>" sorry
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
    43
qed
22
0792821035b6 added a test file
urbanc
parents:
diff changeset
    44
0792821035b6 added a test file
urbanc
parents:
diff changeset
    45
datatype rexp =
0792821035b6 added a test file
urbanc
parents:
diff changeset
    46
  NULL
0792821035b6 added a test file
urbanc
parents:
diff changeset
    47
| EMPTY
0792821035b6 added a test file
urbanc
parents:
diff changeset
    48
| CHAR char
0792821035b6 added a test file
urbanc
parents:
diff changeset
    49
| SEQ rexp rexp
0792821035b6 added a test file
urbanc
parents:
diff changeset
    50
| ALT rexp rexp
0792821035b6 added a test file
urbanc
parents:
diff changeset
    51
| STAR rexp
0792821035b6 added a test file
urbanc
parents:
diff changeset
    52
0792821035b6 added a test file
urbanc
parents:
diff changeset
    53
fun
24
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
    54
  Sem :: "rexp \<Rightarrow> string set" ("\<lparr>_\<rparr>" [0] 1000)
22
0792821035b6 added a test file
urbanc
parents:
diff changeset
    55
where
24
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
    56
    "\<lparr>NULL\<rparr> = {}"
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
    57
  | "\<lparr>EMPTY\<rparr> = {[]}"
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
    58
  | "\<lparr>CHAR c\<rparr> = {[c]}"
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
    59
  | "\<lparr>SEQ r1 r2\<rparr> = \<lparr>r1\<rparr> ;; \<lparr>r2\<rparr>"
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
    60
  | "\<lparr>ALT r1 r2\<rparr> = \<lparr>r1\<rparr> \<union> \<lparr>r2\<rparr>"
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
    61
  | "\<lparr>STAR r\<rparr> = \<lparr>r\<rparr>\<star>"
22
0792821035b6 added a test file
urbanc
parents:
diff changeset
    62
0792821035b6 added a test file
urbanc
parents:
diff changeset
    63
definition 
0792821035b6 added a test file
urbanc
parents:
diff changeset
    64
  folds :: "('a \<Rightarrow> 'b \<Rightarrow> 'b) \<Rightarrow> 'b \<Rightarrow> 'a set \<Rightarrow> 'b"
0792821035b6 added a test file
urbanc
parents:
diff changeset
    65
where
0792821035b6 added a test file
urbanc
parents:
diff changeset
    66
  "folds f z S \<equiv> SOME x. fold_graph f z S x"
0792821035b6 added a test file
urbanc
parents:
diff changeset
    67
0792821035b6 added a test file
urbanc
parents:
diff changeset
    68
lemma folds_simp_null [simp]:
24
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
    69
  "finite rs \<Longrightarrow> x \<in> \<lparr>folds ALT NULL rs\<rparr> \<longleftrightarrow> (\<exists>r \<in> rs. x \<in> \<lparr>r\<rparr>)"
22
0792821035b6 added a test file
urbanc
parents:
diff changeset
    70
apply (simp add: folds_def)
0792821035b6 added a test file
urbanc
parents:
diff changeset
    71
apply (rule someI2_ex)
0792821035b6 added a test file
urbanc
parents:
diff changeset
    72
apply (erule finite_imp_fold_graph)
0792821035b6 added a test file
urbanc
parents:
diff changeset
    73
apply (erule fold_graph.induct)
0792821035b6 added a test file
urbanc
parents:
diff changeset
    74
apply (auto)
0792821035b6 added a test file
urbanc
parents:
diff changeset
    75
done
0792821035b6 added a test file
urbanc
parents:
diff changeset
    76
0792821035b6 added a test file
urbanc
parents:
diff changeset
    77
lemma folds_simp_empty [simp]:
24
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
    78
  "finite rs \<Longrightarrow> x \<in> \<lparr>folds ALT EMPTY rs\<rparr> \<longleftrightarrow> (\<exists>r \<in> rs. x \<in> \<lparr>r\<rparr>) \<or> x = []"
22
0792821035b6 added a test file
urbanc
parents:
diff changeset
    79
apply (simp add: folds_def)
0792821035b6 added a test file
urbanc
parents:
diff changeset
    80
apply (rule someI2_ex)
0792821035b6 added a test file
urbanc
parents:
diff changeset
    81
apply (erule finite_imp_fold_graph)
0792821035b6 added a test file
urbanc
parents:
diff changeset
    82
apply (erule fold_graph.induct)
0792821035b6 added a test file
urbanc
parents:
diff changeset
    83
apply (auto)
0792821035b6 added a test file
urbanc
parents:
diff changeset
    84
done
0792821035b6 added a test file
urbanc
parents:
diff changeset
    85
0792821035b6 added a test file
urbanc
parents:
diff changeset
    86
lemma [simp]:
24
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
    87
  shows "(x, y) \<in> {(x, y). P x y} \<longleftrightarrow> P x y"
22
0792821035b6 added a test file
urbanc
parents:
diff changeset
    88
by simp
0792821035b6 added a test file
urbanc
parents:
diff changeset
    89
0792821035b6 added a test file
urbanc
parents:
diff changeset
    90
definition
0792821035b6 added a test file
urbanc
parents:
diff changeset
    91
  str_eq ("_ \<approx>_ _")
0792821035b6 added a test file
urbanc
parents:
diff changeset
    92
where
0792821035b6 added a test file
urbanc
parents:
diff changeset
    93
  "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
    94
0792821035b6 added a test file
urbanc
parents:
diff changeset
    95
definition
0792821035b6 added a test file
urbanc
parents:
diff changeset
    96
  str_eq_rel ("\<approx>_")
0792821035b6 added a test file
urbanc
parents:
diff changeset
    97
where
0792821035b6 added a test file
urbanc
parents:
diff changeset
    98
  "\<approx>Lang \<equiv> {(x, y). x \<approx>Lang y}"
0792821035b6 added a test file
urbanc
parents:
diff changeset
    99
0792821035b6 added a test file
urbanc
parents:
diff changeset
   100
definition
0792821035b6 added a test file
urbanc
parents:
diff changeset
   101
  final :: "string set \<Rightarrow> string set \<Rightarrow> bool"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   102
where
0792821035b6 added a test file
urbanc
parents:
diff changeset
   103
  "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
   104
0792821035b6 added a test file
urbanc
parents:
diff changeset
   105
lemma lang_is_union_of_finals: 
0792821035b6 added a test file
urbanc
parents:
diff changeset
   106
  "Lang = \<Union> {X. final X Lang}"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   107
proof -
0792821035b6 added a test file
urbanc
parents:
diff changeset
   108
  have  "Lang \<subseteq> \<Union> {X. final X Lang}"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   109
    unfolding final_def
0792821035b6 added a test file
urbanc
parents:
diff changeset
   110
    unfolding quotient_def Image_def
0792821035b6 added a test file
urbanc
parents:
diff changeset
   111
    unfolding str_eq_rel_def
0792821035b6 added a test file
urbanc
parents:
diff changeset
   112
    apply(simp)
0792821035b6 added a test file
urbanc
parents:
diff changeset
   113
    apply(auto)
0792821035b6 added a test file
urbanc
parents:
diff changeset
   114
    apply(rule_tac x="(\<approx>Lang) `` {x}" in exI)
0792821035b6 added a test file
urbanc
parents:
diff changeset
   115
    unfolding Image_def
0792821035b6 added a test file
urbanc
parents:
diff changeset
   116
    unfolding str_eq_rel_def
0792821035b6 added a test file
urbanc
parents:
diff changeset
   117
    apply(auto)
0792821035b6 added a test file
urbanc
parents:
diff changeset
   118
    unfolding str_eq_def
0792821035b6 added a test file
urbanc
parents:
diff changeset
   119
    apply(auto)
0792821035b6 added a test file
urbanc
parents:
diff changeset
   120
    apply(drule_tac x="[]" in spec)
0792821035b6 added a test file
urbanc
parents:
diff changeset
   121
    apply(simp)
0792821035b6 added a test file
urbanc
parents:
diff changeset
   122
    done
0792821035b6 added a test file
urbanc
parents:
diff changeset
   123
  moreover
0792821035b6 added a test file
urbanc
parents:
diff changeset
   124
  have "\<Union>{X. final X Lang} \<subseteq> Lang" 
0792821035b6 added a test file
urbanc
parents:
diff changeset
   125
    unfolding final_def by auto
0792821035b6 added a test file
urbanc
parents:
diff changeset
   126
  ultimately 
0792821035b6 added a test file
urbanc
parents:
diff changeset
   127
  show "Lang = \<Union> {X. final X Lang}"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   128
    by blast
0792821035b6 added a test file
urbanc
parents:
diff changeset
   129
qed
0792821035b6 added a test file
urbanc
parents:
diff changeset
   130
0792821035b6 added a test file
urbanc
parents:
diff changeset
   131
lemma all_rexp:
24
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
   132
  "\<lbrakk>finite (UNIV // \<approx>Lang); X \<in> (UNIV // \<approx>Lang)\<rbrakk> \<Longrightarrow> \<exists>r. X = \<lparr>r\<rparr>"
22
0792821035b6 added a test file
urbanc
parents:
diff changeset
   133
sorry
0792821035b6 added a test file
urbanc
parents:
diff changeset
   134
0792821035b6 added a test file
urbanc
parents:
diff changeset
   135
lemma final_rexp:
24
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
   136
  "\<lbrakk>finite (UNIV // (\<approx>Lang)); final X Lang\<rbrakk> \<Longrightarrow> \<exists>r. X = \<lparr>r\<rparr>"
22
0792821035b6 added a test file
urbanc
parents:
diff changeset
   137
unfolding final_def
0792821035b6 added a test file
urbanc
parents:
diff changeset
   138
using all_rexp by blast
0792821035b6 added a test file
urbanc
parents:
diff changeset
   139
0792821035b6 added a test file
urbanc
parents:
diff changeset
   140
lemma finite_f_one_to_one:
0792821035b6 added a test file
urbanc
parents:
diff changeset
   141
  assumes "finite B"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   142
  and "\<forall>x \<in> B. \<exists>y. f y = x"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   143
  shows "\<exists>rs. finite rs \<and> (B = {f y | y . y \<in> rs})"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   144
using assms
0792821035b6 added a test file
urbanc
parents:
diff changeset
   145
by (induct) (auto)
0792821035b6 added a test file
urbanc
parents:
diff changeset
   146
0792821035b6 added a test file
urbanc
parents:
diff changeset
   147
lemma finite_final:
0792821035b6 added a test file
urbanc
parents:
diff changeset
   148
  assumes "finite (UNIV // (\<approx>Lang))"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   149
  shows "finite {X. final X Lang}"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   150
using assms
0792821035b6 added a test file
urbanc
parents:
diff changeset
   151
proof -
0792821035b6 added a test file
urbanc
parents:
diff changeset
   152
  have "{X. final X Lang} \<subseteq> (UNIV // (\<approx>Lang))"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   153
    unfolding final_def by auto
0792821035b6 added a test file
urbanc
parents:
diff changeset
   154
  with assms show "finite {X. final X Lang}" 
0792821035b6 added a test file
urbanc
parents:
diff changeset
   155
    using finite_subset by auto
0792821035b6 added a test file
urbanc
parents:
diff changeset
   156
qed
0792821035b6 added a test file
urbanc
parents:
diff changeset
   157
0792821035b6 added a test file
urbanc
parents:
diff changeset
   158
lemma finite_regular_aux:
0792821035b6 added a test file
urbanc
parents:
diff changeset
   159
  fixes Lang :: "string set"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   160
  assumes "finite (UNIV // (\<approx>Lang))"
24
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
   161
  shows "\<exists>rs. Lang = \<lparr>folds ALT NULL rs\<rparr>"
22
0792821035b6 added a test file
urbanc
parents:
diff changeset
   162
apply(subst lang_is_union_of_finals)
0792821035b6 added a test file
urbanc
parents:
diff changeset
   163
using assms
0792821035b6 added a test file
urbanc
parents:
diff changeset
   164
apply -
0792821035b6 added a test file
urbanc
parents:
diff changeset
   165
apply(drule finite_final)
24
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
   166
apply(drule_tac f="Sem" in finite_f_one_to_one)
22
0792821035b6 added a test file
urbanc
parents:
diff changeset
   167
apply(clarify)
0792821035b6 added a test file
urbanc
parents:
diff changeset
   168
apply(drule final_rexp[OF assms])
0792821035b6 added a test file
urbanc
parents:
diff changeset
   169
apply(auto)[1]
0792821035b6 added a test file
urbanc
parents:
diff changeset
   170
apply(clarify)
0792821035b6 added a test file
urbanc
parents:
diff changeset
   171
apply(rule_tac x="rs" in exI)
0792821035b6 added a test file
urbanc
parents:
diff changeset
   172
apply(simp)
0792821035b6 added a test file
urbanc
parents:
diff changeset
   173
apply(rule set_eqI)
0792821035b6 added a test file
urbanc
parents:
diff changeset
   174
apply(auto)
0792821035b6 added a test file
urbanc
parents:
diff changeset
   175
done
0792821035b6 added a test file
urbanc
parents:
diff changeset
   176
0792821035b6 added a test file
urbanc
parents:
diff changeset
   177
lemma finite_regular:
0792821035b6 added a test file
urbanc
parents:
diff changeset
   178
  fixes Lang :: "string set"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   179
  assumes "finite (UNIV // (\<approx>Lang))"
24
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
   180
  shows "\<exists>r. Lang =  \<lparr>r\<rparr>"
22
0792821035b6 added a test file
urbanc
parents:
diff changeset
   181
using assms finite_regular_aux
0792821035b6 added a test file
urbanc
parents:
diff changeset
   182
by auto
0792821035b6 added a test file
urbanc
parents:
diff changeset
   183
0792821035b6 added a test file
urbanc
parents:
diff changeset
   184
0792821035b6 added a test file
urbanc
parents:
diff changeset
   185
0792821035b6 added a test file
urbanc
parents:
diff changeset
   186
section {* other direction *}
0792821035b6 added a test file
urbanc
parents:
diff changeset
   187
0792821035b6 added a test file
urbanc
parents:
diff changeset
   188
0792821035b6 added a test file
urbanc
parents:
diff changeset
   189
lemma inj_image_lang:
0792821035b6 added a test file
urbanc
parents:
diff changeset
   190
  fixes f::"string \<Rightarrow> 'a"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   191
  assumes str_inj: "\<And>x y. f x = f y \<Longrightarrow> x \<approx>Lang y"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   192
  shows "inj_on (image f) (UNIV // (\<approx>Lang))"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   193
proof - 
0792821035b6 added a test file
urbanc
parents:
diff changeset
   194
  { fix x y::string
0792821035b6 added a test file
urbanc
parents:
diff changeset
   195
    assume eq_tag: "f ` {z. x \<approx>Lang z} = f ` {z. y \<approx>Lang z}"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   196
    moreover
0792821035b6 added a test file
urbanc
parents:
diff changeset
   197
    have "{z. x \<approx>Lang z} \<noteq> {}" unfolding str_eq_def by auto
0792821035b6 added a test file
urbanc
parents:
diff changeset
   198
    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
   199
    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
   200
    then have "x \<approx>Lang y" unfolding str_eq_def by simp 
0792821035b6 added a test file
urbanc
parents:
diff changeset
   201
    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
   202
  }
0792821035b6 added a test file
urbanc
parents:
diff changeset
   203
  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
   204
    unfolding quotient_def Image_def str_eq_rel_def by simp
0792821035b6 added a test file
urbanc
parents:
diff changeset
   205
  then show "inj_on (image f) (UNIV // (\<approx>Lang))"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   206
    unfolding inj_on_def by simp
0792821035b6 added a test file
urbanc
parents:
diff changeset
   207
qed
0792821035b6 added a test file
urbanc
parents:
diff changeset
   208
0792821035b6 added a test file
urbanc
parents:
diff changeset
   209
0792821035b6 added a test file
urbanc
parents:
diff changeset
   210
lemma finite_range_image: 
0792821035b6 added a test file
urbanc
parents:
diff changeset
   211
  assumes fin: "finite (range f)"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   212
  shows "finite ((image f) ` X)"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   213
proof -
0792821035b6 added a test file
urbanc
parents:
diff changeset
   214
  from fin have "finite (Pow (f ` UNIV))" by auto
0792821035b6 added a test file
urbanc
parents:
diff changeset
   215
  moreover
0792821035b6 added a test file
urbanc
parents:
diff changeset
   216
  have "(image f) ` X \<subseteq> Pow (f ` UNIV)" by auto
0792821035b6 added a test file
urbanc
parents:
diff changeset
   217
  ultimately show "finite ((image f) ` X)" using finite_subset by auto
0792821035b6 added a test file
urbanc
parents:
diff changeset
   218
qed
0792821035b6 added a test file
urbanc
parents:
diff changeset
   219
0792821035b6 added a test file
urbanc
parents:
diff changeset
   220
definition 
0792821035b6 added a test file
urbanc
parents:
diff changeset
   221
  tag1 :: "string set \<Rightarrow> string set \<Rightarrow> string \<Rightarrow> (string set \<times> string set)"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   222
where
0792821035b6 added a test file
urbanc
parents:
diff changeset
   223
  "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
   224
0792821035b6 added a test file
urbanc
parents:
diff changeset
   225
lemma tag1_range_finite:
0792821035b6 added a test file
urbanc
parents:
diff changeset
   226
  assumes finite1: "finite (UNIV // \<approx>L\<^isub>1)"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   227
  and finite2: "finite (UNIV // \<approx>L\<^isub>2)"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   228
  shows "finite (range (tag1 L\<^isub>1 L\<^isub>2))"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   229
proof -
0792821035b6 added a test file
urbanc
parents:
diff changeset
   230
  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
   231
  moreover
0792821035b6 added a test file
urbanc
parents:
diff changeset
   232
  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
   233
    unfolding tag1_def quotient_def by auto
0792821035b6 added a test file
urbanc
parents:
diff changeset
   234
  ultimately show "finite (range (tag1 L\<^isub>1 L\<^isub>2))" 
0792821035b6 added a test file
urbanc
parents:
diff changeset
   235
    using finite_subset by blast
0792821035b6 added a test file
urbanc
parents:
diff changeset
   236
qed
0792821035b6 added a test file
urbanc
parents:
diff changeset
   237
0792821035b6 added a test file
urbanc
parents:
diff changeset
   238
lemma tag1_inj:
0792821035b6 added a test file
urbanc
parents:
diff changeset
   239
  "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
   240
unfolding tag1_def Image_def str_eq_rel_def str_eq_def
0792821035b6 added a test file
urbanc
parents:
diff changeset
   241
by auto
0792821035b6 added a test file
urbanc
parents:
diff changeset
   242
0792821035b6 added a test file
urbanc
parents:
diff changeset
   243
lemma quot_alt_cu:
0792821035b6 added a test file
urbanc
parents:
diff changeset
   244
  fixes L\<^isub>1 L\<^isub>2::"string set"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   245
  assumes fin1: "finite (UNIV // \<approx>L\<^isub>1)"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   246
  and fin2: "finite (UNIV // \<approx>L\<^isub>2)"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   247
  shows "finite (UNIV // \<approx>(L\<^isub>1 \<union> L\<^isub>2))"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   248
proof -
0792821035b6 added a test file
urbanc
parents:
diff changeset
   249
  have "finite (range (tag1 L\<^isub>1 L\<^isub>2))" 
0792821035b6 added a test file
urbanc
parents:
diff changeset
   250
    using fin1 fin2 tag1_range_finite by simp
0792821035b6 added a test file
urbanc
parents:
diff changeset
   251
  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
   252
    using finite_range_image by blast
0792821035b6 added a test file
urbanc
parents:
diff changeset
   253
  moreover 
0792821035b6 added a test file
urbanc
parents:
diff changeset
   254
  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
   255
    using tag1_inj by simp
0792821035b6 added a test file
urbanc
parents:
diff changeset
   256
  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
   257
    using inj_image_lang by blast
0792821035b6 added a test file
urbanc
parents:
diff changeset
   258
  ultimately 
0792821035b6 added a test file
urbanc
parents:
diff changeset
   259
  show "finite (UNIV // \<approx>(L\<^isub>1 \<union> L\<^isub>2))" by (rule finite_imageD)
0792821035b6 added a test file
urbanc
parents:
diff changeset
   260
qed
0792821035b6 added a test file
urbanc
parents:
diff changeset
   261
0792821035b6 added a test file
urbanc
parents:
diff changeset
   262
0792821035b6 added a test file
urbanc
parents:
diff changeset
   263
section {* finite \<Rightarrow> regular *}
0792821035b6 added a test file
urbanc
parents:
diff changeset
   264
0792821035b6 added a test file
urbanc
parents:
diff changeset
   265
definition
0792821035b6 added a test file
urbanc
parents:
diff changeset
   266
  transitions :: "string set \<Rightarrow> string set \<Rightarrow> rexp set" ("_\<Turnstile>\<Rightarrow>_")
0792821035b6 added a test file
urbanc
parents:
diff changeset
   267
where
24
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
   268
  "Y \<Turnstile>\<Rightarrow> X \<equiv> {CHAR c | c. Y ;; {[c]} \<subseteq> X}"
22
0792821035b6 added a test file
urbanc
parents:
diff changeset
   269
0792821035b6 added a test file
urbanc
parents:
diff changeset
   270
definition
0792821035b6 added a test file
urbanc
parents:
diff changeset
   271
  transitions_rexp ("_ \<turnstile>\<rightarrow> _")
0792821035b6 added a test file
urbanc
parents:
diff changeset
   272
where
0792821035b6 added a test file
urbanc
parents:
diff changeset
   273
  "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
   274
0792821035b6 added a test file
urbanc
parents:
diff changeset
   275
definition
0792821035b6 added a test file
urbanc
parents:
diff changeset
   276
  "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
   277
0792821035b6 added a test file
urbanc
parents:
diff changeset
   278
definition
24
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
   279
  "rhs_sem CS X \<equiv> \<Union> {(Y;; \<lparr>r\<rparr>) | Y r . (Y, r) \<in> rhs CS X}"
22
0792821035b6 added a test file
urbanc
parents:
diff changeset
   280
0792821035b6 added a test file
urbanc
parents:
diff changeset
   281
definition
0792821035b6 added a test file
urbanc
parents:
diff changeset
   282
  "eqs CS \<equiv> (\<Union>X \<in> CS. {(X, rhs CS X)})"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   283
0792821035b6 added a test file
urbanc
parents:
diff changeset
   284
definition
0792821035b6 added a test file
urbanc
parents:
diff changeset
   285
  "eqs_sem CS \<equiv> (\<Union>X \<in> CS. {(X, rhs_sem CS X)})"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   286
0792821035b6 added a test file
urbanc
parents:
diff changeset
   287
lemma [simp]:
0792821035b6 added a test file
urbanc
parents:
diff changeset
   288
  shows "finite (Y \<Turnstile>\<Rightarrow> X)"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   289
unfolding transitions_def
0792821035b6 added a test file
urbanc
parents:
diff changeset
   290
by auto
0792821035b6 added a test file
urbanc
parents:
diff changeset
   291
0792821035b6 added a test file
urbanc
parents:
diff changeset
   292
0792821035b6 added a test file
urbanc
parents:
diff changeset
   293
lemma defined_by_str:
0792821035b6 added a test file
urbanc
parents:
diff changeset
   294
  assumes "s \<in> X" 
0792821035b6 added a test file
urbanc
parents:
diff changeset
   295
  and "X \<in> UNIV // (\<approx>Lang)"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   296
  shows "X = (\<approx>Lang) `` {s}"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   297
using assms
0792821035b6 added a test file
urbanc
parents:
diff changeset
   298
unfolding quotient_def Image_def
0792821035b6 added a test file
urbanc
parents:
diff changeset
   299
unfolding str_eq_rel_def str_eq_def
0792821035b6 added a test file
urbanc
parents:
diff changeset
   300
by auto
0792821035b6 added a test file
urbanc
parents:
diff changeset
   301
0792821035b6 added a test file
urbanc
parents:
diff changeset
   302
lemma every_eqclass_has_transition:
0792821035b6 added a test file
urbanc
parents:
diff changeset
   303
  assumes has_str: "s @ [c] \<in> X"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   304
  and     in_CS:   "X \<in> UNIV // (\<approx>Lang)"
24
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
   305
  obtains Y where "Y \<in> UNIV // (\<approx>Lang)" and "Y ;; {[c]} \<subseteq> X" and "s \<in> Y"
22
0792821035b6 added a test file
urbanc
parents:
diff changeset
   306
proof -
0792821035b6 added a test file
urbanc
parents:
diff changeset
   307
  def Y \<equiv> "(\<approx>Lang) `` {s}"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   308
  have "Y \<in> UNIV // (\<approx>Lang)" 
0792821035b6 added a test file
urbanc
parents:
diff changeset
   309
    unfolding Y_def quotient_def by auto
0792821035b6 added a test file
urbanc
parents:
diff changeset
   310
  moreover
0792821035b6 added a test file
urbanc
parents:
diff changeset
   311
  have "X = (\<approx>Lang) `` {s @ [c]}" 
0792821035b6 added a test file
urbanc
parents:
diff changeset
   312
    using has_str in_CS defined_by_str by blast
24
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
   313
  then have "Y ;; {[c]} \<subseteq> X" 
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
   314
    unfolding Y_def Image_def Seq_def
22
0792821035b6 added a test file
urbanc
parents:
diff changeset
   315
    unfolding str_eq_rel_def
0792821035b6 added a test file
urbanc
parents:
diff changeset
   316
    by (auto) (simp add: str_eq_def)
0792821035b6 added a test file
urbanc
parents:
diff changeset
   317
  moreover
0792821035b6 added a test file
urbanc
parents:
diff changeset
   318
  have "s \<in> Y" unfolding Y_def 
0792821035b6 added a test file
urbanc
parents:
diff changeset
   319
    unfolding Image_def str_eq_rel_def str_eq_def by simp
24
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
   320
  (*moreover 
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
   321
  have "True" by simp FIXME *) 
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
   322
  ultimately show thesis by (blast intro: that)
22
0792821035b6 added a test file
urbanc
parents:
diff changeset
   323
qed
0792821035b6 added a test file
urbanc
parents:
diff changeset
   324
0792821035b6 added a test file
urbanc
parents:
diff changeset
   325
lemma test:
0792821035b6 added a test file
urbanc
parents:
diff changeset
   326
  assumes "[] \<in> X"
24
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
   327
  shows "[] \<in> \<lparr>Y \<turnstile>\<rightarrow> X\<rparr>"
22
0792821035b6 added a test file
urbanc
parents:
diff changeset
   328
using assms
0792821035b6 added a test file
urbanc
parents:
diff changeset
   329
by (simp add: transitions_rexp_def)
0792821035b6 added a test file
urbanc
parents:
diff changeset
   330
0792821035b6 added a test file
urbanc
parents:
diff changeset
   331
lemma rhs_sem:
0792821035b6 added a test file
urbanc
parents:
diff changeset
   332
  assumes "X \<in> (UNIV // (\<approx>Lang))"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   333
  shows "X \<subseteq> rhs_sem (UNIV // (\<approx>Lang)) X"
0792821035b6 added a test file
urbanc
parents:
diff changeset
   334
apply(case_tac "X = {[]}")
0792821035b6 added a test file
urbanc
parents:
diff changeset
   335
apply(simp)
24
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
   336
apply(simp add: rhs_sem_def rhs_def Seq_def)
22
0792821035b6 added a test file
urbanc
parents:
diff changeset
   337
apply(rule subsetI)
0792821035b6 added a test file
urbanc
parents:
diff changeset
   338
apply(case_tac "x = []")
0792821035b6 added a test file
urbanc
parents:
diff changeset
   339
apply(simp add: rhs_sem_def rhs_def)
0792821035b6 added a test file
urbanc
parents:
diff changeset
   340
apply(rule_tac x = "X" in exI)
0792821035b6 added a test file
urbanc
parents:
diff changeset
   341
apply(simp)
0792821035b6 added a test file
urbanc
parents:
diff changeset
   342
apply(rule_tac x = "X" in exI)
0792821035b6 added a test file
urbanc
parents:
diff changeset
   343
apply(simp add: assms)
0792821035b6 added a test file
urbanc
parents:
diff changeset
   344
apply(simp add: transitions_rexp_def)
24
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
   345
oops
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
   346
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
   347
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
   348
(*
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
   349
fun
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
   350
  power :: "string \<Rightarrow> nat \<Rightarrow> string" (infixr "\<Up>" 100)
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
   351
where
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
   352
  "s \<Up> 0 = s"
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
   353
| "s \<Up> (Suc n) = s @ (s \<Up> n)"
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
   354
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
   355
definition 
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
   356
 "Lone = {(''0'' \<Up> n) @ (''1'' \<Up> n) | n. True }"
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
   357
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
   358
lemma
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
   359
  "infinite (UNIV // (\<approx>Lone))"
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
   360
unfolding infinite_iff_countable_subset
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
   361
apply(rule_tac x="\<lambda>n. {(''0'' \<Up> n) @ (''1'' \<Up> i) | i. i \<in> {..n} }" in exI)
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
   362
apply(auto)
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
   363
prefer 2
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
   364
unfolding Lone_def
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
   365
unfolding quotient_def
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
   366
unfolding Image_def
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
   367
apply(simp)
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
   368
unfolding str_eq_rel_def
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
   369
unfolding str_eq_def
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
   370
apply(auto)
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
   371
apply(rule_tac x="''0'' \<Up> n" in exI)
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
   372
apply(auto)
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
   373
unfolding infinite_nat_iff_unbounded
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
   374
unfolding Lone_def
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
   375
*)
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
   376
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
   377
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
   378
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
   379
text {* Derivatives *}
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
   380
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
   381
definition
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
   382
  DERS :: "string \<Rightarrow> string set \<Rightarrow> string set"
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
   383
where
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
   384
  "DERS s L \<equiv> {s'. s @ s' \<in> L}"
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
   385
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
   386
lemma
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
   387
  shows "x \<approx>L y \<longleftrightarrow> DERS x L = DERS y L"
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
   388
unfolding DERS_def str_eq_def
f72c82bf59e5 added paper
urbanc
parents: 22
diff changeset
   389
by auto