viperproject / silver

Definition of the Viper intermediate verification language.
Mozilla Public License 2.0
78 stars 40 forks source link

Add Inhaling expression #799

Open manud99 opened 2 months ago

manud99 commented 2 months ago

@JonasAlaif and I have been working on a new inhaling expression. The purpose of this new expression is that we want to temporarily inhale some assertion to check facts that are inaccessible in the current state. An example of this is a magic wand, where we don't hold its LHS and where we want to check a property in the snapshot of this magic wand.

For example, we can use this expression to define the snapshot of a wand as follows:

field f: Int

method test5(x: Ref, y: Ref)
    requires true --* acc(x.f)
    requires acc(x.f) --* acc(y.f)
    requires inhaling (acc(x.f)) in applying (acc(x.f) --* acc(y.f)) in y.f == 10
{
    apply true --* acc(x.f)
    apply acc(x.f) --* acc(y.f)

    assert y.f == 10
}

The syntax is as follows: inhaling (<assertion>) in <expression>

This PR extends Silver to parse this new expression and adds some test files to check the expected behavior. There is also an implementation for Silicon in viperproject/silicon#848.