Constraint propagation

On this page 7

Constraint propagation is the process of using the constraints of a problem to remove values that cannot appear in any solution, so that the domains of the variables shrink before or during search. In Symbolic AI & reasoning, it is the inference engine at the heart of constraint satisfaction problems (CSPs) and constraint programming, and it explains why solvers can handle scheduling, configuration and puzzle problems whose raw search spaces are astronomically large.

Propagation is a form of local deduction: each constraint examines the variables it links and deletes values that have no support among the remaining values of its neighbors. Each deletion can trigger further deletions elsewhere, and the process stops at a fixpoint where no constraint can prune anything more.

How constraint propagation prunes variable domains

Constraint propagation works by repeatedly enforcing a local consistency property on the constraint network until no domain changes. A CSP consists of variables, a finite domain of candidate values for each variable, and constraints that restrict which combinations of values are allowed together.

The classic mechanism is a queue of constraints to revisit. When a value disappears from the domain of variable X, every constraint involving X is placed back on the queue, because a value of a neighbor may have depended on the deleted value for support. The algorithm finishes when the queue is empty, which corresponds to the greatest consistent sub-network for the chosen consistency level.

Propagation has three possible outcomes. It can empty a domain, which proves that the current problem or branch has no solution; it can reduce every domain to a single value, which yields a solution directly; or it can leave several values per variable, in which case search must continue with a smaller space.

The following table lists the core elements of a propagation engine and the role each one plays.

ComponentRoleTypical implementation
Domain storeHolds the remaining values of each variableBit sets, intervals or value lists
PropagatorPrunes domains for one constraintFiltering algorithm per constraint type
Propagation queueSchedules propagators whose inputs changedFIFO queue with priority classes
TrailRecords changes for undo on backtrackingStack of domain modifications
Fixpoint testDetects that nothing more can be prunedEmpty queue after a full pass
Components of a propagation engine

Levels of local consistency

Different propagation algorithms enforce different strengths of consistency, and stronger consistency removes more values at a higher computational cost. The most widely used level is arc consistency, which requires that every value of a variable has at least one compatible value in each neighboring variable for every binary constraint.

The AC-3 algorithm, introduced by Alan Mackworth in 1977, enforces arc consistency in O(e·d³) time for e constraints and domains of size d. Later algorithms such as AC-4, AC-6 and AC-2001 reach the optimal O(e·d²) bound by remembering which supports have already been found.

Consistency levelWhat it guaranteesRelative cost
Node consistencyEvery value satisfies unary constraintsVery low
Arc consistencyEvery value has support on each binary constraintLow to moderate
Bounds consistencyOnly domain minimum and maximum are supportedLow
Generalized arc consistencySupport on constraints of any arityModerate to high
Path consistencyConsistent pairs extend to any third variableHigh
k-consistencyConsistent assignments extend to k variablesExponential in k
Common consistency levels compared

Bounds consistency is preferred for arithmetic constraints over large integer ranges, because it reasons only about interval endpoints. Generalized arc consistency matters for global constraints such as all-different, where specialized filtering based on bipartite matching prunes far more than a decomposition into binary inequalities.

In practice, constraint propagation is interleaved with backtracking search: the solver assigns a value, propagates, and backtracks when a domain becomes empty. This combination is often called maintaining arc consistency (MAC) and is the default strategy in most constraint programming solvers.

A lighter alternative is forward checking, which only prunes the domains of variables directly connected to the newly assigned one. It is cheaper per node but detects failures later, so on hard instances it usually explores many more search nodes than MAC.

StrategyPropagation after each assignmentTypical use
Plain backtrackingNone, only checks completed constraintsTeaching and tiny problems
Forward checkingNeighbors of the assigned variableSparse, loosely constrained problems
Maintaining arc consistencyFull arc consistency to fixpointGeneral-purpose CP solvers
Singleton consistencyTests each value with full propagationHard combinatorial instances
Search strategies and their propagation effort

Propagation also supports variable-ordering heuristics. The popular fail-first principle picks the variable with the smallest remaining domain, and that domain size is only meaningful because propagation keeps the domains up to date.

Relation to neighboring reasoning techniques

Constraint propagation is closely related to inference methods in logic-based AI. Unit propagation in Boolean satisfiability solvers is a special case: when all literals of a clause but one are false, the last literal is forced to be true, exactly as a propagator forces a value.

It also resembles forward chaining in rule-based systems, because both derive consequences until nothing new follows. The difference is that propagation removes possibilities from finite domains, whereas forward chaining adds facts to working memory. In satisfiability modulo theories, theory solvers perform propagation within arithmetic or array theories and report implied literals back to the SAT core.

Limitations and common misconceptions

The most frequent misconception is that a propagated network is guaranteed to have a solution. Arc consistency is incomplete in general: a network can be arc consistent and still be unsolvable, as three variables with domains of two colors and pairwise inequality constraints show.

  • Cost can dominate: strong consistency may spend more time pruning than the search it saves.
  • Decompositions lose pruning: splitting a global constraint into binary parts weakens propagation.
  • Large domains hurt: value-by-value support checks scale poorly without bounds reasoning.
  • Exactness is limited: tree-structured networks become solvable without backtracking after arc consistency, but cyclic networks generally do not.

Stripped to the essentials

Think of a Sudoku puzzle. Each empty cell could hold several digits. When you see a 5 in a row, you cross out 5 from every other cell in that row. That crossing out is constraint propagation.

One deletion often leads to another. A cell may end up with only one possible digit, and then that digit is crossed out from its neighbors too. Computers do the same thing, very fast, on much bigger problems. The key idea is simple: rule out the impossible first, so far fewer guesses remain.

Where it is applied

A regional hospital builds a monthly nurse roster for 60 nurses across three shifts per day. The constraints include minimum staffing per shift, at least 11 hours of rest between shifts, a maximum of five consecutive working days and individual vacation requests. A constraint solver models each nurse and day as a variable whose domain is early, late, night or off.

Before any search begins, propagation of the rest and vacation constraints removes roughly a third of all domain values. During search, every tentative assignment triggers further pruning, so infeasible partial rosters are rejected within a few steps rather than after many wasted assignments. The planning team obtains a valid roster within minutes, and when a nurse reports sick, the solver repairs the plan by re-propagating only the affected days.