@@ -705,10 +705,9 @@ let rec evar_conv_x flags env evd pbty term1 term2 =
705705 destroy beta-redexes that can be used for 1st-order unification *)
706706 let term1 = apprec_nohdbeta flags env evd term1 in
707707 let term2 = apprec_nohdbeta flags env evd term2 in
708- let default () =
709- let hd1 = (whd_nored_state env evd (term1,Stack. empty)) in
710- let hd2 = (whd_nored_state env evd (term2,Stack. empty)) in
711- match
708+ let hd1 = (whd_nored_state env evd (term1,Stack. empty)) in
709+ let hd2 = (whd_nored_state env evd (term2,Stack. empty)) in
710+ begin match
712711 evar_eqappr_x flags env evd pbty (Cs_keys_cache. empty () ) None
713712 { left = hd1; right = hd2 } hd1 hd2
714713 with
@@ -718,30 +717,6 @@ let rec evar_conv_x flags env evd pbty term1 term2 =
718717 then Success evd
719718 else x
720719 | Success _ as x -> x
721- in
722- begin match EConstr. kind evd term1, EConstr. kind evd term2 with
723- | Evar ev , _ when Evd. is_undefined evd (fst ev) && is_evar_allowed flags (fst ev) ->
724- (match solve_simple_eqn (conv_fun evar_conv_x) flags env evd
725- (position_problem true pbty,ev,term2) with
726- | UnifFailure (_ ,(OccurCheck _ | NotClean _ )) ->
727- (* Eta-expansion might apply *)
728- (* OccurCheck: eta-expansion could solve
729- ?X = {| foo := ?X.(foo) |}
730- NotClean: pruning in solve_simple_eqn is incomplete wrt
731- Miller patterns *)
732- default ()
733- | x -> x)
734- | _ , Evar ev when Evd. is_undefined evd (fst ev) && is_evar_allowed flags (fst ev) ->
735- (match solve_simple_eqn (conv_fun evar_conv_x) flags env evd
736- (position_problem false pbty,ev,term1) with
737- | UnifFailure (_ , (OccurCheck _ | NotClean _ )) ->
738- (* OccurCheck: eta-expansion could solve
739- ?X = {| foo := ?X.(foo) |}
740- NotClean: pruning in solve_simple_eqn is incomplete wrt
741- Miller patterns *)
742- default ()
743- | x -> x)
744- | _ -> default ()
745720 end
746721
747722and evar_eqappr_x ?(rhs_is_already_stuck = false ) flags env evd pbty
@@ -752,13 +727,25 @@ and evar_eqappr_x ?(rhs_is_already_stuck = false) flags env evd pbty
752727 UnifFailure (i, NotSameHead )
753728 in
754729 let miller_pfenning l2r fallback ev lF tM evd =
755- match is_unification_pattern_evar env evd ev lF tM with
730+ let r =
731+ if lF = [] then
732+ solve_simple_eqn (conv_fun evar_conv_x) flags env evd
733+ (position_problem l2r pbty,ev,tM)
734+ else UnifFailure (evd, OccurCheck (fst ev, tM)) in
735+ match r with
736+ | UnifFailure (_ , (OccurCheck _ | NotClean _ )) ->
737+ (* OccurCheck: eta-expansion could solve
738+ ?X = {| foo := ?X.(foo) |}
739+ NotClean: pruning in solve_simple_eqn is incomplete wrt
740+ Miller patterns *)
741+ (match is_unification_pattern_evar env evd ev lF tM with
756742 | None -> fallback ()
757743 | Some l1' -> (* Miller-Pfenning's patterns unification *)
758744 let t2 = tM in
759745 let t2 = solve_pattern_eqn env evd l1' t2 in
760746 solve_simple_eqn (conv_fun evar_conv_x) flags env evd
761- (position_problem l2r pbty,ev,t2)
747+ (position_problem l2r pbty,ev,t2))
748+ | r -> r
762749 in
763750 let consume_stack l2r (termF ,skF ) (termO ,skO ) evd =
764751 let switch f a b = if l2r then f a b else f b a in
@@ -803,6 +790,7 @@ and evar_eqappr_x ?(rhs_is_already_stuck = false) flags env evd pbty
803790 else quick_fail i
804791 in
805792 let miller l2r ev (termF ,skF as apprF ) (termM , skM as apprM ) i =
793+ let () = debug_unification (fun () -> Pp. (v 0 (str " miller " ++ pr_state env evd apprF ++ cut () ++ pr_state env evd apprM ++ cut () ))) in
806794 let switch f a b = if l2r then f a b else f b a in
807795 let not_only_app = Stack. not_purely_applicative skM in
808796 match Stack. list_of_app_stack skF with
0 commit comments