This document discusses different search strategies including depth-first search, breadth-first search, and Prolog's top-down resolution strategy. Depth-first search uses a stack to select the last element added to the frontier, while breadth-first search uses a queue. Prolog implements top-down resolution using depth-first search to search through clauses that unify with the query's first atom. The document also discusses how Prolog can be used to program search using its built-in predicates and data structures like lists.
This collection of articles has been compiled by Animal Rights Advocates Inc. (ARA) to provide an overview of affinity groups, meeting processes and consensus decision-making for activists.
This collection of articles has been compiled by Animal Rights Advocates Inc. (ARA) to provide an overview of affinity groups, meeting processes and consensus decision-making for activists.
Omnichannel Commerce & The Customer Experience - Featuring Don PeppersMargot Heiligman
In this presentation content, Don is taking the topic of omnichannel commerce and customer experience right to the core of their essence. What should businesses and management pay attention to in order to successfully transform their business digitally? And what is a good customer experience really about? Access the content now.
Visit "The Future of Customer Engagement and Commerce" by SAP Hybris to get more valuable content around commerce, marketing, and customer engagement here: http://www.the-future-of-commerce.com/
Euro Cup international supporters can book Euro 2024 Tickets from our online platform Worldwideticketsandhospitality.com. Followers can book Portugal Vs Czechia Tickets on our website at sale prices.
Belgium vs Slovakia Belgium announce provisional squad for Euro Cup 2024 Thib...Eticketing.co
Euro 2024 fans worldwide can book Belgium vs Slovakia Tickets from our online platform www.eticketing.co. Fans can book Euro Cup Germany Tickets on our website at discounted prices.
Belgium vs Romania Injuries and Patience in Belgium’s Euro Cup Germany Squad....Eticketing.co
Belgium coach Domenico Tedesco will wait for several key players to recover from injury. Even if it means they miss the opening Euro Cup Germany stages of the European Championship in Germany this month. Veteran defender Jan Vertonghen, midfielder Youri Tielemans and defender Arthur. Theate are being given time to play in the tournament because they are considered vital to Belgium’s cause, Tedesco said on Tuesday.
We offer Euro Cup Tickets to admirers who can get Belgium vs Romania Tickets through our trusted online ticketing marketplace. Eticketing.co is the most reliable source for booking Euro Cup Final Tickets. Sign up for the latest Euro Cup Germany Ticket alert.
UEFA Euro 2024 Tickets | Euro 2024 Tickets | Euro Cup Germany Tickets | Belgium vs Romania Tickets
"Of course, you prefer to take players who are fully fit, but that's okay. We want to wait and be patient for some players even if they cannot play in those first matches," he told a press conference. The 37-year-old Vertonghen, Belgium’s Euro Cup 2024 most-capped international with 154 appearances, is struggling to shake off a groin injury.
"He will be there normally. This also applies to Youri Tielemans and Arthur Theate. The latter's position is very sensitive. We don't have many choices at left back. "It will only change if it turns out that they will only be available when, say, the final of the Euro 2024 Championship comes around. That's too long to wait. "However, I am confident that the injured boys are on track for the Euros.
Belgium vs Romania: Radu Dragusin Prepares for Crucial Role in Euro Cup Germany
Some of them have taken not one but two steps forward in their rehabilitation," he said. None of the injured players will feature in this week’s warm-up friendlies against Montenegro and Luxembourg. Romania centre-back Radu Dragusin found chances limited at Tottenham Hotspur in the second half of the 2023-24 season.
But is crucial to his country's cause at UEFA Euro 2024 where his aerial ability, physicality and hard graft make him a standout player. The 22-year-old moved to North London from Italian side Genoa in January but was kept on the sidelines by the form of another new arrival for the season, Mickey van de Ven, something Romania coach Edward Iordanescu admitted was a concern.
It will mean limited game-time going into the finals, but Dragusin, who cites Netherlands defender Virgil van Dijk as a role model, started every Euro Cup Germany qualifier as Romania went through the campaign unbeaten in their 10 games. He will be among their most important players in their first game in Germany against Ukraine in Munich on June 17, taking the right centre-back role in what is likely to be a back four.
UEFA Euro 2024 Tickets | Euro 2024 Tickets | Euro Cup Germany Tickets | Belgium vs Romania Tickets
Euro fans worldwide can book Euro Cup Germany Tickets from our online platform, www.eticketing.co. Fans can book Euro Cup 2024 Tickets on our website at discounted prices.
Omnichannel Commerce & The Customer Experience - Featuring Don PeppersMargot Heiligman
In this presentation content, Don is taking the topic of omnichannel commerce and customer experience right to the core of their essence. What should businesses and management pay attention to in order to successfully transform their business digitally? And what is a good customer experience really about? Access the content now.
Visit "The Future of Customer Engagement and Commerce" by SAP Hybris to get more valuable content around commerce, marketing, and customer engagement here: http://www.the-future-of-commerce.com/
Euro Cup international supporters can book Euro 2024 Tickets from our online platform Worldwideticketsandhospitality.com. Followers can book Portugal Vs Czechia Tickets on our website at sale prices.
Belgium vs Slovakia Belgium announce provisional squad for Euro Cup 2024 Thib...Eticketing.co
Euro 2024 fans worldwide can book Belgium vs Slovakia Tickets from our online platform www.eticketing.co. Fans can book Euro Cup Germany Tickets on our website at discounted prices.
Belgium vs Romania Injuries and Patience in Belgium’s Euro Cup Germany Squad....Eticketing.co
Belgium coach Domenico Tedesco will wait for several key players to recover from injury. Even if it means they miss the opening Euro Cup Germany stages of the European Championship in Germany this month. Veteran defender Jan Vertonghen, midfielder Youri Tielemans and defender Arthur. Theate are being given time to play in the tournament because they are considered vital to Belgium’s cause, Tedesco said on Tuesday.
We offer Euro Cup Tickets to admirers who can get Belgium vs Romania Tickets through our trusted online ticketing marketplace. Eticketing.co is the most reliable source for booking Euro Cup Final Tickets. Sign up for the latest Euro Cup Germany Ticket alert.
UEFA Euro 2024 Tickets | Euro 2024 Tickets | Euro Cup Germany Tickets | Belgium vs Romania Tickets
"Of course, you prefer to take players who are fully fit, but that's okay. We want to wait and be patient for some players even if they cannot play in those first matches," he told a press conference. The 37-year-old Vertonghen, Belgium’s Euro Cup 2024 most-capped international with 154 appearances, is struggling to shake off a groin injury.
"He will be there normally. This also applies to Youri Tielemans and Arthur Theate. The latter's position is very sensitive. We don't have many choices at left back. "It will only change if it turns out that they will only be available when, say, the final of the Euro 2024 Championship comes around. That's too long to wait. "However, I am confident that the injured boys are on track for the Euros.
Belgium vs Romania: Radu Dragusin Prepares for Crucial Role in Euro Cup Germany
Some of them have taken not one but two steps forward in their rehabilitation," he said. None of the injured players will feature in this week’s warm-up friendlies against Montenegro and Luxembourg. Romania centre-back Radu Dragusin found chances limited at Tottenham Hotspur in the second half of the 2023-24 season.
But is crucial to his country's cause at UEFA Euro 2024 where his aerial ability, physicality and hard graft make him a standout player. The 22-year-old moved to North London from Italian side Genoa in January but was kept on the sidelines by the form of another new arrival for the season, Mickey van de Ven, something Romania coach Edward Iordanescu admitted was a concern.
It will mean limited game-time going into the finals, but Dragusin, who cites Netherlands defender Virgil van Dijk as a role model, started every Euro Cup Germany qualifier as Romania went through the campaign unbeaten in their 10 games. He will be among their most important players in their first game in Germany against Ukraine in Munich on June 17, taking the right centre-back role in what is likely to be a back four.
UEFA Euro 2024 Tickets | Euro 2024 Tickets | Euro Cup Germany Tickets | Belgium vs Romania Tickets
Euro fans worldwide can book Euro Cup Germany Tickets from our online platform, www.eticketing.co. Fans can book Euro Cup 2024 Tickets on our website at discounted prices.
Results for LtCol Thomas Jasper, Marine, for the 2010 Marine Corps Marathon held October 31, 2010, marking the 35th annual marathon known as "The People's Marathon."
An impressive finishing time of 3:46:39, placing 324th in the Male division ages 40-44.
Narrated Business Proposal for the Philadelphia Eaglescamrynascott12
Slide 1:
Welcome, and thank you for joining me today. We will explore a strategic proposal to enhance parking and traffic management at Lincoln Financial Field, aiming to improve the overall fan experience and operational efficiency. This comprehensive plan addresses existing challenges and leverages innovative solutions to create a smoother and more enjoyable experience for our fans.
Slide 2:
Picture this: It’s a crisp fall afternoon, driving towards Lincoln Financial Field. The atmosphere is electric—tailgaters grilling, fans in Eagles jerseys creating a sea of green and white. The air buzzes with camaraderie and anticipation. You park, join the throng, and make your way to your seat. The stadium roars as the Eagles take the field, sending chills down your spine. Each play is a thrilling dance of strategy and skill. This is what being an Eagles fan is all about—the joy, the pride, and the shared experience.
Slide 3:
But now, the day is marred by frustration. The excitement wanes as you struggle to find a parking spot. The congestion is overwhelming, and tempers flare. The delays mean you miss the pre-game excitement, the tailgate camaraderie, and even the opening kick-off. After the game, the joy of victory or the shared solace of defeat is overshadowed by the stress of navigating out of the parking lot. The gridlock, honking horns, and endless waiting drain the energy and joy from what should have been an unforgettable experience.
Our proposal aims to eliminate these frustrations, ensuring that from arrival to departure, your experience is extraordinary. Efficient parking and smooth traffic flow are key to maintaining the high spirits and excitement that make game days special.
Slide 4:
The Philadelphia Eagles are not just a premier NFL team; they are an integral part of the community, hosting games, concerts, and various events at Lincoln Financial Field. Our state-of-the-art stadium is designed to provide a world-class experience for every attendee. Whether it's the thrill of game day, the excitement of a live concert, or the camaraderie of community events, we pride ourselves on delivering a fan-first experience and maintaining operational excellence across all our activities. Our commitment to our fans and community is unwavering, and we continuously strive to enhance every aspect of their experience, ensuring they leave with unforgettable memories.
Slide 5:
Recent trends show an increasing demand for efficient event logistics. Our customer feedback has consistently highlighted frustrations with parking and traffic. Surveys indicate that a significant number of fans are dissatisfied with the current parking situation. Comparisons with other venues like Citizens Bank Park and Wells Fargo Center reveal that we lag in terms of parking efficiency and convenience. These insights underscore the urgent need for innovation to meet and exceed fan expectations.
Slide 6:
As we delve into the intricacies of our operations, one glaring issue emer
Euro Cup fans worldwide can book Euro 2024 Tickets from our online platform www.worldwideticketsandhospitality. Fans can book Croatia vs Italy Tickets on our website at discounted prices.
Turkey vs Georgia Tickets: Turkey's Road to Glory and Building Momentum for U...Eticketing.co
Euro Cup Germany fans worldwide can book Euro 2024 Tickets from our online platform www.eticketing.co.Fans can book Euro Cup 2024 Tickets on our website at discounted prices.
The Split_ Hardik Pandya and Natasa Stankovic Part Ways News by Betkaro247 (3...bet k247
Betting ID
we like to introduce to our Cricket Betting ID platform, which help people to earn lot of money just by doing little-little predictions on games and events.
Indian cricketer Hardik Pandya and Serbian actress Natasha Stankovic have decided to part ways, ending a relationship that captivated fans and followers worldwide. The news of their split has been making headlines, stirring a mixture of shock, sadness, and speculation among their supporters.
Boletin de la I Copa Panamericana de Voleibol Femenino U17 Guatemala 2024Judith Chuquipul
holaesungusto.- Boletín final de la I Copa Panamericana de Voleibol Femenino U17 - Ciudad de Guatemala 2024 que se realizó del 27 de mayo al 01 de julio, en el Domo Polideportivo Zona 13.
Fuente: norceca.net
Spain vs Italy Spain at Euro Cup 2024 Group, Fixtures, Players to Watch and M...Eticketing.co
Euro Cup 2024 fans worldwide can book Spain vs Italy Tickets from our online platform www.eticketing.co. Fans can book Euro Cup Germany Tickets on our website at discounted prices.
Mats André Zuccarello Aasen, commonly known as Mats Zuccarello, was born on September 1, 1987, in
Oslo, Norway. He grew up in the bustling neighborhood of Løren, where his passion for ice hockey began
at a young age. His mother, Anita Zuccarello, is of Italian descent, and his father, Glenn Aasen, is
Norwegian. This multicultural background played a significant role in shaping his identity and versatility
on and off the ice.
Euro Cup fans worldwide can book Euro 2024 Tickets from our online platform www.worldwideticketsandhospitality. Fans can book Austria Vs France Tickets on our website at discounted prices.
Serbia vs England Tickets: Serbia Prepares for Historic UEFA Euro 2024 Debut ...Eticketing.co
Eticketing.co offers UEFA Euro 2024 Tickets to admirers who can get Serbia vs England Tickets through our trusted online ticketing marketplace. Eticketing.co is the most reliable source for booking Euro Cup Final Tickets. Sign up for the latest Euro Cup Germany Ticket alert.
Turkey Hit by Double Injury Blow before of Euro 2024.docx
Class06
1. c P. Heeman, 2005
CSE560 Class 06: 1
Overview
⇒ Search
• Depth-first
• Breadth-first
• Prolog’s Search Strategy
• The ‘Pro’ part of Prolog
• Programming Search in Prolog
c P. Heeman, 2005
CSE560 Class 06: 2
Search
• To convert proof procedure into a reasoning procedure, need to
resolve non-determism
• Search is a way to implement nondeterminism
2. c P. Heeman, 2005
CSE560 Class 06: 3
Search Graphs
• A graph consists of
- a set N of nodes
- a set A of ordered pairs of nodes, called arcs
• Node n2 is a neighbor of n1 if there is an arc from n1 to n2
- if n1, n2 ∈ A
• A path is a sequence of nodes n0, n1, ..., nk such that
ni1 , ni ∈ A
• Given a set of start nodes and goal nodes, a solution is a path
from a start node to a goal node
c P. Heeman, 2005
CSE560 Class 06: 4
Search Graph for Resolution (Top-Down) Proof
yes←a∧d
(From Official Lecture slides)
yes←h∧d
a ← b ∧ c. a ← g. yes←b∧c∧d yes←g∧d
yes←m∧d
a ← h. b ← j. yes←m∧d
yes←j∧c∧d
b ← k. d ← m. yes←f∧d
yes←k∧c∧d
d ← p. f ← m. yes←m∧d yes←p∧d
f ← p. g ← m. yes←m∧c∧d
yes←d
g ← f. k ← m.
yes←p
yes←m
h ← m. p.
yes←
?a ∧ d
3. c P. Heeman, 2005
CSE560 Class 06: 5
Graph Searching
• Generic search algorithm: given a graph, start nodes, and goal
nodes, incrementally explore paths from the start nodes
• Maintain a frontier of paths from the start node that have been
explored
• As search proceeds, the frontier expands into the unexplored
nodes until a goal node is encountered
• The way in which the frontier is expanded defines the search
strategy
c P. Heeman, 2005
CSE560 Class 06: 6
Illustration of Graph Searching
frontier
start
node
explored nodes
unexplored nodes
4. c P. Heeman, 2005
CSE560 Class 06: 7
Generic Graph Search Algorithm
search(F0) ←
select(Node,F0,F1) ∧
is goal(Node).
search(F0) ←
select(Node,F0,F1) ∧
neighbors(Node,NN) ∧
add to frontier(NN,F1,F2) ∧
search(F2).
- Definition of predicates:
+ search(Frontier) is true if path from element of Frontier to a goal node
+ is goal(N) is true if N is a goal node
+ neighbors(N,NN) means NN is list of neighbors of N
+ select(N,F0,F1) means N∈F0 and F1 = F0-{N}. Fails if F 0 is empty
+ add to frontier(NN,F1,F2) means that F2 = F1 ∪ NN
c P. Heeman, 2005
CSE560 Class 06: 8
Summary of Generic Search Algorithm
• select and add to frontier define the search strategy
- Whether add to frontier puts new elements on top or bottom of list
matters
• neighbors defines the graph
• is goal defines what is a solution
• We wrote this in datalog
- Which is a bit perverse as we will be using this to implement a datalog
top-down reasoning procedure
• Could just as easily do written it in Tcl as this can be easily
converted to procedural code
5. c P. Heeman, 2005
CSE560 Class 06: 9
Overview
• Search
⇒ Depth-first
• Breadth-first
• Prolog’s Search Strategy
• The ‘Pro’ part of Prolog
• Programming Search in Prolog
c P. Heeman, 2005
CSE560 Class 06: 10
Depth-first Search
• Depth-first search treats the frontier as a stack: it always selects
the last element added to the frontier
select(Node,p(Node,Frontier),Frontier).
add to frontier(Neighbors,Frontier1,Frontier) ←
append(Neighbors,Frontier1,Frontier2).
• Frontier: p(e1,p(e2,...))
- e1 is selected. Its neighbors are added to the front of the stack
- e2 is only selected when all paths from e1 have been explored
6. c P. Heeman, 2005
CSE560 Class 06: 11
Illustration of Depth-first Search
1
2
3 13
4 12 14
5 7 15 16
6 8 10
9 11
c P. Heeman, 2005
CSE560 Class 06: 12
Complexity of Depth-first Search
• Depth-first search isnt guaranteed to halt on infinite graphs or
graphs with cycles
• The space complexity is linear in the size of the path being
explored
• Search is unconstrained by the goal until it happens to stumble
on the goal
7. c P. Heeman, 2005
CSE560 Class 06: 13
Overview
• Search
• Depth-first
⇒ Breadth-first
• Prolog’s Search Strategy
• The ‘Pro’ part of Prolog
• Programming Search in Prolog
c P. Heeman, 2005
CSE560 Class 06: 14
Breadth-first Search
• Breadth-first search treats the frontier as a queue: it always
selects the earliest element added to the frontier
select(Node,p(Node,Frontier),Frontier).
add to frontier(Neighbors,Frontier1,Frontier) ←
append(Frontier1,Neighbors,Frontier2).
• Frontier: p(e1,p(e2,...))
- e1 is selected. Its neighbors are added to the end of the queue
- e2 is selected next
8. c P. Heeman, 2005
CSE560 Class 06: 15
Illustration of Breadth-first Search
1
2 3
4 5 6 7
8 9 10 11 12 13 14
15 16
c P. Heeman, 2005
CSE560 Class 06: 16
Complexity of Breadth-first Search
• The branching factor of a node is the number of its neighbors
• If the branching factor for all nodes is finite, breadth-first search
is guaranteed to find a solution if one exists
- It is guaranteed to find the path with fewest arcs.
• Time complexity is exponential in the path length: bn, where b is
branching factor, n is path length.
• The space complexity is exponential in path length: bn
• Search is unconstrained by the goal
9. c P. Heeman, 2005
CSE560 Class 06: 17
Overview
• Search
• Depth-first
• Breadth-first
⇒ Prolog’s Search Strategy
• The ‘Pro’ part of Prolog
• Programming Search in Prolog
c P. Heeman, 2005
CSE560 Class 06: 18
Top-Down Resolution
• Need search strategy for doing top-down resolution
- Always resolve first atom of answer clause first
- But many rules/facts from KB might unify with first atom
- Can search through these using depth-first search
- Search is ordered by order of clauses in KB
+ Knowledge engineer can order clauses to ensure solution is found quickly
- Search over space of answer clauses, not over space of proofs
⇒ Prolog
10. c P. Heeman, 2005
CSE560 Class 06: 19
Cycles in Prolog
• What about cycles (since Prolog is depth-first search)?
connected(X,Y) ← connected(Y,X)
- Could check for cycles: list of atoms in answer clause identical to list
earlier up in proof
- Would have to keep answer clauses along the current path we are
exploring
• Cycles part of larger problem of endless loops
- Cannot detect all endless loops (halting problem)
- Prolog also doesn’t do any cycle checking
- Knowledge engineer’s job to be careful in defining clauses
c P. Heeman, 2005
CSE560 Class 06: 20
Overview
• Search
• Depth-first
• Breadth-first
• Prolog’s Search Strategy
⇒ The ‘Pro’ part of Prolog
• Programming Search in Prolog
11. c P. Heeman, 2005
CSE560 Class 06: 21
The ‘Pro’ Stands for Programming
• Prolog is intended as a programming language,
in which programs are written as theorems,
and program execution is theorem proving
• As Prolog is a programming language, can program search in it
• Tension in Prolog between its role as
- A logic specification
- A general purpose programming language
• Has the built-in is(X,Expr) command
- Expr evaluated using normal rules for expressions
- Semantics for is are messy, as it only has a value if Expr is ground
c P. Heeman, 2005
CSE560 Class 06: 22
Prolog Lists
• A special recursive data structure
- with special syntax to make dealing with lists simpler
• List is
- Empty list: []
- An element on top of a list: [ Top | RestOfList ]
- Rewriting our path structure in List notation: [1|[2|[6|[10|[]]]]]
- To get top and remainder, unify with [Top|Rest]
• Syntax shortform:
- [1|[2|[6|[10|[]]]]] can be written as [1, 2, 6, 10]
- or as [1, 2|[6|[10]]] or as [1|[2, 6, 10]] or as ....
- How does [X, Y ] unify with [a, b]?
- How does [X|Y ] unify with [a, b]?
12. c P. Heeman, 2005
CSE560 Class 06: 23
Append and Member
• Rewrite append in new list syntax
append(nil,Z,Z)
append(p(A,X),Y,p(A,Z)) ←
append(X,Y,Z).
• Rewrite member
- member(X,List) true if X is an element in List
c P. Heeman, 2005
CSE560 Class 06: 24
Singleton Variables
• ‘ ’ special syntax for naming a variable
- Used when don’t care about, used for singleton variables
length([ |Rest],Len) ←
length(Rest,L)
Len is L + 1
- Can be used multiple times in same clause, but each use is really a
different varaible
13. c P. Heeman, 2005
CSE560 Class 06: 25
‘Not’ in Prolog
• The operator not(X) means that
- X is not derivable in Prolog given the current instantion of X
- Following two definitions are not equivalent
brother(X,Y) ← brother(X,Y) ←
mother(X,Z) mother(X,Z)
mother(Y,Z) not(X = Y)
not(X = Y) mother(Y,Z)
• Semantics are not very clean
- Its truth depends on order that clauses are evaluated
- Truth does not correlate with semantics of models
c P. Heeman, 2005
CSE560 Class 06: 26
Maze Example
• Example: path through a maze
1 2 3 4
connected(1,2).
connected(2,3).
5 6 7 8
connected(2,6).
connected(4,8).
9 10 11 12
...
13 14 15 16
connectedto(X,Y) :- connected(X,Y).
connectedto(X,Y) :- connected(Y,X).
• Book defined breadth-first and depth-first search in Datalog
- In this example, searching for end point
• But how can we define the neighbors clause that is needed?
- Could define neighbors as primitive
- Or, define neighbors(X,Set) in terms of connected(X,Y)
+ No way to do this in Datalog: Set = all Y s.t. connected(X,Y) is true
14. c P. Heeman, 2005
CSE560 Class 06: 27
Prolog’s Findall
• findall(X,connected(1,X),L)
- Returns a list of all X in which connected(1,X) is true
• findall can return a list of any arbitrary structures
findall(cell(X),connected(Y,X),L) assume Y is already instantiated
- findall(connected(X,Y),connected(X,Y),L)
- findall(X+Y,connected(X,Y),L)
+ + is just an infix operator that we chose to use
+ Could have used any valid Prolog term, e.g. a(X, Y ), [X, Y ]
• Semantics of findall are messy
- Requires universal quantification which is not part of Datalog
- Universal quantification on things that can be named
+ Rather than on objects in the domain, as first order predicate defines it
c P. Heeman, 2005
CSE560 Class 06: 28
Overview
• Search
• Depth-first
• Breadth-first
• Prolog’s Search Strategy
• The ‘Pro’ part of Prolog
⇒ Programming Search in Prolog
15. c P. Heeman, 2005
CSE560 Class 06: 29
Depth-First Search on Nodes
• Define path using KB and use Prolog’s depth-first search
search(16).
search(X) ←
connected(X,Z),
search(Z).
?search(1)
- Prolog keeps track of backtracking alternatives automatically
• Define depth-first search using KB
search([16| ]).
search(Frontier0) ←
Frontier0 = [X|Frontier1],
findall(Z,connected(Z,X),NN), ← calls Prolog to find all solutions
append(NN,Frontier1,Frontier2),
search(Frontier2).
?search([1])
- Explicitly keep backtracking alternatives, and don’t use Prolog’s
c P. Heeman, 2005
CSE560 Class 06: 30
Depth-First Search saving Paths
• Define path using KB and use Prolog’s depth-first search
search(Path,Path) ←
Path = [16| ].
search([X|Rest],Answer) ←
connected(X,Z),
search([Z,X|Rest],Answer).
?search([1],Answer)
• Define depth-first search using KB
search([Path| ],Path) ←
Path = [16| ].
search(Frontier0,Answer) ←
Frontier0 = [Path|Frontier1],
Path = [X|Rest],
findall([Z,X|Rest],connected(Z,X),NN)
append(NN,Frontier1,Frontier2)
search(Frontier2,Answer)
?search([[1]],Answer)
16. c P. Heeman, 2005
CSE560 Class 06: 31
Breadth-First Search
• Define breadth-first search using KB
search([Path| ],Path) ←
Path = [16| ].
search(Frontier0,Answer) ←
Frontier0 = [Path|Frontier1],
Path = [X|Rest],
findall([Z,X|Rest],connected(Z,X),NN)
append(Frontier1,NN,Frontier2)
search(Frontier2,Answer)
?search([[1]],Answer)
• Should we use Prolog to implement search?
- We can, since Prolog is intended as a full programming language
- But, can implement it in anything, including Tcl/Tk
+ Might make it more clear what logic programming is, if we don’t try to do
everything in it
- findall would be call to a theorem prover
c P. Heeman, 2005
CSE560 Class 06: 32
Cycle Checking
• Depth-First search of Maze can easily get stuck in cycle
- i.e. 1 - 2 - 1 - 2 - 1
• Approach:
- Use version where we keep the paths
- Change our definition of path
+ A path is a list of nodes, each connected to the next one, but where any node
only occurs once
17. c P. Heeman, 2005
CSE560 Class 06: 33
Adding in Cycle Checking
• Ensure new cells not already in path
search([Path| ],Path) ←
Path = [16| ].
search(Frontier0,Answer) ←
Frontier0 = [Path|Frontier1],
Path = [X|Rest],
findall([Z,X|Rest],neighbor(Z,[X|Rest]),NN)
append(Frontier1,NN,Frontier2)
search(Frontier2)
neighbor(Z,[X|Rest]) ←
connected(Z,X)
not(member(Z,[X|Rest]))
?search([[1]],Rest)
c P. Heeman, 2005
CSE560 Class 06: 34
Another Cycle Checker
• Ensure that any cell is just visited once
- For simplicity, doing this with version where frontier is list of cells
search([16| ], ).
search(Frontier0,Seen0) ←
Frontier0 = [X|Frontier1]
findall(Z,neighbor(Z,X,Seen0),NN)
append(Frontier1,NN,Frontier2)
append(Seen0,NN,Seen1)
search(Frontier2,Seen1)
neighbor(Z,X,Seen) ←
connected(Z,X)
not(member(Z,Seen))
?search([1],[])