Algebraic Program Analysis

This paper is a tutorial on algebraic program analysis. It explains the foundations of algebraic program analysis, its strengths and limitations, and gives examples of algebraic program analyses for numerical invariant generation and termination analysis.


Introduction
This tutorial provides an introduction to algebraic program analysis, focusing upon techniques for (numerical) invariant generation and termination analysis. By reading this paper, you will learn the answers to the following questions: The origin of algebraic program analysis is the algebraic approach to solving path problems in graphs [1,6,48,59]: (1) compute a regular expression recognizing a set of paths of interest, and (2) interpret that regular expression within an algebraic structure corresponding to the problem at hand. Various path problems (e.g., computing shortest paths, path-finding problems, and dataflow analysis) can be solved by using different algebraic structures to interpret regular expressions.
In the context of program analysis, the graph of interest is a control flow graph for a program, and the algebra defines a space of summaries (approximations of program behavior) and a means for composing them. The algebraic approach amounts to computing a summary for a program in "bottom-up" fashion, building summaries for larger and larger subprograms by applying the operators of the summary algebra.
The general pattern of an algebraic program analysis is: given a system of (recursive) equations defining the semantics of a program, (1) symbolically compute a closed-form solution, and then (2) interpret the closed form within an algebraic structure corresponding to the analysis. The algebraic approach can be contrasted with classical iterative abstract interpretation, which also starts with a system of (recursive) equations defining the semantics of a program. However, the iterative approach is to (a)  by successive approximation. Thus, the classical approach is one of "interpret and then solve," whereas the algebraic approach is "solve and then interpret." The algebraic approach can be applied to various kinds of equations and algebraic structures. Three cases we consider in this article, and the corresponding kind of program-analysis problems they can be used to solve, are: Section 2 (Non-recursive) program summarization: left-linear equations over regular algebras. Section 4 Linearly-recursive procedure summarization: linear equations over tensor-product domains. Section 5 Conditional termination analysis: right-linear equations over ω-regular algebras.
Why Algebraic Program Analysis? Algebraic program analysis is a general framework for understanding compositional program analyses. The principle of compositionality states that "the meaning of a complex expression is determined by its structure and the meanings of its constituents" [57]. A program analysis is compositional when the result of analyzing a composite program is a function of the results of analyzing its components. Compositionality enables program analyses to scale to large programs, to be parallelized, to be applied incrementally, and to be applied to incomplete programs [18]. Algebraic program analysis provides a structure in which to think about how to design such an analysis. Insistence upon compositionality also demands a different perspective on program analysis, which can suggest solutions to problems that may otherwise not be apparent. We demonstrate this principle with a series of examples that illustrate a variety of different ideas that are enabled by thinking of program analysis in compositional terms.
Last, the algebraic framework enables a style of reasoning about the behavior of program analyses themselves. By exploiting compositionality, it is possible to design effective algebraic analyses that satisfy certain laws (e.g., monotonicity-"more information in yields more information out"). Analyses can be classified on the basis of algebraic laws that they satisfy, and we can reason how program transformation affects analysis using these laws.
Why Not Algebraic Program Analysis? While compositionality brings many desirable properties, it comes at the price of losing context. Compositionality requires that the analysis of a program component is a function of the source code of that component, and therefore cannot depend on the surrounding context in which the component appears in the program. Many program analysis techniques make essential use of context, for example: -In an iterative abstract interpreter, which propagates information about reachable states from the program entry forwards, the analysis of a component depends on every component that may precede it in an execution. -In a refinement-based software model checker, which inspects paths that go from entry to an error state, the analysis of a component depends on the whole program.
One of the main challenges of designing a good algebraic program analysis is to overcome this loss of contextual information. Secondly, algebraic program analysis is less general than iterative program analysis, in the sense that any set of semantic (in)equations can be solved iteratively using the same basic algorithm, whereas each particular type of equation system requires a specialized algorithm. Some problems-e.g., resolving semantic equations of recursive procedures-have no known practical algebraic solutions.

Regular Algebraic Program Analysis
This section describes the algebraic approach to solving path problems in graphs [1,6,48,59]. The basic structure of the method is to use regular expressions to capture the set of paths of a graph, and then interpret these expressions to obtain a desired result. We illustrate the approach by considering the problem of computing shortest paths, and then show how it can be applied to numerical invariant generation.
First, we establish some basic definitions. The syntax of regular expressions over an alphabet Σ is as follows: We will sometimes use juxtaposition R 1 R 2 (rather than R 1 · R 2 ) to denote concatenation.
The semantics of regular expressions over Σ is given by a Σ-interpretation I = A, f , which consists of regular algebra A and a semantic function f . A regular algebra A = A, 0 A , 1 A , + A , · A , * A is an algebraic structure consisting of a set A (called its universe) equipped with two distinguished elements 0 A , 1 A ∈ A, two binary operations + A (choice) and · A (sequencing), and a unary operation (−) * A (iteration). 1 When the algebra is clear from context, we will drop the superscript. A semantic function f : Σ → A maps each letter in Σ to an element of A's universe.
A Σ-interpretation I = A, f assigns to each regular expression R over Σ to an element I R of A by interpreting each letter according to the semantic function and each regular operator using its counterpart in A: Notice that the interpretation is compositional: for any expression R, I R is a function of the top-level operator in R and the interpretations of its subexpressions.

Example 1 (Standard interpretation).
The standard interpretation of regular expressions is the language interpretation, L = L, where L is the regular algebra of languages. The universe of the interpretation is the set of regular languages over Σ, 0 ∅ is the empty language, 1 { } is the singleton language containing the empty word, and the operators are The semantic function maps each letter a to the singleton language {a}. For any regular expression R, L R is the (regular) set of words recognized by R. ⌟ We now describe how non-standard interpretations can be used to solve problems over directed graphs. A directed graph G = V, E consists of a finite set of vertices V and a finite set of directed edges E ⊆ V × V . A path in G is a finite sequence e 1 e 2 . . . e n with e i ∈ E such that for each i, the destination of e i matches the source of e i+1 . A path expression (in G) is a regular expression over the alphabet of edges E that recognizes a set of paths in G. For any pair of vertices u, v ∈ V , there is a path expression PathExp G (u, v) that recognizes exactly the set of paths in G that begin at u and end at v. There are several ways to compute path expressions. The classical method is Kleene's algorithm [44] for computing a regular expression for a finite state automaton (thinking of G as an automaton over the alphabet E with start state u and final state v). For sparse graphs, there are more efficient alternatives to Kleene's algorithm, in particular Tarjan's algorithm [58]. The insight of the algebraic approach to path problems is that these algorithms can be re-used for multiple purposes: first use a path expression algorithm to find a regular expression recognizing a set of paths of interest, and then compute a problem-dependent (non-standard) interpretation of that expression.
Example 2 (Shortest paths). Consider the integer-weighted graph depicted in Fig. 1a. Suppose that we wish to compute the length of the shortest path from a to c. We begin by computing a path expression recognizing all paths from a to c: This path expression can be represented succinctly by the directed acyclic graph (DAG) pictured in Fig. 1b. Define the distance interpretation D where the semantic function maps each edge to its weight, and the algebra's universe consists of the integers along with ±∞, 0 is interpreted as ∞, 1 as 0, and the operators are as follows: The weight of the shortest weighted path from a to c is D PathExp G (a, c) = 1, which can be calculated efficiently by interpreting the path expression DAG "bottom-up" (see gray labels in Fig. 1b). ⌟ Algebraic path-finding can be used to generate invariants by representing a program by a control flow graph, and interpreting path expressions within an algebra of program summaries. A control flow graph (CFG) G = V, E, r, C is a directed graph V, E with a distinguished root (or entry) vertex r ∈ V , and where each edge e ∈ E is labeled by a command C(e); see Fig. 2a for an example. In the remainder of this section, we give examples of interpretations that can be used to generate (numerical) program summaries.

Transition-Formula Interpretations
Fix a finite set of variables, X, representing the variables of a program. A transition formula is a logical formula F (X, X ) whose free variables range over X and a set of "primed copies" X {x : x ∈ X}. For the purposes of this exposition, we further suppose that variables range over integers, and that transition formulas are expressed in the language of linear integer arithmetic. A transition formula can be interpreted as a binary relation → F over states State Z X , where s → F s if and only if F is true when s is used to interpret the un-primed variables and s is used to interpret the primed variables. For example, if F is the transition formula

and s(x) < s(y) .
Suppose that G = V, E, r, C is a control flow graph, where commands range over assignments x := e and assumptions [c], where e is a linear integer term and c is a linear arithmetic formula. (An assumption [c] is a command that does not change the program state, but which can only be executed if the formula c holds.) We define a semantic function tf that maps each control flow edge into the universe of transition formulas by translating the command associated with the edge into logic: We define an algebra of transition formulas as follows: Above and elsewhere, we use positional notation for substitution; e.g., F (X, X ) denotes the formula obtained by replacing all the X symbols with "double primed" symbols in X (and leaving the un-primed X symbols as they are). Intuitively, F * should be interpreted as the reflective transitive closure of F . However, in general it is not possible to compute the reflexive transitive closure of a formula (nor even to represent it as a formula). Hence, we must be content with an over-approximate transitive closure operator. There are many different methods for over-approximating transitive closure, so we speak of the family of algebras of transition formulas, which have the same basic structure and differ only in the interpretation of the iteration operator. In the remainder of this section, we describe a selection of methods for implementing the iteration operator. Disclaimer : for each example, the presentation differs somewhat (sometimes substantially) from the cited source. The examples should be read as "how the cited analysis might be presented in the algebraic framework." [47]). Fix a set of variables X. Say that a transition formula p(X, X ) is

Example 3 (Transitive Predicate Abstraction
Let P be a finite set of candidate reflexive and transitive transition formulas. For example we might choose We can define an iteration operator that over-approximates the reflexive transitive closure of a formula F by the conjunction of the subset of P that is entailed by F : Example 4 (Interval analysis [51]). Let F (X, X ) be a transition formula. An inductive interval invariant for F assigns to each variable x ∈ X a pair of integers for all x ∈ X. Monniaux showed that it is possible to determine optimal inductive interval invariants by posing the inductive-invariance condition symbolically and quantifying over the bounds [51]. Let P = {p x : x ∈ X} and Q {q x : x ∈ X} be sets of fresh variables, which we use to the lower and upper bounds of intervals, respectively. The set of inductive interval invariants for a formula F can be represented by the formula That is, the models of Inv (which assign integers to the lower and upper bound variables P and Q) are in one-to-one correspondence with the interval invariants of F . We may universally quantify over all inductive interval invariants to arrive at the following iteration operator: In contrast to the typical iterative approach with classical widening and narrowing operators, this operator computes a formula that implies all (and therefore most precise) inductive interval invariants. 2 For example, for the loop (while (i = n) do i := i + 1), this method yields the following overapproximation of the reflexive transitive closure of F : If we suppose that i is initially 0 and n is initially 100, then this formula implies the loop invariant that n is equal to 100, and i is in the interval [0, 100]. ⌟ Example 5 (Recurrence analysis [4,27]). Let F (X, X ) be a transition formula, and let x and x denote vectors containing the variables X and X , respectively. A linear recurrence inequation of F is a formula of the form a x ≤ a x + b that is entailed by F . The idea behind recurrence analysis is to extract a set of linear recurrence inequations for a formula, {a i x ≤ a i x + b i } i∈I , and to use the closed form of those recurrences to over-approximate the transitive closure of F : For instance, consider the following loop: The loop exhibits the following recurrences which yields the following transition formula that summarizes the loop: The loop also exhibits other recurrences (such as x ≤ x − 1); however, the three selected recurrences are complete in the sense that all implied recurrences are non-negative linear combinations of these three (e.g., x ≤ x − 1 is obtained by adding 1/2-times the first and second recurrences). Such a complete set of recurrences exists for any transition formula F , which can be computed as follows. First, observe that the set of linear recurrences of F , is closed under non-negative linear combinations (i.e., it is a convex cone). Our goal is to find a (finite) set of generators for Rec(F )-a finite set {(a i , b i )} i∈B such that To compute generators for Rec(F ), we first introduce a fresh set of "difference" variables, {δ x } x∈X and form a formula Thus, a set of generators for Rec(F ) corresponds exactly to a half-space representation for the convex hull of Δ(F ), which can be computed using the algorithm from [27].
The class of linear recurrence inequations considered in this example can be generalized in various ways to yield more powerful invariant generation procedures. In particular, - [27] computes linear recurrences with polynomial closed forms - [42] computes polynomial recurrences with polynomial and complex exponential closed forms. - [41] computes polynomial recurrences with polynomial and rational exponential closed forms. ⌟

Weak Interpretations
Transition formulas are an appealing basis for algebraic program analysis, since all the operators (except the iteration operator) are precise-they simply encode the meaning of the program into logic. The significance of this is that transition formula algebras delay precision loss as long as possible, which helps to overcome loss of contextual information. However, there are algebraic analyses of interest that are defined on weak logical fragments that cannot precisely express union and/or relational composition.
Example 6 (Affine relation analysis [38]). An affine relation is a relation that corresponds to the set of models of a transition formula of the form Ax = Bx+c. Define the algebra of affine transition relations to be the regular algebra where the universe is the set of affine transition relations, 0 is interpreted as the empty relation, 1 is interpreted as the identity relation, + is interpreted as the affine hull of R 1 ∪ R 2 (the smallest affine relation that contains both R 1 and R 2 ), · is interpreted as relational composition, and * is interpreted as the operation that sends any affine relation R to the limit of the sequence Since we have R 0 ⊆ R 1 ⊆ . . . and if any R i+1 properly contains R i the dimension of R i+1 is strictly greater than that of R i , this sequence must stabilize in finite time, so the operation R * is computable. ⌟

Semantic Foundations
This section presents a general view of algebraic program analysis, with the goal of elucidating its underlying principles so that they may be understood outside the setting of graphs and regular expressions. This sets the stage for Sect. 4 and Sect. 5, wherein we will develop program analysis schemes that follow the same general "recipe" that we lay out in this section, but deviate from the instance of this recipe that we saw in Sect. 2. Following the theory of abstract interpretation [22], we begin with a concrete semantics that defines the meaning of a program. The concrete semantics is specified as the least (or greatest) solution to a system of recursive equations. The concrete semantics is not computable-the goal of a program analysis is to approximate it. The way that this is accomplished in an algebraic analysis is by symbolically computing a closed-form solution to the semantic equations (i.e., a non-recursive system of equations whose (unique) solution coincides with the concrete semantics), and then interpreting that closed-form solution in an algebraic structure that approximates the algebra of the concrete semantics.

Semantic Equations
Given a control flow graph G, we can syntactically derive a system of equations E(G)-see Fig. 2. For each vertex v, we introduce a variable X v and an equation (X v = R v ) that relates that variable to the variables for v's predecessors. Notice that this system of equations can be viewed as a (left-)regular grammar, with each non-terminal symbol X v recognizing the set of paths from the root r to the vertex v. This is an instance of the more general concept of a solution to a system of equations over an algebraic structure. A solution to the system of equations f is a function σ that maps each variable to an element of A such that each equation is satisfied: where I σ is the interpretation obtained by extending the semantic function to variables by interpreting them according to σ.
The prototypical concrete semantics of interest in algebraic analysis is the relational semantics. The relational semantics of a program associates to every control flow vertex v a reachability relation R v , which is the set of pairs s, s such that if the program begins at r in state s, then it may reach v with state s . The relational semantics may be obtained as the least solution to the system of semantic equations over the relational interpretation, which is defined as follows. The regular algebra of state relations, R, has binary relations on states as its universe, 0 is interpreted as the empty relation ∅, 1 is interpreted as the identity relation { s, s : s ∈ State}, · is interpreted as relational composition, + as union, and * as reflexive, transitive closure. The relational interpretation R is the interpretation over the regular algebra of state relations where the semantic function maps each command to its associated transition relation; e.g., i := i + 2 is associated with the set of all pairs s, s such that s (i) = s(i) + 1 and s (x) = s(x) for all x = i. The relational semantics of a CFG G is the least solution to E(G) over the relational interpretation.
Having formulated the concrete semantics as the solution to a system of equations, we must now solve the system symbolically. The classical algorithm is a variation of Gaussian elimination, given in Algorithm 1. This algorithm is essentially Kleene's algorithm [44] for computing a regular expression for a  finite state automaton, recast in the language of equations. The front-solving step eliminates variables one-by-one, at each step i producing a system of equation of equations that is equivalent to the original, but in which the variable X i does not appear in the right-hand-side of any equations X j = R j for j ≥ i. The back-solving step eliminates all variable occurrences from right-hand-sides, at each step replacing X i with its closed form R i in each equation X j = R j for j < i. An example illustrating the result of solving the system of equations in Fig. 2b symbolically appears in Fig. 2c. The significant difference to the familiar Gaussian elimination algorithm in linear algebra is the "loop-solving" step, which solves a single recursive equation X i = R i symbolically by re-arranging R i into the form X i A + B and taking BA * to be the solution. The loop-solving step is justified under the relational interpretation, and more generally for any interpretation over a Kleene algebra. 3

Input : Left-linear system of equations, E
Algorithm 1: Gaussian elimination for left-linear systems of equations Definition 1. Let A = A, +, ·, * , 0, 1 be a regular algebra. We say that A is an idempotent semiring if it satisfies the following (for all a, b, c, ∈ A): In any idempotent semiring, we may define a natural order ≤, where a ≤ b iff a + b = b. Note that + is the least upper bound with respect to this order. We say that A is a Kleene algebra if it is an idempotent semiring and the following hold (for all a, x ∈ A): Exercise 1. Show that in any Kleene algebra, the least solution to a (left-)linear recursive equation X = a + Xb exists and is equal to ab * The sense in which Gaussian elimination computes a "closed-form solutions" to a system of left-linear equations E is that: -(closed form) the right-hand sides do not refer to variables, and -(solution) for any interpretation I over a Kleene algebra, for each equation The connection between Gaussian elimination and graph algorithms like Floyd-Warshall inspired Tarjan's path-expression algorithm [58]. In the language of graphs, Tarjan's algorithm computes for each vertex v of a control flow graph G with root r a path expression PathExp G (r, v) that recognizes the set of paths from r to v; in the language of equations, it solves left-linear systems of equations symbolically. Tarjan's algorithm is preferred to Gaussian elimination in practice: is more efficient (nearly linear time for reducible flow graphs, compared to cubic time for Gaussian elimination) and produces simpler solutions. For expository purposes, we will continue to refer to Gaussian elimination for solving systems of equations, viewing Tarjan's method as an efficient variation.

Abstract Interpretation
Gaussian elimination can solve a system of left-linear equations over a Kleene algebra (e.g., relational semantics) symbolically. However, the solution cannot be interpreted in the concrete algebra, since operators are not effective (that is, they cannot be implemented by a machine). We approximate the concrete semantics by interpreting the closed-form solution in an effective abstract algebra (e.g., one of the transition-formula algebras from Sect. 2).
Following the theory of abstract interpretation [22], the correctness of this approach is justified by establishing a relationship between the "concrete" and "abstract" interpretations. In the algebraic framework, a natural way to express the relationship is via a soundness relation [24], which is a binary relation between two algebras that is preserved by the operations of the algebra. Membership of a (concrete, abstract) pair in the relation indicates that the concrete element is approximated by the abstract element.

Definition 2 (Soundness relation). Given two Σ-interpretations
f (a) for all a ∈ Σ and is a sub-algebra of the product algebra A × A ; i.e., 0 0 , 1 1 , and for all x 1 y 1 and x 2 y 2 we have The definition of soundness relation generalizes to interpretations over other classes of algebraic structures in the natural way: it is a binary relation over two algebras of the same signature that is preserved by every operation in the signature.

Example 7 (Transition formula overapproximation).
Let R denote the algebra of state relations and TF denote an algebra of transition formulas. The overapproximation relation is defined by Preservation of constants and the sequencing and choice operations is easily verified; to show that O is a soundness relation, we need only to show that i.e., (−) * TF over-approximates reflexive transitive closure. Of course, this proof depends on the particular implementation of the iteration operator.
The over-approximate soundness relation allows us to verify safety properties: if R O F and F entails some property P , then R satisfies P . ⌟

Example 8 (Transition formula underapproximation). The under-approximation relation is defined by
Preservation of constants and the sequencing and choice operations is again easily verified; to show that U is a soundness relation, we need only to show that i.e., (−) * TF under-approximates reflexive transitive closure. The iteration operators in Sect. 2 are all over-approximate. An example of an under-approximate iteration operator is (for some fixed choice of n) which corresponds to bounded model checking [9], with an unrolling bound of n.
The under-approximate soundness relation allows us to refute safety properties: if R U F and F does not entail some property P , then R does not satisfy P . ⌟ The problem of "approximating the behavior of a program" can be formalized as follows: Given a system of semantic equations over a set of variables X describing the concrete semantics of a program (i.e., its least solution σ over some interpretation I ), find some σ : X → A such that for each variable X ∈ X , we have σ (X) σ (X).
The algebraic approach to this problem is to compute for each variable X a closed form R X (such that σ (X) = I (R X )), and define σ (X) I (R X ). The correctness of this approach is justified by the following soundness lemma, which follows by induction on regular expressions.

Lemma 1 (Soundness).
Let Σ be an alphabet, let I = A , f and I = A , f be Σ-interpretations, and let ⊆ A × A be a soundness relation. Then for any regular expression R ∈ RegExp(Σ), we have I R I R

Discussion
A subtlety of algebraic program analysis is that most algebras of interest in program analysis are not Kleene algebras (for instance, none of the algebras in Sect. 2 are), and so in general, Gaussian elimination does not find solutions to systems of equations over "abstract" interpretations corresponding to program analyses. This technical difficulty is sidestepped by appealing to the concrete semantics (which typically is defined over a Kleene algebra, such as the algebra of state relations) to justify the use of path-expression algorithms, and a sound approximating algebra to interpret the resulting expressions. The fact that the abstract interpretation of the closed-form solution to the concrete system of equations does not yield a solution to the abstract system of equations is immaterial: our goal is to overapproximate the concrete rather than solve the abstract. Formalizing a program analysis as an algebraic structure allows one to understand the behavior of program analyses in terms of algebraic laws, and use the language of algebra to reason about program analyses. For example, any transition formula algebra (in the family described in Sect. 2.1) is an idempotent semiring, and so any two * -free regular expressions that denote the same language have the same (up to logical equivalence) interpretation as a transition formula. While none of the iteration operators in Sect. 2.1 satisfy the Unfolding and Induction laws of Kleene algebra, they do satisfy weaker pre-Kleene algebra iteration laws: Monotonicity For any n, (a n ) * ≤ a * Unrolling A concrete use-case for these laws appears in [25], which develops regular expression transformation techniques that preserve concrete semantics but are guaranteed to produce (non-strictly) more precise abstract semantics. Such laws can also be useful for users of program analysis tools. For example, since all operations are monotone (as a consequence of the monotonicity and idempotent-semiring laws), a user can rely on the principle that "more information in yields more information out." If a user alters a program P by adding additional assume commands to get a program P (e.g., expressing invariants that are found by some other automated invariant generation technique, user-provided hints, etc.), monotonicity means that they may rely on the fact that the analysis will produce summaries for P that are at least as precise as those for P .
A Recipe for Algebraic Program Analysis. We conclude this section by presenting a general view of algebraic program analysis, abstracted from the language of graphs and regular expressions: 1. (Modeling) Express the concrete semantics as the least (or greatest) solution to a system of recursive equations (e.g., relational semantics as the least solution to the left-linear system of equations corresponding to a control flow graph).

(Closed forms)
Design a suitable language of "closed-form solutions" and an algorithm for computing them (e.g., regular expressions and path-expression algorithms).

(Interpretation)
Design an abstract interpretation of the language of closed forms and a soundness relation connecting the concrete and abstract interpretations (e.g., transition-formula algebras (Sect. 2.1) and the over-approximate soundness relation (Ex. 7)).
Section 4 and Sect. 5 give two more instances of this generic recipe, generalizing beyond left-linear equations and regular-expressions as closed forms. Section 4 considers linear equations (and an appropriate language of closed forms); Sect. 5 considers another form of equation with ω-regular expressions as closed forms.

Interprocedural Analysis
Algebraic program analyses are oriented around computing summaries for program fragments, and are naturally suited to analyzing programs with procedures. Following Cousot & Cousot [23] and Sharir & Pnueli [56], the idea is to structure the analysis in two phases: Phase I: compute for each procedure X a summary that approximates the behavior of X (including the actions of all procedures called transitively from X). Phase II: analyze whole-program paths from the start of the main procedure, using the summaries to interpret procedure calls.
An example of a program with procedures is given in Fig. 3(a). The CFGs for its procedures are shown in Fig. 3(b) along with a set of equations corresponding to the CFGs (Fig. 3(c)). For Phase I, it is also useful to consider the following equations in which we have eliminated all variables except for those of the form X s,x , which represent the procedure summaries.
This system of equations can be obtained either by a process of successively eliminating variables from Fig. 3(c), or they can be read off directly from each control-flow graph: sequential composition corresponds to ·, and branching corresponds to +.
We can also construct a graph of the dependencies among the variables in the equation system. In this case, we would have (which is also isomorphic to the program's call graph). Note that the equations in Eq. (1) are not left-linear. However, by eliminating variables in a topological order of Eq. (2), these systems can still be solved using Gaussian elimination (Algorithm 1).
Unfortunately, this strategy breaks down for programs with recursive procedures: the essential difficulty is in computing the summaries of procedures that are directly recursive or part of a set of mutually recursive procedures. We will return to this issue shortly, after a brief discussion of Phase II, which can be addressed via algebraic program analysis, regardless of whether the original equation system contains recursion.  With closed-form solutions for the procedure summaries in hand, Phase II can be addressed with Gaussian elimination. (Note that for a program with recursive procedures, the transformed Phase II system is still recursive. However, it is left-recursive, and so can be handled with regular expressions, and analyzed using the transition-formula interpretations of Sect. 2-the "loops" in Phase II correspond to sequences of recursive calls). Figure 4 shows the equation system used for Phase II for the program from Fig. 3 in graphical form. The graph is similar to Fig. 3(b) with (i) additional edges from each call-site to the start node of the called procedure, and (ii) the edges previously labeled with "X 2 " and "X 3 " are now labeled with the values from Eq. (3) for the corresponding procedure summaries: s 3 , x 3 · s 3 , x 3 and s 3 , x 3 , respectively.
The remainder of this section focuses on Phase I: computing procedure summaries. Consider the two-procedure program shown in Fig. 5(a). CFGs for its procedures are shown in Fig. 5(b) along with a set of recursive equations corresponding to the interprocedural CFG. Unfortunately, equations like those in Fig. 5(c) do not fit naturally with the recipe given in Sect. 3.3. The essential difficulty is with item 3.3: "Design a suitable language of 'closed-form solutions' and an algorithm for computing them." In particular, we cannot use regular expressions and path-expression algorithms because the equations in Fig. 5(c) are not left-linear (and they cannot be put in left-linear form).
Two ideas are involved in using algebraic program analysis to summarize recursive procedures:

Motivation: Newtonian Program Analysis
To motivate why we are interested in the special case of linear equations (Sect. 4.2), this section provides a brief overview of how linear equations arise in NPA. Let E = {X i = R i } n i=1 be a system of equations, and fix an interpretation I over some algebra A. Define a function f : A n → A n by f (σ) = (I σ R 1 , . . . , I σ R n ) (i.e., the n-tuple of interpreted right-hand-sides, where variables are interpreted according to σ). NPA is an iterative method for program analysis that solves the following sequence of problems for ν: where Y (i) is the value of Y in the least solution of Thus, NPA is similar to Kleene iteration, except that on each iteration, f (ν (i) ) is "corrected" by an amount controlled by LinearCorrectionTerm(E, ν (i) , Y)-a function of f , the current approximation ν (i) , and (vector) variable Y-which nudges the next approximation ν (i+1) in the right direction at each step. The linear correction term is the result of replacing each right-hand side  Fig. 5(c) that is obtained by eliminating all variables except X s1,x1 , X s2,b , X s2,x2 : The transformation results in the following system (for brevity, we denote Note that the two underlined summands are both truly linear : they are linear, but not left-linear nor right-linear. The process of solving Eqs. (4) and (5) for ν (i+1) , given ν (i) , is called one Newton round. On the initial Newton round, we set ν obtained on round i, and then set ν Operationally, the linearization transformation imposes a particular protocol for sampling the program's space of behaviors. For instance, in Fig. 5(b), the procedure X 2 has two call-sites along the loop through b. In Eq. (7), each right-hand-side summand in the equation for Y 2 has at most one variable: the transformation inserted ν 2 or ν 3 at various call-sites (considering X s2,b as a pseudo-call-site corresponding to tail recursion), and left at most one variable Y i in each summand. In essence, during a given Newton round, the analyzer samples the behavior of f by taking the + of various paths through the transformation of f . Along each path through a (transformed) right-hand side, the summary for each pseudo-call-site X i encountered is held fixed at ν i , except for possibly one pseudo-call-site on the path, which is explored by visiting (the linearized version of) the called procedure. The summaries ν 1 , ν 2 , ν 3 are updated according to the result of this exploration, and the algorithm performs the next Newton round.
The analogy between NPA and Newton's method in numerical analysis is that in both cases one creates a linear approximation of f (X) around the "point" (ν (i) , f (ν (i) )); the solution of the linear system is the next approximation of X.

Algebraic Program Analysis for Linear Equations
In this section, we instantiate the recipe for algebraic program analysis from Sect. 3.3 to solve a system of linear equations, such as the linearized problems that arise as Eq. (5) [53]. This goal may seem out of reach because item 3.3 of the recipe requires us to "design a suitable language of 'closed-form solutions' and an algorithm for computing them." What is a suitable language of closed-form solutions of linear equations? Clearly the regular expressions and path-expression algorithms used in Sect. 2 and Sect. 3 will not do, because the least solution under the language interpretation to the (truly) linear equation X = aXb + 1 is a i b i : i ≥ 0 , which is the canonical example of a linear-context-free language that is not regular. However, over fifty years ago, formal-language theorists established that linear-contextfree languages have certain similarities to regular languages [17,34,61], and we can make use of this property to design a language of closed forms for linear equations. Intuitively, a i b i : i ≥ 0 can be obtained by (i) introducing paired alphabet symbols, such as (a, b), (ii) defining concatenation of paired symbols as (a, b) · (c, d) def = (ca, bd), (iii) defining Kleene-star in the natural way over pairedsymbol concatenation, so (a, b) * is the language of paired words (a i , b i ) : i ≥ 0 , and (iv) applying an operation that concatenates the left word and right word of each paired word: For the purpose of algebraic program analysis, this idea can be formalized by introducing tensored regular expressions over an alphabet Σ, whose syntax is defined as follows: 4 We can now follow the pattern of Sect. 2, and define algebras suitable for interpreting tensored regular expressions.

Definition 3. A tensor-product algebra T = A, T, ⊗,
consists of two regular algebras A and T along with an operation ⊗ : A × A → T , called tensor product, and an operation : T → A, called detensor.

Example 9 (Standard interpretation).
The standard interpretation from Example 1 can be extended to tensored regular expressions by defining a universe of languages over word pairs ("tensored words") T = 2 Σ * ×Σ * , whose operators are given by: Note that this interpretation allows tensored regular expressions to be used to capture linear context-free languages. For instance, the equation X = aXb + 1, whose least solution is a i b i : i ≥ 0 can be written in closed form as X = ((a ⊗ b) ) , and the equation X = aXa + bXb + 1, whose least solution is the language of even-length palindromes over {a, b}, can be written as X = (((a ⊗ a) ⊕ (b ⊗ b)) ) . ⌟

Example 10 (Relational interpretation).
The relational interpretation can be extended to tensored regular expressions by defining an algebra of binary statepair relations, as follows. 5 The universe is the set of relations on State × State (i.e., an element of the universe is a subset of State × State × State × State).
Comparing with the standard interpretation, (in which an element p 1 , p 2 consists of a "backwards path" p and a "forwards continuation") we may think of an element s 1 s 2 , s 1 s 2 of a state-pair relation as consisting of two pre/post state pairs: a "backwards" pair s 1 * ← s 1 and a "forwards" pair s 2 → * s 2 . In the algebra of state-pair relations, 0 is interpreted as the empty relation, 1 as the identity relation, and + as union. The remaining operators are given by: Note that the tensored sequencing operation is just a form of relational composition (over tuples of stacked elements); similarly, tensored iteration is a form of reflexive transitive closure. ⌟

Example 11 (Transition-formula interpretation).
Transition formulas can be used to interpret tensored regular expression in a way analogous to the relational interpretation (as one should expect, because there must be a soundness relation between them!). A tensored transition formula T is a formula over four vocabularies, representing the value of the variables before and after a pair of computations. The tensor and detensor operations are essentially the same as those from the relational interpretation, translated into logic: In the Eq. (9), the vocabularies X 1 , X 1 , X 2 , and X 2 track the original role of the respective vocabulary in F 1 or F 2 . The "stacked" notation is intended to be suggestive of an interpretation of a tensored transition formula over a doubled vocabulary, where the variables are X 1 ∪ X 2 and their "primed copies" are X 1 ∪ X 2 . To make the connection with Sect. 2.1 more apparent, we shall define W 1 = X 1 , W 2 = X 2 , W 1 = X 1 , W 2 = X 2 . With this notation, the product operation can be defined as: As with the relational interpretation, the product operation is just a form of relational composition (over tuples of stacked elements).
Remarkably, the algebra of tensored transition formulas is the same as the algebra of untensored transition formulas, just over an extended set of variables. In particular, the iteration operators from Sect. 3 can be used to implement . For instance, consider the recursive procedure foo(): if (*) then a := a + 1; foo(); b := b + 1 The path to the recursive call of foo and the path from the recursive call to exit can be modeled by the transition formulas F and G, respectively: A procedure summary for foo can be calculated by evaluating ((F ⊗G) ) , using recurrence analysis (Example 5) to implement the operator: We now show how to compute closed forms for linear equations. First, we perform a regularizing transformation, which takes a system of linear equations E Lin and converts it into a system of left-linear equations E LeftLin . The transformation takes each right-hand-side term of the form a · Y · b and converts it to Z (a ⊗ b), where Y and Z are variables whose values are elements of the regular algebras A and T of a tensor-product algebra A, T, ⊗, .
where Z i and Z j are variables that take on values from T.
For instance, if the regularizing transformation is applied to the linear system of equations in Fig. 6a, the result is the system of equations Fig. 6b. Because Fig. 6b is left-linear, we can now use the approach from Sect. 2 and Sect. 3-that is, create a closed-form solution for each variable Z i by finding a path expression for the variable in the graph Fig. 6c. Finally, one gives a closed-form solution for each variable Y i for the linear equation system in Fig. 6a by applying (−) to each path expression-see Fig. 6d. This algorithm for computing closed-form solutions to linear equations is justified in the tensored-relational interpretation, and more generally, in any interpretation whose algebra forms what we dub a Kronecker algebra, defined as follows:

Definition 5. A Kronecker algebra Kr
is a tensor-product algebra that consists of two Kleene algebras A, +, ·, * , 0, 1 and T, ⊕, , , 0, 1 such that (i) the natural order forms a complete lattice (i.e., both algebras have all infinite sums), and (ii) the following properties hold: for all a 1 , a 2 , b 1 We assume that all distributivity properties of A and T , as well as item 5, hold for infinite sums. In particular, for item 5, we have

Discussion
The Instantiation of the Recipe. Returning to the recipe from Sect. 3.3, what we have done for a system of linear equations E Lin is to instantiate the recipe as follows: 1. (Modeling). The concrete semantics is the least solution of E Lin interpreted in relational semantics. 2. (Closed forms). Each variable of E Lin is expressed as the detensor ((−) ) of a tensored regular expression. Closed forms are computed from the closedforms of the left-linear system of equations τ Reg (E Lin ) that results from the regularizing transformation (e.g., see Fig. 6).

(Interpretation).
Tensored regular expressions can be interpreted as tensored transition formulas (Example 11), which are simply transition formulas over a "doubled" vocabulary.
Two Lessons. We would like to mention two lessons that we learned while working on this material over the years.
1. For the problems that arise in NPA, we must solve an equation system that is truly linear, not left-linear or right-linear. A reasonable sanity check might go as follows: -Algebraic program analysisà la Sect. 2 solves a left-linear (or right-linear) system of equations using methods based on regular expressions. -NPA repeatedly creates a system of linear equations that needs to be solved. Such linear equations are related to linear context-free languages, such as the language {a i b i }, which is not regular. -Ergo, it is a non-starter to attempt to apply algebraic program analysis to the equations that arise on each round of NPA. However, as shown in this section, it was possible to side-step this fundamental mismatch, by extending algebraic program analysis to systems of linear equations using Kronecker algebras, which have additional operations, such as tensor product and detensor. Thus, beyond the technical details, perhaps a more important takeaway is "be careful how you apply sanity checks." There is a risk that a plausible-sounding sanity check could cause you to discard an idea that is worth pursuing. 2. In some sense, the solution using Kronecker algebras goes against the grain of what computer scientists typically preach, namely, create appropriate abstractions (in the sense of abstract data-types) for a problem at hand, and then program your solution, thinking of the chosen abstractions as the operations of an abstract machine. This style of thinking is considered central to managing complexity in computer science, and it is generally considered heresy to break an abstraction. For algebraic program analysis, the abstraction is regular algebra, used with interpretations that are abstractions (in the sense of abstract interpretation [22]) of a program's concrete transition relations. However, the introduction of tensor product and detensor breaks that abstraction! To understand what we mean, consider the definition of F · G for transition relations in Boolean programs, i.e., and the definitions of F ⊗ G and T , 6 namely, The product operation F · G has three distinct steps: (i) conjoin F (W, X) and G(Y, Z); (ii) conjoin the equality X = Y ; and (iii) project out vocabularies X and Y . In essence, tensor product and detensor break the abstraction of · as an indivisible operation: · is decomposed into two more-granular operations, ⊗ and . By performing F ⊗ G, we perform just the first step of ·, and only later, when is performed, do we "finish up" by applying the second and third steps of ·. The advantage is that we can operate on tensored values for some number of steps before "finishing" some earlier ·. Again, beyond the technical details, the takeaway may be the process that we went through, which may be of value as a conceptual tool in other contexts: -The insight on how to break the abstraction-both as presented here and as occurred during our research seven or eight years ago-came from thinking about one specific interpretation of Kleene algebra: transition relations for Boolean programs. -The algebraic properties of the new, finer-granularity operations allowed us to abstract out a new algebra, dubbed in this paper Kronecker algebra. -The ideas could now be applied in other contexts by finding other interpretations of Kronecker algebra (or, because we are interested in program analysis, by finding interpretations that over-approximate Kronecker algebra).

Termination Analysis
This section describes how algebraic program analysis can be applied to termination analysis, based on the approach of [63]. The goal of termination analysis is to prove that a program has no infinite executions. Our high-level strategy is to exploit compositionality: we prove that a loop terminates by first computing a summary (e.g., a transition formula) for its body, and then finding a termination argument for the summary. Following Sect. 3, we first formalize a concrete semantics as the (greatest) solution of a system of semantic equations. An appropriate notion of concrete semantics for termination analysis is the set of non-terminating states of the program (from which there exists an infinite execution)-the program terminates exactly when none of the program's initial states belong to this set. As in Sect. 3, this system of equations can be derived syntactically from a program's control flow graph-see Fig. 7 for an example. The non-terminating states of the program are the greatest solution to this system of equations over the algebra where the universe is the set of states, is interpreted as union (a state is non-terminating if it has at least one infinite execution) and is interpreted as preimage (a state is non-terminating iff it can reach a non-terminating state). 7 A suitable language of "closed-form solutions" for the system of equations that arise in termination analysis is ω-regular expressions. The syntax of ωregular expressions over an alphabet Σ is as follows: The semantics of a (ω)-regular expressions is given by an interpretation over an ω-algebra and a regular algebra.

Example 12 (Standard interpretation).
In the standard interpretation of ωregular expressions, the universe consists of sets of infinite sequences over the alphabet Σ, and the operations are For example, an ω-regular expression that recognizes all infinite paths in Fig. 7a starting at r is: , a a, b b, c ( c, d d, e e, c ) , a a, b b, c ( c, d d, e e, c ) Tarjan's path expression algorithm can be adapted to compute an ω-regular expression that recognizes the set of infinite paths in a graph beginning at a particular node [63]. The equational view of this algorithm is that it computes closed-form solutions to right-linear equations over Büchi algebras (e.g., the algebra of non-terminating states).

Definition 7 (Büchi algebra).
A Büchi algebra is an ω-algebra over a Kleene algebra satisfying the following: Left-distributivity Exercise 2. Show that in any Büchi algebra, the greatest solution to the equation X = (a X) z exists and is equal to X = a ω (a * z).
Summarizing: we have modeled a program's non-terminating states as the greatest solution to a system of semantic equations, devised a language of "closed form solutions", and identified an algorithm for computing closed form solutions to the equations. It remains only to develop abstract interpretations of the language of closed forms which implements termination analysis.

Non-terminating State-Formula Interpretations
Just as transition formulas (over variables X and X ) can be used to represent state relations, state formulas (over the variables X) can be used to represent sets of (non-terminating) states. We can extend an algebra of transition formulas to an algebra of non-terminating state formulas by defining Intuitively, the ω operator should compute the set of non-terminating states of a transition formula. Analogously to the * operator in Sect. 2, this set is uncomputable, and we must be satisfied with an over-approximation (i.e., we aim to compute a state formula that contains all non-terminating states-the soundness relation of interest is the one defined by N S ⇐⇒ ∀s ∈ N.s |= S).
There are many ways of doing this, so we speak of the family of non-terminating state formula interpretations. In the remainder of this section, we give examples of ω-operators.
Example 14 (Linear-lexicographic ranking functions [32]). Let F (X, X ) be a transition formula. A linear lexicographic ranking function (LLRF) for F is a sequence of linear terms t 1 , . . . , t n over X such that for any states s and s such that s → F s , each t i evaluates to a non-negative integer in s, and the integer n-tuple decreases in lexicographic order going from s to s . Since there are no infinite strictly descending chains of non-negative n-tuples of integers with respect to the lexicographic order, if F has an LLRF, then F has no nonterminating states. For example, the inner loop of Fig. 7 has a 1-dimensional LLRF k , and the outer loop has a 2-dimensional LLRF n − i, j . The problem of determining whether a linear integer arithmetic formula has an LLRF is decidable [32]. If a formula does not have an LLRF, then we can use a coarse over-approximation of the non-terminating states of a formula (e.g., the set of states that have at least one outgoing transition). This yields the following interpretation of the ω operator: Fig. 7, using recurrence analysis to implement the * operator (Example 5), we get that every non-terminating state must satisfy false-the program terminates from any initial state. ⌟ Example 15 (Unbounded trajectories [63]). Let F (X, X ) be a transition formula. A necessary (but not sufficient) condition for a state s to be a non-terminating for a transition formula F is that there is a computation of F starting from s for every possible length. This condition is undecidable, but it can be approximated using an approximate transitive-closure operator such as the ones in Sect. 2.1. Suppose that (−) * is an over-approximate transitive-closure operator. Letting k and k be symbols that do not appear in F , we can create a transition formula exp(F ) in one parameter k such that for any k , if there exists a sequence s 1 → F s 2 → F · · · → F s k , then s 1 → exp(F ) s k : The states s for which there exists a computation s → exp(F ) s → s for all choices of the parameter k over-approximates the set of non-terminating states of F : For example, if * is instantiated to recurrence analysis (Example 5), then on the transition formula Additional examples of termination analyses in the algebraic framework appear in [63] and [62].

The Instantiation of the Recipe
The recipe from Sect. 3.3 is instantiated for termination analysis as follows: 1. (Modeling). The concrete semantics is the set of non-terminating states, which is the greatest solution to a system of right-linear equations. 2. (Closed forms). The language of closed-forms is given by ω-regular expressions; they can be computed by a variation of Tarjan's algorithm [63].

(Interpretation).
An ω-regular expression can be interpreted as a state formula representing a set of possibly non-terminating states, while regular expressions are interpreted as transition formulas (Sect. 2). The soundness relation is over-approximate: we can prove that a program terminates by finding an unsatisfiable pre-condition, but the analysis cannot prove non-termination.

Recap
This section contains a few remarks about commonalities among the three kinds of problems and the techniques we have presented for applying algebraic program analysis to them. The paper has been structured around the three-part recipe for algebraic program analysis given in Sect. 3.3. Table 1 recaps how the recipe has been instantiated for the three kinds of problems considered. Within this paper, all methods for computing closed-form solutions can be understood as some variation of Gaussian elimination, Algorithm 1 (in practice, they are variations of Tarjan's path-expression algorithm). The essential difference between Sect. 2, Sect. 4, and Sect. 5 is the "loop-solving" step. Each requires the right-hand-side expression R to be in a particular form (left-linear, linear, right-linear), and each requires a different language of expressions in which to express closed forms (regular, tensored regular, ω-regular). Table 2 shows the respective "loop-solving" steps for computing a closed form. Note that in Table 2, the letters a, b i , c i , z range over expressions (which may involve variables other than X). For example, to apply the left-linear rule to the equation X = Xp + Xq + Y r + Z, we first re-arrange terms on the right-hand side as X(p + q) + (Y r + Z) and then compute the "closed-form" (Y r + Z)(p + q) * .

Related Work
Abstracting States Versus State Changes. Classically, invariant generation is conceived as the problem of over-approximating the reachable states of a program. Computing invariants involves solving a system of equations of the form  (11) for the unknowns X[n], n ∈ Nodes, where v r represents the set of initial states and I − provides an interpretation of each CFG edge as a state transformer.
In a solution, X[n] holds a descriptor that represents a superset of the set of program states that can arise at program point n. Note that in Eq. (11), the function I e m,n on edge e m,n is applied to the value X[m] on node m. Algebraic program analyses, in contrast, concern dynamics-state changesrather than states. The reason is that algebraic analyses are compositional: states do not compose, but state changes do.
A first step towards abstracting state changes was taken by Graham & Wegman [33], who gave a method to solve dataflow equations via composition of the state transformers on CFG edges. That is, their basic primitives were (i) composition of functions, and (ii) union of functions. If we adopt this outlook and define r 1 · r 2 to be r 2 • r 1 , r 1 + r 2 to be the union of r 1 and r 2 , and 1 to be the identity function, instead of Eq. (11), the goal would be to solve the following equation system: r ∈ Nodes, the root node where the unknowns X[n] are now function-valued. Note that the function I e m,n on edge e m,n is composed with the value X[m] on node m. From herebecause one is working over function-valued quantities-it is now natural to formulate interprocedural program-analysis problems by means of equations over unknowns that denote procedure summaries, as was done by Cousot and Cousot [23] and Sharir and Pnueli [56].
"Interpret, Then Solve" Versus "Solve, Then Interpret." The systems in Eqs. (11) and (12) are interpreted, in the sense that they are understood as semantic equations valued over a particular abstract domain, say D. Such a system E = {X i = R i } i∈I can be solved by an iterative method: compute a sequence σ 0 , σ 1 , · · · ∈ {X i } i∈I → D of assignments abstract domain values to variables σ 0 (X i ) 0 for all i ∈ I σ n+1 (X i ) I σn R i for all n ≥ 0 and all i ∈ I Eventually this process converges-typically with the aid of widening to extrapolate to the limit-upon an assignment that over-approximates the least solution to E.
In algebraic program analysis, we think of a system of equations as an uninterpreted (syntactic) object. Equations are solved symbolically and then the solutions are interpreted in an algebraic structure to obtain an analysis result. The key step in this direction was made by Tarjan [59], who observed that once a solution to the path-expression problem was in hand, multiple dataflowanalysis problems could be solved merely by reinterpreting the alphabet symbols and operators of regular expressions in different algebras-i.e., "solve and then interpret." Whereas the iterative framework for program analysis has a "built-in" algorithm for analyzing loops and recursive behavior (by computing the limit of a sequence), the algebraic framework does not prescribe any particular method, and it is up to the analysis designer to devise one. This obligation places an additional burden on the analysis designer, but also provides flexibility: the analysis designer may analyze loops in ways that may (Example 6) or may not (Examples 5 and 4) resemble iterative fixpoint computation.

Iteration Operators and Loop Summarization.
In the computer-aided-verification community, there is a body of literature on loop summarization (or "loop leaping") and acceleration. Summarization aims to compute or approximate the behavior of (certain) loops, while acceleration aims to approximate the postimage of a set of states under a loop. These techniques have been incorporated into iterative abstract interpretation [28,31], abstraction-refinement-based software model checking [19,37], termination analysis [7,20,60], and resource bound analysis [10,64]. The most closely related techniques to algebraic program analysis are those that build summaries for whole programs in "bottom-up" fashion. Such analyses have been formalized in various ways, including: recursion on the abstract syntax tree (AST) of a program [51], AST rewriting [8], and graph rewriting [47,60]. Algebraic program analysis provides a unifying foundation for such analyses, in the same way that dataflow analysis [39] and (iterative) abstract interpretation [22] provide a unifying foundation for iterative program analyses.
There are several methods for loop summarization, based on finite-monoid affine transformations [11,12,29], difference-bound relations [15,21], octagonal relations [13,14,45], integer vector addition systems [35], fragments of the theory of arrays [2]. For the most part, these summarization methods are non-uniform in the sense that their input language differs from their output language (e.g., [13] takes as input an octagonal relation and produces as output a Presburger formula). This non-uniformity is the essential barrier that must be overcome to use such techniques to implement the iteration operator of an algebraic program analysis (e.g., we can define an iteration operator by using optimization modulo theories [55] to extract the octagonal hull of a Presburger formula, then use [13] to compute a Presburger formula representing its transitive closure).
Elimination-Based Dataflow Analysis. Elimination-based dataflow analysis is a family of dataflow analyses that computes analysis results using methods that resemble Gaussian elimination [3,33,36] (see [54] for a survey). Early methods were specialized to reducible control flow graphs, but operated faster than general Gaussian elimination. Tarjan's algorithm [58] is an elimination method with fast operation on reducible (and "nearly reducible") control flow graphs, but is applicable to arbitrary graphs.
Weighted Graphs. There is a vast literature on solving path problems on weighted graphs where the weights are drawn from a semiring [1,30,50]. Path problems can also be solved on semiring-weighted pushdown systems, which has applications to interprocedural dataflow analysis [52]. This work focuses on iterative techniques for solving path problems.

Open Problems
We conclude with a list of challenges suggested by algebraic program analysis.
Scaling SMT-Based Algebraic Program Analysis. The bottom-up interpretation step of a closed-form expression is efficient, in that it operates in linear time and space in the size of the expression DAG in a model where each algebraic operation has unit cost. For logic-based interpretations, however, algebraic operations do not have unit cost: operators manipulate formulas, and the size of those formulas may grow as operators are applied. For example, the regular expression a 2 n can be represented by an expression DAG with n+1 nodes, with the following shape: . . . a If the letter a is interpreted as the transition formula x = x + 1 and · as relational composition, then the transition-formula interpretation of a 2 n has size O(2 n ). Scaling SMT-based algebraic program analysis to large programs requires techniques for generating succinct summaries, and/or efficient reasoning about compact formula representations involving λ-expressions.
Recursive Procedures. Section 4.2 shows how the algebraic approach can be applied to summarize linearly recursive procedures. But to compute summaries for generally recursive procedures, current-generation algebraic-programanalysis tools fall back on another non-algebraic scheme (such as hybrid iterative/algebraic, like Kleene or Newton iteration [40,53], or the template-based approach of [16]). This raises the question: is there a practical algebraic method for analyzing general recursion? The essential challenge is in devising a language of "closed forms" that (1) can represent arbitrary context-free languages, and (2) is amenable to an effective interpretation in logic.
Beyond Numerical Domains. To date, all algebraic program analyses have been numerical in nature-they abstract away aspects of program behavior that cannot be captured by integer variables. It remains to be seen whether the algebraic approach can yield practical analyses for reasoning about features like strings, arrays, and the heap. Reasoning about memory manipulation is particularly challenging in a compositional setting, since we cannot rely on the context of a program fragment to resolve aliasing relationships. One possible avenue is to incorporate abductive reasoning to make educated guesses about the shape of memory, as in [18].
Property Refutation. Algebraic program analysis is typically conceived as a method for generating over-approximate summaries. The nature of overapproximation is that the summaries can be used to verify that a program does satisfy a property of interest, but not prove that it doesn't. An interesting direction for future work is to devise methods by which algebraic program analyses can refute properties, perhaps based on bounded model checking [9], under-approximate loop summarization [46], or symbolic execution [43].