HOME

TheInfoList



OR:

In
computer science Computer science is the study of computation, information, and automation. Computer science spans Theoretical computer science, theoretical disciplines (such as algorithms, theory of computation, and information theory) to Applied science, ...
, abstract interpretation is a theory of sound approximation of the semantics of computer programs, based on
monotonic function In mathematics, a monotonic function (or monotone function) is a function between ordered sets that preserves or reverses the given order. This concept first arose in calculus, and was later generalized to the more abstract setting of or ...
s over
ordered set In mathematics, especially order theory, a partial order on a set is an arrangement such that, for certain pairs of elements, one precedes the other. The word ''partial'' is used to indicate that not every pair of elements needs to be comparable; ...
s, especially lattices. It can be viewed as a partial
execution Capital punishment, also known as the death penalty and formerly called judicial homicide, is the state-sanctioned killing of a person as punishment for actual or supposed misconduct. The sentence ordering that an offender be punished in ...
of a
computer program A computer program is a sequence or set of instructions in a programming language for a computer to Execution (computing), execute. It is one component of software, which also includes software documentation, documentation and other intangibl ...
which gains information about its semantics (e.g., control-flow,
data-flow In computing, dataflow is a broad concept, which has various meanings depending on the application and context. In the context of software architecture, data flow relates to stream processing or reactive programming. Software architecture Dataf ...
) without performing all the
calculation A calculation is a deliberate mathematical process that transforms a plurality of inputs into a singular or plurality of outputs, known also as a result or results. The term is used in a variety of senses, from the very definite arithmetical ...
s. Its main concrete application is formal
static analysis Static analysis, static projection, or static scoring is a simplified analysis wherein the effect of an immediate change to a system is calculated without regard to the longer-term response of the system to that change. If the short-term effect i ...
, the automatic extraction of information about the possible executions of computer programs; such analyses have two main usages: * inside
compiler In computing, a compiler is a computer program that Translator (computing), translates computer code written in one programming language (the ''source'' language) into another language (the ''target'' language). The name "compiler" is primaril ...
s, to analyse programs to decide whether certain
optimization Mathematical optimization (alternatively spelled ''optimisation'') or mathematical programming is the selection of a best element, with regard to some criteria, from some set of available alternatives. It is generally divided into two subfiel ...
s or transformations are applicable; * for
debugging In engineering, debugging is the process of finding the Root cause analysis, root cause, workarounds, and possible fixes for bug (engineering), bugs. For software, debugging tactics can involve interactive debugging, control flow analysis, Logf ...
or even the certification of programs against classes of bugs. Abstract interpretation was formalized by the French computer scientist working couple Patrick Cousot and
Radhia Cousot Radhia Cousot (6 August 1947 – 1 May 2014) was a French computer scientist known for inventing abstract interpretation. Studies Radhia Cousot was born on 6 August 1947, in Sakiet Sidi Youssef in Tunisia, where she survived the massacre of ...
in the late 1970s.


Intuition

This section illustrates abstract interpretation by means of real-world, non-computing examples. Consider the people in a conference room. Assume a unique identifier for each person in the room, like a
social security number In the United States, a Social Security number (SSN) is a nine-digit number issued to United States nationality law, U.S. citizens, Permanent residence (United States), permanent residents, and temporary (working) residents under section 205(c)(2 ...
in the United States. To prove that someone is not present, all one needs to do is see if their social security number is not on the list. Since two different people cannot have the same number, it is possible to prove or disprove the presence of a participant simply by looking up their number. However it is possible that only the names of attendees were registered. If the name of a person is not found in the list, we may safely conclude that that person was not present; but if it is, we cannot conclude definitely without further inquiries, due to the possibility of
homonym In linguistics, homonyms are words which are either; '' homographs''—words that mean different things, but have the same spelling (regardless of pronunciation), or '' homophones''—words that mean different things, but have the same pronunciat ...
s (for example, two people named John Smith). Note that this imprecise information will still be adequate for most purposes, because homonyms are rare in practice. However, in all rigor, we cannot say for sure that somebody was present in the room; all we can say is that they were ''possibly'' here. If the person we are looking up is a criminal, we will issue an ''alarm''; but there is of course the possibility of issuing a ''false alarm''. Similar phenomena will occur in the analysis of programs. If we are only interested in some specific information, say, "was there a person of age n in the room?", keeping a list of all names and dates of births is unnecessary. We may safely and without loss of precision restrict ourselves to keeping a list of the participants' ages. If this is already too much to handle, we might keep only the age of the youngest, m and oldest person, M. If the question is about an age strictly lower than m or strictly higher than M, then we may safely respond that no such participant was present. Otherwise, we may only be able to say that we do not know. In the case of computing, concrete, precise information is in general not computable within finite time and memory (see Rice's theorem and the
halting problem In computability theory (computer science), computability theory, the halting problem is the problem of determining, from a description of an arbitrary computer program and an input, whether the program will finish running, or continue to run for ...
).
Abstraction Abstraction is a process where general rules and concepts are derived from the use and classifying of specific examples, literal (reality, real or Abstract and concrete, concrete) signifiers, first principles, or other methods. "An abstraction" ...
is used to allow for generalized answers to questions (for example, answering "maybe" to a yes/no question, meaning "yes or no", when we (an algorithm of abstract interpretation) cannot compute the precise answer with certainty); this simplifies the problems, making them amenable to automatic solutions. One crucial requirement is to add enough vagueness so as to make problems manageable while still retaining enough precision for answering the important questions (such as "might the program crash?").


Abstract interpretation of computer programs

Given a programming or specification language, abstract interpretation consists of giving several semantics linked by relations of abstraction. A semantics is a mathematical characterization of a possible behavior of the program. The most precise semantics, describing very closely the actual execution of the program, are called the ''concrete semantics''. For instance, the concrete semantics of an
imperative programming In computer science, imperative programming is a programming paradigm of software that uses Statement (computer science), statements that change a program's state (computer science), state. In much the same way that the imperative mood in natural ...
language may associate to each program the set of execution traces it may produce – an execution trace being a sequence of possible consecutive states of the execution of the program; a state typically consists of the value of the program counter and the memory locations (globals, stack and heap). More abstract semantics are then derived; for instance, one may consider only the set of reachable states in the executions (which amounts to considering the last states in finite traces). The goal of static analysis is to derive a computable semantic interpretation at some point. For instance, one may choose to represent the state of a program manipulating integer variables by forgetting the actual values of the variables and only keeping their signs (+, − or 0). For some elementary operations, such as
multiplication Multiplication is one of the four elementary mathematical operations of arithmetic, with the other ones being addition, subtraction, and division (mathematics), division. The result of a multiplication operation is called a ''Product (mathem ...
, such an abstraction does not lose any precision: to get the sign of a product, it is sufficient to know the sign of the operands. For some other operations, the abstraction may lose precision: for instance, it is impossible to know the sign of a sum whose operands are respectively positive and negative. Sometimes a loss of precision is necessary to make the semantics decidable (see Rice's theorem and the
halting problem In computability theory (computer science), computability theory, the halting problem is the problem of determining, from a description of an arbitrary computer program and an input, whether the program will finish running, or continue to run for ...
). In general, there is a compromise to be made between the precision of the analysis and its decidability (
computability Computability is the ability to solve a problem by an effective procedure. It is a key topic of the field of computability theory within mathematical logic and the theory of computation within computer science. The computability of a problem is c ...
), or tractability (
computational cost A computation is any type of arithmetic or non-arithmetic calculation that is well-defined. Common examples of computation are mathematical equation solving and the execution of computer algorithms. Mechanical or electronic devices (or, historic ...
). In practice the abstractions that are defined are tailored to both the program properties one desires to analyze, and to the set of target programs. The first large scale automated analysis of computer programs with abstract interpretation was motivated by the accident that resulted in the destruction of the first flight of the Ariane 5 rocket in 1996.


Formalization

Let L be an
ordered set In mathematics, especially order theory, a partial order on a set is an arrangement such that, for certain pairs of elements, one precedes the other. The word ''partial'' is used to indicate that not every pair of elements needs to be comparable; ...
, called ''concrete set'', and let L' be another ordered set, called ''abstract set''. These two sets are related to each other by defining
total function In mathematics, a partial function from a set to a set is a function from a subset of (possibly the whole itself) to . The subset , that is, the '' domain'' of viewed as a function, is called the domain of definition or natural domain o ...
s that map elements from one to the other. A function \alpha is called an ''abstraction function'' if it maps an element x in the concrete set L to an element \alpha(x) in the abstract set L'. That is, element \alpha(x) in L' is the ''abstraction'' of x in L. A function \gamma is called a ''concretization function'' if it maps an element x' in the abstract set L' to an element \gamma(x') in the concrete set L. That is, element \gamma(x') in L is a ''concretization'' of x' in L'. Let L_1, L_2, L'_, and L'_2 be ordered sets. The concrete semantics f is a monotonic function from L_1 to L_2. A function f' from L'_ to L'_2 is said to be a ''valid abstraction'' of f if, for all x' in L'_, we have (f \circ \gamma)(x') \leq (\gamma \circ f')(x'). Program semantics are generally described using fixed points in the presence of loops or recursive procedures. Suppose that L is a
complete lattice In mathematics, a complete lattice is a partially ordered set in which all subsets have both a supremum ( join) and an infimum ( meet). A conditionally complete lattice satisfies at least one of these properties for bounded subsets. For compariso ...
and let f be a
monotonic function In mathematics, a monotonic function (or monotone function) is a function between ordered sets that preserves or reverses the given order. This concept first arose in calculus, and was later generalized to the more abstract setting of or ...
from L into L. Then, any x' such that f(x') \leq x' is an abstraction of the least fixed-point of f, which exists, according to the Knaster–Tarski theorem. The difficulty is now to obtain such an x'. If L' is of finite height, or at least verifies the
ascending chain condition In mathematics, the ascending chain condition (ACC) and descending chain condition (DCC) are finiteness properties satisfied by some algebraic structures, most importantly Ideal (ring theory), ideals in certain commutative rings. These conditions p ...
(all ascending sequences are ultimately stationary), then such an x' may be obtained as the stationary limit of the ascending sequence x'_ defined by induction as follows: x'_ = \bot (the least element of L') and x'_ = f'(x'_). In other cases, it is still possible to obtain such an x' through a (pair-) widening operator, defined as a binary operator \nabla\colon L\times L\to L which satisfies the following conditions: # For all x and y, we have x \leq x \mathbin y and y \leq x \mathbin y, and # For any ascending sequence (y'_)_, the sequence defined by x'_ := \bot and x'_ := x'_ \mathbin y'_ is ultimately stationary. We can then take y'_=f'(x'_). In some cases, it is possible to define abstractions using
Galois connection In mathematics, especially in order theory, a Galois connection is a particular correspondence (typically) between two partially ordered sets (posets). Galois connections find applications in various mathematical theories. They generalize the fun ...
s (\alpha, \gamma) where \alpha is from L to L' and \gamma is from L' to L. This supposes the existence of best abstractions, which is not necessarily the case. For instance, if we abstract sets of couples (x, y) of
real number In mathematics, a real number is a number that can be used to measure a continuous one- dimensional quantity such as a duration or temperature. Here, ''continuous'' means that pairs of values can have arbitrarily small differences. Every re ...
s by enclosing convex
polyhedra In geometry, a polyhedron (: polyhedra or polyhedrons; ) is a three-dimensional figure with flat polygonal faces, straight edges and sharp corners or vertices. The term "polyhedron" may refer either to a solid figure or to its boundary su ...
, there is no optimal abstraction to the disc defined by x^2 + y^2 \leq 1.


Examples of abstract domains


Numerical abstract domains

One can assign to each variable x available at a given program point an interval _, H_/math>. A state assigning the value v(x) to variable x will be a concretization of these intervals if, for all x, we have v(x) \in _, H_/math>. From the intervals _, H_/math> and _, H_/math> for variables x and y, respectively, one can easily obtain intervals for x + y (namely, _+L_, H_+H_/math>) and for x - y (namely, _ - H_, H_ - L_/math>); note that these are ''exact'' abstractions, since the set of possible outcomes for, say, x+y, is precisely the interval _+L_, H_+H_/math>. More complex formulas can be derived for multiplication, division, etc., yielding so-called
interval arithmetic Interval arithmetic (also known as interval mathematics; interval analysis or interval computation) is a mathematical technique used to mitigate rounding and measurement errors in mathematical computation by computing function bounds. Numeri ...
s. Let us now consider the following very simple program:
y = x;
z = x - y;
With reasonable arithmetic types, the result for should be zero. But if we do interval arithmetic starting from in
, 1 The comma is a punctuation mark that appears in several variants in different languages. Some typefaces render it as a small line, slightly curved or straight, but inclined from the vertical; others give it the appearance of a miniature fille ...
one gets in ��1, +1 While each of the operations taken individually was exactly abstracted, their composition isn't. The problem is evident: we did not keep track of the equality relationship between and ; actually, this domain of intervals does not take into account any relationships between variables, and is thus a ''non-relational domain''. Non-relational domains tend to be fast and simple to implement, but imprecise. Some examples of ''relational'' numerical abstract domains are: * congruence relations on integers * convex
polyhedra In geometry, a polyhedron (: polyhedra or polyhedrons; ) is a three-dimensional figure with flat polygonal faces, straight edges and sharp corners or vertices. The term "polyhedron" may refer either to a solid figure or to its boundary su ...
(cf. left picture) – with some high computational costs * difference-bound matrices * "octagons" * linear equalities and combinations thereof (such as the reduced product, cf. right picture). When one chooses an abstract domain, one typically has to strike a balance between keeping fine-grained relationships, and high computational costs.


Machine word abstract domains

While high-level languages such as Python or
Haskell Haskell () is a general-purpose, statically typed, purely functional programming language with type inference and lazy evaluation. Designed for teaching, research, and industrial applications, Haskell pioneered several programming language ...
use unbounded integers by default, lower-level programming languages such as C or
assembly language In computing, assembly language (alternatively assembler language or symbolic machine code), often referred to simply as assembly and commonly abbreviated as ASM or asm, is any low-level programming language with a very strong correspondence bet ...
typically operate on finitely-sized machine words, which are more suitably modeled using the integers modulo 2^n (where ''n'' is the bit width of a machine word). There are several abstract domains suitable for various analyses of such variables. The ''bitfield domain'' treats each bit in a machine word separately, i.e., a word of width ''n'' is treated as an array of ''n'' abstract values. The abstract values are taken from the set \, and the abstraction and concretization functions are given by: \gamma(0) = \, \gamma(1) = \, \gamma(\bot) = \, \alpha(\) = 0, \alpha(\) = 1, \alpha(\) = \bot, \alpha(\) = \bot. Bitwise operations on these abstract values are identical with the corresponding logical operations in some three-valued logics: Further domains include the ''signed interval domain'' and the ''unsigned interval domain''. All three of these domains support forwards and backwards abstract operators for common operations such as addition, shifts, xor, and multiplication. These domains can be combined using the reduced product.


See also

*
Model checking In computer science, model checking or property checking is a method for checking whether a finite-state model of a system meets a given specification (also known as correctness). This is typically associated with hardware or software syst ...
* Symbolic simulation *
Symbolic execution In computer science, symbolic execution (also symbolic evaluation or symbex) is a means of analyzing a program to determine what inputs cause each part of a program to execute. An interpreter follows the program, assuming symbolic values for i ...
* List of tools for static code analysis — contains both abstract-interpretation based (sound) and ad hoc (unsound) tools *
Static program analysis In computer science, static program analysis (also known as static analysis or static simulation) is the analysis of computer programs performed without executing them, in contrast with dynamic program analysis, which is performed on programs duri ...
— overview of analysis methods, including, but not restricted to, abstract interpretation *
Interpreter (computing) In computer science, an interpreter is a computer program that directly executes instructions written in a programming or scripting language, without requiring them previously to have been compiled into a machine language program. An interp ...


References


External links


A web-page on Abstract Interpretation maintained by Patrick Cousot

Roberto Bagnara's paper showing how it is possible to implement an abstract-interpretation based static analyzer for a C-like programming language

The Static Analysis Symposiaproceedings
appearing in the Springer
LNCS ''Lecture Notes in Computer Science'' is a series of computer science books published by Springer Science+Business Media since 1973. Overview The series contains proceedings, post-proceedings, monographs, and Festschrifts. In addition, tutorials ...
series * Conference on Verification, Model-Checking, and Abstract Interpretation (VMCAI), affiliated at the POPL conference
proceedings
appearing in the Springer
LNCS ''Lecture Notes in Computer Science'' is a series of computer science books published by Springer Science+Business Media since 1973. Overview The series contains proceedings, post-proceedings, monographs, and Festschrifts. In addition, tutorials ...
series ; Lecture notes
Abstract Interpretation
Patrick Cousot. MIT.


Møller and Schwarzbach's lecture notes on Static Program Analysis

Agostino Cortesi's lecture notes on Program Analysis and Verification

Slides by Grégoire Sutre going through every step of Abstract Interpretation with many examples - also introducing Galois connections
{{Program analysis
Abstract interpretation In computer science, abstract interpretation is a theory of sound approximation of the semantics of computer programs, based on monotonic functions over ordered sets, especially lattices. It can be viewed as a partial execution of a computer pro ...