Skip to content

Commit da043ce

Browse files
committed
more reductions after tc + debug
1 parent 36f23a0 commit da043ce

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

pretyping/evarconv.ml

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,7 @@ and evar_eqappr_x ?(rhs_is_already_stuck = false) flags env evd pbty
724724
hds (* Copy of the never-reduced appr1 and appr2 *)
725725
lastUnfolded (* tells which side was last unfolded, if any *)
726726
(term1, sk1 as appr1) (term2, sk2 as appr2) =
727+
let t = Random.int 1073741823 in
727728
let quick_fail i = (* not costly, loses info *)
728729
UnifFailure (i, NotSameHead)
729730
in
@@ -951,7 +952,10 @@ and evar_eqappr_x ?(rhs_is_already_stuck = false) flags env evd pbty
951952
let tc evd =
952953
let (e, _) = EConstr.destEvar evd termF in
953954
try let evd = get_tc evd e in
954-
evar_eqappr_x flags env evd pbty hds lastUnfolded (whd_betaiota_deltazeta_for_iota_state flags.open_ts env evd apprF) apprR
955+
let apprF = whd_betaiota_deltazeta_for_iota_state flags.open_ts env evd apprF in
956+
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
958+
evar_eqappr_x flags env evd pbty hds lastUnfolded apprF apprR
955959
with _ -> quick_fail evd in
956960
match Stack.list_of_app_stack skF with
957961
| None ->
@@ -1041,10 +1045,11 @@ and evar_eqappr_x ?(rhs_is_already_stuck = false) flags env evd pbty
10411045
| _, _ -> anomaly (Pp.str "Unexpected result from ise_stack2.")
10421046
in
10431047
let app_empty = match sk1, sk2 with [], [] -> true | _ -> false in
1044-
let () = debug_unification (fun () -> Pp.(v 0 (pr_state env evd appr1 ++ cut () ++ pr_state env evd appr2 ++ cut ()))) 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
10451049
match (flex_kind_of_term flags env evd term1 sk1,
10461050
flex_kind_of_term flags env evd term2 sk2) with
10471051
| Flexible (sp1,al1), Flexible (sp2,al2) ->
1052+
let () = debug_unification Pp.(fun () -> int t ++ str " both sides are flexible") in
10481053
(* Notations:
10491054
- "sk" is a stack (or, more abstractly, an evaluation context, written E)
10501055
- "ev" is an evar "?ev", more precisely an evar ?n with an instance inst
@@ -1083,22 +1088,30 @@ and evar_eqappr_x ?(rhs_is_already_stuck = false) flags env evd pbty
10831088
| Success _ as x -> x
10841089
| UnifFailure _ -> quick_fail i
10851090
and f6 i =
1091+
let () = debug_unification Pp.(fun () -> int t ++ str " get_tc with both sides flexible") in
10861092
try let evd = get_tc evd sp2 in
1087-
evar_eqappr_x flags env evd pbty hds lastUnfolded appr1 (whd_betaiota_deltazeta_for_iota_state flags.open_ts env evd appr2)
1093+
evar_eqappr_x flags env evd pbty hds lastUnfolded
1094+
(whd_betaiota_deltazeta_for_iota_state flags.open_ts env evd appr1)
1095+
(whd_betaiota_deltazeta_for_iota_state flags.open_ts env evd appr2)
10881096
with _ -> try
10891097
let evd = get_tc evd sp1 in
1090-
evar_eqappr_x flags env evd pbty hds lastUnfolded (whd_betaiota_deltazeta_for_iota_state flags.open_ts env evd appr1) appr2
1098+
evar_eqappr_x flags env evd pbty hds lastUnfolded
1099+
(whd_betaiota_deltazeta_for_iota_state flags.open_ts env evd appr1)
1100+
(whd_betaiota_deltazeta_for_iota_state flags.open_ts env evd appr2)
10911101
with _ -> quick_fail i
10921102
in
10931103
ise_try evd [f1; f2; f3; f4; f5; f6]
10941104

10951105
| Flexible ev1, MaybeFlexible v2 ->
1106+
let () = debug_unification Pp.(fun () -> int t ++ str " flex maybeflex") in
10961107
flex_maybeflex true ev1 appr1 appr2 v2
10971108

10981109
| MaybeFlexible vsk1, Flexible ev2 ->
1110+
let () = debug_unification Pp.(fun () -> int t ++ str " maybeflex flex") in
10991111
flex_maybeflex false ev2 appr2 appr1 vsk1
11001112

11011113
| MaybeFlexible (v1', sk1' as vsk1'), MaybeFlexible (v2', sk2' as vsk2') -> begin
1114+
let () = debug_unification Pp.(fun () -> int t ++ str " maybeflex maybeflex") in
11021115
match EConstr.kind evd term1, EConstr.kind evd term2 with
11031116
| LetIn (na1,b1,t1,c'1), LetIn (na2,b2,t2,c'2) ->
11041117
let f1 i = (* FO *)
@@ -1217,6 +1230,7 @@ and evar_eqappr_x ?(rhs_is_already_stuck = false) flags env evd pbty
12171230
end
12181231

12191232
| Rigid, Rigid when EConstr.isLambda evd term1 && EConstr.isLambda evd term2 ->
1233+
let () = debug_unification Pp.(fun () -> int t ++ str " rigid rigid") in
12201234
let (na1,c1,c'1) = EConstr.destLambda evd term1 in
12211235
let (na2,c2,c'2) = EConstr.destLambda evd term2 in
12221236
ise_and evd
@@ -1228,10 +1242,15 @@ and evar_eqappr_x ?(rhs_is_already_stuck = false) flags env evd pbty
12281242
(* When in modulo_betaiota = false case, lambda's are not reduced *)
12291243
(fun i -> exact_ise_stack2 env i (evar_conv_x flags) sk1 sk2)]
12301244

1231-
| Flexible ev1, Rigid -> flex_rigid true ev1 appr1 appr2
1232-
| Rigid, Flexible ev2 -> flex_rigid false ev2 appr2 appr1
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
12331251

12341252
| MaybeFlexible vsk1', Rigid ->
1253+
let () = debug_unification Pp.(fun () -> int t ++ str " maybeflex rigid") in
12351254
let f3 i =
12361255
if (not flags.with_cs) || lastUnfolded = Some true then UnifFailure (i,NoCanonicalStructure)
12371256
else
@@ -1248,6 +1267,7 @@ and evar_eqappr_x ?(rhs_is_already_stuck = false) flags env evd pbty
12481267
ise_try evd [f3; f4]
12491268

12501269
| Rigid, MaybeFlexible vsk2' ->
1270+
let () = debug_unification Pp.(fun () -> int t ++ str " rigid maybeflex") in
12511271
let f3 i =
12521272
if (not flags.with_cs) || lastUnfolded = Some false then UnifFailure (i,NoCanonicalStructure)
12531273
else
@@ -1270,6 +1290,7 @@ and evar_eqappr_x ?(rhs_is_already_stuck = false) flags env evd pbty
12701290
eta_lambda env evd false term2 (term1,sk1)
12711291

12721292
| Rigid, Rigid -> begin
1293+
let () = debug_unification Pp.(fun () -> int t ++ str " rigid rigid") in
12731294
match EConstr.kind evd term1, EConstr.kind evd term2 with
12741295

12751296
| Sort s1, Sort s2 when app_empty ->

0 commit comments

Comments
 (0)