Commit 5e04bf6
committed
TC: drain pending TC-constraints before [try_delta]'s tc_reduce check
Closes the parametric-Path-B witness encoding gap that left class-
lemma applications at parametric carriers ([apply (addrC<:c poly>)]
inside [section ; declare type c <: comring]) unusable.
**The bug.** [opentvi] creates a [TCIUni] for each opened tparam's TC
bound and posts a [`TcCtt] problem, but doesn't itself drain the
queue. The TCIUni stays parked in [tcenv.problems] until something
else triggers [unify_core]. Meanwhile a proof-term carrying
[(+)<:c poly[TCIUni #a [0;0]]>] arrives at the matcher's [try_delta],
which tries [Op.tc_reducible env (+) tys] — and [tc_core_reduce]
raises [NotReducible] on TCIUni witnesses, since it can only walk
[TCIConcrete]/[TCIAbstract] forms. So [try_delta] falls through to
[default]'s [is_conv], which doesn't TC-reduce either; matching
fails, [pf_form_match] raises MatchFailure, [t_apply] reports "the
given proof-term proves: ... it does not apply to the goal".
**The fix.** Two changes:
1. [EcUnify.UniEnv.flush_tc_problems env ue] (new): runs
[Unify.unify_core] on a trivial-true [`TyUni] problem, which
re-pushes every parked [`TcCtt] in [tcenv.problems] and lets the
strategy dispatcher resolve them. After the call, the resolution
map contains a witness for every [TCIUni] that any strategy
(Modes #1..#6) could pin.
2. In [EcMatching.f_match_core]'s [try_delta]: before destructuring
the heads, call [flush_tc_problems env ue] and re-normalise both
sides via [norm]. The substitution machinery in [tcw_subst]
(ecCoreSubst.ml:209) dereferences resolved TCIUnis through
[fs_tw_uni], so after [norm] both forms carry the concrete
witness; [tc_reducible] then succeeds and [doit_tc_reduce]
produces the renamed structural op (e.g. [polyD] for poly's
addgroup-via-class-(+)), which conv'ing against the goal
succeeds.
Combined with the earlier framework fixes [0dd7d21] (infer-via-
abs-decl) and [c182895] (alpha-equivalent chain reuse), this lets
[apply (addrC<:c poly> p q)] and [apply (mulrA<:c poly> p q r)]
inside a [c <: comring] section discharge directly, without
requiring users to fall back to the underlying [polyD_addrC<:c>] /
[polyM_mulrA] structural lemmas. The TcPoly port's structural-form
workaround in Phase 6 / Phase 7 / smoke test stays as-is for the
already-written code, but new code can use the natural class form.
Validates: tcalgebra suite (TcMonoid/TcRing/TcInt/TcBigop/TcBigalg/
TcNumber/TcPoly/TcPolySmokeTest) all pass; the parametric Path B
reproducer at /tmp/repro_pathb.ec now closes [test_path_b] via
[apply (addrC<:c poly>)] without admit.1 parent edfc385 commit 5e04bf6
3 files changed
Lines changed: 30 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1217 | 1217 | | |
1218 | 1218 | | |
1219 | 1219 | | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
1220 | 1230 | | |
1221 | 1231 | | |
1222 | 1232 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
999 | 999 | | |
1000 | 1000 | | |
1001 | 1001 | | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
1002 | 1016 | | |
1003 | 1017 | | |
1004 | 1018 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
62 | 68 | | |
63 | 69 | | |
64 | 70 | | |
| |||
0 commit comments