src/HOL/Datatype.thy
author haftmann
Sun Apr 15 20:51:07 2012 +0200 (2012-04-15)
changeset 47488 be6dd389639d
parent 46950 d0181abdbdac
child 48891 c0eafbd55de3
permissions -rw-r--r--
centralized enriched_type declaration, thanks to in-situ available Isar commands
     1 (*  Title:      HOL/Datatype.thy
     2     Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
     3     Author:     Stefan Berghofer and Markus Wenzel, TU Muenchen
     4 *)
     5 
     6 header {* Datatype package: constructing datatypes from Cartesian Products and Disjoint Sums *}
     7 
     8 theory Datatype
     9 imports Product_Type Sum_Type Nat
    10 keywords "datatype" :: thy_decl
    11 uses
    12   ("Tools/Datatype/datatype.ML")
    13   ("Tools/inductive_realizer.ML")
    14   ("Tools/Datatype/datatype_realizer.ML")
    15 begin
    16 
    17 subsection {* The datatype universe *}
    18 
    19 definition "Node = {p. EX f x k. p = (f :: nat => 'b + nat, x ::'a + nat) & f k = Inr 0}"
    20 
    21 typedef (open) ('a, 'b) node = "Node :: ((nat => 'b + nat) * ('a + nat)) set"
    22   morphisms Rep_Node Abs_Node
    23   unfolding Node_def by auto
    24 
    25 text{*Datatypes will be represented by sets of type @{text node}*}
    26 
    27 type_synonym 'a item        = "('a, unit) node set"
    28 type_synonym ('a, 'b) dtree = "('a, 'b) node set"
    29 
    30 consts
    31   Push      :: "[('b + nat), nat => ('b + nat)] => (nat => ('b + nat))"
    32 
    33   Push_Node :: "[('b + nat), ('a, 'b) node] => ('a, 'b) node"
    34   ndepth    :: "('a, 'b) node => nat"
    35 
    36   Atom      :: "('a + nat) => ('a, 'b) dtree"
    37   Leaf      :: "'a => ('a, 'b) dtree"
    38   Numb      :: "nat => ('a, 'b) dtree"
    39   Scons     :: "[('a, 'b) dtree, ('a, 'b) dtree] => ('a, 'b) dtree"
    40   In0       :: "('a, 'b) dtree => ('a, 'b) dtree"
    41   In1       :: "('a, 'b) dtree => ('a, 'b) dtree"
    42   Lim       :: "('b => ('a, 'b) dtree) => ('a, 'b) dtree"
    43 
    44   ntrunc    :: "[nat, ('a, 'b) dtree] => ('a, 'b) dtree"
    45 
    46   uprod     :: "[('a, 'b) dtree set, ('a, 'b) dtree set]=> ('a, 'b) dtree set"
    47   usum      :: "[('a, 'b) dtree set, ('a, 'b) dtree set]=> ('a, 'b) dtree set"
    48 
    49   Split     :: "[[('a, 'b) dtree, ('a, 'b) dtree]=>'c, ('a, 'b) dtree] => 'c"
    50   Case      :: "[[('a, 'b) dtree]=>'c, [('a, 'b) dtree]=>'c, ('a, 'b) dtree] => 'c"
    51 
    52   dprod     :: "[(('a, 'b) dtree * ('a, 'b) dtree)set, (('a, 'b) dtree * ('a, 'b) dtree)set]
    53                 => (('a, 'b) dtree * ('a, 'b) dtree)set"
    54   dsum      :: "[(('a, 'b) dtree * ('a, 'b) dtree)set, (('a, 'b) dtree * ('a, 'b) dtree)set]
    55                 => (('a, 'b) dtree * ('a, 'b) dtree)set"
    56 
    57 
    58 defs
    59 
    60   Push_Node_def:  "Push_Node == (%n x. Abs_Node (apfst (Push n) (Rep_Node x)))"
    61 
    62   (*crude "lists" of nats -- needed for the constructions*)
    63   Push_def:   "Push == (%b h. nat_case b h)"
    64 
    65   (** operations on S-expressions -- sets of nodes **)
    66 
    67   (*S-expression constructors*)
    68   Atom_def:   "Atom == (%x. {Abs_Node((%k. Inr 0, x))})"
    69   Scons_def:  "Scons M N == (Push_Node (Inr 1) ` M) Un (Push_Node (Inr (Suc 1)) ` N)"
    70 
    71   (*Leaf nodes, with arbitrary or nat labels*)
    72   Leaf_def:   "Leaf == Atom o Inl"
    73   Numb_def:   "Numb == Atom o Inr"
    74 
    75   (*Injections of the "disjoint sum"*)
    76   In0_def:    "In0(M) == Scons (Numb 0) M"
    77   In1_def:    "In1(M) == Scons (Numb 1) M"
    78 
    79   (*Function spaces*)
    80   Lim_def: "Lim f == Union {z. ? x. z = Push_Node (Inl x) ` (f x)}"
    81 
    82   (*the set of nodes with depth less than k*)
    83   ndepth_def: "ndepth(n) == (%(f,x). LEAST k. f k = Inr 0) (Rep_Node n)"
    84   ntrunc_def: "ntrunc k N == {n. n:N & ndepth(n)<k}"
    85 
    86   (*products and sums for the "universe"*)
    87   uprod_def:  "uprod A B == UN x:A. UN y:B. { Scons x y }"
    88   usum_def:   "usum A B == In0`A Un In1`B"
    89 
    90   (*the corresponding eliminators*)
    91   Split_def:  "Split c M == THE u. EX x y. M = Scons x y & u = c x y"
    92 
    93   Case_def:   "Case c d M == THE u.  (EX x . M = In0(x) & u = c(x))
    94                                   | (EX y . M = In1(y) & u = d(y))"
    95 
    96 
    97   (** equality for the "universe" **)
    98 
    99   dprod_def:  "dprod r s == UN (x,x'):r. UN (y,y'):s. {(Scons x y, Scons x' y')}"
   100 
   101   dsum_def:   "dsum r s == (UN (x,x'):r. {(In0(x),In0(x'))}) Un
   102                           (UN (y,y'):s. {(In1(y),In1(y'))})"
   103 
   104 
   105 
   106 lemma apfst_convE: 
   107     "[| q = apfst f p;  !!x y. [| p = (x,y);  q = (f(x),y) |] ==> R  
   108      |] ==> R"
   109 by (force simp add: apfst_def)
   110 
   111 (** Push -- an injection, analogous to Cons on lists **)
   112 
   113 lemma Push_inject1: "Push i f = Push j g  ==> i=j"
   114 apply (simp add: Push_def fun_eq_iff) 
   115 apply (drule_tac x=0 in spec, simp) 
   116 done
   117 
   118 lemma Push_inject2: "Push i f = Push j g  ==> f=g"
   119 apply (auto simp add: Push_def fun_eq_iff) 
   120 apply (drule_tac x="Suc x" in spec, simp) 
   121 done
   122 
   123 lemma Push_inject:
   124     "[| Push i f =Push j g;  [| i=j;  f=g |] ==> P |] ==> P"
   125 by (blast dest: Push_inject1 Push_inject2) 
   126 
   127 lemma Push_neq_K0: "Push (Inr (Suc k)) f = (%z. Inr 0) ==> P"
   128 by (auto simp add: Push_def fun_eq_iff split: nat.split_asm)
   129 
   130 lemmas Abs_Node_inj = Abs_Node_inject [THEN [2] rev_iffD1]
   131 
   132 
   133 (*** Introduction rules for Node ***)
   134 
   135 lemma Node_K0_I: "(%k. Inr 0, a) : Node"
   136 by (simp add: Node_def)
   137 
   138 lemma Node_Push_I: "p: Node ==> apfst (Push i) p : Node"
   139 apply (simp add: Node_def Push_def) 
   140 apply (fast intro!: apfst_conv nat_case_Suc [THEN trans])
   141 done
   142 
   143 
   144 subsection{*Freeness: Distinctness of Constructors*}
   145 
   146 (** Scons vs Atom **)
   147 
   148 lemma Scons_not_Atom [iff]: "Scons M N \<noteq> Atom(a)"
   149 unfolding Atom_def Scons_def Push_Node_def One_nat_def
   150 by (blast intro: Node_K0_I Rep_Node [THEN Node_Push_I] 
   151          dest!: Abs_Node_inj 
   152          elim!: apfst_convE sym [THEN Push_neq_K0])  
   153 
   154 lemmas Atom_not_Scons [iff] = Scons_not_Atom [THEN not_sym]
   155 
   156 
   157 (*** Injectiveness ***)
   158 
   159 (** Atomic nodes **)
   160 
   161 lemma inj_Atom: "inj(Atom)"
   162 apply (simp add: Atom_def)
   163 apply (blast intro!: inj_onI Node_K0_I dest!: Abs_Node_inj)
   164 done
   165 lemmas Atom_inject = inj_Atom [THEN injD]
   166 
   167 lemma Atom_Atom_eq [iff]: "(Atom(a)=Atom(b)) = (a=b)"
   168 by (blast dest!: Atom_inject)
   169 
   170 lemma inj_Leaf: "inj(Leaf)"
   171 apply (simp add: Leaf_def o_def)
   172 apply (rule inj_onI)
   173 apply (erule Atom_inject [THEN Inl_inject])
   174 done
   175 
   176 lemmas Leaf_inject [dest!] = inj_Leaf [THEN injD]
   177 
   178 lemma inj_Numb: "inj(Numb)"
   179 apply (simp add: Numb_def o_def)
   180 apply (rule inj_onI)
   181 apply (erule Atom_inject [THEN Inr_inject])
   182 done
   183 
   184 lemmas Numb_inject [dest!] = inj_Numb [THEN injD]
   185 
   186 
   187 (** Injectiveness of Push_Node **)
   188 
   189 lemma Push_Node_inject:
   190     "[| Push_Node i m =Push_Node j n;  [| i=j;  m=n |] ==> P  
   191      |] ==> P"
   192 apply (simp add: Push_Node_def)
   193 apply (erule Abs_Node_inj [THEN apfst_convE])
   194 apply (rule Rep_Node [THEN Node_Push_I])+
   195 apply (erule sym [THEN apfst_convE]) 
   196 apply (blast intro: Rep_Node_inject [THEN iffD1] trans sym elim!: Push_inject)
   197 done
   198 
   199 
   200 (** Injectiveness of Scons **)
   201 
   202 lemma Scons_inject_lemma1: "Scons M N <= Scons M' N' ==> M<=M'"
   203 unfolding Scons_def One_nat_def
   204 by (blast dest!: Push_Node_inject)
   205 
   206 lemma Scons_inject_lemma2: "Scons M N <= Scons M' N' ==> N<=N'"
   207 unfolding Scons_def One_nat_def
   208 by (blast dest!: Push_Node_inject)
   209 
   210 lemma Scons_inject1: "Scons M N = Scons M' N' ==> M=M'"
   211 apply (erule equalityE)
   212 apply (iprover intro: equalityI Scons_inject_lemma1)
   213 done
   214 
   215 lemma Scons_inject2: "Scons M N = Scons M' N' ==> N=N'"
   216 apply (erule equalityE)
   217 apply (iprover intro: equalityI Scons_inject_lemma2)
   218 done
   219 
   220 lemma Scons_inject:
   221     "[| Scons M N = Scons M' N';  [| M=M';  N=N' |] ==> P |] ==> P"
   222 by (iprover dest: Scons_inject1 Scons_inject2)
   223 
   224 lemma Scons_Scons_eq [iff]: "(Scons M N = Scons M' N') = (M=M' & N=N')"
   225 by (blast elim!: Scons_inject)
   226 
   227 (*** Distinctness involving Leaf and Numb ***)
   228 
   229 (** Scons vs Leaf **)
   230 
   231 lemma Scons_not_Leaf [iff]: "Scons M N \<noteq> Leaf(a)"
   232 unfolding Leaf_def o_def by (rule Scons_not_Atom)
   233 
   234 lemmas Leaf_not_Scons  [iff] = Scons_not_Leaf [THEN not_sym]
   235 
   236 (** Scons vs Numb **)
   237 
   238 lemma Scons_not_Numb [iff]: "Scons M N \<noteq> Numb(k)"
   239 unfolding Numb_def o_def by (rule Scons_not_Atom)
   240 
   241 lemmas Numb_not_Scons [iff] = Scons_not_Numb [THEN not_sym]
   242 
   243 
   244 (** Leaf vs Numb **)
   245 
   246 lemma Leaf_not_Numb [iff]: "Leaf(a) \<noteq> Numb(k)"
   247 by (simp add: Leaf_def Numb_def)
   248 
   249 lemmas Numb_not_Leaf [iff] = Leaf_not_Numb [THEN not_sym]
   250 
   251 
   252 (*** ndepth -- the depth of a node ***)
   253 
   254 lemma ndepth_K0: "ndepth (Abs_Node(%k. Inr 0, x)) = 0"
   255 by (simp add: ndepth_def  Node_K0_I [THEN Abs_Node_inverse] Least_equality)
   256 
   257 lemma ndepth_Push_Node_aux:
   258      "nat_case (Inr (Suc i)) f k = Inr 0 --> Suc(LEAST x. f x = Inr 0) <= k"
   259 apply (induct_tac "k", auto)
   260 apply (erule Least_le)
   261 done
   262 
   263 lemma ndepth_Push_Node: 
   264     "ndepth (Push_Node (Inr (Suc i)) n) = Suc(ndepth(n))"
   265 apply (insert Rep_Node [of n, unfolded Node_def])
   266 apply (auto simp add: ndepth_def Push_Node_def
   267                  Rep_Node [THEN Node_Push_I, THEN Abs_Node_inverse])
   268 apply (rule Least_equality)
   269 apply (auto simp add: Push_def ndepth_Push_Node_aux)
   270 apply (erule LeastI)
   271 done
   272 
   273 
   274 (*** ntrunc applied to the various node sets ***)
   275 
   276 lemma ntrunc_0 [simp]: "ntrunc 0 M = {}"
   277 by (simp add: ntrunc_def)
   278 
   279 lemma ntrunc_Atom [simp]: "ntrunc (Suc k) (Atom a) = Atom(a)"
   280 by (auto simp add: Atom_def ntrunc_def ndepth_K0)
   281 
   282 lemma ntrunc_Leaf [simp]: "ntrunc (Suc k) (Leaf a) = Leaf(a)"
   283 unfolding Leaf_def o_def by (rule ntrunc_Atom)
   284 
   285 lemma ntrunc_Numb [simp]: "ntrunc (Suc k) (Numb i) = Numb(i)"
   286 unfolding Numb_def o_def by (rule ntrunc_Atom)
   287 
   288 lemma ntrunc_Scons [simp]: 
   289     "ntrunc (Suc k) (Scons M N) = Scons (ntrunc k M) (ntrunc k N)"
   290 unfolding Scons_def ntrunc_def One_nat_def
   291 by (auto simp add: ndepth_Push_Node)
   292 
   293 
   294 
   295 (** Injection nodes **)
   296 
   297 lemma ntrunc_one_In0 [simp]: "ntrunc (Suc 0) (In0 M) = {}"
   298 apply (simp add: In0_def)
   299 apply (simp add: Scons_def)
   300 done
   301 
   302 lemma ntrunc_In0 [simp]: "ntrunc (Suc(Suc k)) (In0 M) = In0 (ntrunc (Suc k) M)"
   303 by (simp add: In0_def)
   304 
   305 lemma ntrunc_one_In1 [simp]: "ntrunc (Suc 0) (In1 M) = {}"
   306 apply (simp add: In1_def)
   307 apply (simp add: Scons_def)
   308 done
   309 
   310 lemma ntrunc_In1 [simp]: "ntrunc (Suc(Suc k)) (In1 M) = In1 (ntrunc (Suc k) M)"
   311 by (simp add: In1_def)
   312 
   313 
   314 subsection{*Set Constructions*}
   315 
   316 
   317 (*** Cartesian Product ***)
   318 
   319 lemma uprodI [intro!]: "[| M:A;  N:B |] ==> Scons M N : uprod A B"
   320 by (simp add: uprod_def)
   321 
   322 (*The general elimination rule*)
   323 lemma uprodE [elim!]:
   324     "[| c : uprod A B;   
   325         !!x y. [| x:A;  y:B;  c = Scons x y |] ==> P  
   326      |] ==> P"
   327 by (auto simp add: uprod_def) 
   328 
   329 
   330 (*Elimination of a pair -- introduces no eigenvariables*)
   331 lemma uprodE2: "[| Scons M N : uprod A B;  [| M:A;  N:B |] ==> P |] ==> P"
   332 by (auto simp add: uprod_def)
   333 
   334 
   335 (*** Disjoint Sum ***)
   336 
   337 lemma usum_In0I [intro]: "M:A ==> In0(M) : usum A B"
   338 by (simp add: usum_def)
   339 
   340 lemma usum_In1I [intro]: "N:B ==> In1(N) : usum A B"
   341 by (simp add: usum_def)
   342 
   343 lemma usumE [elim!]: 
   344     "[| u : usum A B;   
   345         !!x. [| x:A;  u=In0(x) |] ==> P;  
   346         !!y. [| y:B;  u=In1(y) |] ==> P  
   347      |] ==> P"
   348 by (auto simp add: usum_def)
   349 
   350 
   351 (** Injection **)
   352 
   353 lemma In0_not_In1 [iff]: "In0(M) \<noteq> In1(N)"
   354 unfolding In0_def In1_def One_nat_def by auto
   355 
   356 lemmas In1_not_In0 [iff] = In0_not_In1 [THEN not_sym]
   357 
   358 lemma In0_inject: "In0(M) = In0(N) ==>  M=N"
   359 by (simp add: In0_def)
   360 
   361 lemma In1_inject: "In1(M) = In1(N) ==>  M=N"
   362 by (simp add: In1_def)
   363 
   364 lemma In0_eq [iff]: "(In0 M = In0 N) = (M=N)"
   365 by (blast dest!: In0_inject)
   366 
   367 lemma In1_eq [iff]: "(In1 M = In1 N) = (M=N)"
   368 by (blast dest!: In1_inject)
   369 
   370 lemma inj_In0: "inj In0"
   371 by (blast intro!: inj_onI)
   372 
   373 lemma inj_In1: "inj In1"
   374 by (blast intro!: inj_onI)
   375 
   376 
   377 (*** Function spaces ***)
   378 
   379 lemma Lim_inject: "Lim f = Lim g ==> f = g"
   380 apply (simp add: Lim_def)
   381 apply (rule ext)
   382 apply (blast elim!: Push_Node_inject)
   383 done
   384 
   385 
   386 (*** proving equality of sets and functions using ntrunc ***)
   387 
   388 lemma ntrunc_subsetI: "ntrunc k M <= M"
   389 by (auto simp add: ntrunc_def)
   390 
   391 lemma ntrunc_subsetD: "(!!k. ntrunc k M <= N) ==> M<=N"
   392 by (auto simp add: ntrunc_def)
   393 
   394 (*A generalized form of the take-lemma*)
   395 lemma ntrunc_equality: "(!!k. ntrunc k M = ntrunc k N) ==> M=N"
   396 apply (rule equalityI)
   397 apply (rule_tac [!] ntrunc_subsetD)
   398 apply (rule_tac [!] ntrunc_subsetI [THEN [2] subset_trans], auto) 
   399 done
   400 
   401 lemma ntrunc_o_equality: 
   402     "[| !!k. (ntrunc(k) o h1) = (ntrunc(k) o h2) |] ==> h1=h2"
   403 apply (rule ntrunc_equality [THEN ext])
   404 apply (simp add: fun_eq_iff) 
   405 done
   406 
   407 
   408 (*** Monotonicity ***)
   409 
   410 lemma uprod_mono: "[| A<=A';  B<=B' |] ==> uprod A B <= uprod A' B'"
   411 by (simp add: uprod_def, blast)
   412 
   413 lemma usum_mono: "[| A<=A';  B<=B' |] ==> usum A B <= usum A' B'"
   414 by (simp add: usum_def, blast)
   415 
   416 lemma Scons_mono: "[| M<=M';  N<=N' |] ==> Scons M N <= Scons M' N'"
   417 by (simp add: Scons_def, blast)
   418 
   419 lemma In0_mono: "M<=N ==> In0(M) <= In0(N)"
   420 by (simp add: In0_def Scons_mono)
   421 
   422 lemma In1_mono: "M<=N ==> In1(M) <= In1(N)"
   423 by (simp add: In1_def Scons_mono)
   424 
   425 
   426 (*** Split and Case ***)
   427 
   428 lemma Split [simp]: "Split c (Scons M N) = c M N"
   429 by (simp add: Split_def)
   430 
   431 lemma Case_In0 [simp]: "Case c d (In0 M) = c(M)"
   432 by (simp add: Case_def)
   433 
   434 lemma Case_In1 [simp]: "Case c d (In1 N) = d(N)"
   435 by (simp add: Case_def)
   436 
   437 
   438 
   439 (**** UN x. B(x) rules ****)
   440 
   441 lemma ntrunc_UN1: "ntrunc k (UN x. f(x)) = (UN x. ntrunc k (f x))"
   442 by (simp add: ntrunc_def, blast)
   443 
   444 lemma Scons_UN1_x: "Scons (UN x. f x) M = (UN x. Scons (f x) M)"
   445 by (simp add: Scons_def, blast)
   446 
   447 lemma Scons_UN1_y: "Scons M (UN x. f x) = (UN x. Scons M (f x))"
   448 by (simp add: Scons_def, blast)
   449 
   450 lemma In0_UN1: "In0(UN x. f(x)) = (UN x. In0(f(x)))"
   451 by (simp add: In0_def Scons_UN1_y)
   452 
   453 lemma In1_UN1: "In1(UN x. f(x)) = (UN x. In1(f(x)))"
   454 by (simp add: In1_def Scons_UN1_y)
   455 
   456 
   457 (*** Equality for Cartesian Product ***)
   458 
   459 lemma dprodI [intro!]: 
   460     "[| (M,M'):r;  (N,N'):s |] ==> (Scons M N, Scons M' N') : dprod r s"
   461 by (auto simp add: dprod_def)
   462 
   463 (*The general elimination rule*)
   464 lemma dprodE [elim!]: 
   465     "[| c : dprod r s;   
   466         !!x y x' y'. [| (x,x') : r;  (y,y') : s;  
   467                         c = (Scons x y, Scons x' y') |] ==> P  
   468      |] ==> P"
   469 by (auto simp add: dprod_def)
   470 
   471 
   472 (*** Equality for Disjoint Sum ***)
   473 
   474 lemma dsum_In0I [intro]: "(M,M'):r ==> (In0(M), In0(M')) : dsum r s"
   475 by (auto simp add: dsum_def)
   476 
   477 lemma dsum_In1I [intro]: "(N,N'):s ==> (In1(N), In1(N')) : dsum r s"
   478 by (auto simp add: dsum_def)
   479 
   480 lemma dsumE [elim!]: 
   481     "[| w : dsum r s;   
   482         !!x x'. [| (x,x') : r;  w = (In0(x), In0(x')) |] ==> P;  
   483         !!y y'. [| (y,y') : s;  w = (In1(y), In1(y')) |] ==> P  
   484      |] ==> P"
   485 by (auto simp add: dsum_def)
   486 
   487 
   488 (*** Monotonicity ***)
   489 
   490 lemma dprod_mono: "[| r<=r';  s<=s' |] ==> dprod r s <= dprod r' s'"
   491 by blast
   492 
   493 lemma dsum_mono: "[| r<=r';  s<=s' |] ==> dsum r s <= dsum r' s'"
   494 by blast
   495 
   496 
   497 (*** Bounding theorems ***)
   498 
   499 lemma dprod_Sigma: "(dprod (A <*> B) (C <*> D)) <= (uprod A C) <*> (uprod B D)"
   500 by blast
   501 
   502 lemmas dprod_subset_Sigma = subset_trans [OF dprod_mono dprod_Sigma]
   503 
   504 (*Dependent version*)
   505 lemma dprod_subset_Sigma2:
   506      "(dprod (Sigma A B) (Sigma C D)) <= 
   507       Sigma (uprod A C) (Split (%x y. uprod (B x) (D y)))"
   508 by auto
   509 
   510 lemma dsum_Sigma: "(dsum (A <*> B) (C <*> D)) <= (usum A C) <*> (usum B D)"
   511 by blast
   512 
   513 lemmas dsum_subset_Sigma = subset_trans [OF dsum_mono dsum_Sigma]
   514 
   515 
   516 text {* hides popular names *}
   517 hide_type (open) node item
   518 hide_const (open) Push Node Atom Leaf Numb Lim Split Case
   519 
   520 use "Tools/Datatype/datatype.ML"
   521 
   522 use "Tools/inductive_realizer.ML"
   523 setup InductiveRealizer.setup
   524 
   525 use "Tools/Datatype/datatype_realizer.ML"
   526 setup Datatype_Realizer.setup
   527 
   528 end
   529