Repository navigation
fix: call /fc must not read the caller's locals in the callee - #1197
Merged
Merged
Conversation
`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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
call /fc(concave ehoare call) typed its specification (call /fc (_ : P ==> Q)) and its invariant (call /fc (: I)) in the memory of thegoal, 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)provesehoare [M.main : 0%xr ==> (res = 1)%xr], hence (withbyehoareandhoare [M.main : true ==> res = 1])false; an invariant mentioninga local of the caller gives
falsethe same way.The specification is now typed in the memories of the called procedure
(
LDecl.hoareF) and the invariant in an abstract memory, ascallalready 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
faillines). unit (124 files), stdlib (128) and examples (49)pass.