You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
call /fc reads the caller's local variables in the callee (ehoare) #1196
call /fc (the concave ehoare call, process_call_concave in src/phl/ecPhlCall.ml) types 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 is therefore read as the callee's variable of the same name, which proves false.
MRE:
require import AllCore Xreal.
module M = {
proc g() = { var y; y <- 0; }
proc main() : int = { var y; y <- 1; g(); return y; }
}.
lemma bad : ehoare [M.main : 0%xr ==> (res = 1)%xr].
proof.
proc.
call /(fun x => x) (_ : 0%xr ==> (y = 1)%xr).
+ by proc; auto.
by auto.
qed.
lemma good : hoare [M.main : true ==> res = 1].
proof. by proc; inline *; auto. qed.
lemma ll : islossless M.main.
proof. by proc; inline *; auto. qed.
lemma false_ &m : false.
proof.
have h0 : Pr[M.main() @ &m : res = 1] <= 0%r.
+ byehoare (bad) => //.
have h1 : Pr[M.main() @ &m : res = 1] = 1%r.
+ by byphoare => //; conseq ll good.
smt().
qed.
The invariant form gives false the same way, e.g. with proc h() = { var y; G.g <- G.g + 1; y <- G.g; }, proc main2() : bool = { var y; G.g <- 0; y <- 0; h(); return y <> G.g; } and call /(fun x => x) (: (y <> G.g)%xr) on ehoare [M.main2 : 0%xr ==> res%xr].
Root cause: process_call_concave types the cut with TTC.tc1_process_Xhl_form tc ty ... (the goal's memory) for both CI_spec and CI_inv. The plain call (process_call) types a specification in the callee's memories (LDecl.hoareF m f hyps) and an invariant in an abstract memory, where the caller's locals are not in scope.
Origin: 99ec9f4 (2023-10-11, "ehoare"), first released in r2024.01.
Activity
fix: `call /fc` must not read the caller's locals in the callee