Skip to content

fix(env): keep calls to parameters in applications and module aliases - #1229

Open
strub wants to merge 1 commit into
mainfrom
fix-unsuspend-oinfos
Open

strub wants to merge 1 commit into
mainfrom
fix-unsuspend-oinfos

Conversation

@strub

@strub strub commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

Fixes #1175.
Fixes #1234.

The oracle infos of a module record, for each procedure, the calls it
may make to the parameters of the module. Two cases lost some of these
calls. The module then looked as if it made no call at all and passed
a restriction that it does not respect, which is enough to prove
false.

Partial applications (#1175). When a functor is partially applied,
Mod.unsuspend keeps the calls whose target is one of the remaining
parameters. It compared the full target of the call with the
parameter, so a call such as S(M).kg, whose target is S(M) and not
S, was dropped even when S is a remaining parameter. In the
example of the issue, the following module is accepted at Adv,
whose run may call nothing:

module (B (D : T) : Adv) (S : Sch) = {
  proc run() : unit = { S(M).kg(); }
}.

The filter now compares the functor of the target, as get_oi_calls
already does when it computes the calls of a module. ModTy.sig_of_mt
uses the same filter and is changed in the same way.

Module aliases (#1234). An alias copied the oracle infos of its
target. These are the calls of the target to its own parameters, and
they miss the calls that reach the parameters of the alias:

module (C1 : V) (O : U) = O.
module (C2 : V) (O : U) = E(O).
module (C3 : V) (O : U) = E(E(O)).

A procedure of C1 is a call to the same procedure of O, a parameter
of the alias. In C2, Mod.unsuspend drops the calls of E to its
parameter, applied to O: that is right when the argument is closed,
since the call is then no longer a call to a parameter, but here O
is a parameter of the alias. In C3, the call of the outer E is to
E(O).p, which only reaches O.p through the inner E. Other
aliases, functor parameters and partially applied functors hide the
call in the same way.

A procedure of an alias is now treated as a call to the same procedure
of its target, applied to the remaining parameters. Its oracle infos
are computed from this call by the transitive closure that
get_oi_calls uses for structures, which now takes a list of entry
calls (get_oi_calls_of_entries).

@strub strub self-assigned this Nov 24, 2026
@strub strub added the yolo-pr Don't bother reviewing, I will merge label Nov 24, 2026
@strub strub changed the title fix(env): keep calls to applied parameters in partial applications fix(env): keep calls to parameters in applications and module aliases Nov 29, 2026
@strub
strub force-pushed the fix-unsuspend-oinfos branch from d5a7709 to 8985f23 Compare November 29, 2026 07:57
Fixes #1175.
Fixes #1234.

The oracle infos of a module record, for each procedure, the calls it
may make to the parameters of the module. Two cases lost some of these
calls. The module then looked as if it made no call at all and passed
a restriction that it does not respect, which is enough to prove
`false`.

Partial applications (#1175). When a functor is partially applied,
`Mod.unsuspend` keeps the calls whose target is one of the remaining
parameters. It compared the full target of the call with the
parameter, so a call such as `S(M).kg`, whose target is `S(M)` and not
`S`, was dropped even when `S` is a remaining parameter. In the
example of the issue, the following module is accepted at `Adv`,
whose `run` may call nothing:

    module (B (D : T) : Adv) (S : Sch) = {
      proc run() : unit = { S(M).kg(); }
    }.

The filter now compares the functor of the target, as `get_oi_calls`
already does when it computes the calls of a module. `ModTy.sig_of_mt`
uses the same filter and is changed in the same way.

Module aliases (#1234). An alias copied the oracle infos of its
target. These are the calls of the target to its own parameters, and
they miss the calls that reach the parameters of the alias:

    module (C1 : V) (O : U) = O.
    module (C2 : V) (O : U) = E(O).
    module (C3 : V) (O : U) = E(E(O)).

A procedure of `C1` is a call to the same procedure of `O`, a parameter
of the alias. In `C2`, `Mod.unsuspend` drops the calls of `E` to its
parameter, applied to `O`: that is right when the argument is closed,
since the call is then no longer a call to a parameter, but here `O`
is a parameter of the alias. In `C3`, the call of the outer `E` is to
`E(O).p`, which only reaches `O.p` through the inner `E`. Other
aliases, functor parameters and partially applied functors hide the
call in the same way.

A procedure of an alias is now treated as a call to the same procedure
of its target, applied to the remaining parameters. Its oracle infos
are computed from this call by the transitive closure that
`get_oi_calls` uses for structures, which now takes a list of entry
calls (`get_oi_calls_of_entries`).
@strub
strub force-pushed the fix-unsuspend-oinfos branch from 8985f23 to 9f9b87b Compare November 29, 2026 08:35
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.

Restrictions of module aliases are not checked correctly Unsound: a module can call its parameter S even though its module type forbids it

1 participant