Unit 3:Adversarial Search and
Games
Types of Constraints
Constraint Satisfaction Problem
● The constraint satisfaction problem consists of three
components:
i) X- set of Variables
ii) D- Set of Domains (one for each variable)
iii) C- set of constraints
● A constraint satisfaction problem ( CSP ) is a problem where
variables must be assigned values that satisfy certain
constraints.
Examples of Constraint satisfaction Problems
● n-queen problem: In n-queen problem, the constraint is that no queen
should be placed either diagonally, in the same row or column.
● Cryptarithmetic Problem: This problem has one most important
constraint that is, we cannot assign a different digit to the same
character. All digits should contain a unique alphabet.
● Sudoku: every row, column and 3* 3 board should have unique digit.
● Graph/map coloring problem: no two adjacent region have same
colour.
Constraint satisfaction Problems
An assignment of values to a variable can be done in three ways:
● Consistent or Legal Assignment: An assignment which does not violate
any constraint or rule is called Consistent or legal assignment.
● Complete Assignment: An assignment where every variable is assigned
with a value, and the solution to the CSP remains consistent. Such
assignment is known as Complete assignment.
● Partial Assignment: An assignment which assigns values to some of the
variables only. Such type of assignments are called Partial assignments.
Types of Constraints in CSP
Constraint Types in CSP
With respect to the variables, basically there are following types of constraints:
● Unary Constraints: It is the simplest type of constraints that restricts the
value of a single variable.
● Binary Constraints: It is the constraint type which relates two variables. A
value x2 will contain a value which lies between x1 and x3.
● Global Constraints: It is the constraint type which involves an arbitrary
number of variables.
Constraint Propagation in CSP
Constraint Propagation
● Constraint Propagation is a technique used in Constraint Satisfaction
Problems (CSPs) to reduce the search space by enforcing constraints before
or during the search. It systematically eliminates inconsistent values from
variable domains by applying constraints iteratively.
● How Constraint Propagation Works
• Each variable in a CSP has a domain of possible values.
• Constraints restrict which values can be assigned to variables.
• Constraint propagation reduces domains by eliminating values that violate
constraints, making the search process more efficient.
Benefits of Constraint Propagation
• Reduces the search space by eliminating inconsistent values early.
• Helps avoid unnecessary backtracking in search algorithms.
• Improves efficiency, especially in large CSPs.
Applications of Constraint Propagation
• Sudoku Solving (removing invalid numbers from each row, column, and
block).
• Scheduling Problems (ensuring time slots do not overlap).
• Graph Coloring (ensuring no two adjacent nodes have the same color).
• AI Planning (optimizing task assignments and dependencies).
Types of consistencies
There are following local consistencies which are discussed below:
● Node Consistency: A single variable is said to be node consistent if all the
values in the variable’s domain satisfy the unary constraints on the variables.
● Arc Consistency: A variable is arc consistent if every value in its domain satisfies
the binary constraints of the variables.
● Path Consistency: When the evaluation of a set of two variable with respect to
a third variable can be extended over another variable, satisfying all the binary
constraints. It is similar to arc consistency.
Constraint Satisfaction: Propagation
Node consistency
Node consistency requires that every unary constraint on a variable is
satisfied by all values in the domain of the variable, and vice versa. This
condition can be trivially enforced by reducing the domain of each variable to
the values that satisfy all unary constraints on that variable.
For example, given a variable {V}
with a domain of {1,2,3,4}
and a constraint {V<3}
Node consistency would restrict the domain to {1,2} and the constraint could
then be discarded.
Node Consistency(X,D,C)
For each x
Constraint Propagation:Inference in CSPs
Arc Consistency
● The pair (X, Y) of constraint variables is arc consistent if for each
value
x∈DX there exists a value y∈DY such that the assignments X = x
and Y = y satisfy all binary constraints between X and Y. A CSP is
arc consistent if all variable pairs are arc consistent.
● Consider a simple CSP with the variables A and B subject to their
respective domains DA={1,2} and DB={1,2,3} , as well as the
Arc Consistency
Revise for arc-consistency
Path-consistency
Path-consistency
Example: before and after path-
consistency
Backtracking Search
N Queen
Gap coloring