NCic.Lambda("x", hole_type, aux ft (List.rev p1))
;;
+(*
+ let mk_morphism eq amount ft p1 vl =
+ let rec aux t p =
+ match p with
+ | [] -> eq
+ | n::tl ->
+ match t with
+ | Terms.Leaf _
+ | Terms.Var _ -> assert false
+ | Terms.Node l ->
+ let dag,arity = ____ in
+ let l =
+ HExtlib.list_rev_mapi_filter
+ (fun t i ->
+ if i < arity then None
+ else if i = n then Some (aux t tl)
+ else Some (NCic.Appl [refl ...]))
+ l
+ in
+ NCic.Appl (dag::l)
+ in aux ft (List.rev pl)
+ ;;
+*)
+
let mk_proof (bag : NCic.term Terms.bag) mp subst steps =
let module Subst = FoSubst in
let position i l =
else
l,r,eq_ind ()
in
- NCic.LetIn ("clause_" ^ string_of_int id,
- close_with_forall vl (extract amount vl lit),
+ let body = aux ongoal
+ ((id,(List.map (fun x -> Terms.Var x) vl,lit))::seen) tl
+ in
+ if NCicUntrusted.count_occurrences [] 0 body <= 1 then
+ NCicSubstitution.subst
+ ~avoid_beta_redexes:true ~no_implicit:false
+ (close_with_lambdas vl (NCic.Appl
+ [ eq_ind ; hole_type; l; pred; p_id1; r; p_id2 ]))
+ body
+ else
+ NCic.LetIn ("clause_" ^ string_of_int id,
+ close_with_forall vl (extract amount vl lit),
(* NCic.Implicit `Type, *)
- close_with_lambdas vl
- (NCic.Appl [ eq_ind ; hole_type; l; pred; p_id1; r; p_id2 ]),
- aux ongoal
- ((id,(List.map (fun x -> Terms.Var x) vl,lit))::seen) tl)
+ close_with_lambdas vl (NCic.Appl
+ [ eq_ind ; hole_type; l; pred; p_id1; r; p_id2 ]),
+ body)
in
aux false [] steps, proof_type
;;