src/ZF/Tools/datatype_package.ML
changeset 36692 54b64d4ad524
parent 36610 bafd82950e24
child 36954 ef698bd61057
equal deleted inserted replaced
36674:d95f39448121 36692:54b64d4ad524
    56                    Syntax.string_of_term_global @{theory IFOL} t);
    56                    Syntax.string_of_term_global @{theory IFOL} t);
    57         val rec_names = (*nat doesn't have to be added*)
    57         val rec_names = (*nat doesn't have to be added*)
    58             @{const_name nat} :: map (#1 o dest_Const) rec_hds
    58             @{const_name nat} :: map (#1 o dest_Const) rec_hds
    59         val u = if co then @{const QUniv.quniv} else @{const Univ.univ}
    59         val u = if co then @{const QUniv.quniv} else @{const Univ.univ}
    60         val cs = (fold o fold) (fn (_, _, _, prems) => prems |> (fold o fold_aterms)
    60         val cs = (fold o fold) (fn (_, _, _, prems) => prems |> (fold o fold_aterms)
    61           (fn t as Const (a, _) => if a mem_string rec_names then I else insert (op =) t
    61           (fn t as Const (a, _) => if member (op =) rec_names a then I else insert (op =) t
    62             | _ => I)) con_ty_lists [];
    62             | _ => I)) con_ty_lists [];
    63     in  u $ Ind_Syntax.union_params (hd rec_tms, cs)  end;
    63     in  u $ Ind_Syntax.union_params (hd rec_tms, cs)  end;
    64 
    64 
    65 fun add_datatype_i (dom_sum, rec_tms) con_ty_lists (monos, type_intrs, type_elims) thy =
    65 fun add_datatype_i (dom_sum, rec_tms) con_ty_lists (monos, type_intrs, type_elims) thy =
    66  let
    66  let
   191   (*Find each recursive argument and add a recursive call for it*)
   191   (*Find each recursive argument and add a recursive call for it*)
   192   fun rec_args [] = []
   192   fun rec_args [] = []
   193     | rec_args ((Const(@{const_name mem},_)$arg$X)::prems) =
   193     | rec_args ((Const(@{const_name mem},_)$arg$X)::prems) =
   194        (case head_of X of
   194        (case head_of X of
   195             Const(a,_) => (*recursive occurrence?*)
   195             Const(a,_) => (*recursive occurrence?*)
   196                           if a mem_string rec_names
   196                           if member (op =) rec_names a
   197                               then arg :: rec_args prems
   197                               then arg :: rec_args prems
   198                           else rec_args prems
   198                           else rec_args prems
   199           | _ => rec_args prems)
   199           | _ => rec_args prems)
   200     | rec_args (_::prems) = rec_args prems;
   200     | rec_args (_::prems) = rec_args prems;
   201 
   201