1 CS 385 Fall 2006 Chapter 6 Building Control Algorithms for State Space Search Read 6.0- 6.2.

Slides:



Advertisements
Similar presentations
Chapter 11 :: Logic Languages
Advertisements

CSC411Artificial Intelligence 1 Chapter 3 Structures and Strategies For Space State Search Contents Graph Theory Strategies for Space State Search Using.
Methods of Proof Chapter 7, second half.. Proof methods Proof methods divide into (roughly) two kinds: Application of inference rules: Legitimate (sound)
Methods of Proof Chapter 7, Part II. Proof methods Proof methods divide into (roughly) two kinds: Application of inference rules: Legitimate (sound) generation.
Logic.
CS 267: Automated Verification Lecture 10: Nested Depth First Search, Counter- Example Generation Revisited, Bit-State Hashing, On-The-Fly Model Checking.
Part2 AI as Representation and Search
KU NLP Artificial Intelligence1 Ch 3. Structures and Strategies for State Space Search q Introduction q Graph Theory  Structures for state space search.
Intelligent systems Lecture 6 Rules, Semantic nets.
Problem Solving and Search in AI Part I Search and Intelligence Search is one of the most powerful approaches to problem solving in AI Search is a universal.
Building Control Algorithms For State Space Search
Control Algorithms 2 Chapter 6 Control Algorithms 2 Chapter 6 Production Systems.
Expert System Human expert level performance Limited application area Large component of task specific knowledge Knowledge based system Task specific knowledge.
Proof methods Proof methods divide into (roughly) two kinds: –Application of inference rules Legitimate (sound) generation of new sentences from old Proof.
Structures and Strategies for State Space Search
Control and Implementation of State Space Search
1 Pertemuan 6 RULE-BASED SYSTEMS Matakuliah: H0383/Sistem Berbasis Pengetahuan Tahun: 2005 Versi: 1/0.
1 Chapter 9 Rules and Expert Systems. 2 Chapter 9 Contents (1) l Rules for Knowledge Representation l Rule Based Production Systems l Forward Chaining.
Methods of Proof Chapter 7, second half.
Production Rules Rule-Based Systems. 2 Production Rules Specify what you should do or what you could conclude in different situations. Specify what you.
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.
Recursion Chapter 7. Chapter 7: Recursion2 Chapter Objectives To understand how to think recursively To learn how to trace a recursive method To learn.
1 Structures and Strategies for State Space Search 3 3.0Introduction 3.1Graph Theory 3.2Strategies for State Space Search 3.3Using the State Space to Represent.
Backtracking.
Depth-First Search Lecture 24 COMP171 Fall Graph / Slide 2 Depth-First Search (DFS) * DFS is another popular graph search strategy n Idea is similar.
1 Control and Implementation of State Space Search 5 5.0Introduction 5.1Recursion-Based Search 5.2Pattern-directed Search 5.3Production Systems 5.4The.
Solving Problems by Searching
3.0 State Space Representation of Problems 3.1 Graphs 3.2 Formulating Search Problems 3.3 The 8-Puzzle as an example 3.4 State Space Representation using.
1 Problem Solving and Searching CS 171/271 (Chapter 3) Some text and images in these slides were drawn from Russel & Norvig’s published material.
Notes for Chapter 12 Logic Programming The AI War Basic Concepts of Logic Programming Prolog Review questions.
CS 321 Programming Languages and Compilers Prolog part 2.
Formal Description of a Problem In AI, we will formally define a problem as –a space of all possible configurations where each configuration is called.
Empirical Explorations with The Logical Theory Machine: A Case Study in Heuristics by Allen Newell, J. C. Shaw, & H. A. Simon by Allen Newell, J. C. Shaw,
Production Systems A production system is –a set of rules (if-then or condition-action statements) –working memory the current state of the problem solving,
KU NLP Structures and Strategies for State Space Search Depth-First and Breadth-First Search q A search algorithm must determine the order in which.
Introduction to search Chapter 3. Why study search? §Search is a basis for all AI l search proposed as the basis of intelligence l inference l all learning.
Building Control Algorithms For State Space Search.
Introduction to search Chapter 3. Why study search? §Search is a basis for all AI l search proposed as the basis of intelligence l all learning algorithms,
Today’s Topics FREE Code that will Write Your PhD Thesis, a Best-Selling Novel, or Your Next Methods for Intelligently/Efficiently Searching a Space.
Logical Agents Logic Propositional Logic Summary
Control Algorithms 1 Chapter 6 Control Algorithms 1 Chapter 6 Pattern Search.
CS 415 – A.I. Slide Set 5. Chapter 3 Structures and Strategies for State Space Search – Predicate Calculus: provides a means of describing objects and.
State-Space Searches. 2 State spaces A state space consists of A (possibly infinite) set of states The start state represents the initial problem Each.
A RTIFICIAL I NTELLIGENCE UNIT : 2 Search Techniques.
An Introduction to Artificial Intelligence – CE Chapter 7- Logical Agents Ramin Halavati
Control Algorithms 2 Chapter 6 Control Algorithms 2 Chapter 6 Production Systems.
Lecture 3: Uninformed Search
Logic Programming CSC 358/ Outline Pattern matching Unification Logic programming.
1 Solving problems by searching 171, Class 2 Chapter 3.
Automated Reasoning Early AI explored how to automated several reasoning tasks – these were solved by what we might call weak problem solving methods as.
Automated Reasoning Early AI explored how to automate several reasoning tasks – these were solved by what we might call weak problem solving methods as.
Search CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
Basic Problem Solving Search strategy  Problem can be solved by searching for a solution. An attempt is to transform initial state of a problem into some.
Programming Languages Third Edition Chapter 4 Logic Programming.
© Copyright 2008 STI INNSBRUCK Intelligent Systems Propositional Logic.
Week 15 – Wednesday.  What did we talk about last time?  Review up to Exam 1.
Search in State Spaces Problem solving as search Search consists of –state space –operators –start state –goal states A Search Tree is an efficient way.
1 Propositional Logic Limits The expressive power of propositional logic is limited. The assumption is that everything can be expressed by simple facts.
07/10/04 AIPP Lecture 5: List Processing1 List Processing Artificial Intelligence Programming in Prolog Lecturer: Tim Smith Lecture 5 07/10/04.
Logical Agents Chapter 7. Outline Knowledge-based agents Propositional (Boolean) logic Equivalence, validity, satisfiability Inference rules and theorem.
Forward and Backward Chaining
Proof Methods for Propositional Logic CIS 391 – Intro to Artificial Intelligence.
Building Control Algorithms for State Space Search. Luger: Artificial Intelligence, 5 th edition. © Pearson Education Limited, 2005.
Lecture 2: Problem Solving using State Space Representation CS 271: Fall, 2008.
Logical Agents. Outline Knowledge-based agents Logic in general - models and entailment Propositional (Boolean) logic Equivalence, validity, satisfiability.
STATE SPACE REPRESENTATION
CSE (c) S. Tanimoto, 2001 Search-Introduction
Methods of Proof Chapter 7, second half.
CSE (c) S. Tanimoto, 2002 State-Space Search
CSE (c) S. Tanimoto, 2004 State-Space Search
Presentation transcript:

1 CS 385 Fall 2006 Chapter 6 Building Control Algorithms for State Space Search Read

2 Summary of Chapters 3 and 4 1.Problem solving is search through a set of problem states 2.The state space model uses graph theory to represent the problem as states and transitions 3.Characteristics of state space search a. Solution is a path from start state to a goal. b. Search systematically tests alternative paths to the goal c. Backtracking allows recovery from paths that fail to reach the goal. d. Lists track states under consideration. e. DFS uses a stack, BFS uses a queue, BFS uses a priority queue

3 Formal Tools Predicate Calculus: 1.A language for capturing complex semantic information and for reasoning based on that information. (formal semantics and inference rules). 2.One could formulate a problem and perform reasoning by hand. State-Space Search: 1.States of a problem are nodes, problem transitions are arcs, a solution is a path from start node to goal. 2.Methods of searching state spaces (dfs, bfs, heuristics). 3.Data-driven versus goal-driven (where on the graph do you start).

4 Tools (cont) Now: We have a formal way to describe a problem using predicate calculus. Next: Automate the search process via an algorithm (pattern- directed search) which will be applied to a space of logical inferences. Recursion-based search Production systems Blackboard architecture (omit)

Recursion A natural for search Algorithms are easier to write easier to analyze formally Recursion consists of a base case a recursive component that resolves into a smaller version of the problem and ultimately to the base case

6 Recursion for List Membership function member(item, tail) //Pascal syntax begin if list is empty then return(fail) else if item = first item of list then return(success) else begin tail=list with first item removed member(item, tail) end member(X, [X|T]).//PROLOG member(X,[Y|T]) :- member(X,T).

7 DFS without/with Recursion procedure depth-first search open = [start]closed = [ ] while open ≠ [ ] do remove leftmost state of open, call it X if X is goal, return success. generate all children of X put X on closed put children of X not already on open or closed on the left end of open function depthsearch(current_state) if current_state is a goal then return success add current_state to closed while current_state has unexmd children child := next unexmd child if depthsearch(child) = success then return(success) return(fail)

8 Trace DFS without/with Recursion goal= 6: openclosed [1][ ] [2,3][1] [4,5,3][2,1] [5,3][4,2,1] 1 [3][5,4,2,1] 2 3 [6, 7] callclosed depthsearch(1)[1] depthsearch(2)[2,1] depthsearch(4)[4,2,1] depthsearch(5)[5,4,2,1] depthsearch(3) depthsearch(6) ←success Notes: 1. The path in maintained in the nested procedure calls. 2. To keep track of the path, retrieve at each successful exit. 3. The open list on left is kept by the procedure activations (e.g. you retain the information necessary to go back to pick up other children). 4. Children are not generated until needed. This is good if it is expensive to generate them.

9 DFS in PROLOG? Represent the state space: % a binary tree move(1, 2). move(1, 3). move(2, 4). move(2, 5). move(3, 6). move(3, 7). %depthfirst with no output dfs1(X, X). dfs1(X, Y) :- move(X, Z), dfs1(Z, Y). Trace: move(1,5)? (1): move(1,2) dfs(2,5)? (3): move(2,4) dfs(4,5) fail (4): move(2,5) dfs(5,5) succeed Problems: no output %depthfirst with output dfs2(X, Y) :- move(X, Z), write('trying node '), write(Z), nl, dfs2(Z, Y).

Pattern-Directed Search Apply recursive search to develop a general search procedure for predicate calculus. How is goal-directed search for predicate calculus recursive? identify subgoal(s) that imply the goal recur on the subgoal(s) success if a subgoal matches a fact in the knowledge base

11 This leaves out two possibilities: current goal is negated (  p) - -success if the goal fails current goal is a disjunction (p ..) -- success if all are satisfied with consistent bindings And directions for consistent bindings Rewritten on p.198

12 Prove h using pattern_search: a b c a  b → d a  c → e b  d → f f → g a  e → h goal(h) (unifies with a conclusion apply to premise e  a) goal(e) (unifies with a conclusion apply to premise c  a) goal(c) (unifies with a fact) true goal(a) (unifies with a fact) true ← e is true goal(a) (unifies with a fact) true ← h is true

13 Production Systems Pattern-directed search: based on a set of production rules (similar to but different from a rep. in predicate calculus). Production system: a system for pattern-directed control of problem solving. A production system consists of 1. A set of production rules (productions) 2. Working memory 3. Recognize/act cycle

Production Systems 1. A set of production rules (productions) (condition/action) pairs condition: when the action can be applied action: the problem-solving step (add something to known facts or do something) if it is cold or rainy then drive to work p(x)  q(x) 2. Working memory the current state of the world what's true production rules can alter this

15 Production Systems 3. Recognize/act cycle match patterns in working memory against conditions of production rules. conflict set = those rules with matches select one member of conflict set to fire (perform the action) this will change the contents of the working memory Conflict resolution: pick which rule to fire. Often the first whose condition matches current state. Pure production systems: no way to recover from dead ends (backtrack)

16 Rewrite Rules for Sorting a String Rewrite rules for sorting a string (productions) 1. ba  ab 2. ca  ac 3. cb  bc Task: sort cbaca IterationWorking memoryConflict setRule fired 0cbaca bcaca2 2 2bacca bacac baacc11 5abacc11 6aabcc

17 Using the Rules in in Reverse Order Rewrite rules for sorting a string (productions) 1. ba  ab 2. ca  ac 3. cb  bc IterationWorking memoryConflict setRule fired 0cbaca bcaca2 2 2bacca bacac baacc11 5abacc11 6aabcc

18 Production System: the Knights Tour Can a knight (chess) visit each square on a board once? productions: knight on 1  move knight to 8,... Is there a path from one square to another? control algorithm:  X path(X,X)  X,Y path(X,Y) ←  Z [move(X,Z)  path(Z,Y)]

19 Knights Tour Is there a path from 1 to 3? IterationCurrent square Goal square Conflict set Fire rule 0133, , done! working memory

20 Knights Tour Is there a path from 2 to 3? IterationCurrent square Goal square Conflict set Fire rule 0233, , , , 1413 working memory

21 Production Systems Newell and Simon: production systems are a model for how humans solve problems. Why? rules  long term memory, working memory (state of the world)  short term memory

22 Control of Search in Production Systems Review: production systems more general than pattern directed search sometimes easier to formulate. This section: production systems allow opportunities to add heuristic control to search. (pattern-directed as implemented by pure PROLOG allowed arrangement and structure of rules, but not much else) 1. Data driven versus goal driven: compare Figures 6.9 and 6.10 on next slides Actually many strategies are combinations. MYCIN: starts with symptoms and forward chains (data driven). If at some point it suspects a disease, backward chain (goal driven).

23 Figure 6.9: Data-driven search in a production system.

24 Figure 6.10: Goal-driven search in a production system.

25 Control of Search in Production Systems 2. Through the rule structure. E.g. the order of premises. Compare gpa_over_3(X)  application_finished(X)  candidate(X) application_finished(X)  gpa_over_3(X)  candidate(X) Harder to finish application than to check the gpa Checking gpa first saves effort. 3. Through conflict resolution. Note, move(1,8) is before move(1.6) in knight’s tour. Often conflict resolution is by order of the rules so that matters. knight0: no control, path(1,7) works, path(1,4) and path(1,9) loop knight1: put a footstep where you have been. knight2: keep a list.

26 Knights Tour in PROLOG knight0.pro: %productions move(1,6). move(1,8). move(2,7). move(2,9).... %control path(Z,Z). path(X,Y):- move(X,W), path(W,Y). Trace path(1,7): path(1,7): move(1,6) try path(6,7) move(6,1) try path(7,2) move(7,6) try path(6,2) Whoops.

27 Knights Tour in PROLOG Resolution (knight1.pro): path(X,Y):- move(X,W), not(been(W)), assert(been(W)), path(W,Y). But this adds been(6) to the database Try path(1,6) twice and the second time fails knight2.pro: path(Z,Z,L). path(X,Y,L):- move(X,Z), not(member(Z, L)), path(Z, Y, [Z|L]).

28 Trace path(1,7, [1]): path(1, 7, [1]). move(1, 6) not member(6, [1]) succeeds path(6, 7, [6, 1] move(6, 1) not member(1, [1]) fails move(6,7) not member(7, [6,1]) succeeds path(7, 7, [7, 6, 1]) writelist([7, 6, 1]) Ch 15 has a longer one. Try yourself. How does the result get printed in knight2.pro? knight2.pro move(1,6). move(1,8). move(2,7). move(2,9). move(3,4). move(3,8). move(4,3). move(4,9). path(Z,Z,L). path(X,Y,L):- move(X,Z), not(member(Z, L)), path(Z, Y, [Z|L]). move(6,1). move(6,7). move(7,2). move(7,6). move(8,1) move(8,3). move(9,2). move(9,4).

29 Blackboard Architecture (omit) Cooperating knowledge sources that share information and results Communication through a blackboard. Really a way of breaking a problem into smaller ones

30 Homework 1a 4. Draw the nodes and arcs for the legal moves. Each node will be a 4-tuple indicating who performs each of the four tasks. The tuples should be ordered by decreasing importance (fire, cakes, tea, and poetry). For example, (c s s e) indicates the child is feeding the fire, the servant is serving cakes and pouring tea, and the elder is reading poetry, 5. Complete part a in full detail. For b and c it suffices to list the order in which states are visited and the current list of closed states. Redo 5a. using the production system notation, producing a trace of execution similar to the tables on p for 2, not 8 of the moves. 9 10