Role inference (docs/roleflow.tex, sec:infer) #
Inference is a single backward pass (backward): starting from the returned variables N, a
line is a spine step if one of its results is in N, and then its consumed arguments are added
to N; otherwise it is a conditioner. Prog.infer runs the pass and checks the result.
Inference is exact (Prog.infer_iff): it finds the roles of every typing, so typings are
unique (Prog.Typed.unique). The reason (backward_typed) is that at every node of a
derivation the needed set below the scope is exactly the live set: a live variable is either
returned or consumed by exactly one later spine step, and a conditioner's results are never
live. Nothing here uses measure theory.
The backward pass over the lines ls at scope n, from the needed set N₀ at the end:
the roles, and the needed set at the start. A line is a spine step if one of its results is
needed and it has a semi-inverse, and a conditioner otherwise. A needed result of a conditioner
is never live, so the typing then fails.
Equations
Instances For
Infer the roles of a program: the backward pass, confirmed by deciding the typing.
Equations
Instances For
The backward pass finds the roles of a derivation, and below the scope its needed set is the live set.