Inference of roles for invertibility #
Unlike role typing, invertibility does not determine the roles: a line whose results nobody
needs may take either role. And the roles of the backward pass (backward) may fail where
others succeed: a line whose results are needed is marked spine, but if its data is returned,
only its conditioner recipe helps (see Examples.lean).
Without roles, every line contributes both of its recipes (xrecsAll). By monotonicity of
Known, these reach at least what the recipes of any roles reach. Conversely, in one closure
only one recipe of a line can add anything: after the conditioner recipe, its arguments, among
them the data, are known; after the spine recipe, its sources, among them the results, are known
(known_pair_spine, known_pair_cond). inferAll picks that recipe line by line, deciding
Known by the schedule (knownSet), so its roles reach everything that xrecsAll reaches
(inferAll_known). Hence P is invertible under some roles iff the inputs are Known under
xrecsAll (Prog.exists_invertible_iff), and then under Prog.rolesAll
(Prog.invertible_rolesAll).
Prog.inferInv tries the roles of the backward pass first, so it agrees with Prog.infer
where that succeeds (inferInv_of_infer), and falls back to Prog.rolesAll; it is sound and
complete (inferInv_sound, inferInv_complete, inferInv_isSome_iff).
Deciding Known #
The schedule's known set from B, ignoring the emitted lines.
Equations
- RoleFlow.knownSet R B = (RoleFlow.fire R.length R 0 id (RoleFlow.insertAll ∅ B)).2.2
Instances For
All recipes #
The recipes of the lines under every role: each line's conditioner recipe and, if it has a partial inverse, its spine recipe.
Instances For
One line's two recipes #
If the conditioner recipe rc only fires once its targets are known anyway, it can be
dropped.
If the sources of the conditioner recipe rc are known without it and its targets are not,
the spine recipe rs, whose sources contain those targets, never fires, and can be dropped.
Choosing the roles #
The roles, line by line, from the base B: F holds the recipes chosen so far. A line
becomes a conditioner if, with all later recipes, its arguments are known but its results are
not; otherwise a spine step. A line without a partial inverse becomes a conditioner.
Equations
Instances For
Programs #
Invertibility under some roles is invertibility under all recipes at once.
rolesAll is complete: if any roles invert P, these do.
Inverse inference without density: the backward pass's roles if they invert P, and
otherwise rolesAll if they do.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Completeness: if any roles invert P, inference succeeds.