 Hello, everyone. This is Alice Gao. In this video, I'm going to trace the AC3 arc consistency algorithm on the four-queens problem. Recall that, when we solve the four-queens problem using backtracking search, the assignment x0 equals 0 does not lead to a solution. This example will show you that we can arrive at the same conclusion by running the AC3 algorithm. I will trace the AC3 algorithm on this constraint graph. Let me start by setting x0 to be 0. For each pair of variables, I have combined the row and the diagonal constraints. For each constraint, there are two arcs, one for each variable. Therefore, at the start of the AC3 algorithm, I will add 12 arcs to the set S. When an arc has a letter S on it, it means that the arc is in set S. Let me start executing the AC3 algorithm. I'm going to remove the arcs in an arbitrary order. Remember that the order does not affect the result. Step one, let's remove the arc between x0 and x1, where x1 is the primary variable. Is this arc consistent? If x1 is 0, then x0 equals 0 violates the row constraint. If x1 is 1, then x0 equals 0 violates the diagonal constraint. If x1 is 2, x0 equals 0 satisfies both constraints. If x1 is 3, x0 equals 0 also satisfies both constraints. Therefore, this arc is not consistent and we need to remove 0 and 1 from the domain of x1. Since we reduced the domain of x1, do we need to add any arcs back to the set S? There are three candidates. The arc between x0 and x1, the arc between x1 and x2, and the arc between x1 and x3. Due to the edge case, we do not add back the arc between x0 and x1, where x0 is the primary variable. This is the arc for the same constraint where the other variable is the primary variable. We should add the other arcs back to S. However, they're in S already and S is a set with no duplicates. We do not need to add them again. This is the end result of step 1. Step 2, let's remove the arc between x0 and x2, where x2 is a primary variable. Is this arc consistent? If x2 is 0, x0 equals 0 violates a row constraint. If x2 is 1, x0 equals 0 satisfies both the row and diagonal constraints. If x2 is 2, x0 equals 0 violates a diagonal constraint. If x2 equals 3, x0 equals 0 satisfies both the row and the diagonal constraint. Therefore, the arc is not consistent and we need to remove 0 and 2 from the domain of x2. Since we reduced the domain of x2, do we need to add any arcs back to the set S? There are three candidates, the arc between x0 and x2, the arc between x1 and x2, and the arc between x2 and x3. Due to the edge case, we do not add back the arc between x0 and x2, where x0 is the primary variable. We should add the other two arcs back to S. Since they're already in S, we do not need to add them again. Step 3, let's remove the arc between x0 and x3, where x3 is the primary variable. Is this arc consistent? If x3 is 0, x0 equals 0 violates a row constraint. If x3 is 1, x0 equals 0 satisfies both constraints. If x3 is 2, x0 equals 0 satisfies both constraints. If x3 is 3, x0 equals 0 violates a diagonal constraint. Therefore, this arc is not consistent and we need to remove 0 and 3 from the domain of x3. Since we reduced the domain of x3, do we need to add any arcs back to the set S? There are three candidates, the arc between x0 and x3, the arc between x1 and x3, and the arc between x2 and x3. Due to the edge case, we do not add back the arc between x0 and x3, where x3 is the primary variable. I mean, x0 is the primary variable. We should add the other two arcs back to S. Since they're already in S, we do not need to add them again. Step 4, let's remove the arc between x1 and x3, where x1 is the primary variable. Is this arc consistent? If x1 is 2, x3 equals 1 satisfies both constraints. If x1 is 3, x3 equals 2 satisfies both constraints. Therefore, this arc is consistent. Let's continue. Step 5, let's remove the arc between x2 and x3, where x2 is the primary variable. Is this arc consistent? If x2 is 1, no value of x3 satisfies both constraints. x3 equals 1 violates a row constraint. x3 equals 2 violates a diagonal constraint. If x2 is 3, x3 equals 2 satisfies both constraints. Therefore, the arc is not consistent, and we need to remove one from the domain of x2. Since we reduce the domain of x2, do we need to add any arcs back to the set S? There are three candidates. Due to the edge case, we do not add back the arc between x2 and x3, where x3 is the primary variable. We should add the other two arcs back to S. Since they're already in S, we do not need to add them again. Step 6, let's remove the arc between x2 and x3, where x3 is the primary variable. Is this arc consistent? If x3 is 1, x2 equals 3 satisfies both constraints. If x3 is 2, x2 equals 3 violates a diagonal constraint. Therefore, the arc is not consistent, and we need to remove 2 from the domain of x3. Since we reduce the domain of x3, do we need to add any arcs back to the set S? There are three candidates. Due to the edge case, we do not add back the arc between x2 and x3, where x2 is the primary variable. We should add the other two arcs back to S. The arc between x0 and x3 is already in S, so we don't need to add it again. The arc between x1 and x3 is not in S, and we will add it to S again. This is our first example where we have to add an arc back to S after reducing a variable's domain. This is one of the most important steps in this video. Step 7, let's remove the arc between x1 and x2, where x2 is the primary variable. Is this arc consistent? If x2 is 3, no value of x1 satisfies both constraints. x1 equals 2 violates a diagonal constraint. x1 equals 3 violates a row constraint. Therefore, this arc is not consistent, and we need to remove 3 from the domain of x2. The domain of x2 is empty. The AC3 algorithm terminates, and we can conclude that no solution exists for this problem. This is consistent with what we found during backtracking search. If we start with the assignment x0 is 0, then the constraint satisfaction problem, the four-queens problem, does not have a solution. That's everything for this video. Let me summarize. After watching this video, you should be able to do the following. Trace the execution of the AC3 algorithm on a constraint satisfaction problem. Thank you very much for watching. I will see you in the next video. Bye for now.