Exercise 2 Name __________________ Score __/12

Repeated states can occur but not infinitely.
Note that the text proved A* is optimal using TREE-SEARCH if h(n) is admissible.
We assume g(n) > 0 for all but the goal node. Then for a node expanded more than one time in a cycle, g(n+1) = g(n) + c(n,a,n+1) > g(n) where n is one expansion, n+1 is the next expansion and c(n,a,n+1) > 0 is the cost of the cycle from n to same node n+1. Therefore, g(n+1) > g(n) and is monotonically increasing to infinity as n increases.
Since A* is optimal either n is on the optimal path or not. If on the optimal path, g(n) <= g(G) so repetitions to n is finite and repeated states stop. If not on the optimal path, some repetition of n will not be expanded and repeated states stop.

Going between Rimnicu Vilcea and Lugoj is one example. The shortest path is the southern one, through Mehadia, Dobreta and Craiova. But a greedy search using the straight-line heuristic starting in Rimnicu Vilcea will start the wrong way heading to Sibiu. Starting at Lugoj, the heuristic will correctly lead us to Mehadia, but then a greedy search will return to Lugoj and oscillate forever between these two cities.
Fails is not quite accurate, it does not fail to find a solution but does fail to find the optimal solution.
Side note:
For the graph to be consistent:
7 = h(S)<=c(S,a,A)+h(A)=
4+1 = 5which is false.
Starting at S, the GRAPH-SEARCH fringe with f(n) and the closed list is:
fringe closed
- [S] []
- [(A, 5=4+1), (B,7=2+5)] [S]
- [(B, 7=2+5), (G,8=8+0)] [S, A]
- [(A, 4=3+1),(G,8)] [S, A, B]
- [(G,8)] [S, A, B]
- [] [S, A, B]
Goal reached S->A->G at cost of 8 though optimal path S->B->A->G cost of 7.