Manuscript Offprint
arXiv:2611.09589Dual-Number Associative Arrays for One-Pass Provenance and Sensitivity
Timothy Habashy, Hayden Jananthan, Jeremy Kepner
MIT
Abstract—Associative arrays and GraphBLAS express sparse computations as matrix operations over a chosen semiring, but the result normally contains only the ordinary value. We define a dual-number extension that carries this value together with independent auxiliary channels in the same computation. We prove that the construction is a split square-zero extension of any commutative semiring. Over min-plus, the auxiliary value is the weight of the shortest walk constrained to use the corresponding edge, excluding the weight of that edge. This gives an exact shortest-path membership test for that edge, although ties return the union of the edges on all optimal paths. We implement the min-plus construction using sparse python-graphblas operations, with a fixpoint test that checks the value and auxiliary components together. We validate the implementation across 18,692 checks, including 2,825 tied target pairs. On random graphs with 100,000 vertices and 32 seed edges, the dual method is faster than the sequential algorithm but slower than a min-plus-specific batched method. This difference is largely explained by the dual method requiring as many sweeps. Thus, the main contribution is a general algebraic approach with competitive sparse performance, rather than information that specialized min-plus algorithms cannot already compute.
I. INTRODUCTION
Associative arrays represent spreadsheets, databases, matrices, and graphs as sparse key-labeled arrays whose operations are determined by a chosen value algebra [1]. GraphBLAS applies the same idea to graph algorithms: the sparse matrix structure stays fixed, while addition and multiplication are replaced by semiring operations suited to the problem [2], [3]. This provides a compact and reusable language for sparse computation. However, the result usually does not record which inputs contributed to it or how auxiliary information moved through the computation.
Semiring provenance approaches this problem by annotating inputs and propagating those annotations through a computation [4], [5]. Extensions cover aggregate queries [6], linear algebra operators [7], and graph queries [8]. Matrix query languages have also been connected to positive relational algebra over semiring-annotated relations [9]. In ordinary arithmetic, dual numbers carry a value and its first-order information through one forward computation [10], [11]. Expectation
semirings similarly carry auxiliary statistics alongside the ordinary value [12] and have been studied algebraically as semiring trivial extensions [13]. Newtonian program analysis provides a related differential calculus for semiring polynomials in fixed-point systems [14]. This leads to the question studied here: can the dual-number product rule be extended to any commutative semiring, and when does the auxiliary component have a useful interpretation?
This paper makes four contributions: (1) define as a flat split square-zero extension; (2) interpret its auxiliary components over min-plus; (3) implement a sparse GraphBLAS recurrence with joint convergence and prove termination without reachable negative-weight cycles; and (4) compare sequential and batched min-plus baselines. The batched method recovers the same information at full convergence, but it depends on a min-plus-specific factorization. The dual construction instead uses the same rule for each semiring and works for hop-bounded (restricted to paths containing edges, where is fixed) computations.
For matrices and over , we write matrix multiplication as , with , and use matrix powers to denote repeated matrix multiplication under the ambient semiring operations. Using different choices of semirings changes what the same sparse matrix multiplication computes. For example, the plus-times semiring counts walks, while the tropical semiring computes shortest distances [15].
Throughout the graph sections in this paper, denotes the number of vertices of the graph and denotes a hop budget. A walk from to is a sequence with , , and an edge between adjacent nodes in the walk for every . Its length (hop count) is , and its weight is .
III. THE SQUARE-ZERO EXTENSION
A. The rank-one construction
Let be a commutative semiring. Define , where is a formal symbol that satisfies .
Research was sponsored by the Department of the Air Force Artificial Intelligence Accelerator and was accomplished under Cooperative Agreement Number FA8750-19-2-1000. The views and conclusions contained in this document are those of the authors and should not be interpreted as representing the official policies, either expressed or implied, of the Department of the Air Force or the U.S. Government. The U.S. Government is authorized to reproduce and distribute reprints for Government purposes notwithstanding any copyright notation herein.
Note that can be written in pair-notation as . The operations are thus
\begin{align*}(a,b)\oplus(c,d)&=(a\oplus c,b\oplus d),\ $ a,b)\otimes(c,d)&=(a\otimes c,(a\otimes d)\oplus(b\otimes c)),\end{align*}with and . This is the semiring form of the Nagata idealization , also called an expectation-semiring or trivial-extension construction [11], [13], [16].
Proposition 1. If is a commutative semiring, then is a commutative semiring, and the projection , , realizes it as a split square-zero extension:
Proof. Showing that is a commutative semiring when is a commutative semiring is a sequence of routine calculations that we omit for brevity.
The semiring laws follow directly from those of . The projection is a surjective homomorphism with section . Moreover, is an ideal and , so . Thus the extension is split and square-zero.
Note that the product rule also holds at matrix level. If and , then . Thus, one lifted matrix multiplication computes both the ordinary and auxiliary components.
B. Multiple independent markers
For k markers, construct the S-semimodule and define
Where are formal symbols that satisfy . In pair notation with and as vectors,
\begin{align*}(a,\mathbf{b})\oplus(c,\mathbf{d})&=\left(a\oplus c,\mathbf{b}\oplus\mathbf{d}\right),\ $ a,\mathbf{b})\otimes(c,\mathbf{d})&=\left(a\otimes c,a\otimes\mathbf{d}\oplus c\otimes\mathbf{b}\right),\end{align*}where the operations and scalar action on are componentwise. The value component and every auxiliary coordinate reduce exactly to the scalar calculations in Proposition 1, so the semiring laws hold coordinate-wise. For , , so . Projection to the value component is split by . Also note that the extension must be defined in this flat form; iterating would retain the cross terms .
IV. SEMIRING INSTANTIATIONS
A. Min-plus detour distance
In , the operations are componentwise in the auxiliary vector. Thus, focusing on a fixed channel (), they reduce to , where , and , with and . For seed edge of weight , set its th auxiliary coefficient to ; every unseeded coefficient is .
Let be this dual-number lift of the weighted adjacency matrix. The dual identity has on its diagonal. Then, define
which follows from the idempotency of . The right hand equality of (1) can be proven by induction. We omit for brevity.
Let be the set of walks with at most edges, and let traverses . Define
where every minimum over an empty set is defined as +∞. Write entries of as
Where is the ordinary value and is the coefficient of the component of the s, j dual number entry.
Proposition 2 ( -formula). For every s, j, r, and N,
with the convention .
Proof. We first prove by induction on h that
At , , which represents the unique 0-hop empty walk from a vertex to itself and no 0-hop walk between distinct vertices. Assume (2) holds for . Matrix multiplication gives
Substituting the induction hypothesis and distributing over gives one term for every -hop walk from to followed by the edge . Every -hop walk has one unique penultimate vertex , so these terms account exactly all -hop walks from to . This proves (2).
Now fix a nonempty walk and write the value and th auxiliary components of its th edge as . We prove by induction on that its dual product has value and th auxiliary component
respectively. For , the product is ; the sum over is empty and equals zero, so (3) holds. Assume it holds for . Multiplying by the next edge's weight gives value and auxiliary component
(4) respectively. The first expression in the auxiliary component in (4) is , which is the term of (3). By the induction hypothesis, the second expression is
which contains exactly the terms with . Their minimum is therefore (3) with in place of h, completing the induction.
The value component is . For channel , exactly when the th edge is and is otherwise. If the seeded edge does not occur, every term in (3) is . If it occurs, then for each seeded edge occurrence, , so its finite term is . Thus the walk contributes exactly when it traverses the seeded edge. The empty walk contributes auxiliary value because the dual multiplicative identity is .
Finally, (1) and (2) show that is the componentwise T-sum over all walks in . Taking the minimum of their value components gives the formula for . Taking the minimum of their th auxiliary components gives
The empty constrained set satisfies the same equality under the stated convention .
Corollary 3. If , then lies on some minimum-weight walk of at most -hops .
Assume no negative-weight cycle is reachable from the source. Under this assumption, this becomes ordinary shortest-path membership.
Proof. By Proposition 2, . Since , equals exactly when some minimum-weight walk traverses the seeded edge. Under the cycle assumption, this is ordinary shortest-path membership once .
Essentially, is a detour distance through edge with the weight of removed. If multiple shortest paths have the same weight, the test identifies an edge whenever it lies on at least one of those shortest paths. Thus, it recovers the union of the edges appearing across all tied shortest paths, but idempotency prevents it from distinguishing which path contributed an edge or how many shortest paths contain it. The hop budget is also part of the output semantics. Let denote unrestricted (no hop bound) shortest-path distance, with when no walk exists. Then , because splitting any forced walk at one seeded edge occurrence gives an 'prefix' walk, the seeded edge, and a 'suffix' walk. Equality requires shortest choices for both outer portions and enough hops to concatenate them. Consequently, there can be a window in which the value channel has converged but an auxiliary channel has not.
B. Other semirings
The construction is not limited to min-plus. Over plus-times, each auxiliary channel counts traversals of its seeded edge across all fixed-hop walks. Other possible instances include max-plus for critical-path slack, max-min for bottleneck dependence, Boolean channels for dependency masks, and sum-product for expectation statistics. We do not evaluate these additional cases here. As the min-plus example shows, the auxiliary interpretation and any faster specialized factorization must be derived separately for each semiring.
V. IMPLEMENTATION AND CONVERGENCE
We implement the recurrence in python-graphblas, a Python interface to SuiteSparse:GraphBLAS [3], [17]. The value channel is a sparse vector . The auxiliary channels are packed as a sparse matrix . We merge a value-only zero diagonal into and leave the auxiliary diagonal structurally absent.
For seed edge , define to be if and otherwise. Before the value vector is frozen, one sweep is
Initialize , for , and . Equation (6) is exactly multiplication of the lifted source row by ; hence, after sweeps, the state equals that row multiplied by and has the at-most-t-hop semantics of Proposition 2.
The first product is a sparse vector-matrix multiplication, and the second is a sparse matrix-matrix multiplication. The implementation uses double buffers and an injection loop, with no Python loop over vertices. Once , we freeze and omit later injections. Indeed, and . Since , ; induction therefore shows that later injections cannot improve .
Proposition 4. If one complete sweep leaves both v and E unchanged, every later sweep also leaves them unchanged.
Proof. After is frozen, the recurrence is . Therefore, if one propagation leaves unchanged, every subsequent propagation has the same input and output.
Proposition 5. Assume no negative-weight cycle is reachable from the source. Every value and auxiliary entry reaches its final value by sweep , and the algorithm terminates by sweep .
Proof. Consider a finite walk that repeats a vertex. The segment between two consecutive occurrences of that vertex is a directed cycle reachable from , so its weight is nonnegative. Removing that segment leaves an walk of no greater weight and with fewer edges. Repeating this operation produces a simple walk. Thus every walk has a simple representative of no greater weight. There are only finitely many simple walks, so if is reachable, the least weight among them exists and is also the unrestricted shortest-path weight. A simple walk has at most edges. If is unreachable, its value remains . Hence every value entry is final by sweep .
Now fix seed edge and target . If no walk traverses the seeded edge, the corresponding auxiliary entry remains and is already final. Otherwise, take any forced walk and choose one occurrence of the seeded edge. Its prefix ends at and its suffix begins at , so
where is unrestricted shortest-path distance. Because a forced walk exists, is reachable from through the seeded edge. Thus every cycle in either outer portion is reachable from and has nonnegative weight. The cycle-removal argument above gives a shortest walk and a shortest walk, each with at most edges. Concatenating them with the seeded edge produces a forced walk whose weight equals the right side of (5). Hence it is minimum-weight and uses at most edges.
By Proposition 2, the auxiliary entry at sweep is the minimum over forced walks of at most edges, hence every auxiliary entry is final by sweep . All value entries are also final by then. Sweep cannot lower either component because each already equals its unrestricted minimum, so is unchanged and the joint fixpoint test terminates the algorithm.
VI. EVALUATION
A. Correctness and protocol
We first compared the min-plus implementation with a NetworkX oracle on graphs with unique and tied shortest paths. The suite checked the ordinary value, every detour channel, and the on-path predicate across 18,692 outputs, including 2,825 tied target pairs. All checks agreed. Before timing, we also required exact agreement among the complete distance and detour arrays from all three methods, including the locations of +∞ entries.
We timed three methods: (1) the coupled one-pass dual recurrence; (2) sequential single-source solves, one from s and one from each ; and (3) one batched GraphBLAS solve. At full convergence, the batched baseline uses to recover each forced distance. This gives the batched method access to the same fully converged detour information and provides a demanding min-plus baseline. The factorization is also closely related to conventional shortest-path sensitivity analysis [18].
We generated random directed graphs with positive integer weights from 1 to 10 and average out-degree 8. The k-scaling experiment fixed and used . The -scaling experiment fixed and used 10,000 through 200,000 vertices. Each point is the median of three trials, with first-to-third-quartile error bars. We ran the experiments with Python 3.13.7, python-graphblas 2025.2.0, and 14 GraphBLAS threads on an Apple arm64 system.
B. Results
As shown in Fig. 1, the sequential runtime increased most quickly with k. At k = 32, its median runtime was 0.993 s, compared with 0.302 s for the dual method and 0.207 s for the batched method. On paired trials, the dual method was faster than sequential and slower than batched. It was slower than sequential at k = 2, approximately tied at k = 4, and grew faster as the number of seed channels grew.
The batched method gains its advantage from the min-plus factorization after ordinary distance convergence. The dual recurrence instead propagates complete forced walks, which can be nearly twice as long as ordinary shortest paths. Across the k experiment, remained between approximately 1.50 and 1.58. At k = 32, it was 1.55, close to the 1.50 runtime ratio.
Runtime also grew approximately linearly over the graph sizes in Fig. 2. At and , median runtimes were 0.231 s for dual, 0.491 s for sequential, and 0.126 s for batched. At full convergence, the dual extension neither adds min-plus detour information nor outperforms the specialized batched method. Its contribution is instead a semiring-generic algebraic framework that propagates auxiliary information uniformly across semiring choices while preserving direct -hop semantics, properties that the min-plus-specific full-distance factorization does not provide.
The timing study uses synthetic graphs, three trials per point, and one local system. We therefore do not yet make a hardware-independent scaling claim.
VII. CONCLUSION
We defined as a flat split square-zero extension that carries one ordinary value and independent auxiliary channels through a sparse semiring computation. In min-plus, it gives a forced-through detour distance and an exact shortest-path membership test, with the stated limits under tied paths and finite hop budgets. Under the cycle assumption of Proposition 5, the packed GraphBLAS implementation reaches a jointly confirmed fixpoint by sweep . Though the experiments show a clear tradeoff—as grows, the dual method becomes faster than sequential solves but remains slower than the min-plus-specific batched solver because forced walks require more sweeps—this still exhibits a win for the proposed method since it is not substantially less performant and provides the user a more robust output.
ACKNOWLEDGMENT
The authors wish to acknowledge the following individuals for their contributions and support L. Anderson, W. Arcand, D. Bestor, W. Bergeron, B. Bond, C. Byun, A. Bonn, D. Burrill, V. Gadepally, J. Gottschalk, T. Hardjono, M. Houle, M. Hubbell, M. Jones, P. Luszczek, P. Michaleas, L. Milechin, J. Mullen, C. Leiserson, C. Milner, S. Mohindra, A. Pentland, A. Prout, C. Prothmann, A. Reuther, A. Rosa, D. Rus, D. Ross, J. Ross, M. Sherman, S. Van Broekhoven, M. Weems, J. Wilkinson, C. Yee.

(a)

(b)
Fig. 1. Seed-channel scaling at . (a) Median wall time for the dual, sequential, and batched methods. (b) Paired runtime ratios. A ratio above 1 favors the denominator method. Error bars show the first and third quartiles.

(a)

(b)
Fig. 2. Graph-size and convergence results. (a) Runtime versus actual vertex count at . (b) The dual joint-fixpoint sweep count divided by the batched distance sweep count .
REFERENCES
[1] J. Kepner, J. Chaidez, V. Gadepally, and H. Jansen, "Associative arrays: Unified mathematics for spreadsheets, databases, matrices, and graphs," 2015. [Online]. Available: https://arxiv.org/abs/1501.05709
[2] J. Kepner, H. Meyerhenke, S. McMillan, C. Yang, J. D. Owens, M. Zalewski, T. Mattson, J. Moreira, P. Aaltonen, D. Bader, A. Buluc, F. Franchetti, J. Gilbert, D. Hutchison, M. Kumar, and A. Lumsdaine, "Mathematical foundations of the GraphBLAS," in 2016 IEEE High Performance Extreme Computing Conference, 2016, pp. 1–9.
[3] T. A. Davis, "Algorithm 1000: SuiteSparse:GraphBLAS: Graph algorithms in the language of sparse linear algebra," ACM Transactions on Mathematical Software, vol. 45, no. 4, pp. 1–25, 2019.
[4] T. J. Green, G. Karvounarakis, and V. Tannen, "Provenance semirings," in Proceedings of the Twenty-Sixth ACM SIGMOD-SIGACT-SIGART Symposium on Principles of Database Systems, ser. PODS '07, 2007, pp. 31–40.
[5] T. J. Green and V. Tannen, "The semiring framework for database provenance," in Proceedings of the 36th ACM SIGMOD-SIGACT-SIGART Symposium on Principles of Database Systems, ser. PODS '17, 2017, pp. 93–99.
[6] Y. Amsterdamer, D. Deutch, and V. Tannen, "Provenance for aggregate queries," in Proceedings of the Thirtieth ACM SIGMOD-SIGACT-SIGART Symposium on Principles of Database Systems, ser. PODS '11, 2011, pp. 153–164.
[7] Z. Yan, V. Tannen, and Z. G. Ives, "Fine-grained provenance for linear algebra operators," in Proceedings of the 8th USENIX Conference on Theory and Practice of Provenance, ser. TaPP '16, 2016, pp. 1–6.
[8] Y. Ramusat, S. Maniu, and P. Senellart, "Provenance-based algorithms for rich queries over graph databases," in Proceedings of the 24th
International Conference on Extending Database Technology, 2021, pp. 73–84.
[9] R. Brijder, M. Gyssens, and J. V. den Bussche, "On matrices and K-relations," Annals of Mathematics and Artificial Intelligence, vol. 90, no. 2–3, pp. 181–210, 2022.
[10] P. Hoffmann, "A hitchhiker's guide to automatic differentiation," Numerical Algorithms, vol. 72, no. 3, pp. 775–811, 2016.
[11] B. van den Berg, T. Schrijvers, J. McKinna, and A. Vandenbroucke, "Forward- or reverse-mode automatic differentiation: What's the difference?" Science of Computer Programming, vol. 231, p. 103010, 2024.
[12] Z. Li and J. Eisner, "First- and second-order expectation semirings with applications to minimum-risk training on translation forests," in Proceedings of the 2009 Conference on Empirical Methods in Natural Language Processing, 2009, pp. 40–51.
[13] P. Nasehpour, "Algebraic properties of expectation semirings," Afrika Matematika, vol. 31, no. 5–6, pp. 903–915, 2020.
[14] J. Esparza, S. Kiefer, and M. Luttenberger, "Newtonian program analysis," Journal of the ACM, vol. 57, no. 6, pp. 33:1–33:47, 2010.
[15] M. Mohri, "Semiring frameworks and algorithms for shortest-distance problems," Journal of Automata, Languages and Combinatorics, vol. 7, no. 3, pp. 321–350, 2002.
[16] M. Nagata, Local Rings, ser. Interscience Tracts in Pure and Applied Mathematics. New York: Interscience Publishers, 1962, no. 13.
[17] python-graphblas developers, "python-graphblas documentation," https://python-graphblas.readthedocs.io/, 2025, version 2025.2.0.
[18] R. Ramaswamy, J. B. Orlin, and N. Chakravarti, "Sensitivity analysis for shortest path problems and maximum capacity path problems in undirected graphs," Mathematical Programming, vol. 102, pp. 355–369, 2005.