The classic Boolean satisfiability problem can be generally stated as follows: for a given Boolean function of variables, determine whether it is possible to assign values to the variables such that the function is satisfied (that is, the function evaluates to true), or whether no such assignment exists. The Boolean satisfiability problem is of significance in both theoretical research and in practical applications such as artificial intelligence planning, circuit testing, software verification, and database validation.
The satisfiability problem can be solved by representing the Boolean function as a directed acyclic graph (DAG), where each vertex of the DAG represents a variable assignment with the exception of two sink nodes. One sink node represents false function results (e.g., binary zero) and the other sink node represents true function results (e.g., binary one). Each vertex of the DAG likewise has a binary domain. Generally speaking, the function is satisfiable if there is a path through the DAG from a root node to the “one” sink (the true node).
The amount of time and resources needed to determine satisfiability of a function using a DAG such as that just described increases as the number of variables in the function increases. A more efficient approach that saves time and resources would be valuable.
Instead of constructing a decision diagram where each vertex has only a binary domain, a decision diagram that has at least one vertex representing a domain of more than two values can be constructed.
This summary is provided to introduce a selection of concepts in a simplified form that are further described below in the Detailed Description. This summary is not intended to identify key features or essential features of the claimed subject matter, nor is it intended to be used to limit the scope of the claimed subject matter.
The accompanying drawings, which are incorporated in and form a part of this specification, illustrate embodiments and, together with the description, serve to explain the principles of the embodiments:
FIG. 1 illustrates a hierarchy of logical functions according to one embodiment.
FIG. 2 is a block diagram of an example of a computer system upon which embodiments of a satisfiability solver may be implemented.
FIG. 3 is a block diagram illustrating the transformation of a function into a decision diagram according to one embodiment.
FIG. 4 is a flowchart of one embodiment of a computer-implemented method for determining satisfiability of a function.
FIG. 5 illustrates an example of a decision diagram structure according to one embodiment.
Some portions of the detailed descriptions which follow are presented in terms of procedures, logic blocks, processing and other symbolic representations of operations on data bits within a computer memory. These descriptions and representations are the means used by those skilled in the data processing arts to most effectively convey the substance of their work to others skilled in the art. In the present application, a procedure, logic block, process, or the like, is conceived to be a self-consistent sequence of steps or instructions leading to a desired result. The steps are those requiring physical manipulations of physical quantities. Usually, although not necessarily, these quantities take the form of electrical or magnetic signals capable of being stored, transferred, combined, compared, and otherwise manipulated in a computer system.
It should be borne in mind, however, that all of these and similar terms are to be associated with the appropriate physical quantities and are merely convenient labels applied to these quantities. Unless specifically stated otherwise as apparent from the following discussions, it is appreciated that throughout the present application, discussions utilizing the terms such as “accessing,” “representing,” “evaluating,” “mapping,” “transforming,” “deriving,” “determining” or the like, refer to the actions and processes of a computer system, or similar electronic computing device, that manipulates and transforms data represented as physical (electronic) quantities within the computer system's registers and memories into other data similarly represented as physical quantities within the computer system memories or registers or other such information storage, transmission or display devices.
Embodiments described herein may be discussed in the general context of computer-executable instructions residing on some form of computer-usable medium, such as program modules, executed by one or more computers or other devices. Generally, program modules include routines, programs, objects, components, data structures, etc., that perform particular tasks or implement particular abstract data types. The functionality of the program modules may be combined or distributed as desired in various embodiments.
According to embodiments described herein, the classic Boolean satisfiability problem can be efficiently solved. In overview, a function can be represented as a canonical decision diagram structure. Each vertex of the diagram is associated with a respective function variable. The vertices include at least one vertex that represents a domain of more than two values for the variable associated with the vertex. The decision diagram demonstrates whether the function is valid, satisfiable or unsatisfiable.
Various terms are used herein as follows:
In one embodiment, logical functions are represented using the hierarchy shown in FIG. 1. All classes are immutable with the exception of the knowledge base class, which aggregates facts. In the example of FIG. 1, a term “TermExpr” and a term “TreeExpr” are forms of the Boolean expression “BoolExpr.” The term “TermExpr” exposes in its “T_Identifier” property either a “DomainConstraint” or a “DomainVariable”—in the latter case, the term is treated as a Boolean variable with domain {true, false}. The terms “NotExpr,” “AndExpr” and “OrExpr” are forms of the term “TreeExpr.”
FIG. 2 shows a block diagram of an example of a computer system 200 upon which the embodiments described herein may be implemented. In its most basic configuration, the system 200 typically includes at least one processing unit 202 and memory 204. Generally speaking, the system 200 includes at least some form of computer-usable media. Computer-usable media can be any available media that can be accessed by the system 200. Depending on the exact configuration and type of computing device, the memory 204 may be volatile (such as random access memory), non-volatile (such as read-only memory, flash memory, etc.) or some combination of the two. This most basic configuration is illustrated in FIG. 2 by dashed line 206. The system 200 may also have additional features/functionality. For example, the system 200 may also include additional storage (removable and/or non-removable) including, but not limited to, magnetic or optical disks or tape. Such additional storage is illustrated in FIG. 2 by removable storage 208 and non-removable storage 210. The system 200 may also contain communications connection(s) 212 that allow the device to communicate with other devices.
Generally speaking, the system 200 includes at least some form of computer-usable media. Computer-usable media can be any available media that can be accessed by the system 200. By way of example, and not limitation, computer-usable media may comprise computer storage media and communication media.
Computer storage media includes volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storage of information such as computer-readable instructions, data structures, program modules or other data. Computer storage media includes, but is not limited to, random access memory (RAM), read only memory (ROM), electrically erasable programmable ROM (EEPROM), flash memory or other memory technology, compact disk ROM (CD-ROM), digital versatile disks (DVDs) or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store the desired information and that can accessed by the system 200. Any such computer storage media may be part of the system 200. The memory 204, removable storage 208 and non-removable storage 210 are all examples of computer storage media.
Communication media can embody computer-readable instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transport mechanism and includes any information delivery media. The term “modulated data signal” means a signal that has one or more of its characteristics set or changed in such a manner as to encode information in the signal. By way of example, and not limitation, communication media includes wired media such as a wired network or direct-wired connection, and wireless media such as acoustic, radio frequency (RF), infrared and other wireless media. Combinations of any of the above can also be included within the scope of computer-readable media. The communications connection(s) 212 is an example of communication media.
The system 200 may also have input device(s) 214 such as keyboard, mouse, pen, voice input device, touch input device, etc. Output device(s) 216 such as a display, speakers, printer, etc. may also be included. All these devices are well know in the art and need not be discussed at length here.
The system 200 may operate in a networked environment using logical connections to one or more remote computers, which may be a personal compute (PC), a server, a router, a network PC, a peer device or other common network node, and which may include many or all of the elements described above relative to the system 200. The logical connections may include a local area network (LAN) and a wide area network (WAN), but may also include other networks. Such networking environments are commonplace in offices, enterprise-wide computer networks, intranets and the Internet. When used in a networking environment, the system 200 can be connected to the network through the communication connection(s) 212.
In the example of FIG. 2, the memory 204 includes computer-readable instructions, data structures, program modules and the like associated with a satisfiability solver application programming interface (API) 250. However, the satisfiability solver API 250 may instead reside in any one of the computer storage media used by the system 200, or may be distributed over some combination of the computer storage media.
FIG. 3 provides an overview of the various stages in the transformation of a function according to one embodiment. In general, the satisfiability solver API 250 decomposes a function 310 of ‘n’ arguments (variables) into a canonical decision diagram structure 330 such as a directed acyclic graph (DAG). If the decision diagram 330 resolves only to a false sink node, then no assignment of the variables can succeed. If the decision diagram resolves only to a true sink node, then all variable assignments are successful. If the decision diagram resolves to both a false sink node and a true sink node, then some variable assignments (the assignments that lead to the true sink) are successful.
An example of a decision diagram is shown in FIG. 5, which is described further below. Continuing with reference to FIG. 3, the decision diagram 330 is canonical in the sense that all functionally equivalent definitions are represented in the same manner. More specifically, in one embodiment, the decision diagram 330 has the following properties:
Generally speaking, in contrast to conventional decision diagrams in which variables have only a binary domain, the satisfiability solver described herein improves efficiency by representing functions as decision diagrams in which variables have arbitrarily sized domains. As a simplification, domain constraints that are always true can be set to 1 while domain constraints that are always false can be set to 0, in which case variables with domains of size 0 or 1 are disqualified from consideration.
As noted above, the decision diagram 330 is ordered. Vertices in the decision diagram have the following structure:
Vertex | |
{ | |
‘ variable identifier | |
int Variable; | |
‘ vertices representing an outcome for each possible variable | |
assignment | |
‘note: children are ordinally aligned with members of the | |
variable domain | |
Vertex[ ] Children; | |
} | |
The function's variables may have a continuous domain. If so, then before the function 310 is decomposed into a decision diagram 330, the function 310 is first mapped to a different representation 320 in which the function is represented using Boolean expressions of variables that have discrete (finite) domains D_{i}={1, 2, . . . , f_{i}}. More specifically, a relational expression of the form “variable equal to/not equal to/less than/greater than/less than or equal to/greater than or equal to a constant” can be mapped to a discrete domain by examining all of the constants used with respect to a variable, and then decomposing the continuous domain into a series of discrete domains linked by Boolean expressions.
For example, given the following function:
X≧10 OR (X=5 AND X<7),
the variable X can be replaced with a new variable X′ with the following discrete values:
X′ in {<5, 5, between 5 and 7, 7, between 7 and 10, 10, >10}.
The function can then be rewritten as:
X′ in {10, > 10} | OR (X ≧ 10) | |
( | ||
X′ in {5} AND | (X = 5) | |
X′ in {< 5, between 5 and 7} | (X < 7) | |
) | ||
In one embodiment, a normal form 340 (e.g., a disjunctive normal form and/or a conjunctive normal form) of the function 310 can be derived from the decision diagram 330. This is discussed further below, in conjunction with FIG. 5.
FIG. 4 is a flowchart 400 of one embodiment of a computer-implemented method for determining satisfiability of a function. Although specific steps are disclosed in the flowchart 400, such steps are exemplary. That is, various other steps or variations of the steps recited in the flowchart 400 can be performed. The steps in the flowchart 400 may be performed in an order different than presented. Furthermore, the features of the various embodiments described by the flowchart 400 can be used alone or in combination with each other. In one embodiment, the flowchart 400 can be implemented as computer-executable instructions stored in a computer-readable medium.
In block 410, a function to be evaluated is accessed from memory. The function includes some number of arguments (variables), some or all of which may have a continuous domain.
In block 420, if the function includes variables with a continuous domain, then the function is represented in a different form (function 320 of FIG. 3) in which the variables have discrete domains, as previously described herein.
In block 430 of FIG. 4, the function 320 is transformed by mapping each of its expressions to a respective if-then-else statement. A mapping of expression to if-then-else form is shown in Table 1.
TABLE 1 | ||
Example Mapping of Expressions | ||
Expression | If-Then-Else Form | |
x (term) | x-1-0 | |
x AND y | x-y-0 | |
x OR y | x-1-y | |
NOT x | x-0-1 | |
Thus, for example, the expression “x AND y” is transformed into “if x, then y, else 0.”
In block 440, each if-then-else statement is transformed into a vertex of the decision diagram 330 (FIG. 3). In one embodiment, the following recursive function is used to affect the transformation from if-then-else form to vertex:
IfThenElse(vertex i, vertex t, vertex e) returns Vertex: |
‘ terminal |
if i = 0 |
return e |
if i = 1 |
return t |
if t = 1 and e = 0 |
return i |
‘ determine top variable from inputs (which roots the return expression) |
top ← min(i.Variable, t.Variable, e.Variable) |
‘ compute children for new Vertex |
Children[ ] ← Vertex[top domain size] |
for each value in top domain |
Children[value] ← IfThenElse( |
EvaluateFor(i, top, value), |
EvaluateFor(t, top, value), |
EvaluateFor(e, top, value)) |
‘ if all children are identical, the value of top does not matter |
if Children are identical |
return Children[1] |
return CreateVertex { .Variable = top, .Children = children } |
In the above, “EvaluateFor” evaluates a vertex for a particular value of the variable corresponding to that vertex. In essence, a vertex representing the function when the variable value is bound to the particular value is returned. “EvaluateFor” can be implemented as follows:
EvaluateFor(Vertex v, int variable, int value) returns Vertex: |
if v.Variable > variable |
‘ by order invariant, variable cannot influence v |
return v |
‘ know that v.Variable must equal variable because top ≦ v.Variable |
return v.Children[value] |
In the implementation just described, one child is generated for each member of the variable domain, in contrast to conventional implementations that generate a fixed pair of children. Each vertex can be viewed as defining the Shannon decomposition of the function at the vertex on the vertex's variable.
In the implementation above, “IfThenElse” will return a vertex that evaluates to true if and only if the given if-then-else statement evaluates to true, and that the ordering invariant is preserved. With a canonical vertex representation, a single instance of any function will exist by remembering all vertices and returning an existing equivalent vertex where one exists according to “CreateVertex.”
As previously noted herein, the resulting decision diagram is used to evaluate the function to determine whether the function is valid, satisfiable or unsatisfiable for given values of the variables. To determine validity/satisfiability/unsatisfiability, the decision diagram generated in block 440 is merely examined. All unsatisfiable functions resolve to 0 and all valid functions resolve to 1; otherwise, the function is satisfiable but not valid.
FIG. 5 illustrates an example of a decision diagram structure 500 according to one embodiment. The decision diagram structure 500 represents the following function of two variables:
f(v1, v2)=(v1 in {1,3} and v2 in {1}) or (v1 in {2} and v2 in {2}),
where v1 has domain {1,2,3,4} and v2 has domain {1,2,3}.
The structure 500 is generated as described above and satisfies each of the properties presented above in conjunction with FIG. 3. In the example of FIG. 5, the vertex 510 corresponds to the variable v1, and the vertices 520 and 521 correspond to the variable v2. Looking at vertex 510, for instance, the outgoing edge 531 is associated with v1 in the domain {1,3}, and the outgoing edge 532 is associated with v2 in the domain {2}. The edge 531 can be alternatively represented as two edges, one for the domain {1} and one for the domain {3}. The structure 500 can be used to evaluate the function f(v1, v2) to determine whether the function is satisfiable or unsatisfiable for given values of the variables. In the example of FIG. 5, the function is satisfiable for the following variable assignment: v1 in {1,3}, v2 in {1}; and v1 in {2}, v2 in {2}.
The normal form of the function can be derived from the decision diagram derived in block 440 of FIG. 4. A disjunctive normal form can be read directly from the decision diagram, where every clause corresponds to a path from the root to the true node. In other words, every variable combination that results in the function being satisfied is a clause in the disjunctive normal form. The example of FIG. 5 can be used to demonstrate the derivation of the disjunction normal form. As already mentioned, the following paths lead to the true node: v1 in {1,3}, v2 in {1}; and v1 in {2}, v2 in {2}. The disjunctive normal form is therefore (v1 in {1,3} AND v2 in {1}) OR (v1 in {2} AND v2 in {2}).
The conjunctive normal form can be readily derived as well by considering the disjunctive normal form of the negation of the function, or the set of all paths that lead to the false node: v1 in {1,3}, v2 in {2,3}; v1 in {2}, v2 in {1,3}; and v1 in {4}, resulting in (v1 in {1,3} AND v2 in {2,3}) OR (v1 in {2} AND v2 in {1,3}) OR (v1 in {4}). Taking the negation of the negated function, and pushing down the “not” yields the conjunctive normal form (the literals are the same, but the constraint ranges are inverted): (v1 in {2,4} OR v2 in {1,4}) AND (v1 in {1,3,4} OR v2 in {2}) AND (v1 in {1,2,3}).
In summary, for a class of functions taking ‘n’ arguments and returning either true or false, the satisfiability solver described herein can efficiently determine whether any assignment to those variables will return true. In particular, the satisfiability solver can handle functions that can be represented in the following grammar:
By virtue of this concise grammar, fairly involved queries can be answered—for instance, whether given facts imply some statement. Given a knowledge base, a determination can be made whether a query is always true (entailment). One practical use of the satisfiability solver described herein is in the ADO.NET Entity Framework by Microsoft™, in particular to validate relational database-to-object mappings.
In the foregoing specification, embodiments have been described with reference to numerous specific details that may vary from implementation to implementation. Thus, the sole and exclusive indicator of what is the invention, and is intended by the applicant to be the invention, is the set of claims that issue from this application, in the specific form in which such claims issue, including any subsequent correction. Hence, no limitation, element, property, feature, advantage, or attribute that is not expressly recited in a claim should limit the scope of such claim in any way. Accordingly, the specification and drawings are to be regarded in an illustrative rather than a restrictive sense.