src/HOL/Tools/typecopy.ML
changeset 35994 9cc3df9a606e
parent 35845 e5980f0ad025
child 36150 123f721c9a37
equal deleted inserted replaced
35993:380b97496734 35994:9cc3df9a606e
    53   let
    53   let
    54     val ty = Sign.certify_typ thy raw_ty;
    54     val ty = Sign.certify_typ thy raw_ty;
    55     val vs =
    55     val vs =
    56       AList.make (the_default HOLogic.typeS o AList.lookup (op =) (Term.add_tfreesT ty [])) raw_vs;
    56       AList.make (the_default HOLogic.typeS o AList.lookup (op =) (Term.add_tfreesT ty [])) raw_vs;
    57     val tac = Tactic.rtac UNIV_witness 1;
    57     val tac = Tactic.rtac UNIV_witness 1;
    58     fun add_info tyco ( { abs_type = ty_abs, rep_type = ty_rep, Abs_name = c_abs,
    58     fun add_info tyco (({ abs_type = ty_abs, rep_type = ty_rep, Abs_name = c_abs,
    59       Rep_name = c_rep, Abs_inject = inject,
    59           Rep_name = c_rep, ...}, { Abs_inject = inject, Abs_inverse = inverse, ... })
    60       Abs_inverse = inverse, ... } : Typedef.info ) thy =
    60           : Typedef.info) thy =
    61         let
    61         let
    62           val exists_thm =
    62           val exists_thm =
    63             UNIV_I
    63             UNIV_I
    64             |> Drule.instantiate' [SOME (ctyp_of thy (Logic.varifyT_global ty_rep))] [];
    64             |> Drule.instantiate' [SOME (ctyp_of thy (Logic.varifyT_global ty_rep))] [];
    65           val inject' = inject OF [exists_thm, exists_thm];
    65           val inject' = inject OF [exists_thm, exists_thm];
    92 fun add_default_code tyco thy =
    92 fun add_default_code tyco thy =
    93   let
    93   let
    94     val SOME { constr = c, proj = (proj, _), proj_def = proj_eq, vs = vs,
    94     val SOME { constr = c, proj = (proj, _), proj_def = proj_eq, vs = vs,
    95       typ = ty_rep, ... } = get_info thy tyco;
    95       typ = ty_rep, ... } = get_info thy tyco;
    96     (* FIXME handle multiple typedef interpretations (!??) *)
    96     (* FIXME handle multiple typedef interpretations (!??) *)
    97     val [{ Rep_inject = proj_inject, ... }] = Typedef.get_info_global thy tyco;
    97     val [(_, { Rep_inject = proj_inject, ... })] = Typedef.get_info_global thy tyco;
    98     val constr = (c, Logic.unvarifyT_global (Sign.the_const_type thy c));
    98     val constr = (c, Logic.unvarifyT_global (Sign.the_const_type thy c));
    99     val ty = Type (tyco, map TFree vs);
    99     val ty = Type (tyco, map TFree vs);
   100     val proj = Const (proj, ty --> ty_rep);
   100     val proj = Const (proj, ty --> ty_rep);
   101     val (t_x, t_y) = (Free ("x", ty), Free ("y", ty));
   101     val (t_x, t_y) = (Free ("x", ty), Free ("y", ty));
   102     val eq_lhs = Const (@{const_name eq_class.eq}, ty --> ty --> HOLogic.boolT)
   102     val eq_lhs = Const (@{const_name eq_class.eq}, ty --> ty --> HOLogic.boolT)