Skip to content

fix(fel): require per-step weights non-negative over the counter range - #1096

Open
namasikanam wants to merge 1 commit into
mainfrom
fix/fel-counter-weight
Open

fix(fel): require per-step weights non-negative over the counter range#1096
namasikanam wants to merge 1 commit into
mainfrom
fix/fel-counter-weight

Conversation

@namasikanam

Copy link
Copy Markdown
Collaborator

Summary

The failure-event lemma tactic (fel) is unsound: it enforces neither that the counter
increments by exactly 1 per bad event, nor that each per-step weight is non-negative at the
indices it skips. A counter that jumps 0 -> 2 with weights (1, -1) sums to 0, so fel
"proves" Pr[bad] <= 0 while the true probability is 1 — hence false.

Root cause

t_failure_event_r sums the per-step weights only over the indices the counter actually
visits, and never requires 0%r <= ash i on the whole range 0 <= i < q. Negative weights
at skipped indices are therefore uncounted.

Fix (src/phl/ecPhlFel.ml)

Add the side-condition forall i, 0 <= i < q => 0%r <= ash i (emitted as the last goal).
Existing library/examples uses of fel are updated to discharge this trivially-true
obligation (all standard weights are already non-negative).

Test

tests/ko/fel-counter-jump.ec (must-fail): the 0 -> 2 counter jump with a negative
weight is now rejected.

The failure-event lemma tactic summed the per-step weights only over the
counter values actually visited and never required `0%r <= ash i` on the whole
range `0 <= i < q`. A counter that jumps (e.g. 0 -> 2) with a negative weight
at a skipped index makes the full-range sum smaller than the visited sum, so
`fel` "proves" `Pr[bad] <= 0` while the true probability is 1 (hence `false`).

Emit the side-condition `forall i, 0 <= i < q => 0%r <= ash i` (as the last
goal, so existing scripts keep their sub-goal positions). Existing library and
`examples` uses of `fel` discharge it trivially (their weights are already
non-negative).

Regression: tests/fel-counter-jump.ec (asserts the buggy 0 -> 2 counter jump
with a negative weight no longer closes, via the `fail` idiom).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@namasikanam
namasikanam force-pushed the fix/fel-counter-weight branch from ffffb12 to bc3b89e Compare August 24, 2026 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant