src/HOL/Tools/Datatype/datatype_case.ML
changeset 35845 e5980f0ad025
parent 35392 5da5ac6c6b77
child 42049 e945717b2b15
equal deleted inserted replaced
35844:65258d2c3214 35845:e5980f0ad025
    44         val mk_ty = Datatype_Aux.typ_of_dtyp descr sorts;
    44         val mk_ty = Datatype_Aux.typ_of_dtyp descr sorts;
    45         val T = Type (tname, map mk_ty dts);
    45         val T = Type (tname, map mk_ty dts);
    46       in
    46       in
    47         SOME {case_name = case_name,
    47         SOME {case_name = case_name,
    48           constructors = map (fn (cname, dts') =>
    48           constructors = map (fn (cname, dts') =>
    49             Const (cname, Logic.varifyT (map mk_ty dts' ---> T))) constrs}
    49             Const (cname, Logic.varifyT_global (map mk_ty dts' ---> T))) constrs}
    50       end
    50       end
    51   | NONE => NONE;
    51   | NONE => NONE;
    52 
    52 
    53 
    53 
    54 (*---------------------------------------------------------------------------
    54 (*---------------------------------------------------------------------------
    85 fun fresh_constr ty_match ty_inst colty used c =
    85 fun fresh_constr ty_match ty_inst colty used c =
    86   let
    86   let
    87     val (_, Ty) = dest_Const c
    87     val (_, Ty) = dest_Const c
    88     val Ts = binder_types Ty;
    88     val Ts = binder_types Ty;
    89     val names = Name.variant_list used
    89     val names = Name.variant_list used
    90       (Datatype_Prop.make_tnames (map Logic.unvarifyT Ts));
    90       (Datatype_Prop.make_tnames (map Logic.unvarifyT_global Ts));
    91     val ty = body_type Ty;
    91     val ty = body_type Ty;
    92     val ty_theta = ty_match ty colty handle Type.TYPE_MATCH =>
    92     val ty_theta = ty_match ty colty handle Type.TYPE_MATCH =>
    93       raise CASE_ERROR ("type mismatch", ~1)
    93       raise CASE_ERROR ("type mismatch", ~1)
    94     val c' = ty_inst ty_theta c
    94     val c' = ty_inst ty_theta c
    95     val gvars = map (ty_inst ty_theta o Free) (names ~~ Ts)
    95     val gvars = map (ty_inst ty_theta o Free) (names ~~ Ts)