Skip to content
STIMSMITH

Complement Edges in BDD

Concept WIKI v1 · 7/13/2026

Complement edges are a BDD representation technique that allows a node to represent both a Boolean function and its complement by marking the incoming edge rather than adding a negated subgraph, enabling reduced, ordered BDDs to contain only the 1-terminal.

Complement Edges in BDD

Definition

A Binary Decision Diagram (BDD) is an ordered directed acyclic graph in which each variable is encountered at most once on every root-to-terminal path and the variable order is consistent across all such paths. A BDD is reduced if it contains no isomorphic subgraphs and no redundant nodes. A reduced and ordered BDD (ROBDD) is a canonical representation of a Boolean function.

Complement edges are a shorthand mechanism used when drawing reduced BDDs: instead of explicitly constructing the negated subgraph for a function f, the same node is reused to represent both f and ¬f, with the edge pointing to the node being marked to indicate which polarity is intended. As a direct consequence, a reduced BDD drawn with complement edges only needs to contain the 1-terminal; the 0-terminal is implicit and is reached via the complemented edge of the root.

Example

Consider the function f = x₁x₂ + x₁x₂x₃. When its ROBDD is drawn using complement edges (Figure 3 of the cited source), the same node set simultaneously encodes f and ¬f. The diagram therefore contains only the 1-terminal node, and the complement of any sub-function is obtained by flipping the polarity bit on its incoming edge rather than by an additional NOT node.

Relevance to Constraint Solving and Weighting

Complement edges interact with algorithms that traverse BDDs to extract solutions. In the SCV constraint solver (built on the CUDD package), the characteristic function of every constraint is represented as a BDD and then traversed to enumerate solutions. Because complement edges let one node stand in for both polarities, naive traversal probabilities (e.g., assuming a 50/50 split between the 0-edge and 1-edge of a node) can be skewed. The cited example shows that for f = x₁x₂ + x₁x₂x₃ the intuitive traversal would assign 50% probability to the root's 1-edge, but the correct uniform distribution requires correcting this to 33%.

To obtain a uniform distribution of solutions across the constraint set, the SCV constraint solver runs a special weighting algorithm in a pre-processing step:

  1. Traverse the BDD of all initial constraints.
  2. Recursively compute the weights of the else- and then-children of each node.
  3. Account for nodes that have been removed by BDD reduction rules (including the polarity flips introduced by complement edges).
  4. Assign each node a probability derived from these weights.

During value generation, the pre-computed probabilities replace the naive per-edge probabilities, yielding a uniform distribution across all solutions.

Bit-Operator Constraints and BDD Construction

Because the SCV solver originally lacked bit-operator support, expressions such as a() & b(), a() | b(), ~a(), bit-select a()[i], and slice-select a().range(x,y) were added. Internally, scv_expression stores an expression tree whose leaves are variables/constants and whose interior nodes are operators; the BDD synthesis then applies the appropriate BDD-level operation (e.g., BDD-AND for each bit) for every bit of the operand vectors. The resulting BDD inherits the same complement-edge representation as the underlying CUDD package, so the weighting algorithm described above applies unchanged.

Limitations

The weighting algorithm is invoked once on the initial constraint BDD. If variables are subsequently fixed (e.g., disabled from randomization), the BDD is simplified but the cached probabilities are not updated. This causes the generated solutions to deviate from a uniform distribution, motivating the improvements described in the source paper.

See Also

  • Binary Decision Diagram — the underlying data structure that uses complement edges to keep ROBDDs canonical and minimal.
  • BDD Weighting Algorithm — the recursive algorithm that compensates for complement-edge-induced probability skew during uniform solution sampling.

CITATIONS

8 sources
8 citations
[1] A BDD is called ordered if each variable is encountered at most once on each path from the root to a terminal and the variable order is consistent across paths. Improvements for Constraint Solving in the SCV Library
[2] A BDD is called reduced if it contains neither isomorphic subgraphs nor redundant nodes; reduced and ordered BDDs are a canonical representation of a Boolean function. Improvements for Constraint Solving in the SCV Library
[3] The BDD for f = x1*x2 + x1*x2*x3 shown in Figure 3 is drawn using complement edges, allowing both the function and its complement to be represented by the same node by modifying the edge instead, so the diagram contains only the 1-terminal. Improvements for Constraint Solving in the SCV Library
[4] The intuitive traversal probability for the 1-edge of the root node in the example BDD should be corrected to 33% instead of 50% to achieve a uniform distribution of solutions. Improvements for Constraint Solving in the SCV Library
[5] The SCV constraint solver implements a recursive weighting algorithm in a pre-processing step that traverses the initial constraint BDD, computes weights for the else- and then-children while accounting for nodes removed by BDD reduction rules, and assigns a probability to each BDD node. Improvements for Constraint Solving in the SCV Library
[6] The SCV constraint solver calls the weighting algorithm only once at the beginning on the initial constraint BDD, so subsequent simplifications such as fixing variables leave the probabilities stale and produce a non-uniform solution distribution. Improvements for Constraint Solving in the SCV Library
[7] The SCV library uses the CUDD package as its BDD implementation. Improvements for Constraint Solving in the SCV Library
[8] Bit operators such as bitwise and, or, not, bit-select, and slice-select were added to scv_expression and mapped to BDD synthesis operations like BDD-AND for each bit of the operand vectors. Improvements for Constraint Solving in the SCV Library