with Not_found -> `Type (CicUniv.fresh())
with Invalid_argument _ -> failwith "A2P.get_sort"
+let get_type msg st bo =
+try
+ let ty, _ = TC.type_of_aux' [] st.context (cic bo) Un.empty_ugraph in
+ ty
+with e -> failwith (msg ^ ": " ^ Printexc.to_string e)
+
(* proof construction *******************************************************)
let unused_premise = "UNUSED"
let ty = C.AImplicit ("", None) in
let name i = Printf.sprintf "%s%u" expanded_premise i in
let lambda i t = C.ALambda (id, C.Name (name i), ty, t) in
- let arg i n = T.mk_arel (n - i) (name (n - i - 1)) in
+ let arg i n = T.mk_arel ((* n - *) succ i) (name (n - i - 1)) in
let rec aux i f a =
if i >= n then f, a else aux (succ i) (comp f (lambda i)) (arg i n :: a)
in
| C.AAppl (_, hd :: tl) as v ->
if is_fwd_rewrite_right hd tl then mk_fwd_rewrite st dtext name tl true else
if is_fwd_rewrite_left hd tl then mk_fwd_rewrite st dtext name tl false else
- let ty, _ = TC.type_of_aux' [] st.context (cic hd) Un.empty_ugraph in
+ let ty = get_type "TC1" st hd in
begin match get_inner_types st v with
| Some (ity, _) when M.bkd st.context ty ->
let qs = [[T.Id ""]; mk_proof (next st) v] in
| C.AAppl (_, hd :: tl) as t ->
let proceed, dtext = test_depth st in
let script = if proceed then
- let ty, _ = TC.type_of_aux' [] st.context (cic hd) Un.empty_ugraph in
+ let ty = get_type "TC2" st hd in
let (classes, rc) as h = Cl.classify st.context ty in
let premises, _ = P.split st.context ty in
let decurry = List.length classes - List.length tl in
- if decurry < 0 then mk_proof (clear st) (appl_expand decurry t) else
+ if decurry <> 0 then
+ Printf.eprintf "DECURRY: %u %s\n" decurry (CicPp.ppterm (cic t));
+ assert (decurry = 0);
+ if decurry < 0 then mk_proof (clear st) (appl_expand decurry t) else
if decurry > 0 then mk_proof (clear st) (eta_expand decurry t) else
let synth = I.S.singleton 0 in
let text = Printf.sprintf "%u %s" (List.length classes) (Cl.to_string h) in
[T.Apply (t, dtext)]
in
mk_intros st script
- | C.AMutCase (id, uri, tyno, outty, arg, cases) ->
+ | C.AMutCase (id, uri, tyno, outty, arg, cases) as t ->
begin match Cn.mk_ind st.context id uri tyno outty arg cases with
| _ (* None *) ->
let text = Printf.sprintf "%s" "UNEXPANDED: mutcase" in