Skip to content

fix: call /fc must not read the caller's locals in the callee - #1197

Merged
strub merged 1 commit into
mainfrom
fix/ehoare-call-concave
Oct 9, 2026
Merged

strub merged 1 commit into
mainfrom
fix/ehoare-call-concave

Conversation

@strub

@strub strub commented Oct 9, 2026

Copy link
Copy Markdown
Member

call /fc (concave ehoare call) typed its specification (call /fc (_ : P ==> Q)) and its invariant (call /fc (: I)) in the memory of the
goal, i.e. of the caller, whereas the premise is a judgement on the
called procedure. A local variable of the caller was therefore read as
the callee's variable of the same name. With

proc g() = { var y; y <- 0; }
proc main() : int = { var y; y <- 1; g(); return y; }

call /(fun x => x) (_ : 0%xr ==> (y = 1)%xr) proves
ehoare [M.main : 0%xr ==> (res = 1)%xr], hence (with byehoare and
hoare [M.main : true ==> res = 1]) false; an invariant mentioning
a local of the caller gives false the same way.

The specification is now typed in the memories of the called procedure
(LDecl.hoareF) and the invariant in an abstract memory, as call
already does: the locals of the caller are no longer in scope.

Fixes #1196.

Origin: 99ec9f4 (2023-10-11, "ehoare"), first released in r2024.01.

Test: tests/ehoare-call-concave-locals.ec (the previous build accepts
the fail lines). unit (124 files), stdlib (128) and examples (49)
pass.

`call /fc` (concave ehoare call) typed its specification (`call /fc (_ :
P ==> Q)`) and its invariant (`call /fc (: I)`) in the memory of the
goal, i.e. of the caller, whereas the premise is a judgement on the
called procedure. A local variable of the caller was therefore read as
the callee's variable of the same name. With

  proc g() = { var y; y <- 0; }
  proc main() : int = { var y; y <- 1; g(); return y; }

`call /(fun x => x) (_ : 0%xr ==> (y = 1)%xr)` proves
`ehoare [M.main : 0%xr ==> (res = 1)%xr]`, hence (with `byehoare` and
`hoare [M.main : true ==> res = 1]`) `false`; an invariant mentioning
a local of the caller gives `false` the same way.

The specification is now typed in the memories of the called procedure
(`LDecl.hoareF`) and the invariant in an abstract memory, as `call`
already does: the locals of the caller are no longer in scope.

Fixes #1196.

Origin: 99ec9f4 (2023-10-11, "ehoare"), first released in r2024.01.

Test: tests/ehoare-call-concave-locals.ec (the previous build accepts
the `fail` lines). unit (124 files), stdlib (128) and examples (49)
pass.
@strub strub self-assigned this Oct 9, 2026
@strub strub added the yolo-pr Don't bother reviewing, I will merge label Oct 9, 2026
@strub
strub merged commit 0a8b40a into main Oct 9, 2026
20 checks passed
@strub
strub deleted the fix/ehoare-call-concave branch October 9, 2026 10:04
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.

call /fc reads the caller's local variables in the callee (ehoare)

1 participant