Constraint Propagation
🎯 Learning Objectives
- Understand constraint propagation as a form of inference
- Compare forward checking and full arc consistency during search
- Handle specialized constraints: AllDiff, AtMost
- Solve tree-structured CSPs in O(nd²) time
- Apply cutset conditioning and understand tree decomposition
- Explain bounds propagation for ordered domains
1. Constraint Propagation as Inference
📚 Constraint Propagation
Constraint propagation uses the constraints to reduce the domains of variables, eliminating values that cannot participate in any solution. It is a form of inference that can be applied before search (as preprocessing) or during search (interleaved with backtracking).
The key idea: when a value is removed from a variable's domain, the effects propagate through the constraint graph. Removing value v from Xi may cause some values in Xj (a neighbour of Xi) to lose support, leading to further removals, and so on. This chain reaction is constraint propagation.
💡 Propagation Strength Spectrum
From weakest to strongest: No propagation (plain backtracking) → Forward checking (check assigned–unassigned pairs) → Arc consistency (check all pairs) → Path consistency (check triples) → Strong n-consistency (backtrack-free, but expensive).
2. Local Consistency
Local consistency is a family of properties that can be enforced in polynomial time. Each level eliminates values (or tuples) that cannot be part of any solution:
| Level | What It Checks | Cost | Detects |
|---|---|---|---|
| Node consistency | Single variable vs unary constraints | O(n · d) | Unary violations |
| Arc consistency | Pairs of variables | O(c · d³) for AC-3 | Binary inconsistencies |
| Path consistency | Triples of variables | O(n³ · d³) | Ternary inconsistencies |
| i-consistency | Sets of i variables | Exponential in i | Higher-order issues |
In practice, arc consistency provides the best cost-benefit trade-off and is the most widely used form of local consistency.
3. Forward Checking vs. Full Arc Consistency
📚 Maintaining Arc Consistency During Search
When combined with backtracking search, there are two main strategies for interleaving propagation:
- Forward Checking (FC): After assigning Xi = v, check only arcs (Xj, Xi) for unassigned neighbours Xj
- MAC (Maintaining Arc Consistency): After assigning Xi = v, run full AC-3 starting from arcs involving Xi
✍ FC Misses What MAC Catches
Consider variables A, B, C with DA={1,2}, DB={1,2}, DC={1,2} and constraints A≠B, B≠C, A≠C.
Assign A = 1:
- FC removes 1 from DB → DB = {2}. Removes 1 from DC → DC = {2}.
- FC does NOT check B vs C. DB={2}, DC={2} with B≠C → inconsistent! FC won't detect this until we try to assign B.
- MAC would propagate: after DB shrinks, check (C, B). C=2 needs B≠2, but DB={2} → no support → domain wipe-out detected immediately!
| Criterion | Forward Checking | MAC |
|---|---|---|
| Propagation scope | Current → neighbours only | Full propagation cascade |
| Early failure detection | Moderate | Strong |
| Cost per assignment | O(n · d) | O(c · d³) worst case |
| Tree size (typically) | Larger | Smaller |
| Best for | Loosely constrained problems | Tightly constrained problems |
4. Specialized Constraints
4.1 AllDiff Constraint
📚 AllDiff Propagation
For AllDiff(X1, …, Xk): if any variable has a singleton domain {v}, remove v from all other variables' domains. More powerfully, if m variables collectively have only m possible values, those values can be removed from all other variables in the constraint.
✍ AllDiff Example (Sudoku Row)
Row variables: X1=5, X2=?, X3=?, …, X9=3
Given X1=5 and X9=3: remove 5 and 3 from the domains of X2…X8.
If D4={7} and D6={7,8}: after AllDiff propagation, X4=7 forces removal of 7 from D6 → D6={8}.
4.2 AtMost Constraint
📚 AtMost Constraint
AtMost(n, X1, …, Xk, v): at most n of the variables can take value v. If already n variables are assigned value v, remove v from all remaining unassigned variables' domains.
4.3 Bounds Propagation
📚 Bounds Propagation
For constraints over ordered domains (integers), maintain only the lower and upper bounds of each variable's domain. When a constraint like X1 + X2 ≤ 10 exists with D1 = [1, 7], D2 = [3, 8], we can tighten: X2 ≤ 10 − 1 = 9 (no change), X1 ≤ 10 − 3 = 7 (no change). If D1 = [4, 7], then X2 ≤ 10 − 4 = 6, so D2 shrinks to [3, 6].
5. Tree-Structured CSPs
📜 Tree CSP Theorem
If the constraint graph is a tree (acyclic connected graph), the CSP can be solved in O(n · d²) time, where n = number of variables and d = maximum domain size. This is linear in the number of variables!
Algorithm: Tree-CSP-Solver
function TREE-CSP-SOLVER(csp) returns solution or failure
1. Choose any variable as root; order variables by topological sort
giving X1, X2, …, Xn where parent(Xi) comes before Xi
2. // Backward pass: make arcs consistent from leaves to root
for j = n down to 2 do
REVISE(csp, parent(Xj), Xj)
if Dparent(Xj) = ∅ then return failure
3. // Forward pass: assign values from root to leaves
for j = 1 to n do
Xj ← any value in Dj consistent with parent's assignment
return assignment
✍ Tree CSP Example
Variables: A — B — C — D (a path/chain, which is a tree)
Domains: all {R, G, B}. Constraints: adjacent ≠.
Backward pass: REVISE(C, D) → no change. REVISE(B, C) → no change. REVISE(A, B) → no change.
Forward pass: A=R, B=G (≠R), C=R (≠G), D=G (≠R). Solution found with no backtracking!
6. Cutset Conditioning
📚 Cycle Cutset
A cycle cutset S is a subset of variables such that removing S from the constraint graph makes it a tree. If |S| = c, the algorithm:
- Try all dc assignments to the cutset variables
- For each assignment, reduce domains of remaining variables and solve the tree-structured CSP in O(n · d²)
Total complexity: O(dc · n · d²) — exponential only in the cutset size c, not in n.
✍ Cutset for Australia Map
The Australia constraint graph has cycles (e.g., WA–NT–SA–WA). Removing SA (which connects to 5 of 6 remaining regions) breaks all cycles, giving a cutset of size 1. The remaining graph {WA, NT, Q, NSW, V, T} restricted by SA's assignment forms a forest. We try 3 values for SA, solving each resulting tree in O(6 · 9) = O(54). Total: 3 × 54 = 162 operations — very fast!
7. Tree Decomposition Overview
📚 Tree Decomposition
A tree decomposition of a constraint graph organizes the variables into clusters (bags) arranged in a tree, such that:
- Every variable appears in at least one bag
- For every constraint, all variables in its scope appear together in at least one bag
- If a variable appears in two bags, it appears in every bag on the path between them (running intersection property)
The tree-width w is one less than the size of the largest bag. If tree-width is w, the CSP can be solved in O(n · dw+1) time.
💡 GATE Tip
For GATE, know that tree-structured CSPs are solvable in polynomial time O(nd²), and that cutset conditioning exploits near-tree structure. The exact tree decomposition algorithm is rarely tested, but understanding the concept (tree-width controls tractability) is valuable.
📜 Structure Exploitation Summary
The structure of the constraint graph is the key to efficient CSP solving:
- Trees: O(n · d²) — polynomial
- Nearly-trees (small cutset c): O(dc · n · d²)
- Low tree-width w: O(n · dw+1)
- General: worst case exponential, but constraint propagation + heuristics make it practical
Summary
- Constraint propagation is inference that reduces variable domains by exploiting constraints.
- Forward checking propagates to direct neighbours only; MAC runs full arc consistency — stronger but costlier.
- AllDiff and AtMost are common global constraints with specialized propagation algorithms.
- Bounds propagation is efficient for constraints over ordered/integer domains.
- Tree-structured CSPs are solvable in O(n · d²) using a two-pass algorithm.
- Cutset conditioning handles near-tree CSPs in O(dc · n · d²) where c is the cutset size.
- Tree decomposition generalizes tree solving; complexity is O(n · dw+1) for tree-width w.