Closures2.thy
author urbanc
Tue, 30 Aug 2011 11:31:18 +0000
changeset 220 91e3e906034c
child 221 68e28debe995
permissions -rw-r--r--
added a further test
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
220
91e3e906034c added a further test
urbanc
parents:
diff changeset
     1
theory Closure2
91e3e906034c added a further test
urbanc
parents:
diff changeset
     2
imports Closures
91e3e906034c added a further test
urbanc
parents:
diff changeset
     3
begin
91e3e906034c added a further test
urbanc
parents:
diff changeset
     4
91e3e906034c added a further test
urbanc
parents:
diff changeset
     5
inductive emb :: "'a list \<Rightarrow> 'a list \<Rightarrow> bool" ("_ \<preceq> _")
91e3e906034c added a further test
urbanc
parents:
diff changeset
     6
where
91e3e906034c added a further test
urbanc
parents:
diff changeset
     7
   emb0 [Pure.intro]: "emb [] bs"
91e3e906034c added a further test
urbanc
parents:
diff changeset
     8
 | emb1 [Pure.intro]: "emb as bs \<Longrightarrow> emb as (b # bs)"
91e3e906034c added a further test
urbanc
parents:
diff changeset
     9
 | emb2 [Pure.intro]: "emb as bs \<Longrightarrow> emb (a # as) (a # bs)"
91e3e906034c added a further test
urbanc
parents:
diff changeset
    10
91e3e906034c added a further test
urbanc
parents:
diff changeset
    11
lemma emb_refl:
91e3e906034c added a further test
urbanc
parents:
diff changeset
    12
  shows "x \<preceq> x"
91e3e906034c added a further test
urbanc
parents:
diff changeset
    13
apply(induct x)
91e3e906034c added a further test
urbanc
parents:
diff changeset
    14
apply(auto intro: emb.intros)
91e3e906034c added a further test
urbanc
parents:
diff changeset
    15
done
91e3e906034c added a further test
urbanc
parents:
diff changeset
    16
91e3e906034c added a further test
urbanc
parents:
diff changeset
    17
lemma emb_right:
91e3e906034c added a further test
urbanc
parents:
diff changeset
    18
  assumes a: "x \<preceq> y"
91e3e906034c added a further test
urbanc
parents:
diff changeset
    19
  shows "x \<preceq> y @ y'"
91e3e906034c added a further test
urbanc
parents:
diff changeset
    20
using a
91e3e906034c added a further test
urbanc
parents:
diff changeset
    21
apply(induct arbitrary: y')
91e3e906034c added a further test
urbanc
parents:
diff changeset
    22
apply(auto intro: emb.intros)
91e3e906034c added a further test
urbanc
parents:
diff changeset
    23
done
91e3e906034c added a further test
urbanc
parents:
diff changeset
    24
91e3e906034c added a further test
urbanc
parents:
diff changeset
    25
lemma emb_left:
91e3e906034c added a further test
urbanc
parents:
diff changeset
    26
  assumes a: "x \<preceq> y"
91e3e906034c added a further test
urbanc
parents:
diff changeset
    27
  shows "x \<preceq> y' @ y"
91e3e906034c added a further test
urbanc
parents:
diff changeset
    28
using a
91e3e906034c added a further test
urbanc
parents:
diff changeset
    29
apply(induct y')
91e3e906034c added a further test
urbanc
parents:
diff changeset
    30
apply(auto intro: emb.intros)
91e3e906034c added a further test
urbanc
parents:
diff changeset
    31
done
91e3e906034c added a further test
urbanc
parents:
diff changeset
    32
91e3e906034c added a further test
urbanc
parents:
diff changeset
    33
lemma emb_appendI:
91e3e906034c added a further test
urbanc
parents:
diff changeset
    34
  assumes a: "x \<preceq> x'"
91e3e906034c added a further test
urbanc
parents:
diff changeset
    35
  and     b: "y \<preceq> y'"
91e3e906034c added a further test
urbanc
parents:
diff changeset
    36
  shows "x @ y \<preceq> x' @ y'"
91e3e906034c added a further test
urbanc
parents:
diff changeset
    37
using a b
91e3e906034c added a further test
urbanc
parents:
diff changeset
    38
apply(induct)
91e3e906034c added a further test
urbanc
parents:
diff changeset
    39
apply(auto intro: emb.intros emb_left)
91e3e906034c added a further test
urbanc
parents:
diff changeset
    40
done
91e3e906034c added a further test
urbanc
parents:
diff changeset
    41
91e3e906034c added a further test
urbanc
parents:
diff changeset
    42
lemma emb_append:
91e3e906034c added a further test
urbanc
parents:
diff changeset
    43
  assumes a: "x \<preceq> y1 @ y2"
91e3e906034c added a further test
urbanc
parents:
diff changeset
    44
  shows "\<exists>x1 x2. x = x1 @ x2 \<and> x1 \<preceq> y1 \<and> x2 \<preceq> y2"
91e3e906034c added a further test
urbanc
parents:
diff changeset
    45
using a
91e3e906034c added a further test
urbanc
parents:
diff changeset
    46
apply(induct x y\<equiv>"y1 @ y2" arbitrary: y1 y2)
91e3e906034c added a further test
urbanc
parents:
diff changeset
    47
apply(auto intro: emb0)[1]
91e3e906034c added a further test
urbanc
parents:
diff changeset
    48
apply(simp add: Cons_eq_append_conv)
91e3e906034c added a further test
urbanc
parents:
diff changeset
    49
apply(auto)[1]
91e3e906034c added a further test
urbanc
parents:
diff changeset
    50
apply(rule_tac x="[]" in exI)
91e3e906034c added a further test
urbanc
parents:
diff changeset
    51
apply(rule_tac x="as" in exI)
91e3e906034c added a further test
urbanc
parents:
diff changeset
    52
apply(auto intro: emb.intros)[1]
91e3e906034c added a further test
urbanc
parents:
diff changeset
    53
apply(simp add: append_eq_append_conv2)
91e3e906034c added a further test
urbanc
parents:
diff changeset
    54
apply(drule_tac x="ys'" in meta_spec)
91e3e906034c added a further test
urbanc
parents:
diff changeset
    55
apply(drule_tac x="y2" in meta_spec)
91e3e906034c added a further test
urbanc
parents:
diff changeset
    56
apply(auto)[1]
91e3e906034c added a further test
urbanc
parents:
diff changeset
    57
apply(rule_tac x="x1" in exI)
91e3e906034c added a further test
urbanc
parents:
diff changeset
    58
apply(rule_tac x="x2" in exI)
91e3e906034c added a further test
urbanc
parents:
diff changeset
    59
apply(auto intro: emb.intros)[1]
91e3e906034c added a further test
urbanc
parents:
diff changeset
    60
apply(subst (asm) Cons_eq_append_conv)
91e3e906034c added a further test
urbanc
parents:
diff changeset
    61
apply(auto)[1]
91e3e906034c added a further test
urbanc
parents:
diff changeset
    62
apply(rule_tac x="[]" in exI)
91e3e906034c added a further test
urbanc
parents:
diff changeset
    63
apply(rule_tac x="a # as" in exI)
91e3e906034c added a further test
urbanc
parents:
diff changeset
    64
apply(auto intro: emb.intros)[1]
91e3e906034c added a further test
urbanc
parents:
diff changeset
    65
apply(simp add: append_eq_append_conv2)
91e3e906034c added a further test
urbanc
parents:
diff changeset
    66
apply(drule_tac x="ys'" in meta_spec)
91e3e906034c added a further test
urbanc
parents:
diff changeset
    67
apply(drule_tac x="y2" in meta_spec)
91e3e906034c added a further test
urbanc
parents:
diff changeset
    68
apply(auto)[1]
91e3e906034c added a further test
urbanc
parents:
diff changeset
    69
apply(rule_tac x="a # x1" in exI)
91e3e906034c added a further test
urbanc
parents:
diff changeset
    70
apply(rule_tac x="x2" in exI)
91e3e906034c added a further test
urbanc
parents:
diff changeset
    71
apply(auto intro: emb.intros)[1]
91e3e906034c added a further test
urbanc
parents:
diff changeset
    72
done
91e3e906034c added a further test
urbanc
parents:
diff changeset
    73
91e3e906034c added a further test
urbanc
parents:
diff changeset
    74
91e3e906034c added a further test
urbanc
parents:
diff changeset
    75
definition
91e3e906034c added a further test
urbanc
parents:
diff changeset
    76
 "SUBSEQ A \<equiv> {x. \<exists>y \<in> A. x \<preceq> y}"
91e3e906034c added a further test
urbanc
parents:
diff changeset
    77
91e3e906034c added a further test
urbanc
parents:
diff changeset
    78
definition
91e3e906034c added a further test
urbanc
parents:
diff changeset
    79
 "SUPSEQ A \<equiv> (- SUBSEQ A) \<union> A"
91e3e906034c added a further test
urbanc
parents:
diff changeset
    80
91e3e906034c added a further test
urbanc
parents:
diff changeset
    81
lemma [simp]:
91e3e906034c added a further test
urbanc
parents:
diff changeset
    82
  "SUBSEQ {} = {}"
91e3e906034c added a further test
urbanc
parents:
diff changeset
    83
unfolding SUBSEQ_def
91e3e906034c added a further test
urbanc
parents:
diff changeset
    84
by auto
91e3e906034c added a further test
urbanc
parents:
diff changeset
    85
91e3e906034c added a further test
urbanc
parents:
diff changeset
    86
lemma [simp]:
91e3e906034c added a further test
urbanc
parents:
diff changeset
    87
  "SUBSEQ {[]} = {[]}"
91e3e906034c added a further test
urbanc
parents:
diff changeset
    88
unfolding SUBSEQ_def
91e3e906034c added a further test
urbanc
parents:
diff changeset
    89
apply(auto)
91e3e906034c added a further test
urbanc
parents:
diff changeset
    90
apply(erule emb.cases)
91e3e906034c added a further test
urbanc
parents:
diff changeset
    91
apply(auto)[3]
91e3e906034c added a further test
urbanc
parents:
diff changeset
    92
apply(rule emb0)
91e3e906034c added a further test
urbanc
parents:
diff changeset
    93
done
91e3e906034c added a further test
urbanc
parents:
diff changeset
    94
91e3e906034c added a further test
urbanc
parents:
diff changeset
    95
lemma SUBSEQ_atom [simp]:
91e3e906034c added a further test
urbanc
parents:
diff changeset
    96
  "SUBSEQ {[a]} = {[], [a]}"
91e3e906034c added a further test
urbanc
parents:
diff changeset
    97
apply(auto simp add: SUBSEQ_def)
91e3e906034c added a further test
urbanc
parents:
diff changeset
    98
apply(erule emb.cases)
91e3e906034c added a further test
urbanc
parents:
diff changeset
    99
apply(auto)[3]
91e3e906034c added a further test
urbanc
parents:
diff changeset
   100
apply(erule emb.cases)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   101
apply(auto)[3]
91e3e906034c added a further test
urbanc
parents:
diff changeset
   102
apply(erule emb.cases)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   103
apply(auto)[3]
91e3e906034c added a further test
urbanc
parents:
diff changeset
   104
apply(rule emb0)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   105
apply(rule emb2)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   106
apply(rule emb0)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   107
done
91e3e906034c added a further test
urbanc
parents:
diff changeset
   108
91e3e906034c added a further test
urbanc
parents:
diff changeset
   109
lemma SUBSEQ_union [simp]:
91e3e906034c added a further test
urbanc
parents:
diff changeset
   110
  "SUBSEQ (A \<union> B) = SUBSEQ A \<union> SUBSEQ B"
91e3e906034c added a further test
urbanc
parents:
diff changeset
   111
unfolding SUBSEQ_def by auto
91e3e906034c added a further test
urbanc
parents:
diff changeset
   112
91e3e906034c added a further test
urbanc
parents:
diff changeset
   113
lemma SUBSEQ_Union [simp]:
91e3e906034c added a further test
urbanc
parents:
diff changeset
   114
  fixes A :: "nat \<Rightarrow> 'a lang"
91e3e906034c added a further test
urbanc
parents:
diff changeset
   115
  shows "SUBSEQ (\<Union>n. (A n)) = (\<Union>n. (SUBSEQ  (A n)))"
91e3e906034c added a further test
urbanc
parents:
diff changeset
   116
unfolding SUBSEQ_def image_def by auto
91e3e906034c added a further test
urbanc
parents:
diff changeset
   117
91e3e906034c added a further test
urbanc
parents:
diff changeset
   118
lemma SUBSEQ_conc1:
91e3e906034c added a further test
urbanc
parents:
diff changeset
   119
  "\<lbrakk>x \<in> SUBSEQ A; y \<in> SUBSEQ B\<rbrakk> \<Longrightarrow> x @ y \<in> SUBSEQ (A \<cdot> B)"
91e3e906034c added a further test
urbanc
parents:
diff changeset
   120
unfolding SUBSEQ_def 
91e3e906034c added a further test
urbanc
parents:
diff changeset
   121
apply(auto)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   122
apply(rule_tac x="xa @ xaa" in bexI)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   123
apply(rule emb_appendI)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   124
apply(simp_all)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   125
done
91e3e906034c added a further test
urbanc
parents:
diff changeset
   126
91e3e906034c added a further test
urbanc
parents:
diff changeset
   127
lemma SUBSEQ_conc2:
91e3e906034c added a further test
urbanc
parents:
diff changeset
   128
  "x \<in> SUBSEQ (A \<cdot> B) \<Longrightarrow> x \<in> (SUBSEQ A) \<cdot> (SUBSEQ B)"
91e3e906034c added a further test
urbanc
parents:
diff changeset
   129
unfolding SUBSEQ_def conc_def 
91e3e906034c added a further test
urbanc
parents:
diff changeset
   130
apply(auto)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   131
apply(drule emb_append)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   132
apply(auto)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   133
done
91e3e906034c added a further test
urbanc
parents:
diff changeset
   134
91e3e906034c added a further test
urbanc
parents:
diff changeset
   135
lemma SUBSEQ_conc [simp]:
91e3e906034c added a further test
urbanc
parents:
diff changeset
   136
  "SUBSEQ (A \<cdot> B) = SUBSEQ A \<cdot> SUBSEQ B"
91e3e906034c added a further test
urbanc
parents:
diff changeset
   137
apply(auto)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   138
apply(simp add: SUBSEQ_conc2)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   139
apply(subst (asm) conc_def)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   140
apply(auto simp add: SUBSEQ_conc1)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   141
done
91e3e906034c added a further test
urbanc
parents:
diff changeset
   142
91e3e906034c added a further test
urbanc
parents:
diff changeset
   143
lemma SUBSEQ_star1:
91e3e906034c added a further test
urbanc
parents:
diff changeset
   144
  assumes a: "x \<in> (SUBSEQ A)\<star>" 
91e3e906034c added a further test
urbanc
parents:
diff changeset
   145
  shows "x \<in> SUBSEQ (A\<star>)"
91e3e906034c added a further test
urbanc
parents:
diff changeset
   146
using a
91e3e906034c added a further test
urbanc
parents:
diff changeset
   147
apply(induct rule: star_induct)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   148
apply(simp add: SUBSEQ_def)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   149
apply(rule_tac x="[]" in bexI)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   150
apply(rule emb0)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   151
apply(auto)[1]
91e3e906034c added a further test
urbanc
parents:
diff changeset
   152
apply(drule SUBSEQ_conc1)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   153
apply(assumption)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   154
apply(subst star_unfold_left)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   155
apply(simp only: SUBSEQ_union)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   156
apply(simp)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   157
done
91e3e906034c added a further test
urbanc
parents:
diff changeset
   158
91e3e906034c added a further test
urbanc
parents:
diff changeset
   159
lemma SUBSEQ_star2_aux:
91e3e906034c added a further test
urbanc
parents:
diff changeset
   160
  assumes a: "x \<in> SUBSEQ (A ^^ n)" 
91e3e906034c added a further test
urbanc
parents:
diff changeset
   161
  shows "x \<in> (SUBSEQ A)\<star>"
91e3e906034c added a further test
urbanc
parents:
diff changeset
   162
using a
91e3e906034c added a further test
urbanc
parents:
diff changeset
   163
apply(induct n arbitrary: x)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   164
apply(simp)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   165
apply(simp)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   166
apply(simp add: conc_def)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   167
apply(auto)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   168
done
91e3e906034c added a further test
urbanc
parents:
diff changeset
   169
91e3e906034c added a further test
urbanc
parents:
diff changeset
   170
lemma SUBSEQ_star2:
91e3e906034c added a further test
urbanc
parents:
diff changeset
   171
  assumes a: "x \<in> SUBSEQ (A\<star>)" 
91e3e906034c added a further test
urbanc
parents:
diff changeset
   172
  shows "x \<in> (SUBSEQ A)\<star>"
91e3e906034c added a further test
urbanc
parents:
diff changeset
   173
using a
91e3e906034c added a further test
urbanc
parents:
diff changeset
   174
apply(subst (asm) star_def)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   175
apply(auto simp add: SUBSEQ_star2_aux)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   176
done
91e3e906034c added a further test
urbanc
parents:
diff changeset
   177
91e3e906034c added a further test
urbanc
parents:
diff changeset
   178
lemma SUBSEQ_star [simp]:
91e3e906034c added a further test
urbanc
parents:
diff changeset
   179
  shows "SUBSEQ (A\<star>) = (SUBSEQ A)\<star>"
91e3e906034c added a further test
urbanc
parents:
diff changeset
   180
using SUBSEQ_star1 SUBSEQ_star2 by auto
91e3e906034c added a further test
urbanc
parents:
diff changeset
   181
91e3e906034c added a further test
urbanc
parents:
diff changeset
   182
lemma SUBSEQ_fold:
91e3e906034c added a further test
urbanc
parents:
diff changeset
   183
  shows "SUBSEQ A \<union> A = SUBSEQ A"
91e3e906034c added a further test
urbanc
parents:
diff changeset
   184
apply(auto simp add: SUBSEQ_def)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   185
apply(rule_tac x="x" in bexI)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   186
apply(auto simp add: emb_refl)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   187
done
91e3e906034c added a further test
urbanc
parents:
diff changeset
   188
91e3e906034c added a further test
urbanc
parents:
diff changeset
   189
91e3e906034c added a further test
urbanc
parents:
diff changeset
   190
lemma SUPSEQ_union [simp]:
91e3e906034c added a further test
urbanc
parents:
diff changeset
   191
  "SUPSEQ (A \<union> B) = (SUPSEQ A \<union> B) \<inter> (SUPSEQ B \<union> A)"
91e3e906034c added a further test
urbanc
parents:
diff changeset
   192
unfolding SUPSEQ_def 
91e3e906034c added a further test
urbanc
parents:
diff changeset
   193
by auto
91e3e906034c added a further test
urbanc
parents:
diff changeset
   194
91e3e906034c added a further test
urbanc
parents:
diff changeset
   195
91e3e906034c added a further test
urbanc
parents:
diff changeset
   196
definition
91e3e906034c added a further test
urbanc
parents:
diff changeset
   197
  Notreg :: "'a::finite rexp \<Rightarrow> 'a rexp"
91e3e906034c added a further test
urbanc
parents:
diff changeset
   198
where
91e3e906034c added a further test
urbanc
parents:
diff changeset
   199
  "Notreg r \<equiv> SOME r'. lang r' = - (lang r)"
91e3e906034c added a further test
urbanc
parents:
diff changeset
   200
91e3e906034c added a further test
urbanc
parents:
diff changeset
   201
lemma [simp]:
91e3e906034c added a further test
urbanc
parents:
diff changeset
   202
  "lang (Notreg r) = - lang r"
91e3e906034c added a further test
urbanc
parents:
diff changeset
   203
apply(simp add: Notreg_def)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   204
apply(rule someI2_ex)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   205
apply(auto)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   206
apply(subgoal_tac "regular (lang r)")
91e3e906034c added a further test
urbanc
parents:
diff changeset
   207
apply(drule closure_complement)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   208
apply(auto) 
91e3e906034c added a further test
urbanc
parents:
diff changeset
   209
done
91e3e906034c added a further test
urbanc
parents:
diff changeset
   210
91e3e906034c added a further test
urbanc
parents:
diff changeset
   211
definition
91e3e906034c added a further test
urbanc
parents:
diff changeset
   212
  Interreg :: "'a::finite rexp \<Rightarrow> 'a rexp \<Rightarrow> 'a rexp"
91e3e906034c added a further test
urbanc
parents:
diff changeset
   213
where
91e3e906034c added a further test
urbanc
parents:
diff changeset
   214
  "Interreg r1 r2 = Notreg (Plus (Notreg r1) (Notreg r2))"
91e3e906034c added a further test
urbanc
parents:
diff changeset
   215
91e3e906034c added a further test
urbanc
parents:
diff changeset
   216
lemma [simp]:
91e3e906034c added a further test
urbanc
parents:
diff changeset
   217
  "lang (Interreg r1 r2) = (lang r1) \<inter> (lang r2)"
91e3e906034c added a further test
urbanc
parents:
diff changeset
   218
by (simp add: Interreg_def)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   219
91e3e906034c added a further test
urbanc
parents:
diff changeset
   220
definition
91e3e906034c added a further test
urbanc
parents:
diff changeset
   221
  Diffreg :: "'a::finite rexp \<Rightarrow> 'a rexp \<Rightarrow> 'a rexp"
91e3e906034c added a further test
urbanc
parents:
diff changeset
   222
where
91e3e906034c added a further test
urbanc
parents:
diff changeset
   223
  "Diffreg r1 r2 = Notreg (Plus (Notreg r1) r2)"
91e3e906034c added a further test
urbanc
parents:
diff changeset
   224
91e3e906034c added a further test
urbanc
parents:
diff changeset
   225
lemma [simp]:
91e3e906034c added a further test
urbanc
parents:
diff changeset
   226
  "lang (Diffreg r1 r2) = (lang r1) - (lang r2)"
91e3e906034c added a further test
urbanc
parents:
diff changeset
   227
by (auto simp add: Diffreg_def)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   228
91e3e906034c added a further test
urbanc
parents:
diff changeset
   229
definition
91e3e906034c added a further test
urbanc
parents:
diff changeset
   230
  Allreg :: "'a::finite rexp"
91e3e906034c added a further test
urbanc
parents:
diff changeset
   231
where
91e3e906034c added a further test
urbanc
parents:
diff changeset
   232
  "Allreg \<equiv> \<Uplus>(Atom ` UNIV)"
91e3e906034c added a further test
urbanc
parents:
diff changeset
   233
91e3e906034c added a further test
urbanc
parents:
diff changeset
   234
lemma Allreg_lang [simp]:
91e3e906034c added a further test
urbanc
parents:
diff changeset
   235
  "lang Allreg = (\<Union>a. {[a]})"
91e3e906034c added a further test
urbanc
parents:
diff changeset
   236
unfolding Allreg_def
91e3e906034c added a further test
urbanc
parents:
diff changeset
   237
by auto
91e3e906034c added a further test
urbanc
parents:
diff changeset
   238
91e3e906034c added a further test
urbanc
parents:
diff changeset
   239
lemma [simp]:
91e3e906034c added a further test
urbanc
parents:
diff changeset
   240
  "(\<Union>a. {[a]})\<star> = UNIV"
91e3e906034c added a further test
urbanc
parents:
diff changeset
   241
apply(auto)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   242
apply(induct_tac x rule: list.induct)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   243
apply(auto)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   244
apply(subgoal_tac "[a] @ list \<in> (\<Union>a. {[a]})\<star>")
91e3e906034c added a further test
urbanc
parents:
diff changeset
   245
apply(simp)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   246
apply(rule append_in_starI)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   247
apply(auto)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   248
done
91e3e906034c added a further test
urbanc
parents:
diff changeset
   249
91e3e906034c added a further test
urbanc
parents:
diff changeset
   250
lemma Star_Allreg_lang [simp]:
91e3e906034c added a further test
urbanc
parents:
diff changeset
   251
  "lang (Star Allreg) = UNIV"
91e3e906034c added a further test
urbanc
parents:
diff changeset
   252
by (simp)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   253
91e3e906034c added a further test
urbanc
parents:
diff changeset
   254
fun UP :: "'a::finite rexp \<Rightarrow> 'a rexp"
91e3e906034c added a further test
urbanc
parents:
diff changeset
   255
where
91e3e906034c added a further test
urbanc
parents:
diff changeset
   256
  "UP (Zero) = Star Allreg"
91e3e906034c added a further test
urbanc
parents:
diff changeset
   257
| "UP (One) = Star Allreg"
91e3e906034c added a further test
urbanc
parents:
diff changeset
   258
| "UP (Atom c) = Times Allreg (Star Allreg)"   
91e3e906034c added a further test
urbanc
parents:
diff changeset
   259
| "UP (Plus r1 r2) = Interreg (Plus (UP r1) (r2)) (Plus (UP r2) r1)"
91e3e906034c added a further test
urbanc
parents:
diff changeset
   260
| "UP (Times r1 r2) = 
91e3e906034c added a further test
urbanc
parents:
diff changeset
   261
     Plus (Notreg (Times (Plus (Notreg (UP r1)) r1) (Plus (Notreg (UP r2)) r2))) (Times r1 r2)"
91e3e906034c added a further test
urbanc
parents:
diff changeset
   262
| "UP (Star r) = Plus (Notreg (Star (Plus (Notreg (UP r)) r))) (Star r)"
91e3e906034c added a further test
urbanc
parents:
diff changeset
   263
91e3e906034c added a further test
urbanc
parents:
diff changeset
   264
lemma UP:
91e3e906034c added a further test
urbanc
parents:
diff changeset
   265
  "lang (UP r) = SUPSEQ (lang r)"
91e3e906034c added a further test
urbanc
parents:
diff changeset
   266
apply(induct r)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   267
apply(simp add: SUPSEQ_def)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   268
apply(simp add: SUPSEQ_def)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   269
apply(simp add: Compl_eq_Diff_UNIV)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   270
apply(auto)[1]
91e3e906034c added a further test
urbanc
parents:
diff changeset
   271
apply(simp add: SUPSEQ_def)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   272
apply(simp add: Compl_eq_Diff_UNIV)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   273
apply(rule sym)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   274
apply(rule_tac s="UNIV - {[]}" in trans)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   275
apply(auto)[1]
91e3e906034c added a further test
urbanc
parents:
diff changeset
   276
apply(auto simp add: conc_def)[1]
91e3e906034c added a further test
urbanc
parents:
diff changeset
   277
apply(case_tac x)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   278
apply(simp)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   279
apply(simp)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   280
apply(rule_tac x="[a]" in exI)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   281
apply(simp)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   282
apply(simp)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   283
apply(simp)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   284
apply(simp add: SUPSEQ_def)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   285
apply(simp add: Un_Int_distrib2)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   286
apply(simp add: Compl_partition2)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   287
apply(simp add: SUBSEQ_fold)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   288
apply(simp add: Un_Diff)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   289
apply(simp add: SUPSEQ_def)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   290
apply(simp add: Un_Int_distrib2)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   291
apply(simp add: Compl_partition2)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   292
apply(simp add: SUBSEQ_fold)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   293
done
91e3e906034c added a further test
urbanc
parents:
diff changeset
   294
91e3e906034c added a further test
urbanc
parents:
diff changeset
   295
lemma SUPSEQ_reg:
91e3e906034c added a further test
urbanc
parents:
diff changeset
   296
  fixes A :: "'a::finite lang"
91e3e906034c added a further test
urbanc
parents:
diff changeset
   297
  assumes "regular A"
91e3e906034c added a further test
urbanc
parents:
diff changeset
   298
  shows "regular (SUPSEQ A)"
91e3e906034c added a further test
urbanc
parents:
diff changeset
   299
proof -
91e3e906034c added a further test
urbanc
parents:
diff changeset
   300
  from assms obtain r::"'a::finite rexp" where eq: "lang r = A" by auto
91e3e906034c added a further test
urbanc
parents:
diff changeset
   301
  moreover 
91e3e906034c added a further test
urbanc
parents:
diff changeset
   302
  have "lang (UP r) = SUPSEQ (lang r)" by (rule UP)
91e3e906034c added a further test
urbanc
parents:
diff changeset
   303
  ultimately show "regular (SUPSEQ A)" by auto
91e3e906034c added a further test
urbanc
parents:
diff changeset
   304
qed
91e3e906034c added a further test
urbanc
parents:
diff changeset
   305
   
91e3e906034c added a further test
urbanc
parents:
diff changeset
   306
91e3e906034c added a further test
urbanc
parents:
diff changeset
   307
 
91e3e906034c added a further test
urbanc
parents:
diff changeset
   308
91e3e906034c added a further test
urbanc
parents:
diff changeset
   309
91e3e906034c added a further test
urbanc
parents:
diff changeset
   310
end