CHA2555 Week 7: Prolog: Some Tips Planners: Some Tips Lee McCluskey First term:

Slides:



Advertisements
Similar presentations
Prolog Nonmonotonic logic.
Advertisements

Chapter 1 OO using C++. Abstract Data Types Before we begin we should know how to accomplish the goal of the program We should know all the input and.
AI – Week 5 Implementing your own AI Planner in Prolog – part II : HEURISTICS Lee McCluskey, room 2/09
1 Prolog III. 2 Lists [ ] is the empty list. [x, 2+2, [a, b, c]] is a list of three elements. The first element in the list is its “head”. The list with.
AI – Week 11 AI and Games (3) Lee McCluskey, room 2/09
Comp 307 Lecture 4:1 Prolog I, II Prolog was taught as a procedural language Control structures: if, while, recursion Data structures: structured terms,
Side effects in Prolog Lecturer: Xinming (Simon) Ou CIS 505: Programming Languages Fall 2010 Kansas State University 1.
F28PL1 Programming Languages Lecture 17: Prolog 2.
For Monday Take home exam due Exam 1. For Wednesday Read chapter 10, sections 1-2 Prolog Handout 4.
CS 330 Programming Languages 12 / 02 / 2008 Instructor: Michael Eckmann.
AI – Week 23 – TERM 2 Machine Learning and Natural Language Processing Lee McCluskey, room 3/10
CS 330 Programming Languages 12 / 12 / 2006 Instructor: Michael Eckmann.
For Friday Read “lectures” 1-5 of Learn Prolog Now: prolog-now/
AI – Week AI Planning – Plan Generation Algorithms: GraphPlan Lee McCluskey, room 2/09
Constraint Logic Programming Ryan Kinworthy. Overview Introduction Logic Programming LP as a constraint programming language Constraint Logic Programming.
AI Week 22 Machine Learning Data Mining Lee McCluskey, room 2/07
AI – Week 5 An Introduction to AI Planning Lee McCluskey, room 2/07
Week 4: Introduction to AI Planning Lee McCluskey, room 2/07
CS 101 Course Summary December 5, Big Ideas Abstraction Problem solving Fundamentals of programming.
CIA2326 Week3: Prolog: List Processing Lee McCluskey First term:
AI - Week 24 Uncertain Reasoning (quick mention) then REVISION Lee McCluskey, room 2/07
Basic Definitions Data Structures: Data Structures: A data structure is a systematic way of organizing and accessing data. Or, It’s the logical relationship.
Prolog Ross (Tate). Filling in the Blanks Rather than reverse((a,b)) returns (b,a) Rather than reverse((a,b)) returns (b,a) What X makes reverse((a,b),
Given Connections Solution
Formal Aspects of Computer Science – Week 12 RECAP Lee McCluskey, room 2/07
CHA2555 Week2: Knowledge Representation, Logic and Prolog Lee McCluskey First term:
School of Computing and Mathematics, University of Huddersfield Week 21: Knowledge Acquisition / GIPO Lee McCluskey, room 2/09
1 Lists (Ref. Brna’s book pp26-32, 53-63)  Unifications (by examples)  Representation of Lists  Recursion  Manipulating Lists  Some Prolog Built-in.
School of Computing and Mathematics, University of Huddersfield Computing Science: WEEK 17 Announcement: next few weeks… 9 nd Feb: Comparative Programming.
Review Topics Test 1. Background Topics Definitions of Artificial Intelligence & Turing Test Physical symbol system hypothesis vs connectionist approaches.
Week 6: PDDL, itSIMPLE and running “state of the art” planners Lee McCluskey, room 3/10
CS 321 Programming Languages and Compilers Prolog part 2.
CHA2555 Week2: Knowledge Representation, Logic and Planning Lee McCluskey First term:
14/10/04 AIPP Lecture 7: The Cut1 Controlling Backtracking: The Cut Artificial Intelligence Programming in Prolog Lecturer: Tim Smith Lecture 7 14/10/04.
30/09/04 AIPP Lecture 3: Recursion, Structures, and Lists1 Recursion, Structures, and Lists Artificial Intelligence Programming in Prolog Lecturer: Tim.
F28PL1 Programming Languages Lecture 16: Prolog 1.
15/11/04 AIPP Lecture 14: Database Manipulation1 Database Manipulation Artificial Intelligence Programming in Prolog Lecturer: Tim Smith Lecture 14 15/11/04.
For Wednesday Read “lectures” 7-10 of Learn Prolog Now Chapter 9, exs 4 and 6. –6 must be in Horn clause form Prolog Handout 2.
1 Knowledge Based Systems (CM0377) Lecture 3 (Last modified 5th February 2001)
CIS2326 Week2: Logic and Prolog Lee McCluskey First term:
CS Introduction to AI Tutorial 8 Resolution Tutorial 8 Resolution.
Logic Programming CSC 358/ Outline Pattern matching Unification Logic programming.
Review: computing list results Many programs require list results to be computed, built and returned Many programs require list results to be computed,
Prolog Program Style (ch. 8) Many style issues are applicable to any program in any language. Many style issues are applicable to any program in any language.
3.2 Semantics. 2 Semantics Attribute Grammars The Meanings of Programs: Semantics Sebesta Chapter 3.
The AI War LISP and Prolog Basic Concepts of Logic Programming
Logic Programming and Prolog Goal: use formalism of first-order logic Output described by logical formula (theorem) Input described by set of formulae.
Automated Reasoning Early AI explored how to automated several reasoning tasks – these were solved by what we might call weak problem solving methods as.
Ch. 13 Ch. 131 jcmt CSE 3302 Programming Languages CSE3302 Programming Languages (notes?) Dr. Carter Tiernan.
The Law of Resolution Formal Aspects of Computer Science - Week 7 The Law of Resolution Lee McCluskey, room 2/07
CHA2555 Week2 Practical: Lee McCluskey First term:
Chapter 16 – Data Structures and Recursion. Data Structures u Built-in –Array –struct u User developed –linked list –stack –queue –tree Lesson 16.1.
COMP307 Artificial Intelligence Xiaoying Gao Victoria University of Wellington Lecture 2:1 
AI – Week 5 More on HEURISTICS and domain modelling Lee McCluskey, room 2/09
Programming Language Concepts Lecture 17 Prepared by Manuel E. Bermúdez, Ph.D. Associate Professor University of Florida Logic Programming.
For Monday Exam 1 is Monday Takehome due Prolog Handout 3 due.
For Friday No reading Prolog Handout 2. Homework.
From Conventional Languages to Prolog –What we can do in conventional languages but not in Prolog –What we can do in Prolog but not in conventional languages.
AI – Week 3 An Introduction to AI Planning Lee McCluskey, room 3/10
Prolog Fundamentals. 2 Review Last Lecture A Prolog program consists of a database of facts and rules, and queries (questions). –Fact:.... –Rule:... :-....
O A procedure: a set of axioms (rules and facts) with identical signature (predicate symbol and arity). o A logic program: a set of procedures (predicates),
Costin Ionita, CERN for the ALICE DAQ collaboration ALICE Expert System ACAT 2013, Beijing, May 16 th – 21 st, 2013.
For Wednesday Read “lectures” 7-10 of Learn Prolog Now:
Prolog fundamentals Module 14.2 COP4020 – Programming Language Concepts Dr. Manuel E. Bermudez.
Discrete Maths 11. Recursion Objective
Horn Clauses and Unification
Programming Paradigms and Languages
Programming Techniques
Prolog III Lists 8-Jul-19.
Presentation transcript:

CHA2555 Week 7: Prolog: Some Tips Planners: Some Tips Lee McCluskey First term:

Artform Research Group Prolog: for coursework.. n PROLOG: From the initial part of the course you should know basic Prolog operation, matching, basic backtracking, variable binding, use of the Cut, list processing + recursive functions. This week: ways of manipulating data stored as facts n PLANNING: changing the Prolog Planners to deal with static relations such as “connects”

Artform Research Group Lists and facts Data can be stored in facts, using combinations of lists / terms: chess_board(1,[white_rook, white_knight, white_bishop, white_king, white_queen, white_bishop, white_knight, white_rook]). chess_board(2,[white_pawn, white_pawn, white_pawn, white_pawn, white_pawn, white_pawn, white_pawn, white_pawn ]). chess_board(3,[blank, blank, blank, blank, blank, blank, blank, blank]). Etc connects(a,[s,d,g,h]). connects(b,[f,g,h]). connects(c,[a,,f]).

Artform Research Group RECALL: List Processing n Virtually all list processing carried out in prolog contains the following Recursive Case: 'Break the input list down into its head and tail with an expression of the form '[ X | Y ]'. Process the head X. Recursively call this procedure with input list = tail Y.‘ BUT what about processing a database of facts?

Artform Research Group RECALL: Assert and Retract “assert(X)” will assert term X as a clause at the end of the program. “retract(X)” will succeed once it has removed a clause that matches with X. EG Retract all instances of a term and make it into a list of terms: Eg node(X,Y) get_list([node(X,Y) | T ]):- retract(node(X,Y)), get_list(T),!. get_list([ ]).

Artform Research Group Example: One way of finding the “highest” value in a set of facts (eg nodes). node(13,tom). node(53,dick). node(51,fred). node(11,harry). node(62,tom). node(23,bill). get_highest(Val, Result) :- node(X,Y), assert(current_highest(X,Y)), get_highest, retract(current_highest(Val,Result)). get_highest :- node(X,Y), current_highest(Val,Current), X > Val, retract(current_highest(Val,Current)), assert(current_highest(X,Y)), fail. get_highest.

Artform Research Group Example: One way of changing representations.. :- dynamic connects/2. connects(a,[e,d,f,c]). connects(c,[a,b,g,h]). connects(h,[c,i,j]). connects(i,[k]). % translate into different representation % next(x,y) translate :- retract(connects(X,L)), member(E,L), assert(next(X,E)), assert(next(E,X)), fail. translate. member(X,[X|_]). member(X,[_|T]) :- member(X,T).

Artform Research Group Prolog Planners: using then to do route finding. Example using WSC planner. task1 :- startOCL([se(c1,[at(c1,corridor)]),se(r2,[position(r2,menstoilet)])], [ ss(c1,[at(c1,landing)]), ss(c2,[at(c2,landing)]), ss(c3,[at(c3,landing)]), ss(c4,[at(c4,landing)]), ss(r1,[position(r1,landing),fuel_level(r1,4)]), ss(r2,[position(r2,landing),fuel_level(r2,4)]), ss(landing, [connects(landing,menstoilet),connects(landing,corridor)]), ss(menstoilet, [connects(menstoilet,landing),connects(menstoilet,corridor)]), ss(corridor, [connects(corridor,menstoilet),connects(corridor,landing)]) ] ). Solution example: goal [se(c1,[at(c1,corridor)]),se(r2,[position(r2,menstoilet)])] achieved by sequence[move(r2,landing,menstoilet),load(c1,r1,landing),move(r1,landin g,corridor),unload(c1,r1,corridor)]

Artform Research Group Prolog Planners: using then to do route finding. Example using WSC planner. op(move(R,A,B), % prevail [se(A,[connects(A,B)])], % necessary [ ssc(R,[position(R,A), fuel_level(R,X), ge(X,1), is(XX,X-1)], [position(R,B), fuel_level(R,XX)] ) ], % conditional [ ]).