The present invention relates to symbolic model checking generally and to symbolic model checking for software in particular.
Modern design of very large-scale integrated circuits and of complex software systems often involves years of research and the efforts of hundreds of engineers. Automated formal verification methods may be an essential part of the design effort, reducing errors, lost time and risk to financial investment. Formal verification involves building a finite model of a system as a group of states and state transitions and checking that a desired property holds in the model. An exhaustive search of all possible states of the model may be performed in order to verify a desired property.
As the size and complexity of designs increase, much effort may be expended to improve the efficiency of automated formal verification methods. One technique used in symbolic model checking to improve efficiency is to employ binary decision diagrams (BDDs). A BDD is a directed acyclic graph that represents a Boolean expression.
Boolean operations performed on a BDD are a polynomial function of the size of the BDD. While BDDs are generally a compact representation of a Boolean expression, they can be exponential in the size of the expression they are representing. In addition, the size of the BDD is significantly affected by the order in which the variables of the expression are listed.
One method for symbolic model checking using BDDs comes from Carnegie Mellon University and is known as the Symbolic Model Verifier (SMV). A good discussion of symbolic model checking may be found in the introduction to the online paper “NuSMV: a new symbolic model checker” by A. Cimatti et al., which can be found in 2003 at the website: nusmv.irst.itc.it/NuSMV/papers/sttt_j/html/paper.html. Another model checker may be Rulebase, commercially available from International Business Machines Inc. (IBM) of the USA, which includes in it a symbolic model checker.
The article by C. Eisner, “Using Symbolic CTL Model Checking to Verify the Railway Stations of Hoorn-Kersenboogerd and Heerhugowaard”, Software Tools for Technology Transfer, Vol. 4, number 1 pp. 107-124, includes a nice tutorial on the process of symbolic model checking.
One of the important functions of symbolic model checkers is to determine which group RS of states of a model may be reached from an initial group S0 of states and which cannot be reached. This is known as “reachability”.
State machine 12 moves through the states as indicated by the arrows on
From the initial group S0 of states {A, B}, the state machine may get to the group S1 of states {A,C,D} in one step. State A has already been explored and thus, the next step is to explore states C and D. From the group {C,D}, the state machine can get to the group S2 comprised of state E. Since state E has no outward going arrow, the model checker is finished. From these results, the reachable states are A,B,C and D. State F is not reachable from any of the initial states.
A model checker may operate on the graph of
The model described above is a Kripke structure M defined over a set of atomic propositions AP. Mathematically, this is written:
M=(S,S0,R,L)
where L is a labeling function that labels each state S with the set of atomic propositions that are true in that state S. The states of the Kzipke structure are coded by the group of state variables
The basic operations in symbolic model checking may be the image computation and the pre-image computation. The image computation of Si uses transition relation R to move to the next group of states Si+1. The pre-image computation of Si uses transition relation R to take a step backwards to the group of states Si−1.
More precisely:
image(S(
and
pre_image (S(
where S(
A “conjunctive partitioned transition relation” may be composed of a set of partitions and_Ri such that, when they are ‘anded’ together, they produce the transition relation R(
R(
If each state variable νi can be described by a single conjunctive partition, then and_Ri=(ν′i=ƒν
A “disjunctive partitioned transition relation” may be composed of a set of partitions or_Ri such that, when they are “or'ed” together, they produce the transition relation R(
R(
If each current state variable νi can be changed only in a single disjunctive partition, then
The image computation in this case is:
Because existential quantification distributes, mathematically, over disjunction, every quantification may be performed before performing the disjunction operation and thus:
Because quantification may be done before disjunction for every variable vi in the disjunctive partitioning, all intermediate BDD results depend only on the set of next step variables
The following articles discussed the application of symbolic model checking to general purpose software by translating C source code to EDL (Environment Description Language), which may be the input language to the RuleBase model checker:
The subject matter regarded as the invention may be particularly pointed out and distinctly claimed in the concluding portion of the specification. The invention, however, both as to organization and method of operation, together with objects, features, and advantages thereof, may best be understood by reference to the following detailed description when read with the accompanying drawings in which:
It will be appreciated that for simplicity and clarity of illustration, elements shown in the figures have not necessarily been drawn to scale. For example, the dimensions of some of the elements may be exaggerated relative to other elements for clarity. Further, where considered appropriate, reference numerals may be repeated among the figures to indicate corresponding or analogous elements.
In the following detailed description, numerous specific details may be set forth in order to provide a thorough understanding of the invention. However, it will be understood by those skilled in the art that the present invention may be practiced without these specific details. In other instances, well-known methods, procedures, and components have not been described in detail so as not to obscure the present invention.
Applicants have realized that, in software, there may be little change in the program variables per step of the program. Thus, the present invention first may generate a model of a software program to be checked, where, in the program model, each step changes only a program counter (pc) indicating the current step in the program, and at most, one additional state variable x. With only two state variables changing, disjunctive partitions may be utilized and may be kept small. The present invention may thus be useful for software and for other methods and models where only a subset of the variables change their value at any given time.
In another embodiment, a new image and pre-image computation may be presented. In the traditional image computation algorithm, each disjunctive partition must represent the next value for all variables, so the disjunctive partition of state variable x should indicate the change of x and pc, and the fact that all the other variables keep their value. However, the fact that all the other variables keep their value increases the size of the BDD of the partition. The present invention may include new image and pre-image computations which operate on the partial disjunctive partition of x, which represents only the changes of x and pc, and not the fact that all other variables keep their value. The present invention decreases the BDD size needed to represent the disjunctive partitions, which may improve the image computation.
Reference is now briefly made to
The system of
Conjunctive partitioner 28, another part of the RuleBase system, may produce conjunctive partitions from EDL model 44. Partitioner 28 may also perform BDD reductions, thereby to produce smaller partitions. Disjunctive partitioner 24, described in more detail hereinbelow, may produce disjunctive partitions from ODL model 42. Both models 42 and 44 may be provided to model checker 32. Model checker 32 may be any suitable symbolic model checker, such as RuleBase. Converter 30 may convert the reduced size conjunctive partitions produced by conjunctive partitioner 28 to reduced size disjunctive partitions 46, which, in turn, may be input into model checker 32.
Reference is now made to
The code of
The first two lines of
Disjunctive modeler 22 may translate intermediate code 40 to ODL, a language that may have the style of a guarded transition system. In the present invention, each transition may be of the form:
pc=PC1P(x,Y,Z)(x←ƒ(x,Y,Z)pc←PC2)
In the present invention, the guard may be a condition minimally about the value of program counter pc. The guard may also be a condition about the value of one additional state variable and may have a predicate P about other variables x,Y,Z. Note that this transition may change a different variable depending on the value of other state variables but only one state variable may change its value at any one time. For instance, an assignment of an array a of the form a[i]=5 may change a[0] (P=:i=0) or a[1], etc., depending on the value of i. But only one array location may change at any one time. For a[0]=5, predicate P is “i=0” while for a[1]=5, predicate P is “i=1”.
Reference is now briefly made to
For ODL model 42, each line in the intermediate code may be translated to a guarded expression representing the changes for this value of the program counter pc. For example in line pc=19, state variable z may receive main_r1 and pc may be set to 22. This is listed in ODL model 42 as: pc=19(z←main_rpc←22). It will be appreciated that ODL model 42 may encode only those state variables that change their values, it being implicit that every non-listed state variable keeps its value.
In EDL model 44, the assignments of each state variable may be gathered together. Thus, in
Three exemplary assignments are shown in
It is further noted that, when using translator 20 on software containing assignments of the type: x=ar[i]; x=ar[j]; y=ar[i]; y=ar[j], translator 20 may produce intermediate code in which r_indexar may be dependent on i and j, r_arrayar may be dependent on r_indexar and on the ar cells, and x and y may be dependent only on r arrayar. Without cut-points, x and y would be dependent on i and j and on all cells of array ar.
For assignments of the type x=a[i]+a[j], translator 20 may split such statements into two: temp=a[i]; x=temp+a[j].
For assignments such as a[a[i]]=5, translator 20 may produce intermediate code with two different accesses to the array, one to get a[i] and the second to assign it to a[a[i]]. This may be seen in
Translator 20 may perform similar operations for pointers. For pointers, translator 20 may have four additional variables, L_PTR, R_PTR, L_VALUE and R_VALUE, where, as for arrays, the prefix L/R means that the pointer is in the left/right side of the assignment.
Translator 20 may translate an assignment x=*p into the following three assignments, having consecutive program counters pc:
R_PTR=p
R_VALUE=*R_PTR
x=R_VALUE
Translator 20 may translate an assignment *p=x into the following three assignments:
L_PTR=p
L_VALUE=x
*L_PTR=L_VALUE
When using this translation on C++ code containing the following assignments:
x=*p;
x=*q;
y=*P;
y=*q;
translator 20 may produce code in which R_PTR is dependent on p and q, R_VALUE is dependent on R_PTR and all pointed memory locations, and x and y are dependent only on R_VALUE. Without cut-points, x and y would be dependent on p, q and all pointed memory locations.
Translator 20 may translate self-assignment statements in which the value assigned to a variable, such as x, is a function of that variable (e.g., in C++ notation, x+=y or x=x+w+z). There are two types: constant self-assignment statements, where the variable may be updated by a constant (e.g., x+=4, x++), and variable self-assignment statements (e.g. x+=y, x=x iff b+c). Translator 20 may divide variable self-assignment statements into two statements: thus, for like x+=y, translator 20 may produce: temp=x, x=temp+y. This split may increase the number of program counter pc values and adds the variable temp (used for all such splits) but may improve overall performance.
From ODL model 42, disjunctive partitioner 24 may produce disjunctive partitions 46. Since, in each line of ODL model 42, the program counter pc changes and at most one other variable changes, disjunctive partitioner 24 may build disjunctive partitions 46 with a partition for each variable. This may generate a reasonable number of partitions, each of a reasonable size. Reference is now made to
22: x=x+1
25: a[i]=x
28: if x>2 goto 25
where the intervening steps (23, 24, 26, 27) are not related to variable x.
Partition 46A may encode the code for variable x. Thus, for the example it may include a BDD for the following code: if pc=22→x′=x+1, pc′=23, where the symbol “=” indicates “exactly equals” and the variable ν′ is the next value of variable ν.
The BDD of partition 46B may encode the code for variable a[0], the BDD of partition 46C may encode the code for variable a[1], the BDD of partition 46D may encode the code for a special state variable overflow, and the BDD of partition 46E may be the partition for variable pc. It may be noted that partition 46E may encode those lines of code which change program counter pc only. It may be further noted that state variable overflow may be included to deal with overflows of arrays. The program developer does not intend to have any overflows; however, overflows do occasionally occur. By including an overflow variable, the model may be more complete.
In
Disjunctive partitioner 24 (
It will be appreciated that ODL model 42 may be considered a language for describing disjunctive BDDs, since each line of ODL model 42 describes the value in the next state x′ of a variable x as a Boolean expression. Thus, disjunctive partitioner 24 may translate each line of ODL model 42 as a BDD, such as discussed hereinabove in the Background, and each per line BDD may be treated as a disjunctive partition.
In order to get a reasonable number of disjunctive partitions, partitioner 24 may disjunct all partitions which change a certain variable x, producing a single disjunctive partition for each variable x. In addition, partitioner 24 may disjunct all per line partitions which change only program counter pc, producing a single disjunctive partition for pc control.
Conjunctive partitioner 28 may be any suitable partitioner which may generate BDDs from EDL model 44. Code for one suitable conjunctive partitioner is found in the article by C. Eisner, “Using Symbolic CTL Model Checking to Verify the Railway Stations of Hoorn-Kersenboogerd and Heerhugowaard”, mentioned hereinabove. RuleBase may provide another suitable partitioner.
Converter 30 may convert conjunctive partitions 48 (
As can be seen, conjunctive partition 48A for variable x lists the state of next variable x′ for each value of program counter pc and conjunctive partition 48B for program counter pc lists the next value of the program counter. For example, one line says: if pc=22, then pc′=23.
Disjunctive partition 46G for variable x looks different than conjunctive partition 48A for variable x. Disjunctive partition 46G lists the state of all variables for each program counter value. Thus, it lists, in part, if pc=22, then x′=x+1, pc′=23, y′=y.
For converter 30, the disjunctive partitions 46 of a state variable x may be an array or_Rx(
Converter 30 may define a variable dep_statesx(
Converter 30 may build a disjunctive partition for state variable x from the conjunctive partition for that state variable and the conjunctive partition for the program counter pc. For the state variables which are not program counter pc, the translation is:
1. Calculate dep_statesx(
dep_statesx(
2. Intersect the quantification of x from dep_statesx(
por—Rx(Pc,x,
It is noted that the disjunctive partition or_Rx(
or—Rx(
The following describes how converter 30 may build a disjunctive partition for the program counter PC:
1. Calculate dep_pcsx(pc) for each x≠pc:
dep—pcsx(pc)=dep_statesx(
where A|
2. Calculate the set of pc values jump_pcs(pc) that are related to statements in which PC is the only state variable that is changed. These pc values are related to statements in which there is a control branch, like an if statement:
jump—pcs(pc)=x≠pc(
3. Intersect conjunctive partition and_Rpc(
por—Rpc(pc,x,
Once again, the disjunctive partition or_Rpc(
or—Rpc(
Model checker 32 (
pre_image(S(pc′,x′,
image(S(pc,x,
Thus, model checker 32 may perform the following code using the partial disjunctive partitions:
where “pre_image” may be a function implementing the pre_image computation of the prior art.
where “image” may be a function implementing the image computation of the prior art.
It will be appreciated that the exist operation may be implemented in many different ways, including ones which are linear in the size of the BDD.
When performing the image or pre-image computations using disjunctive partitions, it may be possible to calculate the image or pre-image on each disjunctive partition independently and then union the results. In accordance with a preferred embodiment of the present invention, the calculations may be performed on distributed processors.
Reference is now made to
In
In this embodiment, processes A, B and C may read each set that may enter queue 66. At the beginning, queue 66 may have the initial set of states. Each process Pi, at each iteration, may perform the following actions:
The calculation may end when all processes Pi point to an empty slot in queue 66.
In accordance with an additional preferred embodiment of the present invention, the partial disjunctive partition for program counter pc need not always be generated. Instead, a new version of the image and pre-image calculations, called tango_image and tango_pre_image, respectively, may be performed. The tango_image and tango_pre_image operators may hold when the model of the present invention has the following properties:
It is noted that the above three conditions do not always hold. For example, in the intermediate code of
Reference is now made to
or—TR={por—Rx(
Disjunctive partitioned, transition relation or_TR may be a reduced model, as it may refer only to the activities of the non-program-counter variables. Thus, the following two types of transitions are missing from relation or_TR, and thus, are not present in partial image 100:
when pc=7. In both cases, all the transitions from the states in the domain of the missing transitions change only the value of program counter pc.
According to property 3 above, the transition relation of the full model is total. However, in the reduced model, partitioned transition relation or_TR does not contain all of the transitions of the full model. Thus, there may be “sink states” 104 (i.e. states which other states transition to but no states transition from) in current set 102 of states which have not transitioned to partial image 100. Moreover, since partitioned transition relation or_TR may only contain transitions of the non-program-counter variables, sink states 104 of current set 102 may change only program counter pc.
Operator tango_image may find sink states 104 by performing a new pre image operation on partial image 100 and then may generate a second partial image 106 of the missing transitions by doing a new_image computation using and—Rpc on sink states 104 to determine any changes in the value of program counter pc. Afterwards, the two partial images 100 and 106 may be joined (i.e. via a union operation) to generate a new current group of states 108.
tango_image(S(
According to the properties above, the transitions which enter a single reachable state in current set 102 of states are either all missing or all present in or_TR. Since at least one transition enters each reachable state in current set 102, if a reachable state in current set 102 has no predecessors in partial image 110, then there may be transitions which enter this state in current set 102 and these transitions may change only the program counter pc. Operator tango_pre_image may find the states 112 without predecessors in partial image 110, by doing a new_image computation on or_TR, and may add the missing transitions 114 by doing a new_pre_image computation using the conjunctive operator and_Rpc to know the previous program counter pc values.
tango_pre_image(S(
It will be appreciated that the tango operations may be performed on disjunctive partitions instead of the partial disjunctive partitions. To do so, the equations in paragraphs (152 160) and in paragraphs (153, 159) may be calculated using the image and pre-image operators, respectively, rather than the new_image and new_pre_image operators.
While certain features of the invention have been illustrated and described herein, many modifications, substitutions, changes, and equivalents will now occur to those of ordinary skill in the art. It is, therefore, to be understood that the appended claims may be intended to cover all such modifications and changes as fall within the true spirit of the invention.
Number | Date | Country | Kind |
---|---|---|---|
0407657.6 | Apr 2004 | GB | national |
Number | Name | Date | Kind |
---|---|---|---|
6728665 | Gupta et al. | Apr 2004 | B1 |
20060058989 | Keidar-Barner et al. | Mar 2006 | A1 |
Number | Date | Country | |
---|---|---|---|
20050223353 A1 | Oct 2005 | US |