problem solving and uninformed searchsoftware.ucv.ro/~cbadica/ai/cap5.pdf · problem solving and...

39
2017 Problem solving and uninformed search Chapter 5

Upload: voanh

Post on 06-Mar-2018

215 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Problem solving and uninformed searchsoftware.ucv.ro/~cbadica/ai/cap5.pdf · Problem solving and uninformed search Chapter 5 . 2017 Example: ... So, if the search strategy is fair,

2017

Problem solving and uninformed

search

Chapter 5

Page 2: Problem solving and uninformed searchsoftware.ucv.ro/~cbadica/ai/cap5.pdf · Problem solving and uninformed search Chapter 5 . 2017 Example: ... So, if the search strategy is fair,

2017

Example: map of Romania

Page 3: Problem solving and uninformed searchsoftware.ucv.ro/~cbadica/ai/cap5.pdf · Problem solving and uninformed search Chapter 5 . 2017 Example: ... So, if the search strategy is fair,

2017

Example: travelling in Romania

• While on a trip in Romania, currently in Arad, let’s assume you have a meeting tomorrow morning in Craiova

• Formulate goal:

– Goal: be in Craiova

• Formulate problem:

– States: reach of various Romanian cities

– Actions: drive between two directly connected cities

• Find solution:

– Solution: sequence of cities, for example: Arad → Sibiu → Rimnicu Vilcea → Craiova

Page 4: Problem solving and uninformed searchsoftware.ucv.ro/~cbadica/ai/cap5.pdf · Problem solving and uninformed search Chapter 5 . 2017 Example: ... So, if the search strategy is fair,

2017

Simple problem solving agent

Page 5: Problem solving and uninformed searchsoftware.ucv.ro/~cbadica/ai/cap5.pdf · Problem solving and uninformed search Chapter 5 . 2017 Example: ... So, if the search strategy is fair,

2017

Problems

• Initial state: 𝑠0, e.g. 𝐼𝑛(𝐴𝑟𝑎𝑑)

• Actions: for each state 𝑠, ACTIONS 𝑠 is the set of actions that can be applied in 𝑠. E.g.: from the state 𝐼𝑛(𝑆𝑖𝑏𝑖𝑢), the applicable actions are *𝐺𝑜(𝐹𝑎𝑔𝑎𝑟𝑎𝑠), 𝐺𝑜(𝑅𝑖𝑚𝑛𝑖𝑐𝑢 𝑉𝑖𝑙𝑐𝑒𝑎)+.

• Transitions : for each state 𝑠 and action a RESULT(𝑠, 𝑎) is the state that results by doing action 𝑎 in state 𝑠. If RESULT(𝑠, 𝑎) = 𝑡 then 𝑡 is called successor state of 𝑠. E.g.: RESULT(𝐼𝑛(𝑆𝑖𝑏𝑖𝑢), 𝐺𝑜(𝐹𝑎𝑔𝑎𝑟𝑎𝑠)) =𝐼𝑛(𝐹𝑎𝑔𝑎𝑟𝑎𝑠).

– State space: defined by initial state, actions and transitions. It is a directed graph.

– Path: defines a path in the state space graph.

• Goal: checks if a state is a goal state:

– Explicit: enumerates goal states, e.g. *𝐼𝑛(𝐶𝑟𝑎𝑖𝑜𝑣𝑎)+

– Implicit: defines an abstract property of the goal state

• Path cost: a numeric cost assigned to each path. Usually a non-negative cost 𝑐(𝑠, 𝑎, 𝑡) is assigned to each state transition determined by executing action 𝑎 in state 𝑠 to produce state 𝑡.

Page 6: Problem solving and uninformed searchsoftware.ucv.ro/~cbadica/ai/cap5.pdf · Problem solving and uninformed search Chapter 5 . 2017 Example: ... So, if the search strategy is fair,

2017

Solutions

• Solution: a sequence of actions (or path) that leads from the initial state to a goal state.

• Optimal solution: a solution that has the lowest path cost from all the solutions.

Page 7: Problem solving and uninformed searchsoftware.ucv.ro/~cbadica/ai/cap5.pdf · Problem solving and uninformed search Chapter 5 . 2017 Example: ... So, if the search strategy is fair,

2017

Example: block world

• Initial state: given configuration of blocks a a set of block stacks.

• Actions and transitions: move block from the top of one stack onto the table or onto the top of another stack.

• Goal:

– Explicit: a given final configuration of the stacks of blocks

– Implicit: block 𝐵 on top of block 𝐶.

• Path cost: number of moves.

• HW: size of the state space for n blocks = ?

C

A

B

B

A

C

A

B C

A

B C

B

A C

C

A B

B

A C

C

A B

A B C

C

B

A

B

C

A

A

B

C

A

C

B

Page 8: Problem solving and uninformed searchsoftware.ucv.ro/~cbadica/ai/cap5.pdf · Problem solving and uninformed search Chapter 5 . 2017 Example: ... So, if the search strategy is fair,

2017

Example: top-down proof

using SLD resolution

- Assume the Prolog strategy: always select the leftmost atom from the answer clause

- States, Actions, Transitions, Goal, Path cost = ?

Page 9: Problem solving and uninformed searchsoftware.ucv.ro/~cbadica/ai/cap5.pdf · Problem solving and uninformed search Chapter 5 . 2017 Example: ... So, if the search strategy is fair,

2017

Example: vacuum cleaner

• States, Actions, Transitions, Goal, Path cost = ?

Page 10: Problem solving and uninformed searchsoftware.ucv.ro/~cbadica/ai/cap5.pdf · Problem solving and uninformed search Chapter 5 . 2017 Example: ... So, if the search strategy is fair,

2017

Example: the 8-puzzle

• States: locations of the 8 tiles, as well as of the blank tile

• Initial state: initial configuration of tiles

• Actions and transition model: movements of the blank tile: 𝐿𝑒𝑓𝑡, 𝑅𝑖𝑔𝑕𝑡, 𝑈𝑝, 𝐷𝑜𝑤𝑛.

• Goal: a given final configuration of tiles.

• Path cost: number of steps, cost of 1 step is 1

Page 11: Problem solving and uninformed searchsoftware.ucv.ro/~cbadica/ai/cap5.pdf · Problem solving and uninformed search Chapter 5 . 2017 Example: ... So, if the search strategy is fair,

2017

Example: the 8-queens problem

• States: ?

• Initial state: ?

• Actions and transition model: ?.

• Goal: ?.

• Path cost: ?

Page 12: Problem solving and uninformed searchsoftware.ucv.ro/~cbadica/ai/cap5.pdf · Problem solving and uninformed search Chapter 5 . 2017 Example: ... So, if the search strategy is fair,

2017

Tree search

• The possible action sequences generate a search tree rooted at the initial state.

– Branches = actions

– Nodes = states

• Various actions are considered by expanding the current state to generate new states.

– Parent node = current state

– Child nodes = new states

– Braches = possible actions

• The set of leaf nodes available for expansion determines the frontier.

• The selection of nodes from frontier for expansion is called search strategy.

• Each selected node is firstly checked to see if it is a goal.

Page 13: Problem solving and uninformed searchsoftware.ucv.ro/~cbadica/ai/cap5.pdf · Problem solving and uninformed search Chapter 5 . 2017 Example: ... So, if the search strategy is fair,

2017

Tree search visualization

Page 14: Problem solving and uninformed searchsoftware.ucv.ro/~cbadica/ai/cap5.pdf · Problem solving and uninformed search Chapter 5 . 2017 Example: ... So, if the search strategy is fair,

2017

Generic tree search algorithm

Page 15: Problem solving and uninformed searchsoftware.ucv.ro/~cbadica/ai/cap5.pdf · Problem solving and uninformed search Chapter 5 . 2017 Example: ... So, if the search strategy is fair,

2017

Example: loopy paths

• The path Arad → Timisoara → Arad is a loopy path !

Arad

Sibiu Timisoara Zerind

Lugoj Arad

Page 16: Problem solving and uninformed searchsoftware.ucv.ro/~cbadica/ai/cap5.pdf · Problem solving and uninformed search Chapter 5 . 2017 Example: ... So, if the search strategy is fair,

2017

Redundant paths

• Loopy paths ⇒ infinite search tree !

• Redundant paths: whenever there is more than one way to get from one state to another.

• 𝐿𝑜𝑜𝑝𝑦 𝑝𝑎𝑡𝑕𝑠 ⊂ 𝑅𝑒𝑑𝑢𝑛𝑑𝑎𝑛𝑡 𝑝𝑎𝑡𝑕𝑠

• Redundant paths occur in problems with reversible actions.

• Avoiding redundant paths ⇒ we must remember them.

• Explored set: remembers all the expanded nodes.

• Tree search becomes graph search.

A

B C

A

B C

A B C

Page 17: Problem solving and uninformed searchsoftware.ucv.ro/~cbadica/ai/cap5.pdf · Problem solving and uninformed search Chapter 5 . 2017 Example: ... So, if the search strategy is fair,

2017

Generic graph search algorithm

Page 18: Problem solving and uninformed searchsoftware.ucv.ro/~cbadica/ai/cap5.pdf · Problem solving and uninformed search Chapter 5 . 2017 Example: ... So, if the search strategy is fair,

2017

Separation property of graph search

• The frontier separates / partitions the state-space graph into:

– Explored set

– Unexplored set

– Every path from the initial state to an unexplored has to pass through the frontier

Page 19: Problem solving and uninformed searchsoftware.ucv.ro/~cbadica/ai/cap5.pdf · Problem solving and uninformed search Chapter 5 . 2017 Example: ... So, if the search strategy is fair,

2017

Infrastructure of searching

• Search tree:

– 𝑛.STATE : the state to which the node corresponds

– 𝑛.PARENT : the node that generated 𝑛

– 𝑛.ACTION : the action that generated the current node 𝑛 by expanding the parent node

– 𝑛.PATH-COST : the cost of the past from the initial node to the current node 𝑛

Page 20: Problem solving and uninformed searchsoftware.ucv.ro/~cbadica/ai/cap5.pdf · Problem solving and uninformed search Chapter 5 . 2017 Example: ... So, if the search strategy is fair,

2017

Representing a problem using logic programming

neighbors(a,[b,d])

neighbors(b,[g])

neighbors(a,[d])

neighbors(d,[c])

neighbors(c,[e])

neighbors(g,[f])

neighbors(e,[f])

is_goal(f)

B A

C D

G F E

4

4

2 2

2

1 1 arc(a,b)

arc(a,d)

arc(d,c)

...

neighbors(N,NN)

findall(X,arc(N,X),NN)

Page 21: Problem solving and uninformed searchsoftware.ucv.ro/~cbadica/ai/cap5.pdf · Problem solving and uninformed search Chapter 5 . 2017 Example: ... So, if the search strategy is fair,

2017

Generic search in logic programming

search(F0)

select(Node,F0,F1)

is_goal(Node)

search(F0)

select(Node,F0,F1)

neighbors(Node,NN)

ad_to_frontier (NN,F1,F2)

search(F2).

search(F) there exists a path

from a node in frontier F to a

goal node

is_goal(N) N is a goal node

neighbors(N,NN) NN is the list

of neighbors of N

select(N,F0,F1) N F0 F1 =

F0 \ { N }

ad_to_frontier(NN,F1,F2) F2

= F1 NN

If the initial states are 𝑆 = *𝑠1, … , 𝑠𝑛+ then we must use the query:

? 𝑠𝑒𝑎𝑟𝑐𝑕 𝑠1, … , 𝑠𝑛

Page 22: Problem solving and uninformed searchsoftware.ucv.ro/~cbadica/ai/cap5.pdf · Problem solving and uninformed search Chapter 5 . 2017 Example: ... So, if the search strategy is fair,

2017

Correctness and completeness of generic search

• Correctness: both clause are true in the intended interpretation: – First clause is true: if 𝑁𝑜𝑑𝑒 ∈ 𝐹0 and 𝑁𝑜𝑑𝑒 is a goal node then there

exists a trivial empty path from a node in 𝐹0 tpo a goal node. – Second clause is true: Assume that the clause body is true. There

exists a path from a node 𝑋 in 𝐹2 to a goal node. This node 𝑋 is either from F1, or from 𝑁𝑁. If 𝑋 ∈ 𝐹1 then 𝑋 ∈ 𝐹0, so the head of the clause is true. If 𝑋 ∈ 𝑁𝑁 then there exists an arc from 𝑁𝑜𝑑𝑒 to 𝑋. Adding it to the path from 𝑋 to the goal node we obtain a path from 𝑁𝑜𝑑𝑒 to the goal node, so the clause head is true.

• Completeness: for each solution there exists a sequence of choices in the second clause that generates the solution. – Assume there exists a solution. If at each step we choose from the

frontier the node on the solution path then after each choice we will get one step closer to the goal. The length of a solution is finite so this process terminates in a finite number of steps. So, if the search strategy is fair, each node of the frontier will be selected and the search will terminate with success.

Page 23: Problem solving and uninformed searchsoftware.ucv.ro/~cbadica/ai/cap5.pdf · Problem solving and uninformed search Chapter 5 . 2017 Example: ... So, if the search strategy is fair,

2017

Search infrastructure in logic programming

• Costs:

cost(N1,N2,C) cost of arc from N1 to N2 is C

cost(a,b,4)

cost(a,d,2)

...

• Paths:

– The generic search only checks the existence of a solution, but it does

not determine explicitly a solution.

– A node on a path is a term with the following structure:

node(Node,Path,PathCost) such that:

- Path = list of nodes representing the path from the start node to Node

(excluding Node)

- PathCost = cost of this path. Path expansion assumes adding a new

node at the head of this list.

Page 24: Problem solving and uninformed searchsoftware.ucv.ro/~cbadica/ai/cap5.pdf · Problem solving and uninformed search Chapter 5 . 2017 Example: ... So, if the search strategy is fair,

2017

Computing solutions

search(F0,[N | P])

select(node(N,P,PC),F0,F1)

is_goal(N)

search(F0,Path)

select(node(N,P,PC),F0,F1)

neighbors(N,NN)

ad_paths(NN, node(N,P,PC),NN1)

ad_to_frontier(NN1,F1,F2)

search(F2,Path).

ad_paths(NN, node(N,P,PC),NN1)

NN1 is the list of the new nodes on

the frontier that will replace

node(N,P,PC)

ad_paths([],N,[])

ad_paths([M|R],node(N,P,PC),

[node(M,[N|P],NPC)|FR])

cost(N,M,C)

NPC is PC+C

ad_paths(R,nod(N,P,PC),FR)

If the initial states are 𝑆 = *𝑠1, … , 𝑠𝑛+ then we must use the query:

? 𝑠𝑒𝑎𝑟𝑐𝑕(,𝑛𝑜𝑑𝑒(𝑠1, ,-, 0), … , 𝑛𝑜𝑑𝑒(𝑠𝑛, ,-, 0)-, 𝑃𝑎𝑡𝑕)

Page 25: Problem solving and uninformed searchsoftware.ucv.ro/~cbadica/ai/cap5.pdf · Problem solving and uninformed search Chapter 5 . 2017 Example: ... So, if the search strategy is fair,

2017

The search process

… [Node|Path]

Start

Path Cost

Node

Node

Path

Cost

Nk

Nk

Cost+Ck

N1

N1

[Node|Path]

Cost+C1

Ck

C1

Goal

? ?

• 𝑁𝑜𝑑𝑒 expands to neighbors 𝑁1, … 𝑁𝑘

• Cost of arc from 𝑁𝑜𝑑𝑒 to 𝑁𝑖 is 𝐶𝑖 for

1 ≤ 𝑖 ≤ 𝑘.

• 𝑃𝑎𝑡𝑕 is the current search path from

𝑆𝑡𝑎𝑟𝑡 to 𝑁𝑜𝑑𝑒 (including 𝑆𝑡𝑎𝑟𝑡 and

excluding 𝑁𝑜𝑑𝑒).

• 𝐶𝑜𝑠𝑡 is cost of 𝑃𝑎𝑡𝑕.

• Expansion of 𝑁𝑜𝑑𝑒 assumes to

update the path and cost for each

neighbor 𝑁𝑖 of 𝑁𝑜𝑑𝑒 to

– ,𝑁𝑜𝑑𝑒 | 𝑃𝑎𝑡𝑕-

– 𝐶𝑜𝑠𝑡 + 𝐶𝑖

Page 26: Problem solving and uninformed searchsoftware.ucv.ro/~cbadica/ai/cap5.pdf · Problem solving and uninformed search Chapter 5 . 2017 Example: ... So, if the search strategy is fair,

2017

Search strategies

• Search strategy = specifies the policy of selecting and adding

nodes to the frontier using relations 𝑐𝑕𝑜𝑜𝑠𝑒 and

𝑎𝑑_𝑡𝑜_𝑓𝑟𝑜𝑛𝑡𝑖𝑒𝑟.

• Classification of search strategies:

– Blind (uniformed) search strategies: have no additional information

about states beyond that provided in the problem definition

– Heuristic (informed) search strategies: know whether one non-goal

state is “more promising” than another

Page 27: Problem solving and uninformed searchsoftware.ucv.ro/~cbadica/ai/cap5.pdf · Problem solving and uninformed search Chapter 5 . 2017 Example: ... So, if the search strategy is fair,

2017

Depth-first search

• The current path is explored until there are no successor nodes.

• The next path corresponds to the last choice point, i.e. the last node whose neighbors have not been explored yet.

• Depth-first search loops infinitely when reaching an infinite search path !

Page 28: Problem solving and uninformed searchsoftware.ucv.ro/~cbadica/ai/cap5.pdf · Problem solving and uninformed search Chapter 5 . 2017 Example: ... So, if the search strategy is fair,

2017

Depth-first search tree

Page 29: Problem solving and uninformed searchsoftware.ucv.ro/~cbadica/ai/cap5.pdf · Problem solving and uninformed search Chapter 5 . 2017 Example: ... So, if the search strategy is fair,

2017

Implementation of depth-first search

• The frontier is implemented as a stack: we select for expansion the last element that was added to the frontier.

select(Node,[Node | Frontier], Frontier)

ad_to_frontier(Neighbors,F1,F2)

append(Neighbors,F1,F2)

• If the frontier is [e1, e2, …] then we shall select for expansion e1. We shall replace it in the frontier with its neighbors. e2 will be selected when all the paths from e1 will be explored.

Page 30: Problem solving and uninformed searchsoftware.ucv.ro/~cbadica/ai/cap5.pdf · Problem solving and uninformed search Chapter 5 . 2017 Example: ... So, if the search strategy is fair,

2017

Depth-first search - example

• [A] [B,D] [G,D] [F,D] [D] [C] [E] [F] [] STOP !

B A

C D

G F E

4

4

2 2

2

1 1

Page 31: Problem solving and uninformed searchsoftware.ucv.ro/~cbadica/ai/cap5.pdf · Problem solving and uninformed search Chapter 5 . 2017 Example: ... So, if the search strategy is fair,

2017

Complexity of depth-first search

• For infinite graphs of for graphs with loops depth-first search

will loop infinitely.

• Space complexity is linear with the search depth.

– If the forward branching factor is 𝑏 and the current path has 𝑛 nodes

then the frontier will contain at most 𝑛(𝑏1) nodes, i.e.: at most 𝑏1

siblings of the current node, at most 𝑏1 siblings of the parent of the

current node, etc.

Page 32: Problem solving and uninformed searchsoftware.ucv.ro/~cbadica/ai/cap5.pdf · Problem solving and uninformed search Chapter 5 . 2017 Example: ... So, if the search strategy is fair,

2017

Breadth-first search

Page 33: Problem solving and uninformed searchsoftware.ucv.ro/~cbadica/ai/cap5.pdf · Problem solving and uninformed search Chapter 5 . 2017 Example: ... So, if the search strategy is fair,

2017

Implementation of breadth-first search

• In breadth-first search, the paths from the start node are generated in increasing order of their length. Always will be selected for expansion the shortest path.

• Breadth-first search is obtained by implementing the frontier as a queue: always is selected for expansion the node added latest to the frontier.

select(Node,[Node | Frontier], Frontier)

ad_to_frontier(Neighbors,F1,F2)

append(F1, Neighbors,F2)

• If the frontier is Fr = [e1, e2, …] then e1 is selected for expansion. It will be replaced in the frontier with his neighbors. The neighbors are appended at the end of list Fr. e2 will be selected after e1.

Page 34: Problem solving and uninformed searchsoftware.ucv.ro/~cbadica/ai/cap5.pdf · Problem solving and uninformed search Chapter 5 . 2017 Example: ... So, if the search strategy is fair,

2017

Breadth-first search - example

• [A] [B,D] [D,G] [G,C] [C,F] [F,E] [E] [F] [] STOP !

• [A/[]] [B/[A],D/[A]] [D/[A],G/[B,A]] [G/[B,A],C/[D,A]] [C/[D,A],F/[G,B,A]] [F/[G,B,A],E/[C,D,A]] [E/[C,D,A]] [F/[E,C,D,A]] [] STOP !

B A

C D

G F E

4

4

2 2

2

1 1

Page 35: Problem solving and uninformed searchsoftware.ucv.ro/~cbadica/ai/cap5.pdf · Problem solving and uninformed search Chapter 5 . 2017 Example: ... So, if the search strategy is fair,

2017

Complexity of breadth-first search

• If the forward branching factor if finite then breadth-first search

guarantees to find a solution whenever there is at least one

solution. Moreover, the first solution found has minimum

length of the search path.

• Time complexity is exponential with the length of the search

path. If the forward branching factor is 𝑏 and the current path

has 𝑛 nodes then time complexity is 𝑏𝑛.

• Space complexity is 𝑏𝑛. If the length of the path to the current

expanded node from the frontier is 𝑛 then there exist at least 𝑏𝑛

elements in the frontier, as all the other paths to the nodes of the

frontier contain 𝑛 or 𝑛1 arcs.

Page 36: Problem solving and uninformed searchsoftware.ucv.ro/~cbadica/ai/cap5.pdf · Problem solving and uninformed search Chapter 5 . 2017 Example: ... So, if the search strategy is fair,

2017

Least-cost search

• In least-cost search, paths from the start node are generated in increasing order of their cost. Always we select for expansion the path of minimum cost. The cost of a path from the start node to the current node 𝑛 is equal to the sum of the costs of its arcs and is denoted by 𝑔(𝑛).

• Least-cost search is obtained by implementing the frontier as a priority queue: always will be selected for expansion the node of minimum cost from the frontier.

select(Node,[Node | Frontier], Frontier)

ad_la_frontier(Neighbors,F1,F3)

append(Neighbors,F1,F2)

sort_after_g(F2,F3)

Page 37: Problem solving and uninformed searchsoftware.ucv.ro/~cbadica/ai/cap5.pdf · Problem solving and uninformed search Chapter 5 . 2017 Example: ... So, if the search strategy is fair,

2017

Least-cost search - example

• [(A,[],0)] [(B,[A],4),(D,[A],2)] [(B,[A],4),(C,[D,A],4)]

[(G,[B,A],8),(C,[D,A],4)] [(G,[B,A],8),(E,[C,D,A],6)]

[(G,[B,A],8),(F,[E,C,D,A],7)] [(G,[B,A],8)]

[(F,[G,B,A],9)] [] STOP !

B A

C D

G F E

4

4

2 2

2

1 1

Page 38: Problem solving and uninformed searchsoftware.ucv.ro/~cbadica/ai/cap5.pdf · Problem solving and uninformed search Chapter 5 . 2017 Example: ... So, if the search strategy is fair,

2017

Implementing the frontier using heaps

• The frontier can be implemented using an efficient data structure – heap. Adding an element and removing the minimum cost element from the frontier can be achieved in time 𝑂(log (𝑛)). Here 𝑛 is the number of nodes in the frontier.

• Heaps are already implemented in SWI-Prolog in the heaps library. A heap is a set of pairs priority-key, such that the nodes (keys) are ordered according to the priority.

• The library is loaded with:

?- use_module(library(heaps)).

• The priority is the path cost and the key is the node. Operations are:

empty_heap(?Heap)

add_to_heap(+Heap0, +Priority, ?Key, -Heap)

get_from_heap(+Heap0, +Priority, ?Key, -Heap)

Page 39: Problem solving and uninformed searchsoftware.ucv.ro/~cbadica/ai/cap5.pdf · Problem solving and uninformed search Chapter 5 . 2017 Example: ... So, if the search strategy is fair,

2017

Optimality of least-cost search

• Proposition: If: – the forward branching factor is upper bounded

– the arc costs have a strictly positive lower bound

– there exist solutions

then least-cost search will always find the minimum cost solution.

Proof:

• By induction on the length of a path from the start node to a

goal node we show that least-cost search will always find a

solution (if there exist at least one solution).

• Let us know assume that the first found solution 𝑛 is not

optimal, i.e. 𝑔(𝑛) > 𝑔∗(𝑛). Then, when 𝑛 is selected for

expansion, the frontier will contain a node 𝑛′ on the path from

the start node to 𝑛 and 𝑔 𝑛 ≤ 𝑔(𝑛′). On the other hand

𝑔(𝑛) > 𝑔∗(𝑛) > 𝑔(𝑛′), contradiction !