 Hello everyone, this is Alice Gao. In this video, I will introduce the AC3 arc consistency algorithm. In the previous video, I introduced the arc consistency definition. The AC3 algorithm uses a arc consistency definition to reduce the variable's domains and bring us closer to solving the CSP. The AC3 algorithm was proposed in 1977 by Alan McWhorth, who is a professor emeritus in computer science at UBC. He is also one of the two authors in the Poole and McWhorth textbook. Also, you should know that Peter Van Beek, a CS professor at the University of Waterloo, worked extensively on constraint satisfaction problems. The Russell Norvig textbook has many citations of research by Professor Van Beek. I think it is very exciting that we're learning concepts developed by our professors and our colleagues. The goal of the AC3 algorithm is to make every arc consistent by reducing the variable's domains. The algorithm starts by putting every arc into a set called S. Remember that each binary constraint has two arcs associated with it. We need to put both arcs into S. Next, we'll go into a loop. While the set S is not empty, select and remove one arc from the set. The order of removing arcs is not important. Any order will lead us to the same solution. Suppose that the arc we removed is between x and y, where x is a primary variable. Next, check whether this arc is consistent. If the arc is consistent, we can go back to the beginning of the loop and select another arc to remove. If the arc is not consistent, we will reduce the domain of the primary variable, x's domain, until the arc becomes consistent. After reducing x's domain, if the domain becomes empty, we know that the problem has no solution and the algorithm can terminate. If x's domain is not empty, we may need to add one or more arcs back to S. At this step, consider any arc where x is a secondary variable, and y is not the primary variable. If any such arc is not in S, we will add the arc back to S. The last few lines in the algorithm deserve some further discussion. In particular, after reducing a variable's domain, why do we need to add these arcs back into the set S? The reason is that reducing a variable's domain may cause a previously consistent arc to become inconsistent. If this is a possibility, we need to add the arc back to S so that we will check it again. Let's look at an example. The diagram shows three variables, y, x, and z. There are two binary constraints, y equals x and x is less than z. Consider two arcs, one with x as the primary variable with the constraint y equals x, and the other one with z as the primary variable and the constraint x is less than z. Right now, the right arc, z, x is less than z, is consistent, but the left arc, x, y equals x, is not consistent. Let's verify this quickly. For the right arc, z, x is less than z. If z is 2, we can choose x equals 1, and x is less than z. If z is 3, we can choose x equals 2, and x is less than z. Therefore, the arc is consistent. For the left arc, x, y equals x, if x is 2, we can choose y equals 2. If x is 1, no value of y can satisfy the constraint. Therefore, the left arc is not consistent. To make the left arc consistent, we need to remove one from x's domain. After this change, the left arc becomes consistent. What about the right arc? The right arc becomes inconsistent because of this change. Let's verify it. If z equals 3, we can choose x equals 2, and x is less than z. If z equals 2, no value of x can satisfy the constraint, x is less than z. Before reducing x's domain, the right arc was consistent. After reducing x's domain, the right arc becomes inconsistent. In this case, we need to add the right arc, z, x is less than z, back to s, so that we can make it consistent by reducing z's domain. Finally, there is an edge case to consider. Let's look at the diagram again. To make the left arc, x, y equals x, consistent, we need to reduce x's domain. After this change, we do not need to add the arc, y, equals x, back to s. In other words, we do not need to add back the other arc for the same constraint. Proofing this is relatively straightforward, and I will leave it as an exercise for you. Listen closely for the exact statement that you will want to prove. Consider two variables, x and y, and the binary constraint, c of x and y. Assume that the arc x, c of x and y with x as a primary variable is not consistent. And the other arc, y, c of x and y with y as a primary variable is consistent. Also, assume that after removing one value from x's domain, the arc with x as a primary variable becomes consistent. Proof that after reducing x's domain, the arc with y as a primary variable remains consistent. That is everything on the AC3 arc consistency algorithm. Let me summarize. After watching this video, you should be able to do the following. Describe the steps of the AC3 arc consistency algorithm. Explain why we need to add arcs back to the set s after reducing the domain of a variable. Thank you very much for watching. I will see you in the next video. Bye for now.