Skip to content

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

Closed

Description

@strub

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

  1. added a commit that references this issue on Oct 15, 2026
    0a8b40a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions