MB: 26 Feb 2001CS 360 - Lecture 11 Introduction Reading: Read Chapter 1 of Bratko Programming in Logic: Prolog.

Slides:



Advertisements
Similar presentations
Knowledge Representation using First-Order Logic
Advertisements

First-Order Logic Chapter 8.
Intelligent Architectures for Electronic Commerce A (Brief) Prolog Tutorial.
Some Prolog Prolog is a logic programming language
First-Order Logic.
1. An Overview of Prolog.
Prolog The language of logic. History Kowalski: late 60’s Logician who showed logical proof can support computation. Colmerauer: early 70’s Developed.
Introduction to Prolog, cont’d Lecturer: Xinming (Simon) Ou CIS 505: Programming Languages Fall 2010 Kansas State University 1.
Prolog The language of logic. History Kowalski: late 60’s Logician who showed logical proof can support computation. Colmerauer: early 70’s Developed.
CS344 : Introduction to Artificial Intelligence Pushpak Bhattacharyya CSE Dept., IIT Bombay Lecture 16- Prolog.
1 Introduction to Prolog References: – – Bratko, I., Prolog Programming.
Logic.
Prolog Programming for Artificial Intelligence Three edition 2001
About prolog  History  Symbolic Programming Language  Logic Programming Language  Declarative Programming Language.
MB: 2 March 2001CS360 Lecture 31 Programming in Logic: Prolog Prolog’s Declarative & Procedural Semantics Readings: Sections
CSE 425: Logic Programming I Logic and Programs Most programs use Boolean expressions over data Logic statements can express program semantics –I.e., axiomatic.
Chapter 8: The Logical Paradigm Lecturer: Xinming (Simon) Ou CIS 505: Programming Languages Fall 2010 Kansas State University 1.
For Friday Read “lectures” 1-5 of Learn Prolog Now: prolog-now/
Comp 205: Comparative Programming Languages Declarative Programming Languages Logic Programming Horn-Clause Logic Prolog Lecture notes, exercises, etc.,
CPSC 322 Introduction to Artificial Intelligence September 15, 2004.
Knowledge Representation using First-Order Logic (Part II) Reading: Chapter 8, First lecture slides read: Second lecture slides read:
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science and Engineering Introduction to Prolog Notes for Ch.1 of Bratko For CSCE 580 Sp03 Marco Valtorta.
Predicate Calculus.
Formal Models of Computation Part II The Logic Model
1 Prolog I. 2 Syllogisms “Prolog” is all about programming in logic. –Socrates is a man. –All men are mortal. –Therefore, Socrates is mortal.
Notes for Chapter 12 Logic Programming The AI War Basic Concepts of Logic Programming Prolog Review questions.
1 Lecture 6 Logic Programming introduction to Prolog, facts, rules Ras Bodik Shaon Barman Thibaud Hottelier Hack Your Language! CS164: Introduction to.
Logical Agents Logic Propositional Logic Summary
1 Last time: Logic and Reasoning Knowledge Base (KB): contains a set of sentences expressed using a knowledge representation language TELL: operator to.
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.
Introduction To PROLOG World view of imperative languages. World view of relational languages. A PROLOG program. Running a PROLOG program. A PROLOG.
First-Order Logic Chapter 8. Outline Why FOL? Syntax and semantics of FOL Using FOL Wumpus world in FOL Knowledge engineering in FOL.
CT214 – Logical Foundations of Computing Lecture 8 Introduction to Prolog.
MB: 5 March 2001CS360 Lecture 41 Programming in Logic: Prolog Lists and List Operations Readings: Sections 3.1 & 3.2.
PROLOG SYNTAX AND MEANING Ivan Bratko University of Ljubljana Faculty of Computer and Info. Sc. Ljubljana, Slovenia.
CS4026 Formal Models of Computation Part II The Logic Model Lecture 2 – Prolog: History and Introduction.
CS 603: Programming Languages Lecture 25 Spring 2004 Department of Computer Science University of Alabama Joel Jones.
I Power Higher Computing Software Development Development Languages and Environments.
CS 4100 Artificial Intelligence Prof. C. Hafner Class Notes Jan 17, 2012.
Dr. Muhammed Al-Mulhem ICS An Introduction to Logical Programming.
Logic Programming Languages Session 13 Course : T Programming Language Concept Year : February 2011.
Logic Programming and Prolog Goal: use formalism of first-order logic Output described by logical formula (theorem) Input described by set of formulae.
Logical Agents Chapter 7. Outline Knowledge-based agents Logic in general Propositional (Boolean) logic Equivalence, validity, satisfiability.
Kansas State University Department of Computing and Information Sciences CIS 730: Introduction to Artificial Intelligence Lecture 15 of 41 Friday 24 September.
For Monday Read “lectures” 1-5 of Learn Prolog Now: prolog-now/
Introduction to Prolog. Outline What is Prolog? Prolog basics Prolog Demo Syntax: –Atoms and Variables –Complex Terms –Facts & Queries –Rules Examples.
First-Order Logic Chapter 8 (not 8.1). Outline Why FOL? Why FOL? Syntax and semantics of FOL Syntax and semantics of FOL Using FOL Using FOL Wumpus world.
First-Order Logic. Outline Why FOL? Syntax and semantics of FOL Using FOL Knowledge engineering in FOL.
CS412/413 Introduction to Compilers Radu Rugina Lecture 13 : Static Semantics 18 Feb 02.
Artificial Intelligence CS370D
1-1 An Introduction to Logical Programming Sept
Lecture 4-1CS250: Intro to AI/Lisp Logical Reasoning I Lecture 4-2 January 25 th, 1999 CS250.
Artificial Intelligence CIS 342 The College of Saint Rose David Goldschmidt, Ph.D.
First-Order Logic Semantics Reading: Chapter 8, , FOL Syntax and Semantics read: FOL Knowledge Engineering read: FOL.
1 First Order Logic CS 171/271 (Chapter 8) Some text and images in these slides were drawn from Russel & Norvig’s published material.
07/10/04 AIPP Lecture 5: List Processing1 List Processing Artificial Intelligence Programming in Prolog Lecturer: Tim Smith Lecture 5 07/10/04.
First-Order Logic Chapter 8. Problem of Propositional Logic  Propositional logic has very limited expressive power –E.g., cannot say "pits cause breezes.
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science and Engineering Introduction to Logic Programming: Prolog Notes for CSCE 190 Based on Bratko,
Prolog Fundamentals. 2 Review Last Lecture A Prolog program consists of a database of facts and rules, and queries (questions). –Fact:.... –Rule:... :-....
Logic Programming Logic programming Candidates should be familiar with the concept of logic programming for declaring logical relationships.
By P. S. Suryateja Asst. Professor, CSE Vishnu Institute of Technology
First-Order Logic Chapter 8.
Prolog programming Introduction to Prolog
Notes 8: Predicate logic and inference
First-Order Logic Chapter 8.
CA 208 Logic Ex8 Describe (i.e. axiomatise, define) the following situation as a Prolog programme (use parent/2 and john, mary etc. as your vocabulary):
JOHN’S FAMILY.
First-Order Logic Chapter 8.
Chapter 2: Prolog (Introduction and Basic Concepts)
Representations & Reasoning Systems (RRS) (2.2)
Presentation transcript:

MB: 26 Feb 2001CS Lecture 11 Introduction Reading: Read Chapter 1 of Bratko Programming in Logic: Prolog

MB: 26 Feb 2001CS Lecture 12 Declarative Programming n Declarative programming describes what to compute rather than how to compute it. n E.g., blueprints for a house are declarative, they describe what to build not how to build it. n Describing “what” is often much easier than describing “how” (but not always). n Algorithm = Logic + Control (R. Kowalski, 1979) n Logic expressions are declarative.

MB: 26 Feb 2001CS Lecture 13 Advantages of Declarative Style of Programming n Simply encode your knowledge without worrying how the knowledge will be used. n The underlying inference engine uses that knowledge to answer the user’s queries. n Knowledge can be used in many ways: – Is Mary Peter’s sister? – Who is Peter’s sister? – Who is whose sister?

MB: 26 Feb 2001CS Lecture 14 Knowledge Bases n A Knowledge Base has: – Knowledge in the form of: n Facts (e.g., Socrates is a man) n Rules (e.g., All men are mortals) – An inference engine n A Knowledge Base uses its facts, rules, and inference engine to answer questions. – Is Socrates mortal? – yes

MB: 26 Feb 2001CS Lecture 15 Logic Programming & Knowledge Bases n Logic programming languages are one way to implement knowledge bases. n Encode your knowledge base and your queries then the underlying inference engine will attempt to answer your queries. n The inference engine answers your queries by building constructive proofs that your queries are entailed by the knowledge base.

MB: 26 Feb 2001CS Lecture 16 Simple Example: Families n Define the relevant relationships: – mother, father, brother, sister, aunt, uncle, cousin, ancestor, descendant n Store the basic facts: – parents, siblings, and gender n Ask your queries: – Who is whose sister?

MB: 26 Feb 2001CS Lecture 17 Some Rules n motherOf(M,O) :- parentOf(M,O), female(M). n sisterOf(S,P) :- siblingOf(S,P), female(S). n auntOf(A,N) :- sisterOf(A,X), parentOf(X,N). n grandmotherOf(G,P) :- motherOf(G,X), parentOf(P). n ancestor(A,P) :- parentOf(A,P). n ancestor(A,P) :- parentOf(A,X), ancestor(X,P). n...

MB: 26 Feb 2001CS Lecture 18 Some Facts n male(john). n female(mary). n male(peter). n parentOf(john, mary). n siblingOf(mary, peter). n parentOf(ann, john). n parentOf(mark, ann). n...

MB: 26 Feb 2001CS Lecture 19 Some Queries n ?- sisterOf(mary, peter). n ?- sisterOf(mary, Who). n ?- sisterOf(Sis, peter). n ?- sisterOf(Sister, Sibling). n ?- ancestorOf(A,P).

MB: 26 Feb 2001CS Lecture 110 Their Answers n ?- sisterOf(mary, peter). – yes n ?- sisterOf(mary, Who). – Who = peter ? ; – no n ?- sisterOf(Sis, peter). – Sis = mary ? ; – no

MB: 26 Feb 2001CS Lecture 111 More Answers n ?- sisterOf(Sister, Sibling). – Sibling = peter, – Sister = mary ? ; – no

MB: 26 Feb 2001CS Lecture 112 Last Answer n ?- ancestorOf(A,P). – A = john, – P = mary ? ; – A = ann, – P = john ? ; – A = mark, – P = ann ? ; – A = ann, – P = mary ? ; –...

MB: 26 Feb 2001CS Lecture 113 Running Prolog n Create knowledge base using favorite editor. n Type /usr/local/bin/prolog on cs26. n Load that knowledge base into Prolog: – [‘myKnowledgeBase.pl’]. n Ask queries: – sisterOf(X,Y). n Exit Prolog: – halt.

MB: 26 Feb 2001CS Lecture 114 Prolog Knowledge Base Anatomy n Knowledge Base – Relations n Clauses – Terms

MB: 26 Feb 2001CS Lecture 115 Terms n Terms are things like atoms, numbers, variables, and structures: – tom, 25.3, X, name(mike, barley) n In happy(P) :- paid(P, X), spend(P,Y), X>Y happy(P), :-, paid(P, X), spend(P,Y), X>Y, P, X, and Y are all terms.

MB: 26 Feb 2001CS Lecture 116 Anatomy of a Clause n All clauses terminated by full-stop(“.”). n Clauses have the form: n head :- body.

MB: 26 Feb 2001CS Lecture 117 Head of a Clause n The head may be the relation name with arguments or may be missing, Examples: – likes(X,Z) :- likes(X,Y), likes(Y,Z). – likes(mike,X) :- true. – :- write(***). n likes(mike,X) :- true.  likes(mike,X). n Clauses with missing bodies are called facts. n Facts with variables are called universal facts.

MB: 26 Feb 2001CS Lecture 118 Body of a Clause n Body is an expression composed of terms. n When the clause head is missing then the body is executed at load-time.

MB: 26 Feb 2001CS Lecture 119 Anatomy of a Relation n A relation is identified by its name and its arity (# of arguments) - name/arity – likes/2 is a different relation from likes/3 n A relation is defined by the clauses whose heads match the relation id, e.g., the clause – ancestor(A, P) :- parentOf(A, P). is part of the definition of ancestor/2

MB: 26 Feb 2001CS Lecture 120 Anatomy of a Query n Queries are input by the user (rather than part of the knowledge base). n Queries have clause body syntax & semantics, notably variables are existentially quantified. n When query has variables, & Prolog succeeds in proving it follows from KB, Prolog displays variable bindings used in proof.

MB: 26 Feb 2001CS Lecture 121 Quick Quiz n What do you ignore (at least initially) in declarative-style programming? n What are the two main components of a knowledge-based system? n What is the type of knowledge encoded in a Prolog knowledge base?

MB: 26 Feb 2001CS Lecture 122 Quick Quiz cont’d n By what two things are relations identified? n In a Prolog knowledge base, what constitutes the definition of a relation? n What forms can a clause take? n What are the two parts of a clause? n What terminates a clause? n Give examples of different types of terms.

MB: 26 Feb 2001CS Lecture 123 Summary n Declarative programming focuses on specifying what you want, not on how to get it. n Knowledge based systems provide an underlying inference engine, the user provides (in declarative form) the knowledge and the queries. n Prolog can be viewed as a type of knowledge based programming system.

MB: 26 Feb 2001CS Lecture 124 Summary cont’d n Prolog knowledge base = relation collection. n Relation identified by name/arity. n Relation defined by clauses whose heads agree with that id (i.e., name & number of arguments)

MB: 26 Feb 2001CS Lecture 125 Summary cont’d n Clauses have following forms: – head :- body. – head. – :- body. n Queries are entered by the user (i.e., not in knowledge base) and have form of clause body.