Delta Type Concept
1 Changes and Incremental Strategies
Setting. Let , where , , is a total product of nonempty sets. No algebraic structure is assumed. Write for replacement of by , and for a context subtuple. The empty product is a singleton. An incremental computation starts with a current input and its already computed output . It receives a description of an input change and must produce the corresponding new output.
Why identify context? The central form is All inputs may already be accessible when a delta is consumed. A context declares which other input coordinates the selected consumer may consult. It therefore identifies work that can be separated from the changing query. Here contains the current output and the dynamic change data, including a baseline when required; is that context. Preparation performs work depending only on that context. Application combines its result with the query at consumption. If the context stays fixed, the same preparation can serve changing queries. In an ordered batch, a preparation can also be used once and discarded before a later edit disturbs its context. These are the two reuse patterns proved below.
Definition 1 (Delta function and delta value). A delta function on a set is a map Each names the endomorphism . A delta value identifies the family and its member; write . At coordinate its input edit is A bound packet retains a baseline , thereby determining the endpoints . An unbound reading supplies the transform without the baseline.
An endomorphism here is a self-map of a set. The family need not be closed under composition. Different parameters may name the same map. Conversely, every family of self-maps is parameterized by its evaluation map.
Example 2 (Replacement and shift). On any set, . Its bound packet presents the substitution ; its unbound reading is the constant self-map with value . On an abelian group, names a shift without supplying its baseline. The same delta function can be read bound or unbound when the appropriate consumer exists.
What the delta carries. A delta value is an abstract carrier for an incremental strategy: its family and member describe the input edit and may select a specialized evaluator. The consumer’s coordinate, reading, and context specify its consumption contract. The endpoint need not be materialized before consumption. A delta need not be an additive difference or a small object. Exactness comes from the consumer equation, and reusable work from its factorization as in (1).
Relation to the prerequisites. We use Transition Context, Transform Context, and Contextual Order from Prerequisite Mathematical Definitions, restating the needed conditions. This document develops their mathematical application to incremental computation; concrete Delta Type Classes form the subsequent implementation layer.
2 Exact Consumption at a Context
Jointly reachable data. Fix a coordinate , delta function , and context . Put . For a state and a delta , the dynamic queries are For either reading, let Thus the current output, baseline when present, and context come from one state. The bound query records the endpoints presented by the packet.
Definition 3 (Exact consumer and admission). An exact consumer is a map satisfying The family is admitted at on in the chosen reading when such a map exists. Admission covers every member of the family.
The associated output maps. Define For a presented pair , a bound consumer determines An unbound consumer determines The target sets follow from (2). A bound map is generally partial on ; the unbound map is an endomorphism of its slice range. These are their declared domains throughout.
Proposition 4 (Determinacy and exact consumption). Bound admission is equivalent to the implication for all and all . Unbound admission is equivalent to the same condition with omitted. Every admitted consumer is unique on its declared domain.
Proof. An admitted consumer receives equal queries and contexts under the stated hypotheses, so (2) gives equal edited outputs. Conversely, in the bound case, take a realizable and choose with , , and . A parameter presenting exists by realizability. Assign the answer . Condition (3), applied to that parameter, makes the answer independent of the chosen . It depends only on the endpoints, so a second parameter presenting them gives the same answer. This defines and proves exactness. In the unbound case, for realizable choose with and , and assign . The criterion without the baseline hypothesis makes this independent of the witness. In either reading every domain point has a realization, and (2) forces the assigned answer, proving uniqueness. □
Endpoints and family. A bound family’s parameters may select a particular evaluation strategy, but the exact map on each source fibre is forced by the presented endpoints. For , all endpoints are presented: bound admission says exactly that is a sufficient transition context for . Unbound admission is the prerequisite’s transform-context condition for . Empty context specializes each statement to independence. Enlarging the context preserves either condition, because agreement on a larger context implies agreement on the smaller one in Proposition 4.
3 Preparing and Reusing Context
Separating preparation from application. Suppress the fixed coordinate, family, and reading, and write the exact consumer as with . A preparation is sufficient for if an evaluator satisfies The prepared value can be retained while later invocations supply their current queries.
Theorem 5 (Exactly when a preparation suffices). A chosen is sufficient if and only if for every common realizable query , meaning . The evaluator is then unique on .
Proof. If (4) holds, the two queries with equal prepared values give identical arguments to , proving (5). Conversely, given , choose with and , and define . Every other such witness is covered by (5), so the definition is independent of the choice. It satisfies (4), which also forces its value at every point of . □
Retaining original context. If application reads as well as auxiliary work, use . This models exactly the available information. The first component guarantees semantic sufficiency; the second may contain work that the selected evaluator reuses. Caching does not require discarding the context.
The packet can select the evaluator. Bound semantic queries record endpoints, but an implementation may evaluate directly from the family and its parameter. On jointly realizable bound packet data, a packet evaluator can satisfy This is an equality of results. It does not prescribe evaluating first. The family can identify a specialized strategy and work to prepare before the particular parameter arrives.
Exactness and computation. The factorization is a statement about mathematical maps. An executable strategy also supplies representations and algorithms for and . The work comparisons below concern those specified algorithms in an additive cost model. Semantic existence alone asserts no running-time improvement.
Example 6 (A prepared dictionary of input changes). Let be a fixed finite field, let , and fix a dictionary . Consider with the delta family For changes to , the matrix is a sufficient transform context; the current value of need not be read by this consumer. Put and, writing the fixed family implicitly in its query, define For every input and parameter, This proves exactness and the asserted transform context. Preparation depends on the current context and the fixed family dictionary, but not on , , , or . It can precede the arrival of the next delta value.
Repeated use. Hold fixed and start with . For any sequence , set If , substitution gives . The initial equality and induction therefore prove exactness at every step. Every update uses the same prepared matrix .
An explicit work comparison. In an arithmetic work model, count one field addition or multiplication as one operation, using ordinary dense dot products and vector operations. Preparing costs operations. Each output application costs , and updating the stored input costs . For updates, extend this arithmetic count by charging all additional retention and reuse work to in the same units. After cancelling other common work, the same factored algorithm has costs The saving is . The retained object contains field elements. These counts establish the saving for this chosen strategy; they make no optimality claim. The inputs can all remain accessible throughout. The benefit comes from reusing intermediate computation determined by the context.
Lemma 7 (Sequential exactness). Let be an input run, each step an admitted coordinate edit. Start with . At step , apply its exact consumer to using the actual context and, when bound, the actual baseline and resulting endpoint. Then every invocation is defined and . An exact factorization may be used at any step whose preparation equals for that step’s actual context .
Proof. If , the supplied query and labels are jointly realized by the actual state and edit. Equation (2) therefore returns . A factored invocation returns the same value by (4). The assumed equality at step zero and induction prove the assertion. No closure of the admitted families is used. □
Theorem 8 (Reuse while context is fixed). Fix a consumer with context and factorization (4). Consider any finite admitted input run in which throughout. Prepare once. At every invocation of this consumer, use with the current query, including the actual baseline and endpoint when bound. Let any intervening edits use their own exact consumers with actual labels. Starting from , the maintained output after every step is , and remains valid for every designated invocation.
Proof. The stored value is initially . Every state has context by hypothesis, so this stored value remains throughout the run. At a designated invocation, the baseline and endpoint, if required, are those of the actual edit; its current-output query therefore meets the factorization hypothesis of Lemma 7. The intervening invocations meet that lemma’s direct exactness hypothesis. It follows inductively that after every step. Thus both the current output and the preparation remain correct at each designated use. □
Finite-run work. Suppose there are designated uses. Let preparation cost , let application at use cost , and let retaining and obtaining the cache add . Assume these costs add, retention leaves the unchanged, and all other work is identical. For the same factored consumer, the costs are Both runs are exact by Theorem 8. Counting their preparations and subtracting gives saved work ; retention is cheaper exactly when this quantity is positive.
Corollary 9 (Maintaining preparation under a context edit). For , an exact map with exists if and only if
Proof. An exact map sends equal prepared values to equal new prepared values, proving necessity. Conversely, define using any with . The condition makes the answer independent of the witness, with image in , and proves the required equation. □
4 Temporary Caches and Contextual Order
Preparation before a batch. A cache may be needed only until one designated use. Later edits may then change its context after it has served the batch. We first record why several such preparations can be made together.
Lemma 10 (Independent preparation). Fix context values and deterministic, terminating algorithms for . Each algorithm reads only its fixed context value and uses private intermediate and result storage. Every completed interleaving preserving each algorithm’s instruction order produces Thus the preparations may be evaluated independently, including in parallel. Their contexts may involve overlapping input coordinates.
Proof. For each algorithm, its input reads remain fixed and only its own instructions change its intermediate state. Induction on those instructions gives the same local state as in its isolated evaluation. It therefore produces after its finite isolated instruction sequence. An interleaving executing all these sequences produces every component of the stated tuple, independently of their relative order. □
The ordered setting. Fix an initial tuple and a target . At each coordinate choose a globally sufficient transition context and an exact factorization for its bound replacement consumer. Prepare . Each cache is needed once in this batch, for the substitution , then is no longer required.
Theorem 11 (Consumption before context disturbance). Set and consume the prepared caches in increasing order: After step , the output is and every pending has Every cache is thus consumed before its declared context changes, and . Under the algorithmic hypotheses of Lemma 10, all preparations can be evaluated in parallel from the fixed context values at .
Proof. At , the stated invariant follows from initialization. Assume it holds after steps. Coordinate is still pending, so its actual baseline is , its actual context is , and is the preparation for that context. Its query in (7) uses the current output , hence is jointly realizable. Exactness gives For every still-pending , both and all are larger than , so none has yet changed. Their values, and the preparation made from them, retain their original values. This proves the full invariant by induction. At , . The parallel preparation claim follows from Lemma 10 applied to the fixed subtuples of . □
The lifetime protected. The proof keeps each pending baseline and context at its original value, even while the earlier inputs and the output change. It imposes no continuing requirement on a cache after its designated use. In particular, the preparation work can precede the sequence of current-output applications even when each cache is used only once.
Example 12 (Three caches, used in order). Consider the scalar mechanism It has sufficient transition contexts , , and . The preparations and exact applications are
For the first equation, replacing by adds . For the second, with , For the third, replacing by changes only its square factor. The positive domains make every denominator nonzero. These identities prove the global transition conditions and all three factorizations.
Take The exact trace is , , , and . Each table row records a complete consume-and-replace step; its context column is measured at consumption.
| Step | State after step | Output | Context at use | Pending caches |
|---|---|---|---|---|
| — | ||||
| none |
Updating consumes while both context coordinates still have their original values. Updating then changes that context: the current value of becomes , but has finished its job. That step uses while is still unchanged. Finally, updating changes the contexts of both earlier caches after both have been used. Its own cache has empty context. Direct evaluation gives , as required.
Original and final contexts. Increasing order uses preparations from the original later-coordinate values. Decreasing order can instead use . Indeed, before step in decreasing order the tuple is . Its active baseline is and its context is . Given its exact current output, the factored consumer therefore gives the output after replacing by . Starting from , descending induction proves exactness through the final tuple . The temporary-cache theorem above uses the increasing order and preparations made at the original tuple.
The Precedence Graph
A fixed batch and chosen contexts. Now allow arbitrary chosen sufficient transition contexts . Fix , prepare at , and let . The batch contains one fixed genuine substitution at each , and no other mutations. A schedule is a permutation of complete steps: consume at the current output and replace that coordinate before the next step begins. Its directed graph has vertex set and edges The edge means: consume before changing the context coordinate . A schedule is context-preserving if every original declared context remains unchanged until its designated use.
Theorem 13 (Exactly when original contexts can be preserved). The context-preserving schedules are precisely the topological orders of this graph. Such a schedule exists if and only if the graph is acyclic. With exact factorizations, its initial preparations compute when applied to the current output.
Proof. Suppose the schedule preserves contexts and . If preceded , the entry of ’s context would be at use. There is only one substitution at , so it could not have returned to . Thus precedes , and every edge is respected.
Conversely, in a topological order, every lies after , so still equals when is consumed. Every remains fixed throughout. The context is therefore and its initial preparation is valid. Coordinate also still has baseline . Starting with , Lemma 7 now gives the exact output at every step; the last tuple is .
A topological order cannot contain a directed cycle. Conversely, a nonempty finite acyclic graph has a vertex of indegree zero: otherwise following incoming edges would eventually repeat a vertex, giving a cycle. Remove such a vertex first and repeat on the remaining acyclic graph. The resulting list is a topological order. This proves the existence equivalence as well as the schedule characterization. □
The three-cache example has exactly these precedence edges: each arrow places a cache’s use before a later change to its context.
Corollary 14 (Contextual orderability). Call an order contextual when the full suffix after each coordinate is sufficient for its transitions, and the inputs contextually orderable when some permutation is contextual. They are contextually orderable if and only if one can choose a globally sufficient for every coordinate so that the graph for on all coordinates is acyclic.
Proof. For an acyclic choice, take a topological order. Each is contained in the suffix after , which is sufficient by upward closure. Thus the order is contextual. Conversely, from a contextual order choose its full suffixes as the . They are sufficient by definition, and every edge points forward, so the graph is acyclic. □
The corollary quantifies over a choice of sufficient contexts. The lifetime guarantee for a particular batch depends on its chosen declared contexts, whose graph must respect that batch’s uses.
5 Composing Exact Consumers
One coordinate at one context. The sequential lemma already proves exactness of arbitrary admitted runs. When a context stays fixed, the corresponding operators also satisfy the following typed laws.
Proposition 15 (Transition and transform composition). If is a sufficient transition context for , write for its replacement operator. Then Consequently is a bijection with inverse .
For an admitted unbound family at fixed , let be the monoid generated by its input transforms and . The family’s output maps extend to an action of on : composition is preserved, and induces .
Proof. Take . Replacing by itself leaves unchanged. Replacing by gives , and then replacing by gives . These are exactly the asserted identities at . Every source value has such a realization. Taking , then reversing , gives both inverse identities on their respective fibres.
For the unbound case, any finite word of admitted transforms, including the empty word, preserves the input context slice. Repeated exactness sends to the value of after that word acts at coordinate . Two words naming the same input transform give the same resulting tuple for every , so give equal output maps on . Hence the output map depends only on the generated transform and respects composition. The empty word leaves every realizing tuple unchanged and induces the identity map. □
Distinct coordinates. Fix admitted edits at distinct coordinates , each a fixed member of its family. For a source , write for the consumers labeled at ; write for the consumer labeled at , and for the consumer labeled at . Labels include the actual context and, when bound, the actual endpoints. The edit itself remains fixed.
Proposition 16 (Commutation with refreshed labels). The two input edits commute on . Their correctly labeled consumers satisfy Both compositions are defined at . If neither edit changes the other’s declared context tuple at , the refreshed labels equal the original labels.
Proof. Each fixed edit determines the new value from its own coordinate alone. Both composite tuples therefore have the same new and entries, with all other entries unchanged. Thus on the total product. Applying Lemma 7 in each order proves the outer equalities and definedness in (9). The other edit does not change a coordinate’s bound baseline, and hence does not change its endpoint under its fixed transform. If its context is also unchanged, every label is the original one. □
Proposition 17 (A common domain for frozen consumers). Suppose and . Fix compatible context labels and a baseline for each bound reading. Let be the joint source stratum defined by those context constraints and those bound baselines. For the originally labeled consumers , with both sides defined on . When both readings are unbound, is an invariant joint context slice and the restricted consumers are commuting endomorphisms of .
Proof. For choose a realizing . Each edit preserves the other’s context by the exclusions, and its baseline when bound because the coordinates differ. The labels in Proposition 16 therefore remain the original ones. That proposition gives definedness and equality at , proving (10). If both readings are unbound, has only context constraints. Both edits preserve these, so . Exactness gives , proving the endomorphism assertion. □
For bound partial maps, the two maximal composition domains in need not coincide; (10) states the equality on the joint compatible source range.
Example 18 (Commuting maps at stale contexts). Let on . Unbound increments of and have respective contexts and , with exact consumers Each relevant slice range is all of , since is free. At , prepare increments from the original contexts. Both maps are , and they commute on . Yet After the edit, the actual context for the edit is . Refreshing it gives The stale consumer accepts the intermediate number , but describes a different context. Context correspondence is stronger than numerical domain acceptance, exactly as used in the composition proofs.
Example 19 (Composition is not addition of differences). Let on . Incrementing either coordinate has empty transform context and induces the exact map on . The two frozen consumers commute, and from their composition gives . Each separately evaluated initial difference is , but adding both to the initial output gives . Thus even valid commuting consumers do not justify merging their initial output differences by addition.
Preparation and application. Independent preparation in Lemma 10 produces values for fixed context tuples. Consumption uses the current output and preparations matching the actual context at each invocation. Frozen labels suffice under Proposition 17; changing labels use Proposition 16. The results justify independent preparation and exact operator composition. Their elapsed-time costs depend on the specified evaluators and execution resources.