Chapter 5: Constraint Satisfaction Problems

5.1 What is a CSP?

A Constraint Satisfaction Problem is a type of problem where:

CSP = Find valid values

5.2 Components of a CSP

Component Description Example: Map Coloring
Variables The items to assign values to Regions: A, B, C
Domains Allowed values for each variable Colors: Red, Green, Blue
Constraints Rules that limit how variables can be assigned Adjacent regions ≠ same color

5.3 Types of Constraints

Type Description Example
Unary Applies to a single variable A ≠ Red
Binary Applies between two variables A ≠ B
Higher-Order Involves 3 or more variables in a rule A ≠ B ≠ C
Global Constraints Apply to large sets, often patterns "AllDifferent" in Sudoku

5.4 Solving CSPs: Techniques

Backtracking Search

Try assigning values one by one, and backtrack when a constraint is violated.

Recursive, depth-first search approach.

Forward Checking

After assigning a variable, look ahead and remove values from other variable domains that are no longer valid.

Constraint Propagation

Propagate changes to narrow down possible values in all related variables.

5.5 Frequently Asked Exam Questions

  1. Define CSP. Explain components with examples.
  2. What is constraint propagation? How does it differ from forward checking?
  3. Solve the following map coloring problem with a constraint graph.
  4. Define arc consistency. Explain AC-3 with a suitable example.
  5. Compare backtracking, forward checking, and constraint propagation.