Skip to content

fix(ehoare): reject negative probability bound in byehoare deno - #1095

Open
namasikanam wants to merge 1 commit into
mainfrom
fix/byehoare-neg-bound
Open

fix(ehoare): reject negative probability bound in byehoare deno#1095
namasikanam wants to merge 1 commit into
mainfrom
fix/byehoare-neg-bound

Conversation

@namasikanam

Copy link
Copy Markdown
Collaborator

Summary

byehoare / the ehoare-deno path accepts a negative probability bound, which is
unsound: it lets one derive Pr[M.f() @ &m : false] <= -1%r, and hence false.

Root cause

The real bound supplied to the deno rule is coerced into a non-negative extended real
(xreal) and negative values are silently clamped to 0. The side-condition that the
bound is non-negative (0%r <= bd) is never emitted, so a user-supplied negative literal
is accepted as if it were 0.

Fix (src/phl/ecPhlDeno.ml)

Emit the real side-goal 0%r <= bd for concrete/literal bounds instead of relying on the
clamping coercion. A genuinely non-negative bound discharges trivially (f_real_le_simpl);
a negative one now produces an open, unprovable obligation.

Test

tests/ko/byehoare-neg-bound.ec (must-fail): the previously-accepted negative-bound
judgment is now rejected.

@namasikanam
namasikanam force-pushed the fix/byehoare-neg-bound branch 2 times, most recently from 8efb727 to 0bbdf64 Compare August 24, 2026 09:49
The ehoare-deno rule (`t_ehoare_deno_r`) coerces the real bound `bd` into a
non-negative extended real via `f_r2xr`, which clamps any `bd < 0` to `0`.
The non-negativity side-condition on `bd` was therefore never enforced, so
`byehoare` accepted an absurd negative bound and could "prove"
`Pr[M.f() @ &m : false] <= -1%r` (hence `false`).

Emit the real side-goal `0%r <= bd`. When `bd` is a concrete non-negative
literal it is discharged in the rule (`f_real_le_simpl`) so common uses stay
effort-free; for a symbolic bound the goal is surfaced (and is unprovable for
a genuinely negative bound). `examples/ehoare/adversary.ec` (the only
ehoare-deno user) discharges the new goal from `eps_ge0`, `Q_nneg`, `0 < p`.

Regression: tests/byehoare-neg-bound.ec (asserts the buggy proof no longer
closes, via the `fail` idiom).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@namasikanam
namasikanam force-pushed the fix/byehoare-neg-bound branch from 0bbdf64 to 228a3b8 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