418 val ((tyco, sorts), (abs, (vs, ty'))) = ty_sorts thy abs_ty; |
418 val ((tyco, sorts), (abs, (vs, ty'))) = ty_sorts thy abs_ty; |
419 val (ty, ty_abs) = case ty' |
419 val (ty, ty_abs) = case ty' |
420 of Type ("fun", [ty, ty_abs]) => (ty, ty_abs) |
420 of Type ("fun", [ty, ty_abs]) => (ty, ty_abs) |
421 | _ => error ("Not a datatype abstractor:\n" ^ string_of_const thy abs |
421 | _ => error ("Not a datatype abstractor:\n" ^ string_of_const thy abs |
422 ^ " :: " ^ string_of_typ thy ty'); |
422 ^ " :: " ^ string_of_typ thy ty'); |
423 val _ = Thm.cterm_of thy (Const (rep, ty_abs --> ty)) handle CTERM _ => |
423 val _ = Thm.cterm_of thy (Const (rep, ty_abs --> ty)) handle TYPE _ => |
424 error ("Not a projection:\n" ^ string_of_const thy rep); |
424 error ("Not a projection:\n" ^ string_of_const thy rep); |
425 val cert = Logic.mk_equals (Const (abs, ty --> ty_abs) $ (Const (rep, ty_abs --> ty) |
425 val cert = Logic.mk_equals (Const (abs, ty --> ty_abs) $ (Const (rep, ty_abs --> ty) |
426 $ Free ("x", ty_abs)), Free ("x", ty_abs)); |
426 $ Free ("x", ty_abs)), Free ("x", ty_abs)); |
427 in (tyco, (vs ~~ sorts, ((fst abs_ty, ty), (rep, cert)))) end; |
427 in (tyco, (vs ~~ sorts, ((fst abs_ty, ty), (rep, cert)))) end; |
428 |
428 |