Prolog Prolog: Programming in Logic Prolog programs consist of clauses and rules. Declarative programming –Emphasis is on data and relations between objects.

Slides:



Advertisements
Similar presentations
Artificial Intelligence
Advertisements

First-Order Logic Chapter 8.
Some Prolog Prolog is a logic programming language
First-Order Logic.
Standard Logical Equivalences
We have seen that we can use Generalized Modus Ponens (GMP) combined with search to see if a fact is entailed from a Knowledge Base. Unfortunately, there.
Logic Use mathematical deduction to derive new knowledge.
Propositional Logic CMSC 471 Chapter , 7.7 and Chuck Dyer
Logic.
Formal Logic Mathematical Structures for Computer Science Chapter 1 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesFormal Logic.
Knowledge Representation Methods
Knowledge Representation I Suppose I tell you the following... The Duck-Bill Platypus and the Echidna are the only two mammals that lay eggs. Only birds.
Propositional Calculus A propositional calculus formula is composed of atomic propositions, which area simply statements that are either true or false.
Outline Recap Knowledge Representation I Textbook: Chapters 6, 7, 9 and 10.
Logic. Propositional Logic Logic as a Knowledge Representation Language A Logic is a formal language, with precisely defined syntax and semantics, which.
Programming Language Paradigms: summary. Object-oriented programming Objects are the fundamental building blocks of a program. Interaction is structured.
Logic Programming Languages. Objective To introduce the concepts of logic programming and logic programming languages To introduce a brief description.
CSE 311 Foundations of Computing I Lecture 6 Predicate Logic Autumn 2011 CSE 3111.
Inference in First-Order Logic
Predicate Calculus.
1 Knowledge Representation and Reasoning. 2 Knowledge Representation & Reasoning How knowledge about the world can be represented How knowledge about.
Propositional Logic Agenda: Other forms of inference in propositional logic Basics of First Order Logic (FOL) Vision Final Homework now posted on web site.
ISBN Chapter 16 Logic Programming Languages.
Logic Programming Languages
CSCI 115 Chapter 2 Logic. CSCI 115 §2.1 Propositions and Logical Operations.
Knowledge Interchange Format Michael Gruninger National Institute of Standards and Technology
Proof Systems KB |- Q iff there is a sequence of wffs D1,..., Dn such that Dn is Q and for each Di in the sequence: a) either Di is in KB or b) Di can.
1-1 Introduction Logic programming languages, sometimes called declarative programming languages Express programs in a form of symbolic logic Use a logical.
Declarative vs Procedural Programming  Procedural programming requires that – the programmer tell the computer what to do. That is, how to get the output.
Chapter 1, Part II: Predicate Logic With Question/Answer Animations.
Pattern-directed inference systems
Logical Agents Logic Propositional Logic Summary
ARTIFICIAL INTELLIGENCE Lecture 3 Predicate Calculus.
1 CMSC 471 Fall 2002 Class #10/12–Wednesday, October 2 / Wednesday, October 9.
Inference in FOL Compared to predicate logic, more abstract reasoning and specific conclusions.
CHAPTER 15 & 16 Functional & Logic Programming Languages.
First-Order Logic Introduction Syntax and Semantics Using First-Order Logic Summary.
Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers.
CS Introduction to AI Tutorial 8 Resolution Tutorial 8 Resolution.
Dr. Muhammed Al-Mulhem ICS An Introduction to Logical Programming.
Logic Programming Languages Session 13 Course : T Programming Language Concept Year : February 2011.
Computing & Information Sciences Kansas State University Lecture 14 of 42 CIS 530 / 730 Artificial Intelligence Lecture 14 of 42 William H. Hsu Department.
Automated Reasoning Early AI explored how to automated several reasoning tasks – these were solved by what we might call weak problem solving methods as.
Artificial Intelligence 7. Making Deductive Inferences Course V231 Department of Computing Imperial College, London Jeremy Gow.
Artificial Intelligence Chapter 15 The Predicate Calculus Artificial Intelligence Chapter 15 The Predicate Calculus Biointelligence Lab School of Computer.
C. Varela1 Logic Programming (PLP 11) Predicate Calculus, Horn Clauses, Clocksin-Mellish Procedure Carlos Varela Rennselaer Polytechnic Institute November.
For Wednesday Read chapter 9, sections 1-3 Homework: –Chapter 7, exercises 8 and 9.
Propositional Logic Predicate Logic
For Friday Read chapter 8 Homework: –Chapter 7, exercises 2 and 10 Program 1, Milestone 2 due.
CSCI 5582 Fall 2006 CSCI 5582 Artificial Intelligence Lecture 11 Jim Martin.
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.
ISBN Chapter 16 Logic Programming Languages.
Knowledge Repn. & Reasoning Lec. #5: First-Order Logic UIUC CS 498: Section EA Professor: Eyal Amir Fall Semester 2004.
Reasoning with Propositional Logic automated processing of a simple knowledge base CD.
First-Order Logic Reading: C. 8 and C. 9 Pente specifications handed back at end of class.
1-1 An Introduction to Logical Programming Sept
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.
Section 1.4. Propositional Functions Propositional functions become propositions (and have truth values) when their variables are each replaced by a value.
Discrete Mathematical Structures: Theory and Applications 1 Logic: Learning Objectives  Learn about statements (propositions)  Learn how to use logical.
Propositional Logic. Assignment Write any five rules each from two games which you like by using propositional logic notations.
Announcements  Upcoming due dates  Thursday 10/1 in class Midterm  Coverage: everything in lecture and readings except first-order logic; NOT probability.
By P. S. Suryateja Asst. Professor, CSE Vishnu Institute of Technology
Knowledge Representation
Logic Programming Languages
Carlos Varela Rensselaer Polytechnic Institute November 10, 2017
Horn Clauses and Unification
CS 188: Artificial Intelligence
Horn Clauses and Unification
Presentation transcript:

Prolog Prolog: Programming in Logic Prolog programs consist of clauses and rules. Declarative programming –Emphasis is on data and relations between objects. –No familiar procedural controls. –Built-in inference engine.

Where is declarative programming useful? Data-driven programming tasks –Verification –Natural Language –Expert Systems –Relational Databases –Diagnostic Systems

Logical Operators ABA^B AND: Conjunction ABAvB OR: Disjunction NOT: Inversion A!A 01 10

Logical Operators ABA->B Implication A->B is equivalent to !AvB ABA B Equivalence A B is equivalent to: A->B ^ B->A (A ^ B) v (!A ^ !B)

Propositional Calculus Represent facts as symbols. –Homer_likes_beer. –Lisa_likes_tofu. –!(Bart_likes_school) –Bart_likes_school -> Bart_does_homework. –Lisa_likes_school ^ Lisa_likes_music Easy, but overly verbose. No reuse.

Predicate Calculus A predicate is a function that maps from zero or more objects to {T,F}. –Likes(Homer, beer) –!Likes(Bart, school) –Likes(Bart, school) -> Does(Bart, homework). –Happy(Lisa). –Gives(Moe, Homer, beer) -> Happy(Homer). Predicates provides a syntactic shorthand for propositions. No extra representational power.

Inference Rules AND-elimination: –If A^B is true, then A is true. –likes(Homer,beer) ^ likes(Homer, food)->likes(Homer,beer) OR-introduction: –If A is true, then AvB is true. –likes(Homer,food)->likes(Homer,food)v likes(Homer,work). Modus Ponens: –If A->B is true, and A is true, then B is true. –likes(Lisa,school)->does(Lisa,homework) ^ likes(Lisa,school) -> Does(Lisa,homework)

Quantification We would like to be able to express facts such as: –“Everyone who likes school does their homework.” –“No one who likes beef also likes tofu.” –“Someone likes beef.” This requires us to be able to quantify over variables in the domain.

First-Order Logic First order logic allows quantification over objects. Universal quantification: “For all x”  x likes(x,school) -> does(x, homework). “Everyone who likes school does their homework.” Existential quantification: “There exists an x”  x likes(x,tofu). “There exists someone who likes tofu.”

Computational Issues Full FOL is too computationally difficult to work with. –Nested quantifiers are semi-decidable.  x  y  z likes(x,y) ^ likes(y,z). “Everyone likes a person who likes everyone.” –Implications with an AND in the consequent are exponentially hard.  x likes(x, school) -> does(x,homework) ^ attends(x,class) “Everyone who likes school does their homework and attends class.”

Horn clauses Horn clauses are implications of the form: x ^ y ^ z -> a Only a single term in the consequent. Horn clause inference is computationally tractable. Prolog uses Horn clauses.

Knowledge Representation in Prolog Facts (unit clauses): –likes(homer, beer). Constants are lower case. Names of relations are lower case. Conjunctions: –likes(homer,beer). –likes(homer,food). Statement is represented as separate Prolog clauses. <- ends with a period

Knowledge Representation in Prolog Rules –does(lisa,homework) :- likes(lisa,school). –Equivalent to: likes(lisa,school) ->does(lisa,homework) –Read as: “Lisa does homework if she likes school.” or … –“To prove that Lisa does homework, prove that she likes school.”

Variables Variables are all upper-case. Universal quantification is achieved by using variables in rules. –does(X,homework) :- likes(X,school). “Everyone who likes school does their homework.” “To prove that someone does their homework, prove that they like school.”