Skip to content

fix: kill must respect the exceptional postconditions - #1176

Merged
strub merged 1 commit into
mainfrom
fix/kill-exn
Oct 7, 2026
Merged

strub merged 1 commit into
mainfrom
fix/kill-exn

Conversation

@strub

@strub strub commented Oct 7, 2026

Copy link
Copy Markdown
Member

On a hoare goal, EcLowPhlGoal.t_code_transform handed the code
transformations the main postcondition only. kill uses it to check
that the killed code writes no variable read by the postcondition, so a
variable read only by an exceptional postcondition could be killed,
which proves false judgements, e.g.

hoare [N.f : N.x = 0 ==> true | oops _ => N.x = 0]

for N.f = { N.x <- 1; raise (oops 0); }, by kill 1. As for #1129
(swap), no derivation of false is known: no rule relates exceptional
postconditions to phoare / Pr.

The transformations now get the conjunction of the main and exceptional
postconditions (they only use it for the variables it reads; kill is
the only one that does). The issue dates from the introduction of
exceptions (bba1f1b, first released in r2026.03).

tests/kill-exn.ec checks that kill is rejected in that case and still
applies when the exceptional postconditions do not read the killed
variables. The stdlib, the unit tests and the examples pass.

On a hoare goal, `EcLowPhlGoal.t_code_transform` handed the code
transformations the main postcondition only. `kill` uses it to check
that the killed code writes no variable read by the postcondition, so a
variable read only by an exceptional postcondition could be killed,
which proves false judgements, e.g.

  hoare [N.f : N.x = 0 ==> true | oops _ => N.x = 0]

for `N.f = { N.x <- 1; raise (oops 0); }`, by `kill 1`. As for #1129
(`swap`), no derivation of `false` is known: no rule relates exceptional
postconditions to `phoare` / `Pr`.

The transformations now get the conjunction of the main and exceptional
postconditions (they only use it for the variables it reads; `kill` is
the only one that does). The issue dates from the introduction of
exceptions (bba1f1b, first released in r2026.03).

tests/kill-exn.ec checks that `kill` is rejected in that case and still
applies when the exceptional postconditions do not read the killed
variables. The stdlib, the unit tests and the examples pass.
@strub strub self-assigned this Oct 7, 2026
@strub strub added the yolo-pr Don't bother reviewing, I will merge label Oct 7, 2026
@strub
strub merged commit a6f249a into main Oct 7, 2026
20 checks passed
@strub
strub deleted the fix/kill-exn branch October 7, 2026 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

yolo-pr Don't bother reviewing, I will merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant