Abstract
This paper addresses the problem of abstracting a set of affine transformers \(\overrightarrow{v}' = \overrightarrow{v} \cdot C + \overrightarrow{d}\), where \(\overrightarrow{v}\) and \(\overrightarrow{v}'\) represent the pre-state and post-state, respectively. We introduce a framework to harness any base abstract domain \(\mathcal {B}\) in an abstract domain of affine transformations. Abstract domains are usually used to define constraints on the variables of a program. In this paper, however, abstract domain \(\mathcal {B}\) is re-purposed to constrain the elements of C and \(\overrightarrow{d}\)—thereby defining a set of affine transformers on program states. This framework facilitates intra- and interprocedural analyses to obtain function and loop summaries, as well as to prove program assertions.
Similar content being viewed by others
Notes
k of the coefficients are always 0, and one coefficient is always 1 (i.e., the first column is always \((1\vert \ 0\ 0\ ...\ 0)^t\)). For this reason, we really need only \(k+k^2\) elements, but we will sometimes refer to \((k+1)^2\) elements for brevity.
We will continue to refer to the \({\text {MOS}}\) domain directly, rather than “the instantiation of Observation 2 with an \({\text {AG}}\) element containing \((k+1)^2\) columns” (à la Example 3.1).
The abstract domain \(\mathcal {I}_{\mathbb {Z}_{2^w}}^{(k+1)^2}\) is the product domain of \((k+1)^2\) interval domains, that is, \(\mathcal {I}_{\mathbb {Z}_{2^w}}^{(k+1)^2}= \mathcal {I}_{\mathbb {Z}_{2^w}}\times \mathcal {I}_{\mathbb {Z}_{2^w}}\times \ldots \times \mathcal {I}_{\mathbb {Z}_{2^w}}\). \(\mathcal {I}_{\mathbb {Z}_{2^w}}^{(k+1)^2}\) uses smash product to maintain a canonical representation for \(\bot _{{\text {ATA}}\left[ \mathcal {I}_{\mathbb {Z}_{2^w}}^{(k+1)^2}\right] }\). Thus, if any of the coefficients in an abstract-domain element \(b\in {\text {ATA}}\left[ \mathcal {I}_{\mathbb {Z}_{2^w}}^{(k+1)^2}\right] \) is \(\bot _{\mathcal {I}_{\mathbb {Z}_{2^w}}}\), then b is smashed to \(\bot _{{\text {ATA}}\left[ \mathcal {I}_{\mathbb {Z}_{2^w}}^{(k+1)^2}\right] }\).
References
Chen L, Miné A, Wang J, Cousot P (2009) Interval polyhedra: an abstract domain to infer interval linear relationships. In: SAS
Cousot P, Cousot R (1976) Static determination of dynamic properties of programs. In: Proceedings of the 2nd international symposium on programming, Paris
Cousot P, Cousot R (1977) Abstract interpretation: a unified lattice model for static analysis of programs by construction of approximation of fixed points. In: POPL, pp 238–252
Cousot P, Cousot R (1979) Systematic design of program analysis frameworks. In: POPL
Cousot P, Halbwachs N (1978) Automatic discovery of linear constraints among variables of a program. In: POPL
Elder M, Lim J, Sharma T, Andersen T, Reps T (2014) Abstract domains of affine relations. In: TOPLAS
Gange G, Navas J, Schachte P, Søndergaard H, Stuckey P (2013) Abstract interpretation over non-lattice abstract domains. In: SAS
Goubault E, Putot S, Védrine F (2012) Modular static analysis with zonotopes. In: CAV
Jeannet B, Gopan D, Reps T (2005) A relational abstraction for functions. In: SAS
Jones N, Mycroft A (1986) Data flow analysis of applicative programs using minimal function graphs. In: POPL, pp 296–306
Kidd N, Lal A, Reps T (2007) WALi: the weighted automaton library. www.cs.wisc.edu/wpis/wpds/download.php
King A, Søndergaard H (2010) Automatic abstraction for congruences. In: VMCAI
Knoop J, Steffen B (1992) The interprocedural coincidence theorem. In: CC
Lal A, Reps T, Balakrishnan G (2005) Extended weighted pushdown systems. In: CAV
Lattner C, Adve V (2004) LLVM: a compilation framework for lifelong program analysis and transformation. In: International symposium on code generation and optimization
Lim J, Reps T (2008) A system for generating static analyzers for machine instructions. In: CC
Lim J, Reps T (2013) TSL: a system for generating abstract interpreters and its application to machine-code analysis. TOPLAS 35(1):841–847
LLVM: Low level virtual machine. Llvm.org
Malmkjær K (1993) Abstract interpretation of partial-evaluation algorithms. PhD thesis, Department of Computing and Information Sciences, Kansas State University, Manhattan
Miné A (2001) The octagon abstract domain. In: WCRE
Miné A (2002) A few graph-based relational numerical abstract domains. In: SAS
Müller-Olm M, Seidl H (2004) Precise interprocedural analysis through linear algebra. In: POPL
Müller-Olm M, Seidl H (2007) Analysis of modular arithmetic. TOPLAS 29(5):29
Mycroft A, Jones N (1986) A relational framework for abstract interpretation. In: Programs as data objects. Springer, Berlin, Heidelberg. https://link.springer.com/chapter/10.1007/3-540-16446-4_9
Nielson F (1989) Two-level semantics and abstract interpretation. Theor Comput Sci 69:117–242
Reps T, Balakrishnan G, Lim J (2006) Intermediate-representation recovery from low-level code. In: Partial evaluation and semantics-based program manipulation
Reps T, Sagiv M, Yorsh G (2004) Symbolic implementation of the best transformer. In: VMCAI
Reps T, Schwoon S, Jha S, Melski D (2005) Weighted pushdown systems and their application to interprocedural dataflow analysis. SCP 58(1–2):206–263
Sankaranarayanan S, Sipma H, Manna Z (2005) Scalable analysis of linear systems using mathematical programming. In: VMCAI
Schmidt D (1986) Denotational semantics. Allyn and Bacon Inc., Boston
Sen R, Srikant Y (2007) Executable analysis using abstract interpretation with circular linear progressions. In: MEMOCODE
Sharir M, Pnueli A (1981) Two approaches to interprocedural data flow analysis. In: Muchnick SS, Jones ND (eds) Program flow analysis: theory and applications. Prentice-Hall, Englewood Cliffs, NJ
Sharma T, Reps T (2017) Sound bit-precise numerical domains. In: VMCAI
Simon A, King A (2007) Taming the wrapping of integer arithmetic. In: SAS
Thakur A, Elder M, Reps T (2012) Bilateral algorithms for symbolic abstraction. In: SAS
Warren H Jr (2003) Hacker’s delight. Addison-Wesley, Reading
Author information
Authors and Affiliations
Corresponding author
Additional information
Supported, in part, by a gift from Rajiv and Ritu Batra; DARPA MUSE award FA8750-14-2-0270 and DARPA STAC award FA8750-15-C-0082; and by the UW-Madison Office of the Vice Chancellor for Research and Graduate Education with funding from the Wisconsin Alumni Research Foundation. Any opinions, findings, and conclusions or recommendations expressed in this publication are those of the authors, and do not necessarily reflect the views of the sponsoring agencies.
T. Reps has an ownership interest in GrammaTech, Inc., which has licensed elements of the technology discussed in this publication.
Appendices
Soundness of the abstract-domain operations
In this section, we show that the abstract-domain operations for the \({\text {ATA}}[\mathcal {B}]\) framework are sound with respect to the concrete semantics of the programming language.
Lemma A.1
The bottom element represents the empty set.
Proof
\(\square \)
Lemma A.2
The equality operation is sound.
Proof
We will prove Lemma A.2 by contradiction. Assume that \(a_1 \widetilde{==} a_2\) but \(\gamma (a_1) \ne \gamma (a_2)\). Without loss of generality, we can assume that there exists \((\overrightarrow{v}, \overrightarrow{v}')\) such that:
\(\square \)
Lemma A.3
The join operation is sound.
Proof
Assume that Lemma A.3 is incorrect. Then there exists \((\overrightarrow{v}, \overrightarrow{v}')\notin \gamma (a_1 \tilde{\sqcup } a_2)\) such that:
\(\square \)
The soundness of widening, statement abstractions, and identity function are easy to prove, and follow similar reasoning.
Soundness of abstract composition
In this section, we show that the abstract-composition operations defined in Sect. 4.2 are sound. From Eq. (2), an exact abstract composition \(C_e=\gamma (a' \circ a)\) is defined as follows:
1.1 Non-relational base domain
In this section, we show that the fast abstract composition for \({\text {ATA}}[\mathcal {B}]\) (Eq. (4)), when \(\mathcal {B}\) is non-relational, is sound. Remember that any non-relational domain can be formulated as follows: \(\mathcal {B}\ {\mathop {=}\limits ^{def}}\ symbols(C:\overrightarrow{d}) \rightarrow \mathcal {F}_{\mathcal {B}}\). The term b[s], where \(b\in \mathcal {B}\) and \(s\in symbols(C:\overrightarrow{d})\), refers to the element in the foundation domain \(f\in \mathcal {F}_{\mathcal {B}}\) corresponding to the symbol s.
Axiom 1
Abstract addition is sound for \(\mathcal {F}_{\mathcal {B}}\); i.e.,
Axiom 2
Abstract multiplication is sound for \(\mathcal {F}_{\mathcal {B}}\); i.e.,
Theorem B.1
(Soundness of \(\circ _{{\text {NR}}}\))
Proof
We will prove Theorem B.1 by contradiction. Consider a model \(m=(\overrightarrow{v}, \overrightarrow{v}'')\), such that \(m \in C_e\) and \(m \notin \gamma (a' \circ _{{\text {NR}}} a)\). We will show that such a model cannot exists.
\(\square \)
1.2 Weakly-convex base domain
In this subsection, we present a proof of soundness of abstract composition for weakly-convex base domains, denoted by \(a' \circ _{{\text {WC}}} a\) (Eq. (7)).
We present some useful axioms and lemmas before presenting the soundness theorem and its proof. Let \(min_{\mathbb {Z}_{2^w}}\) and \(max_{\mathbb {Z}_{2^w}}\) be the minimum and maximum bitvector values in \(\mathbb {Z}_{2^w}\). Let \(min_\mathbb {Q}= min_{\mathbb {Z}_{2^w}}\) and \(max_\mathbb {Q}= max_{\mathbb {Z}_{2^w}}\).
Axiom 3
\(cast_{\mathbb {Q}}\) is distributive over bitvector addition in the absence of overflows: that is, if \(min_\mathbb {Q}\le cast_{\mathbb {Q}}(bv_1)+cast_{\mathbb {Q}}(bv_2)\le max_\mathbb {Q}\), where \(bv_1, bv_2 \in \mathbb {Z}_{2^w}\), then
Axiom 4
\(cast_{\mathbb {Q}}\) is distributive over bitvector multiplication in the absence of overflows: that is, if \(min_\mathbb {Q}\le cast_{\mathbb {Q}}(bv_1)\cdot cast_{\mathbb {Q}}(bv_2)\le max_\mathbb {Q}\), where \(bv_1, bv_2 \in \mathbb {Z}_{2^w}\), then
Lemma B.1
\(cast_{\mathbb {Q}}\) is distributive over matrix multiplication for bitvectors, if there are no overflows in the matrix multiplication. That is, for \(n\times n\) matrices M and \(M'\) where \(\forall _{1\le i,j\le n} M[i,j], M'[i,j] \in \mathbb {Z}_{2^w}\),
Proof
Let \(M'' = cast_{\mathbb {Q}}(M) \times cast_{\mathbb {Q}}(M')\). Then,
\(\square \)
Lemma B.2
A convex combination of a set of rationals is inside bitvector boundaries if each of the rational values in the set is inside bitvector boundaries. Given any \(0\le \lambda _1, \lambda _2, \dots , \lambda _l\le 1\), such that \((\mathop {\sum }\nolimits _{i=1}^{l} \lambda _i=1)\).
Proof
Suppose \(min_{\mathbb {Q}} > \mathop {\sum }\nolimits _{i=1}^{l} \lambda _i q_i\).
Consequently, \(min_{\mathbb {Q}} \le \mathop {\sum }\nolimits _{i=1}^{l} \lambda _i q_i\). The other inequality \(\mathop {\sum }\nolimits _{i=1}^{l} \lambda _i q_i\le max_{\mathbb {Q}}\) can be proved in a similar fashion. \(\square \)
Lemma B.3
There are no overflows in a matrix multiplication of a convex combination of matrices, if there are no overflows in the matrix multiplications of the underlying matrices involved in the convex combination.
and,
Proof
Because \((t_i \times t_j')\) does not overflow, we know that each entry in the computation of the matrix multiplication does not overflow:
where \(t_i\) and \(t_j'\) are \(o\times o\) matrices.
Suppose that \(l'' = l\cdot l'\) and . Then, \(\overset{l''}{\underset{m=1}{\Sigma }} \lambda _m'' = \mathop {\sum }\nolimits _{i=1}^{l'} \lambda _i \cdot \mathop {\sum }\nolimits _{j=1}^{l'} \lambda _j' = 1\cdot 1 = 1\). Then, by applying Lemma B.2 to Eq. (26), we get for all \(1\le p,q\le o\):
Hence \((t \times t')\) does not overflow. \(\square \)
Theorem B.2
(Soundness of \(\circ _{{\text {WC}}}\))
Proof
Consider any model \(m=(\overrightarrow{v}, \overrightarrow{v}'')\), such that \(m \in C_e\). To prove Theorem B.2, we need to show that \(m \in \gamma (a' \circ _{{\text {WC}}} a)\). Equation (7) defines \(a'' = a' \circ _{{\text {WC}}} a\) as follows
We know that for \(m=(\overrightarrow{v},\overrightarrow{v}')\),
By the properties of weakly-convex domains (see Sect. 4.2.4), we know that
To show that \(m \in \gamma (a' \circ _{{\text {WC}}} a)\), we consider two cases.
Overflows in matrix multiplication. If there is an overflow encountered in any matrix multiplication \(t_i \times t_j'\), then \(base(a'') = \top _{\mathcal {B}}\) and consequently, \(m \in \gamma (a' \circ _{{\text {WC}}} a)\) is true trivially.
No overflows in matrix multiplication. If there is no overflow encountered in any of the matrix multiplications \(t_i \times t_j'\), then it suffices to prove that
Equation (32) translates to proving that for some \(\{\lambda _1'', \lambda _2'',\ldots , \lambda _{l''}''\}\):
where , and \(\overset{l''}{\underset{m=1}{\Sigma }} \lambda _m'' = \mathop {\sum }\nolimits _{i=1}^{l'} \lambda _i \cdot \mathop {\sum }\nolimits _{j=1}^{l'} \lambda _j' = 1\cdot 1 = 1\).
Soundness of merge functions
In this section, we show that the merge operation defined in Sect. 4.4 is sound. Recall that the merge function is defined as:
As mentioned in (9), the exact merge-function semantics are specified as follows:
Theorem C.1
Soundness of the merge function
Proof
We will prove Theorem 4.3 by contradiction. Consider a model \(m=(\overrightarrow{g_m},\overrightarrow{l_m};\overrightarrow{g_m}',\overrightarrow{l_m}')\), such that \(m \in {\textsc {Merge}}(\gamma (a), \gamma (a'))\) and \(m \notin \gamma (\textit{Merge}(a, a'))\). Let \(a_{RevLocs}\in {\text {ATA}}[\mathcal {B}]\) be an abstract domain value such that
By the soundness of abstract composition, existence of m implies existence of \(n=(\overrightarrow{g_n},\overrightarrow{l_n};\overrightarrow{g_n}',\overrightarrow{l_n}')\), such that \(n\in {\textsc {RevertLocals}}(\gamma (a'))\) and \(n \notin \gamma (a_{RevLocs})\). We will show that n cannot exist. Consequently, m cannot exist, and thus merge is sound.
If the abstract meet is exact, then the implication in the fourth-from-last step of the proof becomes an if and only if (\({\Leftrightarrow }\)). Furthermore, if the abstract-composition operation is exact, then the implication in the last step of the proof becomes an if and only if (\({\Leftrightarrow }\)). Thus, if abstract meet and abstract composition are exact, the merge operation is exact.
Rights and permissions
About this article
Cite this article
Sharma, T., Reps, T. A new abstraction framework for affine transformers. Form Methods Syst Des 54, 110–143 (2019). https://doi.org/10.1007/s10703-018-0325-z
Published:
Issue Date:
DOI: https://doi.org/10.1007/s10703-018-0325-z