Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Generating Annotations for Magic Wands

Clients like Prusti want to generate magic wands from function bodies.

The PCG facilitates this via the UnblockGraph interface. The interface takes a PCG and a PCG node , and returns an ordered list of annotations that describe how to unblock in . Prusti can consume these annotations to generate magic wands.

The interface could trivially be extended to unblock multiple nodes simultaneously

The annotations generated from the UnblockGraph are Borrow PCG edges.

At a high level, the resulting annotations are a topological sort of the edges in the subgraph of that contains and all of its ancestors. Concretely, the procedure to generate the list of annotations is as follows:

  1. Let be the subgraph containing and its ancestors in
  2. While has at least one edge:
    1. Let be the set of leaf edges in .
    2. If is empty fail
    3. Append to
    4. Remove from

We note that the above procedure could fail, for example, could contain a cycle. We expect that in practice this is quite rare. Furthermore, we believe the following property should hold:

For any list of PCG edges forming a cycle, there does not exist any execution path that call satisfy the validity conditions of every edge in the cycle.

Therefore, it should be possible to modify the implementation to e.g. produce multiple lists for distinct paths.