Definitioncore
Symbolic execution tree
Also called execution tree.
The tree of all paths of symbolic execution of a program, with a node per statement and a path condition per branch.
The symbolic execution tree of a program is the tree of all its feasible paths: the root is the start of the program, each node is a point reached by some input together with the path condition of the way there, and a node has two children where both sides of a branch are feasible. It is the object that symbolic execution explores, and that concolic testing and generational search explore one run at a time. It differs from the control flow graph in two ways: it unfolds every join and every loop, so it can be exponentially larger or infinite, and it drops the branches that no input takes.
Definition
Take a program in the toy IR with parameters and input symbols . A symbolic state is a triple : a block label , a symbolic store from names to expressions over the symbols, and a path condition . The symbolic execution tree is the rooted tree defined as follows.
- The root is , where is the entry block and .
- Let be a node. Run the instructions of on , as in the definition of the path condition, and add the implicit condition of each instruction that can trap. Call the result and .
- Let be the path condition just before an instruction that can trap, with the implicit condition . If is satisfiable, then has a trap leaf child with this condition.
- If ends in
ret a, has one return leaf child with the condition . - If ends in
jump L, has one child . - If ends in
br a L1 L2, let . The node has the child if this condition is satisfiable, and the child if that one is satisfiable.
- Each edge is labeled with the condition that it adds.
A branch where both sides are feasible is a forking node, as King calls it. A branch where implies one side is non-forking: it has one child and it adds a condition that changes no set of inputs. King's tree has one node per statement. The tree above has one node per block visit. The two trees have the same leaves and the same forks, and one is the other with chains of straight-line steps contracted.
Basic facts. Write for the set of inputs that satisfy the path condition of .
- Every node is reached by some input, because each node has a satisfiable path condition. Every input follows exactly one path from the root, and the children of a node split into disjoint parts. The page symbolic execution proves this partition property.
- So, for a program whose runs all end, the leaves of are in one-to-one correspondence with the feasible complete paths, and the sets of the leaves partition the input space .
- A node has at most children, where is the largest number of instructions that can trap in one block: one trap leaf per such instruction, and one or two other children.
Finiteness. The tree is finite if and only if there is a number such that every run of visits at most blocks.
Proof. Suppose there is such an . A block node at depth has a satisfiable path condition, so some input follows the path to , and its run visits at least blocks. So . A leaf is a child of a block node, so its depth is at most . A tree of depth at most in which each node has at most children has at most nodes, so it is finite. Conversely, suppose the tree is finite with height . By the partition property, the run of each input visits the blocks of one path from the root, and that path stays in the tree. So the run visits at most blocks; in particular it ends.
The condition "every run ends" is weaker than "the tree is finite". By the infinity lemma (König's lemma), an infinite tree in which each node has finitely many children has an infinite path from the root. Each finite prefix of that path is feasible, but no single input may follow the whole path. The loop example below shows this.
Decidability. For the toy IR over unbounded integers, whether is finite is undecidable. Take a two-counter machine, which is a register machine with two counters, and translate it into a toy IR program that ignores its parameters. Each test of a counter is a branch on known values, so it is non-forking, and is a single chain that copies the run of the machine. The tree is finite exactly when the machine halts, and the halting problem for two-counter machines is undecidable. Even the one-child case needs a solver when the branches are on symbols: deciding whether a node has a given child is the feasibility of a path condition, which is decidable only in decidable theories (see path condition).
Examples and non-examples
A join with an infeasible combination. The parameter is , with the symbol .
entry:
t = x < 5
br t a b
a:
y = x + 1
jump join
b:
y = x - 1
jump join
join:
u = 10 < y
br u c d
c:
ret 1
d:
ret 0
The CFG has 6 blocks, 6 edges and 4 complete paths. The tree has these nodes, written by block, with the store of and the path condition:
entry, . Forking: both and are satisfiable.a, . One child.join, , . Non-forking: is unsatisfiable, so only the side todexists.d, , which is . Return leaf.
b, . One child.join, , . Forking.c, , which is . Return leaf.d, , which is . Return leaf.
The tree has 3 leaves, one for each feasible path. The block join appears twice, with two different stores: the tree copies the code after a join once per incoming path. The three leaf conditions , and split the integers into three parts. For in to , they hold for 35, 7 and 19 values.
Exponential size. Put tests one after another, each on its own parameter: t1 = x1 < 0; br t1 ... with both arms joining before the next test. The CFG has blocks. Every combination of sides is feasible, so the tree has leaves and forking nodes. This is the path explosion problem in its simplest form.
An infinite tree in which every run ends. The parameter is , with the symbol .
entry:
i = 0
jump head
head:
t = i < n
br t body exit
body:
i = i + 1
jump head
exit:
ret i
The -th visit of head has and the path condition , so both sides are feasible and the node forks: the exit side gives a leaf with (or for ), and the body side goes on. The tree has infinitely many leaves and one infinite path, the path that always enters the body. Each prefix of the infinite path is followed by large values of , but no integer satisfies for all . So every run ends, and the tree is still infinite. This agrees with the finiteness criterion: the run on visits blocks for , and that number has no bound. Tools cut such a tree at a depth bound and give up any claim about the part below it.
Non-examples.
- The control flow graph. The CFG has one node per block and shares the code after a join. It has paths that no input takes, such as entry, a, join, c above. The tree has neither property.
- The tree of one run. A concolic tool records the path of one concrete run with its path condition. That is one root-to-leaf path of the tree, not the tree. The tree is the union of all such paths, which the tool never stores in full.
- A merged state graph. A tool that merges the two
joinstates into one state with the store and the path condition true builds a directed acyclic graph, not a tree. It has fewer nodes and harder formulas. See path explosion for state merging.
Related definitions
- Path condition. The label of a node is a path condition, and the leaves are the feasible complete paths.
- Execution tree in testing tools. Concolic testing explores this tree by depth-first search, one run per leaf. Generational search explores it by expanding all branches of a run at once.
- Unrolled formula. Bounded model checking encodes the tree up to a depth as one formula, with one copy of each variable per step, instead of one formula per leaf.
- Computation tree. In model checking, the computation tree of a transition system unfolds the concrete states, one tree per start state. The symbolic execution tree is one tree for all inputs, with sets of inputs at the nodes.
References
- James C. King, Symbolic execution and program testing, Communications of the ACM 19(7), 1976, pp. 385 to 394, the section on the execution tree (forking and non-forking IF statements, the properties of the tree)
- Roberto Baldoni, Emilio Coppa, Daniele Cono D'Elia, Camil Demetrescu and Irene Finocchi, A survey of symbolic execution techniques, ACM Computing Surveys 51(3), 2018, Article 50, Section 1 (the symbolic execution tree of the running example) and Section 2 (the symbolic execution engine and its states)
- Cristian Cadar and Koushik Sen, Symbolic execution for software testing, three decades later, Communications of the ACM 56(2), 2013, pp. 82 to 90, the section on classical symbolic execution and its execution tree
- Donald E. Knuth, The Art of Computer Programming, Volume 1, third edition, Section 2.3.4.3 (the infinity lemma)
Where this leads
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H0 no proof |
|
| Lean | L0 no Lean part |
|
| Visual | V0 none |
|
| Writing | W4 complete |
|
Tag 6MEYWW Edit this page History Report an error Markdown