Pruned tensor evaluation and the calls it makes #
The recursion skips children with no requested output strings, reading only precomputed leaf encodings. Its values agree with the full recursion on the requested set and vanish elsewhere. A call trace records finite recursive calls and passed sets; it is not a machine execution or an instruction counter.
The root is always called. At depth zero with an empty request set it is itself a visited leaf, although the set of contributing leaves is empty. The leaf characterization therefore requires positive depth or a nonempty request set. The value and total-set-size statements hold without that qualification.
Main definitions #
Pruned.run,Pruned.result,Pruned.calls: pruned evaluation and its call trace.Pruned.Visits,Pruned.totalSize: visited leaves and total size of passed sets.computeEncoding: recursive computation of either input encoding.
Main results #
Pruned.result_eq_piecewise_full: agreement on requested strings and zero elsewhere.Pruned.visits_iff_mem_leaves: exact visited-leaf characterization with the root exception.Pruned.totalSize_le: passed-set total bounded by depth plus one times leaf count.pruned_spec: all three properties together for the two input encodings.
References #
Part of [AlmanWilliams2026, Section 2]. Direct mathematical adaptation of
Anthropic's pinned formal source.
Definitions are selectively extracted from that pin's PaperStatements.lean; no machine
semantics or running-time statement is imported. The docstrings below explain the local
declarations in our own words.
One mathematical call record, pairing its label-sequence position with the request set supplied there. The dependent pairs retain the two tuple lengths.
The call depth and the terms identifying its vertex.
The remaining string length and requested output strings.
Instances For
Embed a child call into its parent by prepending the child label to its recorded vertex.
Instances For
Evaluate requested outputs from the two supplied leaf-encoding arrays. For each term, form its child request set and recurse only when that set is nonempty. Decode the child values and set unrequested outputs to zero. The second component records recursive calls and their requested sets as a multiset. Each child receives the corresponding slices of the encoding arrays. The root call is always recorded, including at depth zero with an empty request set. These are mathematical values and call records, without a native execution cost.
Instances For
Choose the private label at every output coordinate. The resulting leaf is relevant to that output tuple and distinguishes it from every other output tuple.
Instances For
Section 2.4.1: the encodings #
Recursively apply the coefficient family c along a term string. Each level replaces the
input array by a weighted sum of its first-letter slices; depth zero returns its unique entry.
Choosing phi or psi computes the corresponding shared input encoding.
Instances For
Specializing recursive encoding to phi gives the existing left-encoding array.
Specializing recursive encoding to psi gives the existing right-encoding array.
Section 2.4.2: the sets S_λ of step (2) #
Every requested suffix in a relevant output slice belongs to the corresponding child request set.
Lemma 10, first claim: the values #
At a requested tuple, decoding sums child values at its tail over labels relevant to its leading coordinate; every unrequested tuple has value zero.
Lemma 10, second claim: the calls that are made and the sets passed to them #
At full depth, vertex relevance coincides with the existing leaf-relevance predicate.
Unfold call recording into the parent record and the embedded records from nonempty children.
Membership in the positive-depth call multiset means being the root record or an embedded call of some nonempty child.
For vertices within the recursion depth, being called is equivalent to being the root or being relevant to at least one requested tuple.
Away from the empty-request root exception, a vertex within the recursion depth is called
exactly when some requested tuple is relevant to it. The hypothesis hk admits every
positive-depth vertex and also admits the root when requests are nonempty.
A recorded call receives exactly the suffixes of original requests relevant to its vertex. Its recorded remaining length and depth identify the suffix position.
A leaf is visited exactly when it is the zero-depth root or contributes to a request. This includes the empty request set without an exceptional hypothesis.
With positive depth or nonempty requests, the visited-leaf set is exactly leaves U. The
unconditional root case is given separately by Pruned.visits_iff_root_or_mem_leaves.
Lemma 10, third claim: the total size of the sets passed #
Count relevant leaves by summing the relevant-leaf counts of all children; distinct leading labels keep these families disjoint.
Different output strings have different private leaves.
At any fixed depth, the sum of all passed request-set cardinalities is bounded by the root request set's relevant-leaf count.
Combine value correctness, the visited-leaf characterization and the passed-set cardinality
bound for the two input encodings. Values and the set-size bound apply at every depth and request
set. The leaf equivalence excludes the empty zero-depth root;
Pruned.visits_iff_root_or_mem_leaves gives the unconditional alternative for that case.