For Monday Exam 1 is Monday Takehome due Prolog Handout 3 due.

Slides:



Advertisements
Similar presentations
Artificial Intelligence: Natural Language and Prolog
Advertisements

CS4026 Formal Models of Computation Part II The Logic Model Lecture 6 – Arithmetic, fail and the cut.
CS344: Introduction to Artificial Intelligence Pushpak Bhattacharyya CSE Dept., IIT Bombay Lecture 12–Prolog examples: Himalayan club, member, rem_duplicate,
Built-in Functions listing(fruit).: Lists all the objects within this relation halt. Exit from Prolog write(X). /* Write to console */ nl /* New Line */
Prolog Nonmonotonic logic.
Computational Models The exam. Models of computation. –The Turing machine. –The Von Neumann machine. –The calculus. –The predicate calculus. Turing.
Prolog.
Declarative Programming Lists in PROLOG Autumn 2014.
© Patrick Blackburn, Johan Bos & Kristina Striegnitz Lecture 6: More Lists Theory –Define append/3, a predicate for concatenating two lists, and illustrate.
© Patrick Blackburn, Johan Bos & Kristina Striegnitz Lecture 6: More Lists Theory –Define append/3, a predicate for concatenating two lists, and illustrate.
Prolog: List © Patrick Blackburn, Johan Bos & Kristina Striegnitz.
Prolog Programming (Volume 3) Dr W.F. Clocksin. Mapping: The Full Map sqlist(, ) sqlist([], []). sqlist([X|T], [Y|L]) :- Y is X * X, sqlist(T, L). List.
1 Basic Prolog ?- prolog prompt A :- B IMPLIES in rules; if B then A, logical AND ; logical OR -> if-then-else. END of predicate switch query/database.
CS344 : Introduction to Artificial Intelligence Pushpak Bhattacharyya CSE Dept., IIT Bombay Lecture 16- Prolog.
1 Introduction to Prolog References: – – Bratko, I., Prolog Programming.
1 Logic Programming. 2 A little bit of Prolog Objects and relations between objects Facts and rules. Upper case are variables. parent(pam, bob).parent(tom,bob).
INTRODUCTION TO PROLOG. PROLOG BASICS Atoms - most primitive terms that the language manipulates start with lower case letter includes strings (‘inside.
1 Knowledge Based Systems (CM0377) Lecture 8 (Last modified 5th March 2001)
Prolog OR (disjunction) “;” is same as a logical OR “;” is same as a logical OR It is also equivalent to using separate clauses... It is also equivalent.
CSI 3120, Prolog recap, page 1 Prolog recap Prolog was invented in 1970, first implemented in 1972, first implemented efficiently in Excellent commercial-
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.
For Friday Finish chapter 10 No homework (get started on program 2)
Comp 307 Lecture 4:1 Prolog I, II Prolog was taught as a procedural language Control structures: if, while, recursion Data structures: structured terms,
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.
1 Prolog II. 2 The Notion of Unification Unification is when two things “become one” Unification is kind of like assignment Unification is kind of like.
CS 330 Programming Languages 12 / 12 / 2006 Instructor: Michael Eckmann.
For Friday Read “lectures” 1-5 of Learn Prolog Now: prolog-now/
11-Jun-15 Prolog II Unification and clause order.
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science and Engineering More Built-in Predicates Notes for Ch.7 of Bratko For CSCE 580 Sp03 Marco Valtorta.
16-Jun-15 Recursion. 2 Definitions I A recursive definition is a definition in which the thing being defined occurs as part of its own definition Example:
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),
(9.1) COEN Logic Programming  Logic programming and predicate calculus  Prolog statements  Facts and rules  Matching  Subgoals and backtracking.
P-Phunck - Prolog1 Introduction to Prolog Brian Paden.
CS 321 Programming Languages and Compilers Prolog part 2.
For Wednesday Read chapter 10 Prolog Handout 4. Exam 1 Monday Take home due at the exam.
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.
15/11/04 AIPP Lecture 14: Database Manipulation1 Database Manipulation Artificial Intelligence Programming in Prolog Lecturer: Tim Smith Lecture 14 15/11/04.
Control Algorithms 1 Chapter 6 Control Algorithms 1 Chapter 6 Pattern Search.
For Wednesday No new reading Prolog handout 2 Chapter 9, exercise 4.
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 COMP 205 Introduction to Prolog Dr. Chunbo Chu Week 14.
1 Prolog and Logic Languages Aaron Bloomfield CS 415 Fall 2005.
For Monday Read “lectures” 6,9-12 of Learn Prolog Now: saarland.de/~kris/learn-prolog-now/ saarland.de/~kris/learn-prolog-now/
CS4026 Formal Models of Computation Part II The Logic Model Lecture 2 – Prolog: History and Introduction.
Logic Programming CSC 358/ Outline Pattern matching Unification Logic programming.
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.
Logic Programming and Prolog Goal: use formalism of first-order logic Output described by logical formula (theorem) Input described by set of formulae.
Ch. 13 Ch. 131 jcmt CSE 3302 Programming Languages CSE3302 Programming Languages (notes?) Dr. Carter Tiernan.
1 Logic programming and Prolog Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section 8.4.
Negation Chapter 5. Stating Negative Conditions n Sometimes you want to say that some condition does not hold n Prolog allows this –not/1this is a predicate.
Lists in Prolog Sections 3.1, 3.2. Lists n List = sequence of values –[1, 2, 3, 4, 5] –[bob, brian, cathy, mark, david, loretta] –[birds(4, calling),
Prolog Unification and clause order. The notion of Unification Unification is when two things “become one” Unification is kind of like assignment Unification.
In The Name Of Allah Lab 03 1Tahani Aldweesh. objectives Searching for the solution’s. Declaration. Query. Comments. Prolog Concepts. Unification. Disjunction.
For Friday No reading Prolog Handout 2. Homework.
Prolog 3 Tests and Backtracking 1. Arithmetic Operators Operators for arithmetic and value comparisons are built-in to Prolog = always accessible / don’t.
07/10/04 AIPP Lecture 5: List Processing1 List Processing Artificial Intelligence Programming in Prolog Lecturer: Tim Smith Lecture 5 07/10/04.
23-Feb-16 Prolog II Unification and clause order.
For Wednesday No reading Prolog handout 2 Chapter 9, exercise 4.
1 TP #2: How does Prolog answer questions? n Miscellaneous info; n Last TP exercises solved; n How does Prolog answer questions? n Recursive Prolog programs;
Chapter Three: Operators, Arithmetic 1. Chapter three: 3.3Operator notation 3.4Arithmetic 2.
C. Varela1 Logic Programming (PLP 11, CTM 9.3) Prolog Imperative Control Flow: Backtracking, Cut, Fail, Not Lists, Append Carlos Varela Rennselaer Polytechnic.
For Friday No reading Prolog handout 3 Chapter 9, exercises 9-11.
For Wednesday Read “lectures” 7-10 of Learn Prolog Now:
For Monday Read chapter 10, sections 1-3 Prolog handout 4
Unification and clause order
Programming Paradigms and Languages
Prolog III.
Prolog III Lists 8-Jul-19.
Presentation transcript:

For Monday Exam 1 is Monday Takehome due Prolog Handout 3 due

For Wednesday Read Prolog Handout 4

Exam 1 Monday Covers through chapter 9 Topics include: –History –Agents/Environments –Search –Logic/Inference –No Prolog Take home due at the exam

Questions?

Some List Predicates member/2 append/3

Try It reverse(List,ReversedList) evenlength(List) oddlength(List)

The Anonymous Variable Some variables only appear once in a rule Have no relationship with anything else Can use _ for each such variable

Arithmetic in Prolog Basic arithmetic operators are provided for by built-in procedures: +, -, *, /, mod, // Note carefully: ?- X = X = ?- X is X = 3

Arithmetic Comparison Comparison operators: > = =< (note the order: NOT <=) =:=(equal values) =\=(not equal values)

Arithmetic Examples Retrieving people born : ?- born(Name, Year), Year >= 1950, Year =< Difference between = and =:= ? =:= yes ? = no ?- 1 + A = B + 2. A = 2 B = 1

Length of a List Definition of length/2 length([], 0). length([_ | Tail], N) :- length(Tail, N1), N is 1 + N1. Note: all loops must be implemented via recursion

Counting Loops Definition of sum/3 sum(Begin, End, Sum) :- sum(Begin, End, Begin, Sum). sum(X, X, Y, Y). sum(Begin, End, Sum1, Sum) :- Begin < End, Next is Begin + 1, Sum2 is Sum1 + Next, sum(Next, End, Sum2, Sum).

The Cut (!) A way to prevent backtracking. Used to simplify and to improve efficiency.

Negation Can’t say something is NOT true Use a closed world assumption Not simply means “I can’t prove that it is true”

Dynamic Predicates A way to write self-modifying code, in essence. Typically just storing data using Prolog’s built-in predicate database. Dynamic predicates must be declared as such.

Using Dynamic Predicates assert and variants retract –Fails if there is no clause to retract retractall –Doesn’t fail if no clauses