Simply Logical – Chapter 5© Peter Flach, 2000 Agenda-based search % search(Agenda,Goal) <- Goal is a goal node, and a % descendant of one of the nodes.

Slides:



Advertisements
Similar presentations
Uninformed Search in Prolog
Advertisements

Simply Logical – Chapter 2© Peter Flach, 2000 Clausal logic Propositional clausal logic Propositional clausal logic expressions that can be true or false.
Review: Search problem formulation
Simply Logical – Chapter 3© Peter Flach, 2000 :-teaches(peter,ai_techniques) :-teaches(peter,expert_systems) :-teaches(peter,computer_science) ?-student_of(S,peter)
Simply Logical – Chapter 8© Peter Flach, 2000 Induction +Given a background theory Th (clauses) positive examples Pos (ground facts) negative examples.
1 Logic Programming School of Informatics, University of Edinburgh Forcing Determinacy: Example minimum(X, Y, X) :- X =< Y. minimum(X, Y, Y) :- X > Y.
Informed Search Strategies
Search in Python Chapter 3.
Tree Searching. Tree searches A tree search starts at the root and explores nodes from there, looking for a goal node (a node that satisfies certain conditions,
Artificial Intelligence Chapter 14. Resolution in the Propositional Calculus Artificial Intelligence Chapter 14. Resolution in the Propositional Calculus.
Breadth First Search
Resolution Refutation Formal Aspects of Computer Science - Week 10 An Automated Theorem Prover Lee McCluskey, room 2/07
Blind Search-Part 2 Ref: Chapter 2. Search Trees The search for a solution can be described by a tree - each node represents one state. The path from.
Using Search in Problem Solving
Biointelligence Lab School of Computer Sci. & Eng. Seoul National University Artificial Intelligence Chapter 8 Uninformed Search.
Representing Graphs Depth First Search Breadth First Search Graph Searching Algorithms.
Artificial Intelligence Solving problems by searching.
Lecture 3 Problem Solving through search Uninformed Search
Review: Tree search Initialize the frontier using the starting state
Uniformed Search (cont.) Computer Science cpsc322, Lecture 6
SMART VACUUM CLEANER PRESENTED BY PROJECT PRESENTATION CSE 591
Problem Solving Agents
Resolution in the Propositional Calculus
COMP 103 Tree Traversals Lindsay Groves 2016-T2 Lecture 22
Graph Searching.
CSE 473 Artificial Intelligence Oren Etzioni
Graph Search Lecture 17 CS 2110 Fall 2017.
Artificial Intelligence (CS 370D)
Depth First Search—Backtracking
Unweighted Shortest Path Neil Tang 3/11/2010
Uniformed Search (cont.) Computer Science cpsc322, Lecture 6
هوش مصنوعی فصل سوم: حل مسئله با جستجو
Prof. Dechter ICS 270A Winter 2003
CSC 172 DATA STRUCTURES.
Elementary graph algorithms Chapter 22
Lecture 12 CSE 331 Sep 26, 2016.
Breadth First Search 11/21/ s
Problem Solving and Searching
Search Related Algorithms
EA C461 – Artificial Intelligence
Lecture 13 CSE 331 Oct 1, 2012.
Biointelligence Lab School of Computer Sci. & Eng.
Problem Solving and Searching
Tree Searching.
Lecture 13 CSE 331 Sep 24, 2013.
Search Exercise Search Tree? Solution (Breadth First Search)?
Biointelligence Lab School of Computer Sci. & Eng.
Lecture 12 CSE 331 Sep 26, 2011.
Artificial Intelligence Chapter 8 Uninformed Search
CSE 473 University of Washington
Simply Logical – Chapter 5
Algorithms Lecture # 29 Dr. Sohail Aslam.
Breadth First Search s
Chap 4: Searching Techniques
Lecture 11 CSE 331 Sep 21, 2017.
Lecture 12 CSE 331 Sep 22, 2014.
EMIS 8374 Search Algorithms Updated 9 February 2004
GRAPHS G=<V,E> Adjacent vertices Undirected graph
Tree Searching.
Tree Searching.
Tree Searching.
Lecture 11 CSE 331 Sep 22, 2016.
Elementary graph algorithms Chapter 22
Breadth First Search s
SEG 4560 Midterm Review.
CMSC 471 Fall 2011 Class #4 Tue 9/13/11 Uninformed Search
Model Minimization Computational Logic Lecture 16
Graph Search in C++ Andrew Lindsay.
EMIS 8374 Search Algorithms Updated 12 February 2008
Search Strategies CMPT 420 / CMPG 720.
Presentation transcript:

Simply Logical – Chapter 5© Peter Flach, 2000 Agenda-based search % search(Agenda,Goal) <- Goal is a goal node, and a % descendant of one of the nodes % on the Agenda search(Agenda,Goal):- next(Agenda,Goal,Rest), goal(Goal). search(Agenda,Goal):- next(Agenda,Current,Rest), children(Current,Children), add(Children,Rest,NewAgenda), search(NewAgenda,Goal). p.102

Simply Logical – Chapter 5© Peter Flach, 2000 Depth-first vs. breadth-first search search_df([Goal|Rest],Goal):- goal(Goal). search_df([Current|Rest],Goal):- children(Current,Children), append(Children,Rest,NewAgenda), search_df(NewAgenda,Goal). search_bf([Goal|Rest],Goal):- goal(Goal). search_bf([Current|Rest],Goal):- children(Current,Children), append(Rest,Children,NewAgenda), search_bf(NewAgenda,Goal). children(Node,Children):- findall(C,arc(Node,C),Children). p.103-6

Simply Logical – Chapter 5© Peter Flach, 2000 Depth-first vs. breadth-first search Breadth-first search agenda = queue (first-in first-out) complete: guaranteed to find all solutions first solution founds along shortest path requires O(B n ) memory Depth-first search agenda = stack (last-in first-out) incomplete: may get trapped in infinite branch no shortest-path property requires O(B n) memory p.103-6

Simply Logical – Chapter 5© Peter Flach, 2000 Loop detection % depth-first search with loop detection search_df_loop([Goal|Rest],Visited,Goal):- goal(Goal). search_df_loop([Current|Rest],Visited,Goal):- children(Current,Children), add_df(Children,Rest,Visited,NewAgenda), search_df_loop(NewAgenda,[Current|Visited],Goal). add_df([],Agenda,Visited,Agenda). add_df([Child|Rest],OldAgenda,Visited,[Child|NewAgenda]):- not element(Child,OldAgenda), not element(Child,Visited), add_df(Rest,OldAgenda,Visited,NewAgenda). add_df([Child|Rest],OldAgenda,Visited,NewAgenda):- element(Child,OldAgenda), add_df(Rest,OldAgenda,Visited,NewAgenda). add_df([Child|Rest],OldAgenda,Visited,NewAgenda):- element(Child,Visited), add_df(Rest,OldAgenda,Visited,NewAgenda). p.104

Simply Logical – Chapter 5© Peter Flach, 2000 Backtracking search % depth-first search by means of backtracking search_bt(Goal,Goal):- goal(Goal). search_bt(Current,Goal):- arc(Current,Child), search_bt(Child,Goal). % backtracking depth-first search with depth bound search_d(D,Goal,Goal):- goal(Goal). search_d(D,Current,Goal):- D>0, D1 is D-1, arc(Current,Child), search_d(D1,Child,Goal). p.105

Simply Logical – Chapter 5© Peter Flach, 2000 Iterative deepening search_id(First,Goal):- search_id(1,First,Goal).% start with depth 1 search_id(D,Current,Goal):- search_d(D,Current,Goal). search_id(D,Current,Goal):- D1 is D+1,% increase depth search_id(D1,Current,Goal). combines advantages of breadth-first search (complete, shortest path) with those of depth-first search (memory-efficient) p.106

Simply Logical – Chapter 5© Peter Flach, 2000 Agenda-based SLD-prover prove_df_a(Goal):- prove_df_a([Goal]). prove_df_a([true|Agenda]). prove_df_a([(A,B)|Agenda]):-!, findall(D,(clause(A,C),conj_append(C,B,D)),Children), append(Children,Agenda,NewAgenda), prove_df_a(NewAgenda). prove_df_a([A|Agenda]):- findall(B,clause(A,B),Children), append(Children,Agenda,NewAgenda), prove_df_a(NewAgenda). p.108 prove(true):-!. prove((A,B)):-!, clause(A,C), conj_append(C,B,D), prove(D). prove(A):- clause(A,B), prove(B).

Simply Logical – Chapter 5© Peter Flach, 2000 Refutation prover for clausal logic % refute_bf(Clause) <- Clause is refuted by clauses % defined by cl/1 % (breadth-first search strategy) refute_bf_a(Clause):- refute_bf_a([a(Clause,Clause)],Clause). refute_bf_a([a((false:-true),Clause)|Rest],Clause). refute_bf_a([a(A,C)|Rest],Clause):- findall(a(R,C),(cl(Cl),resolve(A,Cl,R)),Children), append(Rest,Children,NewAgenda),% breadth-first refute_bf_a(NewAgenda,Clause). p.109 refute((false:-true)). refute((A,C)):- cl(Cl), resolve(A,Cl,R), refute(R).

Simply Logical – Chapter 5© Peter Flach, 2000 Forward chaining % model(M) <- M is a model of the clauses defined by cl/1 model(M):- model([],M). model(M0,M):- is_violated(Head,M0),!,% instance of violated clause disj_element(L,Head),% L: ground literal from head model([L|M0],M).% add L to the model model(M,M).% no more violated clauses is_violated(H,M):- cl((H:-B)), satisfied_body(B,M),% grounds the variables not satisfied_head(H,M). p.111

Simply Logical – Chapter 5© Peter Flach, 2000 Forward chaining: example married(X);bachelor(X):-man(X),adult(X). has_wife(X):-married(X),man(X). man(paul). adult(paul). ?-model([],M) :-is_violated(Head,[]),!, disj_element(L,Head), model([L],M). :-model([adult(p),man(p)],M) [] M=[] :-model([man(p)],M) :-model([bachelor(p), adult(p),man(p)],M) [] :-model([has_wife(p),married(p), adult(p),man(p)],M) :-model([married(p), adult(p),man(p)],M) []

Simply Logical – Chapter 5© Peter Flach, 2000 Forward chaining with depth-bound % model_d(D,M) <- M is a submodel of the clauses % defined by cl/1 model_d(D,M):- model_d(D,[],M). model_d(0,M,M). model_d(D,M0,M):- D>0,D1 is D-1, findall(H,is_violated(H,M0),Heads), satisfy_clauses(Heads,M0,M1), model_d(D1,M1,M). satisfy_clauses([],M,M). satisfy_clauses([H|Hs],M0,M):- disj_element(L,H), satisfy_clauses(Hs,[L|M0],M). p.113