+ let parsno, argsno = List.length classes, List.length tl in
+ let decurry = parsno - argsno in
+ let diff = goal_arity - decurry in
+ if diff < 0 then failwith (Printf.sprintf "NOT TOTAL: %i %s |--- %s" diff (Pp.ppcontext st.context) (Pp.ppterm (cic hd)));
+ let rec mk_synth a n =
+ if n < 0 then a else mk_synth (I.S.add n a) (pred n)
+ in
+ let synth = mk_synth I.S.empty decurry in
+ let text = "" (* Printf.sprintf "%u %s" parsno (Cl.to_string h) *) in
+ let script = List.rev (mk_arg st hd) @ convert st what in
+ match rc with
+ | Some (i, j, uri, tyno) ->
+ let classes, tl, _, where = split2_last classes tl in
+ let script = List.rev (mk_arg st where) @ script in
+ let synth = I.S.add 1 synth in
+ let names = get_ind_names uri tyno in
+ let qs = proc_bkd_proofs (next st) synth names classes tl in
+ if is_rewrite_right hd then
+ script @ mk_rewrite st dtext where qs tl false
+ else if is_rewrite_left hd then
+ script @ mk_rewrite st dtext where qs tl true
+ else
+ let predicate = List.nth tl (parsno - i) in
+ let e = Cn.mk_pattern j predicate in
+ let using = Some hd in
+ script @
+ [T.Elim (where, using, e, dtext ^ text); T.Branch (qs, "")]
+ | None ->
+ let qs = proc_bkd_proofs (next st) synth [] classes tl in
+ let hd = mk_exp_args hd tl classes synth in
+ script @ [T.Apply (hd, dtext ^ text); T.Branch (qs, "")]
+ else
+ [T.Apply (what, dtext)]
+ in
+ mk_intros st script
+
+and proc_other st what =
+ let text = Printf.sprintf "%s: %s" "UNEXPANDED" (string_of_head what) in
+ let script = [T.Note text] in
+ mk_intros st script
+
+and proc_proof st = function
+ | C.ALambda (_, name, w, t) -> proc_lambda st name w t
+ | C.ALetIn (_, name, v, t) as what -> proc_letin st what name v t
+ | C.ARel _ as what -> proc_rel st what
+ | C.AMutConstruct _ as what -> proc_mutconstruct st what
+ | C.AAppl (_, hd :: tl) as what -> proc_appl st what hd tl
+ | what -> proc_other st what
+
+and proc_bkd_proofs st synth names classes ts =