@@ -356,8 +356,7 @@ let check_conv_record env sigma ((proji, u), (params1, c1, extra_args1)) (t2,sk2
356356 end
357357 with | Not_found -> (* If we find no solution, we ask the hook if it has any. *)
358358 match (apply_hooks env sigma ((proji, u), params1, c1) (t2, args2)) with
359- | Some r ->
360- r, args2' @ args2
359+ | Some r -> r, args2' @ args2
361360 | None -> raise Not_found
362361 in
363362 let t2 = Stack. zip sigma (h2, (Stack. append_app_list args2 Stack. empty)) in
@@ -655,8 +654,6 @@ let infer_conv_noticing_evars ~pb ~ts env sigma t1 t2 =
655654 else Some (UnifFailure (sigma, UnifUnivInconsistency e))
656655
657656let rec evar_conv_x flags env evd pbty term1 term2 =
658- let t = Random. int 1073741823 in
659- let () = debug_unification (fun () -> Pp. (v 0 (str " evar_conv_x: " ++ int t ++ cut () ++ Termops.Internal. print_constr_env env evd term1 ++ cut () ++ Termops.Internal. print_constr_env env evd term2 ++ cut () ))) in
660657 let term1 = whd_head_evar evd term1 in
661658 let term2 = whd_head_evar evd term2 in
662659 (* Maybe convertible but since reducing can erase evars which [evar_apprec]
@@ -667,8 +664,7 @@ let rec evar_conv_x flags env evd pbty term1 term2 =
667664 infer_conv_noticing_evars ~pb: pbty ~ts: flags.closed_ts env evd term1 term2
668665 else None
669666 in
670- let r =
671- match ground_test with
667+ match ground_test with
672668 | Some result -> result
673669 | None ->
674670 (* Until pattern-unification is used consistently, use nohdbeta to not
@@ -699,8 +695,6 @@ let rec evar_conv_x flags env evd pbty term1 term2 =
699695 NotClean: pruning in solve_simple_eqn is incomplete wrt
700696 Miller patterns *)
701697 default ()
702- | UnifFailure (_ , CannotSolveConstraint _ ) as x ->
703- x
704698 | x -> x)
705699 | _ , Evar ev when Evd. is_undefined evd (fst ev) && is_evar_allowed flags (fst ev) ->
706700 (match solve_simple_eqn (conv_fun evar_conv_x) flags env evd
@@ -711,20 +705,14 @@ let rec evar_conv_x flags env evd pbty term1 term2 =
711705 NotClean: pruning in solve_simple_eqn is incomplete wrt
712706 Miller patterns *)
713707 default ()
714- | UnifFailure (_ , CannotSolveConstraint _ ) as x ->
715- x
716708 | x -> x)
717709 | _ -> default ()
718710 end
719- in
720- let () = debug_unification (fun () -> Pp. (v 0 (str " end evar_conv_x " ++ int t ++ str " with " ++ str (match r with Success _ -> " success" | _ -> " failure" ) ++ cut () ))) in
721- r
722711
723712and evar_eqappr_x ?(rhs_is_already_stuck = false ) flags env evd pbty
724713 hds (* Copy of the never-reduced appr1 and appr2 *)
725714 lastUnfolded (* tells which side was last unfolded, if any *)
726715 (term1 , sk1 as appr1 ) (term2 , sk2 as appr2 ) =
727- let t = Random. int 1073741823 in
728716 let quick_fail i = (* not costly, loses info *)
729717 UnifFailure (i, NotSameHead )
730718 in
@@ -808,8 +796,7 @@ and evar_eqappr_x ?(rhs_is_already_stuck = false) flags env evd pbty
808796 let consume_stack l2r (termF ,skF ) (termO ,skO ) evd =
809797 let switch f a b = if l2r then f a b else f b a in
810798 let not_only_app = Stack. not_purely_applicative skO in
811- let r = (ise_stack2 not_only_app env evd (evar_conv_x flags)) in
812- match switch r skF skO with
799+ match switch (ise_stack2 not_only_app env evd (evar_conv_x flags)) skF skO with
813800 | Some (l ,r ), Success i' when l2r && (not_only_app || List. is_empty l) ->
814801 (* E[?n]=E'[redex] reduces to either l[?n]=r[redex] with
815802 case/fix/proj in E' (why?) or ?n=r[redex] *)
@@ -818,8 +805,7 @@ and evar_eqappr_x ?(rhs_is_already_stuck = false) flags env evd pbty
818805 (* E'[redex]=E[?n] reduces to either r[redex]=l[?n] with
819806 case/fix/proj in E' (why?) or r[redex]=?n *)
820807 switch (evar_conv_x flags env i' pbty) (Stack. zip evd (termF,l)) (Stack. zip evd (termO,r))
821- | None , Success i' ->
822- switch (evar_conv_x flags env i' pbty) termF termO
808+ | None , Success i' -> switch (evar_conv_x flags env i' pbty) termF termO
823809 | _ , (UnifFailure _ as x ) -> x
824810 | Some _ , _ -> UnifFailure (evd,NotSameArgSize ) in
825811 let eta_lambda env evd onleft term (term' ,sk' ) =
@@ -945,16 +931,14 @@ and evar_eqappr_x ?(rhs_is_already_stuck = false) flags env evd pbty
945931 match EConstr. kind evd termR with
946932 | Lambda _ when (* if ever problem is ill-typed: *) List. is_empty skR ->
947933 eta_lambda env evd false termR apprF
948- | Construct u ->
949- eta_constructor flags env evd u skR apprF
934+ | Construct u -> eta_constructor flags env evd u skR apprF
950935 | _ -> UnifFailure (evd,NotSameHead )
951936 in
952937 let tc evd =
953938 let (e, _) = EConstr. destEvar evd termF in
954939 try let evd = get_tc evd e in
955940 let apprF = whd_betaiota_deltazeta_for_iota_state flags.open_ts env evd apprF in
956941 let apprR = whd_betaiota_deltazeta_for_iota_state flags.open_ts env evd apprR in
957- let () = debug_unification Pp. (fun () -> int t ++ str " get_tc succeeds with " ++ pr_state env evd apprF ++ cut () ) in
958942 evar_eqappr_x flags env evd pbty hds lastUnfolded apprF apprR
959943 with _ -> quick_fail evd in
960944 match Stack. list_of_app_stack skF with
@@ -1045,11 +1029,10 @@ and evar_eqappr_x ?(rhs_is_already_stuck = false) flags env evd pbty
10451029 | _ , _ -> anomaly (Pp. str " Unexpected result from ise_stack2." )
10461030 in
10471031 let app_empty = match sk1, sk2 with [] , [] -> true | _ -> false in
1048- let () = debug_unification (fun () -> Pp. (v 0 (int t ++ str " " ++ pr_state env evd appr1 ++ cut () ++ pr_state env evd appr2 ++ cut () ))) in
1032+ let () = debug_unification (fun () -> Pp. (v 0 (pr_state env evd appr1 ++ cut () ++ pr_state env evd appr2 ++ cut () ))) in
10491033 match (flex_kind_of_term flags env evd term1 sk1,
10501034 flex_kind_of_term flags env evd term2 sk2) with
10511035 | Flexible (sp1 ,al1 ), Flexible (sp2 ,al2 ) ->
1052- let () = debug_unification Pp. (fun () -> int t ++ str " both sides are flexible" ) in
10531036 (* Notations:
10541037 - "sk" is a stack (or, more abstractly, an evaluation context, written E)
10551038 - "ev" is an evar "?ev", more precisely an evar ?n with an instance inst
@@ -1088,7 +1071,6 @@ and evar_eqappr_x ?(rhs_is_already_stuck = false) flags env evd pbty
10881071 | Success _ as x -> x
10891072 | UnifFailure _ -> quick_fail i
10901073 and f6 i =
1091- let () = debug_unification Pp. (fun () -> int t ++ str " get_tc with both sides flexible" ) in
10921074 try let evd = get_tc evd sp2 in
10931075 evar_eqappr_x flags env evd pbty hds lastUnfolded
10941076 (whd_betaiota_deltazeta_for_iota_state flags.open_ts env evd appr1)
@@ -1103,15 +1085,12 @@ and evar_eqappr_x ?(rhs_is_already_stuck = false) flags env evd pbty
11031085 ise_try evd [f1; f2; f3; f4; f5; f6]
11041086
11051087 | Flexible ev1 , MaybeFlexible v2 ->
1106- let () = debug_unification Pp. (fun () -> int t ++ str " flex maybeflex" ) in
11071088 flex_maybeflex true ev1 appr1 appr2 v2
11081089
11091090 | MaybeFlexible vsk1 , Flexible ev2 ->
1110- let () = debug_unification Pp. (fun () -> int t ++ str " maybeflex flex" ) in
11111091 flex_maybeflex false ev2 appr2 appr1 vsk1
11121092
11131093 | MaybeFlexible (v1' , sk1' as vsk1' ), MaybeFlexible (v2' , sk2' as vsk2' ) -> begin
1114- let () = debug_unification Pp. (fun () -> int t ++ str " maybeflex maybeflex" ) in
11151094 match EConstr. kind evd term1, EConstr. kind evd term2 with
11161095 | LetIn (na1 ,b1 ,t1 ,c'1 ), LetIn (na2 ,b2 ,t2 ,c'2 ) ->
11171096 let f1 i = (* FO *)
@@ -1230,7 +1209,6 @@ and evar_eqappr_x ?(rhs_is_already_stuck = false) flags env evd pbty
12301209 end
12311210
12321211 | Rigid , Rigid when EConstr. isLambda evd term1 && EConstr. isLambda evd term2 ->
1233- let () = debug_unification Pp. (fun () -> int t ++ str " rigid rigid" ) in
12341212 let (na1,c1,c'1 ) = EConstr. destLambda evd term1 in
12351213 let (na2,c2,c'2 ) = EConstr. destLambda evd term2 in
12361214 ise_and evd
@@ -1242,15 +1220,10 @@ and evar_eqappr_x ?(rhs_is_already_stuck = false) flags env evd pbty
12421220 (* When in modulo_betaiota = false case, lambda's are not reduced *)
12431221 (fun i -> exact_ise_stack2 env i (evar_conv_x flags) sk1 sk2)]
12441222
1245- | Flexible ev1 , Rigid ->
1246- let () = debug_unification Pp. (fun () -> int t ++ str " flex rigid" ) in
1247- flex_rigid true ev1 appr1 appr2
1248- | Rigid , Flexible ev2 ->
1249- let () = debug_unification Pp. (fun () -> int t ++ str " rigid flex" ) in
1250- flex_rigid false ev2 appr2 appr1
1223+ | Flexible ev1 , Rigid -> flex_rigid true ev1 appr1 appr2
1224+ | Rigid , Flexible ev2 -> flex_rigid false ev2 appr2 appr1
12511225
12521226 | MaybeFlexible vsk1' , Rigid ->
1253- let () = debug_unification Pp. (fun () -> int t ++ str " maybeflex rigid" ) in
12541227 let f3 i =
12551228 if (not flags.with_cs) || lastUnfolded = Some true then UnifFailure (i,NoCanonicalStructure )
12561229 else
@@ -1267,7 +1240,6 @@ and evar_eqappr_x ?(rhs_is_already_stuck = false) flags env evd pbty
12671240 ise_try evd [f3; f4]
12681241
12691242 | Rigid , MaybeFlexible vsk2' ->
1270- let () = debug_unification Pp. (fun () -> int t ++ str " rigid maybeflex" ) in
12711243 let f3 i =
12721244 if (not flags.with_cs) || lastUnfolded = Some false then UnifFailure (i,NoCanonicalStructure )
12731245 else
@@ -1290,7 +1262,6 @@ and evar_eqappr_x ?(rhs_is_already_stuck = false) flags env evd pbty
12901262 eta_lambda env evd false term2 (term1,sk1)
12911263
12921264 | Rigid , Rigid -> begin
1293- let () = debug_unification Pp. (fun () -> int t ++ str " rigid rigid" ) in
12941265 match EConstr. kind evd term1, EConstr. kind evd term2 with
12951266
12961267 | Sort s1 , Sort s2 when app_empty ->
@@ -1463,7 +1434,6 @@ and conv_record flags env (evd,(h,h2),c,bs,(params,params1),(us,us2),(sk1,sk2),c
14631434 in
14641435 let app = mkApp (c, Array. rev_of_list ks) in
14651436 let unif_params =
1466- let () = debug_unification (fun () -> Pp. (v 0 (str " unif_params" ++ cut () ))) in
14671437 match params1 with
14681438 | None -> []
14691439 | Some params1 ->
@@ -1473,34 +1443,25 @@ and conv_record flags env (evd,(h,h2),c,bs,(params,params1),(us,us2),(sk1,sk2),c
14731443 params1 params)] in
14741444 ise_and evd' (
14751445 unif_params @
1476- [(fun i ->
1477- ise_list2 i
1478- (fun i' u1 u ->
1479- evar_conv_x flags env i' CONV u1 (substl ks u))
1446+ [(fun i -> ise_list2 i
1447+ (fun i' u1 u -> evar_conv_x flags env i' CONV u1 (substl ks u))
14801448 us2 us);
1481- (fun i ->
1482- evar_conv_x flags env i CONV c1 app);
1483- (fun i ->
1484- exact_ise_stack2 env i (evar_conv_x flags) sk1 sk2);
1449+ (fun i -> evar_conv_x flags env i CONV c1 app);
1450+ (fun i -> exact_ise_stack2 env i (evar_conv_x flags) sk1 sk2);
14851451 test;
1486- (fun i ->
1487- evar_conv_x flags env i CONV h2
1452+ (fun i -> evar_conv_x flags env i CONV h2
14881453 (fst (decompose_app i (substl ks h))))])
14891454 else UnifFailure (evd,(* dummy*) NotSameHead )
14901455
14911456and eta_constructor flags env evd ((ind , i ), u ) sk1 (term2 ,sk2 ) =
1492- let () = debug_unification (fun () -> Pp. (v 0 (str " eta_constructor" ++ cut () ))) in
14931457 (* reduces an equation <Construct(ind,i)|sk1> == <term2|sk2> to the
14941458 equations [arg_i = Proj_i (sk2[term2])] where [sk1] is [params args] *)
14951459 let open Declarations in
14961460 let mib = lookup_mind (fst ind) env in
14971461 if mib.mind_finite <> BiFinite then
1498- let () = debug_unification (fun () -> Pp. (v 0 (str " inductive is not BiFinite" ++ cut () ))) in
14991462 UnifFailure (evd,NotSameHead ) else
15001463 match Stack. list_of_app_stack sk1 with
1501- | None ->
1502- let () = debug_unification (fun () -> Pp. (v 0 (str " stack is not applicative" ++ cut () ))) in
1503- UnifFailure (evd,NotSameHead )
1464+ | None -> UnifFailure (evd,NotSameHead )
15041465 | Some l1 -> begin
15051466 match get_projections env ind with
15061467 | Some projs ->
@@ -1532,28 +1493,25 @@ and eta_constructor flags env evd ((ind, i), u) sk1 (term2,sk2) =
15321493 s.projections in
15331494 let f i t1 t2 = evar_conv_x { flags with with_cs = false } env i CONV t1 t2 in
15341495 ise_list2 evd f l1' l2'
1535- with
1536- | _ ->
1537- let () = debug_unification (fun () -> Pp. (v 0 (str " stack is not applicative" ++ cut () ))) in
1538- UnifFailure (evd,NotSameHead ))
1496+ with _ -> UnifFailure (evd,NotSameHead ))
15391497 end
15401498
15411499let evar_conv_x flags env evd pbty term1 term2 =
1542- (* debug_unification Pp.(fun () ->
1500+ debug_unification Pp. (fun () ->
15431501 str " Starting unification:" ++ spc() ++
15441502 Termops.Internal. print_constr_env env evd term1 ++
15451503 (match pbty with CONV -> strbrk " =~= " | CUMUL -> strbrk " <~= " ) ++
1546- Termops.Internal.print_constr_env env evd term2);*)
1504+ Termops.Internal. print_constr_env env evd term2);
15471505 let res =
15481506 evar_conv_x flags env evd pbty term1 term2
15491507 in
1550- (* let () = debug_unification Pp.(fun () ->
1508+ let () = debug_unification Pp. (fun () ->
15511509 let success = match res with
15521510 | Success _ -> " success"
15531511 | UnifFailure _ -> " failure"
15541512 in
15551513 str " Leaving unification with " ++ str success)
1556- in*)
1514+ in
15571515 res
15581516
15591517let evar_unify = conv_fun evar_conv_x
@@ -1774,7 +1732,6 @@ let second_order_matching flags env_rhs evd (evk,args) (test,argoccs) rhs =
17741732 if not (noccur_evar env_rhs evd evk rhs) then raise (TypingFailed evd);
17751733 (* Ensure that any progress made by Typing.e_solve_evars will not contradict
17761734 the solution we are trying to build here by adding the problem as a constraint. *)
1777- let () = debug_unification (fun () -> Pp. (v 0 (str " postpone in 2nd order matching" ++ cut () ))) in
17781735 let evd = Evarutil. add_unification_pb (CONV ,env_rhs,mkLEvar evd (evk, args),rhs) evd in
17791736 let prc env evd c = Termops.Internal. print_constr_env env evd c in
17801737 let rec make_subst i = function
@@ -2150,7 +2107,6 @@ exception UnableToUnify of evar_map * unification_error
21502107
21512108let evar_conv_x flags env evd pb x1 x2 : unification_result =
21522109 NewProfile. profile " unification" (fun () ->
2153- let () = debug_unification (fun () -> Pp. (v 0 (str " toplevel evar_conv_x: " ++ cut () ))) in
21542110 evar_conv_x flags env evd pb x1 x2)
21552111 ()
21562112
0 commit comments