This is a classic problem in search algorithms and artificial intelligence. Let me provide a comprehensive proof of A* optimality under the conditions of admissible and consistent heuristics.
Key Definitions
First, let me establish the key definitions:
- Admissible heuristic: h(n) ≤ h*(n) for all nodes n, where h*(n) is the true cost from n to the goal
- Consistent heuristic (also called monotonic): h(n) ≤ c(n,n') + h(n') for all nodes n and successors n', where c(n,n') is the cost of the edge from n to n'
- f(n): The evaluation function f(n) = g(n) + h(n), where g(n) is the actual cost from start to n
- C*: The optimal cost to reach a goal
Let me structure a proper mathematical proof.
Proof of A* Optimality
I'll prove two related but distinct properties:
Property 1: When A* expands a node, it has found an optimal path to that node (under consistency)
Property 2: A* never expands a node with f(n) > C* (the lemma we need to prove)
Property 3: A* expands nodes in order of increasing f value (consequence of consistency)
Let me provide the complete proof:
Theorem: If h is admissible and consistent, A* expands nodes in order of increasing f-value and is optimal.
Proof:
Part 1: Consistency implies f is non-decreasing
Lemma 1: If h is consistent, then f values are non-decreasing along any path.
Proof: Consider a path from node n to its successor n'.
-
f(n) = g(n) + h(n)
-
f(n') = g(n') + h(n') = g(n) + c(n,n') + h(n')
-
By consistency: h(n) ≤ c(n,n') + h(n')
-
Therefore: f(n) ≤ f(n')
This establishes that f values never decrease along any path. ∎
Part 2: A expands nodes in order of increasing f-value*
Lemma 2: A* expands nodes in order of non-decreasing f-value.
Proof: A* always selects the node with minimum f-value from the open set. Since f values are non-decreasing along paths (from Lemma 1), and A* uses a priority queue ordered by f-value, each node expanded has an f-value at least as large as the previously expanded node.
Part 3: Main Theorem - A Never Expands a Node with f > C**
Theorem: If h is admissible and consistent, A* never expands a node n where f(n) > C*.
Proof by contradiction: Assume A* expands some node n with f(n) > C*. Since an optimal solution exists with cost C*, there's a goal node g_optimal on an optimal path. Consider the first unexpanded node n' along this optimal path at the moment n gets expanded. Since A* chose n over n', we have f(n) ≤ f(n'). Now, let
's trace from n' to g_optimal. Because n' lies on the optimal path, the cost from start to n' plus the heuristic estimate satisfies: f(n') = g(n') + h(n') ≤ C*, where the inequality follows from h(n') being admissible and bounded by the remaining optimal cost. This means f(n') ≤ C*, but we assumed f(n) > C*, which contradicts f(n) ≤ f(n').
Since A* expanded n before n', we have a contradiction. Therefore A* cannot expand any node exceeding cost C*.
When A* terminates by selecting a goal node g for expansion, we know h(g) = 0 since g is a goal. The f-value at this point is f(g) = g(g), which represents the actual path cost to reach g. By Part 3, this cost cannot exceed C*, so the selected goal must be optimal.
Regarding consistency and admissibility: consistency is the stronger condition. When h is consistent, it satisfies h(n) ≤ c(n,n') + h(n') for all successors n', which ensures the heuristic never overestimates and implies admissibility as well. So h(n) ≤ h*(n) for all nodes follows from consistency. While admissibility alone could work with careful termination conditions, the proof becomes cleaner when both properties are leveraged together—consistency keeps f values non-decreasing along paths, and admissibility provides the necessary bound on heuristic values.
The core claim to establish is that A* never expands any node n where f(n) exceeds the optimal cost C*. This f-cost bound is what ensures A* finds optimal solutions.
Assume for contradiction that A* expands some node n with f(n) > C*. Since an optimal solution exists with cost C*, there's a path from the start to a goal node with that cost. On this optimal path, consider the first node n* that hasn't been expanded yet when n gets expanded—such a node must exist because the start has been expanded but goal nodes aren't expanded (the algorithm terminates upon selection). At the moment n is expanded, n* remains either in the open list or hasn't been discovered.
When n is selected for expansion, A* must have f(n) ≤ f(n*) since it always picks the minimum f-value node. For n* on the optimal path, I can compute f(n*) = g(n*) + h(n*), where g(n*) is the actual cost from start to n* along the optimal path, and h(n*) estimates the remaining cost to the goal.
By the admissibility of h, we know h(n*) ≤ C* - g(n*), so f(n*) ≤ C*. But this contradicts our assumption that f(n) > C*, since we also have f(n) ≤ f(n*) ≤ C*. This contradiction means our assumption must be false—A* cannot expand a node with f-value exceeding C* before reaching the goal.
The proof fundamentally relies on admissibility to establish the upper bound on f(n*). Consistency plays a supporting role by ensuring f-values remain monotonic along paths and by reducing the number of nodes A* needs to explore, though the core optimality argument holds with admissibility alone.
The distinction matters when considering graph search versus tree search: graph search with consistency prevents reopening nodes with potentially better paths, while tree search only requires admissibility since it doesn't track visited nodes. For this particular result about never expanding nodes exceeding C*, admissibility is the essential property.
If A* expands node n with f(n) > C*, but an optimal solution exists with cost C*, then when A* eventually selects a goal node g* with g(g*) = C*, we'd have f(g*) = C*. Since A* chose n over g*, we'd need f(n) ≤ f(g*) = C*, contradicting our assumption—unless g* hadn't been discovered yet. This reveals the subtlety: the proof requires careful handling of when nodes enter the open list and how admissibility constrains the heuristic values throughout the search.
The distinction between tree search and graph search matters here. Tree search only needs admissibility, but graph search requires consistency to prevent reopening nodes through better paths. Without consistency, a node in the closed set might be reached again with lower cost, breaking optimality guarantees.
For the standard result—that A* with graph search is optimal under consistent heuristics—I need to establish that consistency ensures f values are non-decreasing along any path. If h is consistent and n' is a successor of n, then f(n) = g(n) + h(n) relates to f(n') = g(n') + h(n') where g(n') = g(n) + c(n,n').
By the consistency condition h(n) ≤ c(n,n') + h(n'), I can show that f(n) ≤ f(n'), meaning f never decreases as we traverse paths. This non-decreasing property is crucial: when A* first selects a goal node for expansion, that node must have optimal cost, since any alternative path would have produced an equal or higher f value and would have been selected earlier or simultaneously. I need to complete the partial thought and then summarize the next thinking.
Completing the partial thought: If g_opt was in OPEN when n was expanded, then f(n) ≤ f(g_opt) = C*, which contradicts our assumption that f(n) > C*. If g_opt hadn't been discovered yet, it must have been reachable through some path, and by the properties of f-values along paths, we'd still get f(n) ≤ C*.
For Case 1, since n isn't a goal, when the algorithm terminates at some optimal goal g_opt with cost C*, the fact that n was expanded before g_opt was selected means f(n) couldn't exceed C* without violating A*'s greedy selection of minimum f-values. If g_opt was already in OPEN, we'd have f(n) ≤ f(g_opt) = C*, contradicting f(n) > C*. If g_opt wasn't yet discovered, the admissibility of h ensures that once found, its f-value would be at most C*, so n couldn't have been expanded first.
For Case 2, if n itself is a goal with f(n) > C*, then g(n) > C*, which contradicts C* being the optimal solution cost by definition.
But actually, A* terminates upon selecting a goal node rather than expanding it. Under the standard algorithm, when a node with minimum f-value is selected and found to be a goal, we return immediately without expanding its successors. This means any goal node selected will have f-value equal to C*, since the proof shows no node with f > C* can be selected before reaching the optimal goal. The key insight is that A* with an admissible heuristic guarantees the first goal selected is optimal. When A* terminates by selecting goal g*, we have f(g*) = g(g*). By consistency, A* never re-opens nodes and always expands the minimum f-value node. Since any alternate goal g_opt must satisfy f(g_opt) = C* (by admissibility), and A* chose g* first, we know g(g*) ≤ C*. Combined with the fact that g(g*) ≥ C* (since C* is optimal), this gives g(g*) = C*. The key distinction is whether we're using graph search with consistency or tree search—in the graph search case with consistency, nodes are never re-opened, ensuring the first goal selected is optimal. If n* is in the open list, then A* would have selected it before expanding n, since f(n*) ≤ C* < f(n). If n* hasn't been discovered yet, its predecessor on the optimal path must have been expanded, which means n* should have been generated and added to the open list—a contradiction.
Therefore, A* never expands a node with f(n) > C*. Since the algorithm terminates with an optimal solution, it must select a goal node before expanding any node exceeding this threshold, guaranteeing optimality. Since n* lies on an optimal path with total cost C*, and h is admissible, we know h(n*) ≤ C* - g(n*). This means f(n*) = g(n*) + h(n*) ≤ C*.
But we've established that f(n) ≤ f(n*), which gives us f(n) ≤ C*. This contradicts our assumption that f(n) > C*, so A* cannot expand nodes exceeding the optimal cost. The proof is complete, and I should also touch on how consistency relates to this result.
Proof of A* Optimality
Theorem
If h is admissible and consistent, A never expands a node n where f(n) > C, where C* is the optimal solution cost.**
Proof (by Contradiction)
Setup premise: Assume A* expands some node n with f(n) > C*.
Since A* eventually terminates with an optimal solution, there exists an optimal path:
start→⋯→g∗(goal)
with total cost exactly C*
Step 1: Identify the Critical Node
Consider the first node n on the optimal path that has NOT yet been expanded* when n is expanded.
Why n exists:*
- Start node is expanded first ✓
- Goal nodes are selected (not expanded) for termination
- Therefore a "first unexpanded node" must exist on the path
At expansion time, n is in the OPEN list* (discovered but not expanded)
Step 2: Compare f-values
Since A* always expands the node with minimum f-value from OPEN:
f(n)≤f(n∗)
This is the definition of A*'s greedy selection criterion.
Step 3: Bound f(n*)
Since n* lies on an optimal path with total cost C*:
- Path cost to n*: g(n∗) (actual distance from start)
- Remaining cost from n* to goal: C∗−g(n
By admissibility:
h(n∗)≤h∗(n∗)=
Therefore:
f(n∗)=g(n∗)+
Step 4: Contradiction
Combining all inequalities:
C∗<f(n)≤f(n∗)≤
This is impossible — a logical contradiction!
Conclusion
Our assumption must be false. Therefore:
A* never expands a node n with f(n)>C∗
Corollary: A* is Optimal
When A* terminates by selecting a goal node g*:
- f(g∗)=g(g∗)+0=g(g
Thus A* returns an optimal solution.
Role of the Conditions
| Condition | Role |
|---|
| Admissibility | Bound h(n*) ≤ C* - g(n*); ensures heuristic underestimates |
| Consistency | Ensures f-values are non-decreasing along paths; prevents cycles and redundant expansions; needed for graph search optimality |
Note: Consistency alone implies admissibility, but both are stated for clarity in the proof structure.