Inferensys

Glossary

Arc Consistency (AC-3)

Arc Consistency (AC-3) is a specific, widely-used algorithm for enforcing arc consistency, a local consistency property in constraint satisfaction problems.
Strategy consultant facilitating AI use case discovery workshop, sticky notes on glass wall, casual corporate meeting.
CONSTRAINT SATISFACTION PROBLEM SOLVING

What is Arc Consistency (AC-3)?

Arc Consistency (AC-3) is a specific, widely-used algorithm for enforcing arc consistency, a local consistency property where, for every binary constraint, every value in a variable's domain has a compatible value in the domain of the other variable.

Arc Consistency (AC-3) is a specific, widely-used algorithm for enforcing arc consistency, a fundamental local consistency property in Constraint Satisfaction Problems (CSPs). The algorithm operates on the constraint graph, systematically checking and revising arcs (directed constraint pairs) between variables to ensure that for every value in one variable's domain, there exists at least one compatible value in the neighboring variable's domain. This process of constraint propagation prunes the search space by eliminating locally inconsistent values, making subsequent backtracking search far more efficient.

The AC-3 algorithm, introduced by Alan Mackworth in 1977, maintains a queue of arcs to be revised. When a domain is reduced, all arcs pointing to that variable are re-added to the queue to ensure propagation is complete. It achieves a time complexity of O(ed³) and space complexity of O(e), where e is the number of constraints and d is the maximum domain size. AC-3 is a core subroutine in more advanced algorithms like Maintaining Arc Consistency (MAC), which enforces full arc consistency at every node of a search tree to aggressively prune dead-ends.

ALGORITHM DEEP DIVE

Key Characteristics of AC-3

The AC-3 (Arc Consistency 3) algorithm is the seminal method for enforcing arc consistency, a core inference technique in constraint satisfaction. Its design prioritizes efficiency and systematic domain reduction.

01

Local Consistency Enforcement

AC-3 enforces arc consistency, a specific type of local consistency. For every binary constraint between two variables (X, Y), the algorithm ensures that for every value 'a' remaining in the domain of X, there exists at least one value 'b' in the domain of Y such that the pair (a, b) satisfies the constraint. This property is checked locally for each arc (directed constraint) but propagates globally as domains are reduced.

02

Worklist-Driven Propagation

The algorithm's core is a worklist (queue) of arcs to be revised. It begins with all arcs in the constraint graph. When the domain of a variable Y is reduced during a revision, all arcs pointing to Y (except the one just processed) are added back to the worklist. This ensures that changes propagate efficiently without redundant checks, making AC-3 sound (never removes a solution value) and complete for arc consistency (achieves the strongest possible domain reduction under this property).

03

Revise(X, Y) Function

The fundamental operation is the Revise(X, Y) function. For a given arc (X, Y):

  • It inspects each value 'a' in the current domain of X.
  • It checks if there exists any value 'b' in the domain of Y that satisfies the constraint C(X, Y).
  • If no such 'b' exists for a given 'a', then 'a' is removed from the domain of X. The function returns true if the domain of X was actually changed. This boolean return drives the worklist propagation logic.
04

Time and Space Complexity

AC-3 has a worst-case time complexity of O(ed³) and a space complexity of O(e), where:

  • e is the number of arcs (directed constraints) in the graph.
  • d is the maximum size of any variable's initial domain. The d³ factor arises because Revise can, in the worst case, check all d values in X against all d values in Y (d²), and an arc can be processed up to d times. In practice, with good heuristics and sparse constraints, performance is often far better.
05

Role in Search (MAC)

AC-3 is rarely used in isolation. Its primary role is as the inference engine inside Maintaining Arc Consistency (MAC), a complete search algorithm. In MAC, AC-3 (or a more advanced variant like AC-2001) is called at every node of the backtracking search tree after a variable assignment. This aggressively prunes future search space by eliminating values from unassigned variables that are now arc-inconsistent with the current partial assignment.

06

Comparison to Other AC Algorithms

AC-3 is simpler but less optimal than later algorithms:

  • AC-1 & AC-2: Earlier, less efficient versions. AC-1 revisits all arcs after any change.
  • AC-4: A more complex, optimal algorithm with O(ed²) worst-case time complexity. It uses counters and support lists to avoid redundant checks but has higher overhead and memory use (O(ed²)).
  • AC-2001/3.1: Modern optimal variants that retain AC-3's simplicity by remembering a single latest supporting value for each (variable, value, constraint), achieving O(ed²) complexity. AC-3 remains the practical default due to its simplicity and good average-case performance.
ARC CONSISTENCY (AC-3)

Frequently Asked Questions

Essential questions and answers about the AC-3 algorithm, a cornerstone technique for efficiently solving Constraint Satisfaction Problems (CSPs) by enforcing local consistency.

The AC-3 algorithm is a specific, widely-used procedure for enforcing arc consistency, a local consistency property in Constraint Satisfaction Problems (CSPs). It works by iteratively processing a queue of arcs (directed constraints between two variables). For each arc (Xi, Xj), the algorithm examines each value v in the domain of Xi to see if there exists at least one compatible value in the domain of Xj that satisfies the binary constraint between them. If a value v has no supporting value in Xj's domain, v is removed from Xi's domain. This removal may make other arcs inconsistent, so they are added back to the queue. The algorithm terminates when the queue is empty (a fixed point is reached) or if a variable's domain becomes empty (proving inconsistency).

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.