Skip to content

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

Merged
fdupress merged 1 commit into
mainfrom
fix/byehoare-neg-bound
Sep 5, 2026
Merged

fix(ehoare): reject negative probability bound in byehoare deno#1095
fdupress merged 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 3 times, most recently from 0bbdf64 to 228a3b8 Compare August 24, 2026 10:02
@strub
strub force-pushed the fix/byehoare-neg-bound branch from 228a3b8 to 8cbaed6 Compare August 26, 2026 08:19
@fdupress
fdupress requested a review from bgregoir September 4, 2026 13:56
Comment thread src/phl/ecPhlDeno.ml Outdated
Comment thread tests/byehoare-neg-bound.ec Outdated

@bgregoir bgregoir left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot to say thank you for the fix.

@namasikanam

namasikanam commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator Author

I forgot to say thank you for the fix.

The credit should go to Claude Code. It was discovered and fixed automatically by Claude Code :)

@namasikanam
namasikanam force-pushed the fix/byehoare-neg-bound branch from 8cbaed6 to ef6dcc0 Compare September 4, 2026 15:23
@namasikanam
namasikanam requested a review from bgregoir September 4, 2026 15:33

@fdupress fdupress left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new commit addresses the comments from @bgregoir. Merging.

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`).

The low-level rule now always emits the extra real goal `0%r <= bd` as a fourth
conclusion `[concl_e; concl_pr; concl_po; concl_nn]`, and the high-level tactic
`process_ehoare_deno` runs `t_trivial` on it so trivially non-negative bounds
stay effort-free; a genuinely negative bound is left as an unprovable goal.
`examples/ehoare/adversary.ec` (the only ehoare-deno user) discharges the
non-trivial symbolic bound from `eps_ge0`, `Q_nneg`, `0 < p`.

Regression: tests/byehoare-neg-bound.ec.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@fdupress
fdupress force-pushed the fix/byehoare-neg-bound branch from ef6dcc0 to 05d9f0f Compare September 5, 2026 12:27
@fdupress
fdupress merged commit 2aaa14a into main Sep 5, 2026
16 checks passed
@fdupress
fdupress deleted the fix/byehoare-neg-bound branch September 5, 2026 12:36
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.

3 participants