AI Search · Exam notes

CSP: Relations, Arc Consistency, Path Consistency, Solution

One CSP comprehension per paper, five sub-questions on three variables: which tuples are in each relation? is it arc consistent? after enforcing it, is it path consistent? what is the solution? One chain answers all: build each relation value by value, delete unsupported values with revise until nothing changes, check witnesses on the triangle, read off the singletons.

Points 1 and 2 are the rules. Point 3 applies them to a mod-arithmetic CSP on A, B, C. Point 4 has two drills to solve with a pen.

1. Vocabulary in one table

TermMeaning
Variable, domainA variable (A, B, C) with a set of possible values, here each \(\{1,2,3,4\}\).
Constraint, relationA rule like \(A = mod(2C,3)\); the relation lists the allowed value pairs, e.g. \(R_{AC}\).
Constraint graphVariables as nodes, constraints as edges. Here a triangle: A-B, B-C, A-C.
Matching diagramValues as nodes, allowed pairs as links. Support = a link to the other side.
Arc consistentEvery value of every variable has a supporting value in each neighbor. One unsupported value breaks it.
Revise(X,Y)Delete values of X with no support in Y. Repeat over all arcs (AC-3 queues them) until no change.
Path consistentFor every allowed pair on one edge, some value of the third variable completes both links of the triangle.

2. The four checks

  1. Relations: plug each domain value into the mod formula and keep results inside the domain. Tuples print in relation-name order: (A,C) for \(R_{AC}\), (B,A) for \(R_{BA}\). Shortcut: \(mod(n,3)\) only yields 0, 1, 2, so a value like 4 as a mod-3 result is impossible.
  2. Arc consistent? For each directed arc, every value needs a partner. Find one unsupported value and stop: answer No.
  3. Enforce then path check: run revise round-robin, deleting dead values (deletions cascade: a deleted value kills values that only it supported). Then on each triangle edge, every surviving pair needs a witness value in the third variable.
  4. Solution: singleton domains read off directly. Non-singleton domains need search; arc consistency alone does not finish the job.

3. Worked example: \(D_A = D_B = D_C = \{1,2,3,4\}\), three mod constraints

3a. The data as tables (solve from this, then check the walkthrough)

ConstraintMeaning
R_AC: A = mod(2C,3)C=1 gives A=2; C=2 gives A=1; C=3 gives 0 (out); C=4 gives A=2
R_BA: B = mod(3A,4)A=1 gives B=3; A=2 gives B=2; A=3 gives B=1; A=4 gives 0 (out)
R_CB: C = mod(2B,3)B=1 gives C=2; B=2 gives C=1; B=3 gives 0 (out); B=4 gives C=2
RelationTuples
R_AC (A,C)(1,2), (2,1), (2,4)
R_BA (B,A)(1,3), (2,2), (3,1)
R_CB (C,B)(1,2), (2,1), (2,4)

Cover the walkthrough. Compute the three relations, revise each arc until the domains stop shrinking, check witnesses, read the answer.

3b. Walkthrough: one revise per step, deletions tracked

Step 0 | filled chip = kept or hits, dashed chip = misses, struck chip = deleted by revise

Why this step

Tracker

3c. The five questions

CSP on A, B, C with \(D_A = D_B = D_C = \{1,2,3,4\}\), \(R_{AC}\): \(A = mod(2C,3)\), \(R_{BA}\): \(B = mod(3A,4)\), \(R_{CB}\): \(C = mod(2B,3)\). \(mod(n,d)\) is the remainder, e.g. \(mod(8,3) = 2\).

  1. Which tuples occur in \(R_{AC}\)? Candidates: (1,2), (2,1), (2,4), (4,2).
  2. Which tuples occur in \(R_{BA}\)? Candidates: (1,3), (2,2), (3,1), (4,2).
  3. Is the CSP arc consistent? Yes / No / Cannot be determined.
  4. If not, make it arc consistent: is the result path consistent? Path consistent / Not path consistent / Does not apply (cycle).
  5. Solution for A,B,C, or NIL.

3d. Answers first, then the working

\(R_{AC}\): (1,2), (2,1), (2,4). \(R_{BA}\): (1,3), (2,2), (3,1). Arc consistent? No. After enforcing: path consistent. Solution: 2,2,1.

Revise stepSupport rowsDomains after
A wrt C1 keeps (C=2); 2 keeps (C=1,4); 3 dead; 4 deadA={1,2}
C wrt A1,2,4 keep; 3 dead (needs A=0)C={1,2,4}
B wrt A2 keeps (A=2); 3 keeps (A=1); 1 dead (needs A=3); 4 impossibleB={2,3}
A wrt B1 keeps (B=3); 2 keeps (B=2): no change-
C wrt B1 keeps (B=2); 2 dead (needs B=1,4); 4 impossibleC={1}
B wrt C2 keeps (C=1); 3 dead (needs C=0)B={2}
A wrt B2 keeps (B=2); 1 dead (needs B=3)A={2}
re-verifyno change anywhere: arc consistent2,2,1
  1. Q32 is No already at the first support check: C=3 needs \(A = mod(6,3) = 0\), outside every domain. (A=3 and A=4 are dead the same way.)
  2. Q33 witnesses (all singleton, so one check per edge). Pair (A,C)=(2,1) via B=2: (B=2,A=2) is in \(R_{BA}\) since \(mod(6,4) = 2\), and (C=1,B=2) is in \(R_{CB}\) since \(mod(4,3) = 1\). Pair (B,A)=(2,2) via C=1 and pair (C,B)=(1,2) via A=2 close the same way. Path consistent. The cycle option is the trap: path consistency is defined for cycles, it does not fail because of them.
  3. Q34 verifies: \(A = mod(2C,3) = mod(2,3) = 2\). \(B = mod(3A,4) = mod(6,4) = 2\). \(C = mod(2B,3) = mod(4,3) = 1\). All three hold: 2,2,1.

4. Practice: two drills

Solve each with a pen before opening the answer. Each drill is self contained.

Drill C1: strict order on two values

Variables A, B with \(D_A = D_B = \{1,2\}\), one constraint \(A < B\). Q1: is the CSP arc consistent? Q2: run revise both ways; Q3: solution?

Step 0

Why this step

Tracker

Answer C1

Q1: No. A=2 has no B above it; B=1 has no A below it. Q2: revise A wrt B deletes 2 (\(D_A = \{1\}\)); revise B wrt A deletes 1 (\(D_B = \{2\}\)). Q3: singletons read off: A=1, B=2, and \(1 < 2\) holds.

Drill C2: mod with two solutions left

Variables A, B with \(D_A = D_B = \{1,2,3\}\), one constraint \(B = mod(2A,3)\). Q1: list \(R_{BA}\) as (B,A) tuples. Q2: arc consistent? Q3: domains after enforcing? Q4: solution?

Step 0

Why this step

Tracker

Answer C2

Q1: A=1 gives B=2; A=2 gives B=1; A=3 gives 0, out. So (2,1), (1,2). Q2: No, A=3 is dead. Q3: revise A wrt B drops 3 (\(D_A = \{1,2\}\)); B=1 keeps A=2, B=2 keeps A=1, B=3 was never producible (mod 3 yields 0,1,2) so it drops too (\(D_B = \{1,2\}\)). Q4: not unique: (A,B) = (1,2) or (2,1). Arc consistency shrinks domains; search picks the solution. That is the standard follow-up trap.

5. Exam checklist (write this on the rough sheet)

  1. Write each relation as tuples before anything else. Note the tuple order from the relation name.
  2. Use the mod-range shortcut: mod 3 yields only 0,1,2; mod 4 only 0..3. Out-of-domain results kill values fast.
  3. Arc check: one unsupported value anywhere means No. Check the value the formula can never produce first.
  4. Revise round-robin and cascade: after each deletion, recheck arcs that used the deleted value.
  5. Path check: every surviving pair needs one witness in the third variable. On singletons that is one check per edge.
  6. Cycles do not block path consistency. Singleton domains read off as the solution, then verify all three constraints.