Optimal Sharing and Graph Reduction
Prerequisites. Direct starred prerequisites: Chapter 41. No later core chapter depends on this route.
Consider the finite untyped term
One shared node, calculated
A directed-acyclic sharing skeleton already exposes the distinction. Let Diagram Two incoming edges represent two uses, but there is only one node to rewrite. This is ordinary graph sharing. Recognizing one Lévy family through later rewrites requires the labeled calculus introduced in the next section.
Definition 42.1 — The opening labeled term graph¶
For finite untyped lambda terms
Referenced from 4 locations
The outer source contraction is represented by
Proposition 42.2 — One graph contraction discharges both residuals¶
The node name and family label of
Referenced from 4 locations
Proof of Proposition 42.2 — One graph contraction discharges both residuals
Proof. Equation (42.1) changes only the stored body. Readback gives
The Gonthier–Abadi–Lévy graph interface
The imported result uses Gonthier, Abadi, and Lévy’s bus presentation of Lamping-style sharing graphs. The following convention fixes every object that appears in the theorem; it also records where the source remains diagrammatic.
Convention 42.3 — GAL graph system¶
A bus is a finite ordered bundle of parallel wires. A GAL graph is a finite undirected port graph assembled from five node forms:
| Node | Bus presentation | Role |
|---|---|---|
| root | one incident bus | closes a result or variable edge |
| void | one incident bus | terminates an unused branch |
| croissant | unary on a bus slice | creates one wire ex nihilo |
| bracket | terminal on two slices | combines two wires |
| fan | three buses, total arity |
shares a bus |
A fan has one marked main level; the other bus levels carry no context mark. Its three buses have corresponding rightmost wires, and the incident ports on those wires are rightmost fan ports.
The full one-step relation
Definition 42.4 — Diagrammatic translation¶
For a finite untyped lambda term
A variable is a bus of width three, with one result edge and one edge bearing its variable name.
For
, place and side by side. The upper fan sends the call into , routes the reply to the result, and routes the argument request to ; the adjacent croissant creates the null offset for that call. For each variable free in both subterms, a lower fan merges the two named buses while retaining their distinct offsets.For
, feed the bus named back through the abstraction fan. If , terminate that branch with a void. Put a bracket on every other free-variable bus so that its address is restored on leaving the scope; the dual croissant removes that offset when the bus returns.
The second stage forgets edge directions, moves variable names to roots, and adds roots to the result and free-variable edges. Left, middle, and right within every bus are those shown in the diagrams; they are not quotient data. The source explicitly calls this translation informal because a set-theoretic definition would first have to construct those left/right bus positions. Accordingly,
A graph is reachable and well formed for
Definition 42.5 — Access-path readback¶
An access path starts at the top root with a star-free context and follows directed bus edges whose adjacent contexts agree, except for the source’s shunt step that transfers a suffix between the input and output contexts. Readback
For graphs reachable from
Referenced from 3 locations
Labels, readback, and qualified optimality
Labels are placed on rightmost wires of
For the opening term, the translation and readback obligations form the following worked calculation. Let
Theorem 42.6 — Readback and family nonduplication, imported¶
For every finite untyped lambda term
modulo alpha-equivalence.If
and , then . If such a reachable is a graph normal form, is beta-normal.During reduction, no two redexes of rightmost fans have the same label. Hence graph reduction never duplicates contraction of one Lévy family.
Proof of Theorem 42.6 — Readback and family nonduplication, imported
Imported proof. Source boundary. Clauses 1 and 2 are GAL Theorem 3 and clause 3 is Theorem 4, both in the local author copy at printed p. 11. Theorem 4’s proof sketch continues onto p. 12 [GAL92]. Their translation is explicitly diagrammatic and informal; definition 42.4 preserves that boundary. Theorem 4 calls the resulting reductions optimal, but the adjacent qualification matters: family work is not duplicated, yet a reduction may still evaluate a subterm later found useless. A normal-order strategy, such as leftmost-outermost, avoids that useless work. Thus family nonduplication does not make every scheduler time- or space-optimal. ◻
Exercise 42.1¶
Apply definition 42.4 to
Referenced from 3 locations
Exercise 42.2¶
For the worked
Referenced from 3 locations
Parallel beta is not a machine cost
The lower bound of Asperti and Mairson concerns simply typed terms, not the untyped GAL signature. We therefore freeze its separate vocabulary.
Definition 42.7 — Asperti–Mairson cost signature¶
Simple types and explicitly typed terms are
Referenced from 2 locations
The lower bound uses four facts whose scopes must remain visible. The first two turn term size into a family-step bound. The last two turn a hypothetical unit-cost implementation into a forbidden decision procedure.
Proposition 42.8 — Prerequisite package for the cost obstruction¶
Fix
For every explicitly typed term
, typed eta-expansion followed by the sharing-graph translation produces a graph satisfying .Every fan in
has atomic type. Hence fan propagation creates no lambda or application node, and a family contraction removes one lambda–application pair. A normalization of therefore has at most parallel beta steps.For each input word
, there is a higher-order formula of size such that is true if and only if accepts within steps. The powerset hierarchy in the formula is bounded by a level depending on , not on .The formula
compiles to a closed explicitly typed term . There is a constant , independent of , such that , and normalizes to if and only if accepts .
Referenced from 3 locations
Proof of Proposition 42.8 — Prerequisite package for the cost obstruction
Proof. For (i), eta-expand a variable of type
For (ii), atomic fans cannot meet a lambda or application at functional type. No reduction can consequently create either kind of node. Each family contraction removes one node of each kind, so their number is bounded by
For (iii), encode the finite base set as a Boolean tuple and encode its iterated powersets by typed Church lists. Membership, subset, and equality at level
For (iv), compile disjunction, conjunction, negation, and implication to their Church Boolean terms. Compile a quantifier over a finite type to iteration over the corresponding list: universal quantification folds conjunction from
Theorem 42.9 — Parallel-beta cost obstruction, imported¶
For every fixed integer
Referenced from 2 locations
Proof of Theorem 42.9 — Parallel-beta cost obstruction, imported
Proof. By the deterministic time-hierarchy theorem, choose a language
The statement and construction are Asperti–Mairson Theorem 5.3 on printed p. 24 [AM01]. Unit cost per family step would give a linear implementation-time bound and therefore contradict the theorem. The separation is between a semantic family count and all concrete work assigned to its implementation; it does not identify which bookkeeping operation pays the lower bound.
Corollary 42.10 — Transfer to Lamping graph reduction, imported¶
For every fixed
Referenced from 2 locations
Proof of Corollary 42.10 — Transfer to Lamping graph reduction, imported
Imported proof. This is Asperti–Mairson Corollary 5.4 on printed p. 24. It counts interactions of lambda, application, and fan nodes together with the croissant/bracket interactions that manage indices. The transfer uses their observation that Lamping’s local graph operations form a first-class machine with polynomial overhead. It is a theorem about that algorithm, not an automatic lower bound for every graph reducer or runtime representation. ◻
Corollary 42.11 — Ordinary versus parallel beta, imported¶
Fix
Referenced from 2 locations
Proof of Corollary 42.11 — Ordinary versus parallel beta, imported
Imported proof. This is their Corollary 5.6 on printed p. 25. It separates the number of family contractions from ordinary beta work before any graph representation or scheduler is chosen. Neither corollary is a wall-clock, memory-use, or parallel-speedup claim; those require a concrete implementation, allocation policy, scheduler, machine, and measurement protocol. ◻
Exercise 42.3¶
Compute
Referenced from 3 locations
What the executable certificate establishes
The Kappa companion checks the opening let-graph and a finite certificate syntax. A certificate endpoint is a natural-number identifier tagged left-rightmost, right-rightmost, or auxiliary. A trace entry is
This format audits supplied finite data. It does not decide whether two endpoints are incident to facing fans in a GAL graph, whether the graph lies in the image of
None of these problems is a prerequisite for a later chapter.
Suggested first pass.
Compute the opening readbacks, audit the GAL import boundary, separate the three cost measures, and only then extend the certificate checker.
Exercise 42.4¶
Fill the three fields of the opening certificate
Referenced from 3 locations
Exercise 42.5¶
Reconstruct the use of GAL Theorem 3 in theorem 42.6. State both reachability hypotheses, explain why full graph reduction rather than the labeled-fan subrelation is required, and identify the point where the source supplies only a proof sketch. Then give a reduction strategy under which Theorem 4’s useless-work caveat is discharged.
Referenced from 3 locations
Exercise 42.6¶
Construct a certificate whose endpoint tags, beta path, and fresh label all pass the finite checker but whose endpoints do not belong to one graph. Which premise of theorem 42.6 is absent? Explain why acceptance must not be reported as an optimality proof.
Referenced from 3 locations
Exercise 42.7¶
Suppose a reducer reports ten family contractions, ten thousand local graph interactions, and eight milliseconds. Classify each number using section 42.4. State why none of the three determines either of the others without a simulation and cost relation.
Referenced from 3 locations
Exercise 42.8¶
Practical project.optimal-sharing-auditor Implement the labeled term graph of definition 42.1, its shared-beta operation, and readback in Kappa. Maintain the node-name and family-label invariants through contraction. Then implement the finite certificate checker of section 42.5, maintaining its four entry invariants after every accepted item. Check the preserved node name, preserved label, and complete readback calculation of proposition 42.2. Include one crossed-binder beta step that requires freshening. Reject an invalid tag pair, an empty or non-beta path, and a repeated label independently. A typechecking mutation must target each invariant, and each isolated negative case must fail. Appendix E records the commands and appendix F develops the checker.