@@ -214,37 +214,58 @@ let flags_FO env =
214214 Unification. resolve_evars =
215215 (Unification. default_no_delta_unify_flags ts).Unification. resolve_evars
216216 }
217-
218217let unif_FO env ise metas p c = Unification. w_unify ~metas env ise Conversion. CONV ~flags: (flags_FO env) p c
219218
219+ type hd_comparison = CompareArgs of Impargs .implicit_status list | CanonicalInfRequired | Different
220+
220221let same_hd ise p c =
221222 match EConstr. kind ise p, EConstr. kind ise c with
222223 | Const (c1 ,_ ), Const (c2 ,_ ) when Constant.CanOrd. equal c1 c2 ->
223- Some (Impargs. implicits_of_global (GlobRef. ConstRef c1) |> List. hd |> snd)
224- | _ -> None
224+ CompareArgs (Impargs. implicits_of_global (GlobRef. ConstRef c1) |> List. hd |> snd)
225+ | Ind (c1 ,_ ), Ind (c2 ,_ ) when Ind.CanOrd. equal c1 c2 ->
226+ CompareArgs (Impargs. implicits_of_global (GlobRef. IndRef c1) |> List. hd |> snd)
227+ | Construct (c1 ,_ ), Construct (c2 ,_ ) when Construct.CanOrd. equal c1 c2 ->
228+ CompareArgs (Impargs. implicits_of_global (GlobRef. ConstructRef c1) |> List. hd |> snd)
229+ | Const (c1 ,_ ), _ when Structures.Structure. is_projection c1 -> CanonicalInfRequired
230+ | _ -> Different
225231
226232let rec unif_FO_skip_impl env ise metas p c =
227233 match EConstr. kind ise p, EConstr. kind ise c with
234+ | Meta _ , _ -> metas, ise
235+ | App (hd ,_ ), _ when EConstr. isMeta ise hd -> metas, ise
228236 | App (hd1 ,args1 ), App (hd2 ,args2 ) ->
229237 begin match same_hd ise hd1 hd2 with
230- | None -> unif_FO env ise metas p c
231- | Some imp -> unif_FO_skip_impl3 env ise metas (Array. to_list args1) (Array. to_list args2) imp
238+ | CanonicalInfRequired -> raise (CErrors. user_err Pp. (mt () ))
239+ (* pp(lazy(str"ho "));
240+ metas, unif_HO env ise p c *)
241+ | Different -> raise (CErrors. user_err Pp. (mt () ))
242+ | CompareArgs imp -> unif_FO_skip_impl3 env ise metas (Array. to_list args1) (Array. to_list args2) imp
232243 end
233244 | _ -> unif_FO env ise metas p c
234245and unif_FO_skip_impl3 env ise metas args1 args2 imp =
235246 match args1, args2, imp with
236- | _ ::args1 , _ ::args2 , Some _ :: imp -> unif_FO_skip_impl3 env ise metas args1 args2 imp
247+ | a1 ::args1 , a2 ::args2 , Some _ :: imp ->
248+ pp(lazy (str" skip " ++ pr_econstr_env env ise a1 ++ str " = " ++ pr_econstr_env env ise a2));
249+ unif_FO_skip_impl3 env ise metas args1 args2 imp
237250 | a1 ::args1 , a2 ::args2 , None :: imp ->
251+ pp(lazy (str" do " ++ pr_econstr_env env ise a1 ++ str " = " ++ pr_econstr_env env ise a2));
252+
238253 let metas, ise = unif_FO_skip_impl env ise metas a1 a2 in
239254 unif_FO_skip_impl3 env ise metas args1 args2 imp
240255 | a1 ::args1 , a2 ::args2 , [] ->
241- let metas, ise = unif_FO_skip_impl env ise metas a1 a2 in
256+ pp(lazy (str" do " ++ pr_econstr_env env ise a1 ++ str " = " ++ pr_econstr_env env ise a2));
257+ let metas, ise = unif_FO_skip_impl env ise metas a1 a2 in
242258 unif_FO_skip_impl3 env ise metas args1 args2 []
243- | [] , [] , _ -> metas, ise
244- | _ -> raise (CErrors. user_err Pp. (mt () ))
259+ | [] , [] , _ ->
260+ pp(lazy (str" good" ));
261+ metas, ise
262+ | _ ->
263+ pp(lazy (str" bad" ));
264+ raise (CErrors. user_err Pp. (mt () ))
245265
246266let unif_FO env ise metas p c =
247267 let metas = Unification.Metamap. fold (fun mv t accu -> Unification.Meta. meta_declare mv t accu) metas Unification.Meta. empty in
268+ pp(lazy (str" FO " ++ pr_econstr_env env ise p ++ str " = " ++ pr_econstr_env env ise c));
248269 let _ : _ * Evd.evar_map = unif_FO_skip_impl env ise metas p c in
249270 ()
250271
@@ -594,7 +615,11 @@ let match_upats_FO upats env sigma0 ise orig_c =
594615 raise (FoundUnif (ungen_upat lhs pt' u))
595616 with FoundUnif (_ , s ,_ ,_ ) as sig_u when dont_impact_evars s -> raise sig_u
596617 | Not_found -> CErrors. anomaly (str" incomplete ise in match_upats_FO." )
597- | e when CErrors. noncritical e -> () in
618+ | e when CErrors. noncritical e ->
619+ pp(lazy (str" FO fail: " ++ CErrors. print e));
620+
621+
622+ () in
598623 List. iter one_match fpats
599624 done ;
600625 iter_constr_LR ise loop f; Array. iter loop a in
0 commit comments