CS4026 Formal Models of Computation Part II The Logic Model Lecture 2 – Prolog: History and Introduction.

Slides:



Advertisements
Similar presentations
CS4026 Formal Models of Computation Part II The Logic Model Lecture 1 – Programming in Logic.
Advertisements

Formal Models of Computation Part II The Logic Model
Some Prolog Prolog is a logic programming language
First-Order Logic.
1 Declarative Programming Motivation Warm Fuzzies What is Logic?... Logic Programming? Mechanics of Prolog Terms, Substitution, Unification, Horn Clauses,
Logic Programming Automated Reasoning in practice.
Prolog The language of logic. History Kowalski: late 60’s Logician who showed logical proof can support computation. Colmerauer: early 70’s Developed.
LING 388: Language and Computers Sandiway Fong Lecture 5: 9/5.
LING 388: Language and Computers Sandiway Fong Lecture 5: 9/8.
Prolog The language of logic. History Kowalski: late 60’s Logician who showed logical proof can support computation. Colmerauer: early 70’s Developed.
Rigorous Software Development CSCI-GA Instructor: Thomas Wies Spring 2012 Lecture 11.
Logic CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
Quiz Propositional Logic. 1. Let A,B,C be propositions, i.e. they can take values False (F) or True (T). a) How many possible worlds are there.
MB: 2 March 2001CS360 Lecture 31 Programming in Logic: Prolog Prolog’s Declarative & Procedural Semantics Readings: Sections
Comp 205: Comparative Programming Languages Declarative Programming Languages Logic Programming Horn-Clause Logic Prolog Lecture notes, exercises, etc.,
Outline Recap Knowledge Representation I Textbook: Chapters 6, 7, 9 and 10.
Comp 205: Comparative Programming Languages Semantics of Imperative Programming Languages denotational semantics operational semantics logical semantics.
LING 388 Language and Computers Lecture 2 9/04/03 Sandiway FONG.
Constraint Logic Programming Ryan Kinworthy. Overview Introduction Logic Programming LP as a constraint programming language Constraint Logic Programming.
CPSC 322 Introduction to Artificial Intelligence September 20, 2004.
Knowledge Representation I (Propositional Logic) CSE 473.
PZ08B Programming Language design and Implementation -4th Edition Copyright©Prentice Hall, PZ08B - Logic programming and Prolog Programming Language.
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science and Engineering Introduction to Functional Programming Notes for CSCE 190 Based on Sebesta,
Survey of Mathematical Ideas Math 100 Chapter 3, Logic
CS1502 Formal Methods in Computer Science Lecture Notes 10 Resolution and Horn Sentences.
DEDUCTIVE DATABASE.
Formal Models of Computation Part II The Logic Model
Notes for Chapter 12 Logic Programming The AI War Basic Concepts of Logic Programming Prolog Review questions.
Patterns in OCaml functions. Formal vs. actual parameters Here's a function definition (in C): –int add (int x, int y) { return x + y; } –x and y are.
Cs7120 (Prasad)L16-Meaning1 Procedural and Declarative Meaning of Prolog
Lecture on Programming Languages
Slide 1 Propositional Definite Clause Logic: Syntax, Semantics and Bottom-up Proofs Jim Little UBC CS 322 – CSP October 20, 2014.
Introduction To PROLOG World view of imperative languages. World view of relational languages. A PROLOG program. Running a PROLOG program. A PROLOG.
1 Prolog and Logic Languages Aaron Bloomfield CS 415 Fall 2005.
CS Introduction to AI Tutorial 8 Resolution Tutorial 8 Resolution.
By: Cory Canter CSC 415 Programming Languages. History  Created by Alain Colmerauer, Phillipe Roussel and Robert Kowalski in 1971  Started as a natural.
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.
Logical Agents Chapter 7. Outline Knowledge-based agents Logic in general Propositional (Boolean) logic Equivalence, validity, satisfiability.
Computing & Information Sciences Kansas State University Monday, 25 Sep 2006CIS 490 / 730: Artificial Intelligence Lecture 14 of 42 Monday, 25 September.
Ch. 13 Ch. 131 jcmt CSE 3302 Programming Languages CSE3302 Programming Languages (notes?) Dr. Carter Tiernan.
Automated Reasoning Systems For first order Predicate Logic.
Kansas State University Department of Computing and Information Sciences CIS 730: Introduction to Artificial Intelligence Lecture 15 of 41 Friday 24 September.
Computing & Information Sciences Kansas State University Lecture 15 of 42 CIS 530 / 730 Artificial Intelligence Lecture 15 of 42 William H. Hsu Department.
Logical and Functional Programming
1 Logic programming and Prolog Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section 8.4.
Introduction to Prolog. Outline What is Prolog? Prolog basics Prolog Demo Syntax: –Atoms and Variables –Complex Terms –Facts & Queries –Rules Examples.
For Wednesday Read chapter 9, sections 1-3 Homework: –Chapter 7, exercises 8 and 9.
CSE (c) S. Tanimoto, 2008 Predicate Calculus II 1 Predicate Calculus 2 Outline: Unification: definitions, algorithm Formal interpretations and satisfiability.
CSE 3302 Programming Languages Chengkai Li Spring 2008 Logic Programming: Prolog Lecture 21 – Prolog, Spring CSE3302 Programming Languages, UT-Arlington.
11 Artificial Intelligence CS 165A Thursday, October 25, 2007  Knowledge and reasoning (Ch 7) Propositional logic 1.
1 Knowledge Based Systems (CM0377) Lecture 6 (last modified 20th February 2002)
Basic Definitions of Set Theory Lecture 24 Section 5.1 Fri, Mar 2, 2007.
MB: 26 Feb 2001CS Lecture 11 Introduction Reading: Read Chapter 1 of Bratko Programming in Logic: Prolog.
Invitation to Computer Science, Java Version, Second Edition 1 Logic Programming Logic programming  Various facts are asserted to be true  On the basis.
Logic: Proof procedures, soundness and correctness CPSC 322 – Logic 2 Textbook §5.2 March 7, 2011.
In The Name Of Allah Lab 03 1Tahani Aldweesh. objectives Searching for the solution’s. Declaration. Query. Comments. Prolog Concepts. Unification. Disjunction.
First-Order Logic Semantics Reading: Chapter 8, , FOL Syntax and Semantics read: FOL Knowledge Engineering read: FOL.
Instructor: Eyal Amir Grad TAs: Wen Pu, Yonatan Bisk Undergrad TAs: Sam Johnson, Nikhil Johri CS 440 / ECE 448 Introduction to Artificial Intelligence.
Done By :- -Nesreen Basem -Sara nabil -Rawan Prolog Program.
Prolog Overview Syntax Mechanism Summary. Overview PROLOG : Programming with Logic Uses predicate (first-order) calculus History: Roots: J.A. Robinson.
Knowledge Repn. & Reasoning Lecture #9: Propositional Logic UIUC CS 498: Section EA Professor: Eyal Amir Fall Semester 2005.
Copyright 1999Paul F. Reynolds, Jr. Foundations of Logic Programming.
Recursive stack-based version of Back-chaining using Propositional Logic
Prolog syntax + Unification
CS2136: Paradigms of Computation
Logic programming and Prolog
Chapter 2: Prolog (Introduction and Basic Concepts)
Representations & Reasoning Systems (RRS) (2.2)
Presentation transcript:

CS4026 Formal Models of Computation Part II The Logic Model Lecture 2 – Prolog: History and Introduction

formal models of computation 2 Prolog: Origin and History Prolog = Programming in Logic (1974) R.A. Kowalski: ‘Predicate logic as a programming language’ : –First-order predicate logic for the specification of data and relations among data –Computation = logical deduction (1972) A. Colmerauer, P. Roussel: first Prolog-like interpreter (1980’s) Adopted as language for Japanese 5th Generation project.

formal models of computation 3 Logic Programming (LP) R.A. Kowalski (Imperial College): Algorithm = Logic + Control Imperative languages (Pascal, C++, Java): –data (what) –operations on data (how) –no separation between ‘what’ and ‘how’

formal models of computation 4 LP: Logic + Control Logic: What Logical Formulae:  x (p(x)  q(x)) Control: How Logical Deduction: if A  B and A then B

formal models of computation 5 What: Problem Description Horn clause: A  B 1,…,B n A,B 1,…,B n are predicates, i.e., p(a 1,…,a m ) Meaning: –A is true if B 1, B 2,…., and B n are true Horn clauses allow us to specify –Facts –Rules –Queries about objects and relations between them.

formal models of computation 6 What: Problem Description Facts are represented as A  has(john,jaguar)  “john has a jaguar” Rules are represented as A  B 1,…,B n rich(X)  has(X,jaguar) “if someone has a jag they are rich” Queries are represented as  B 1,…,B n  rich(Y) “who is rich?” Facts + rules: Knowledge Base (KB)

formal models of computation 7 How: Computing with Logic Computation as Resolution, a deduction mechanism. A query starts up a computation which uses rules and facts (KB) to answer the query. A query is answered as true or false, and its variables are (possibly) assigned values. Queries may loop! (as in any programming language programs may loop…)

formal models of computation 8 How: Computing with Logic resolution(KB,Query):boolean let Query be  C 1,…,C n for i = 1 to n do if there is a fact A  in KB such that A = C i then true else if there is a rule A  B 1,…,B n in KB such that A = C i then resolution(KB,  B 1,…,B n ) else false if all C i are true then return true else return false

formal models of computation 9 How: Computing with Logic Recursive formulation of resolution; Exhaustive: –in order to say “no” resolution must try all possibilities!! Simple & general definition of computation

formal models of computation 10 How: Computing with Logic KB={has(john,jaguar) , rich(X)  has(X,jaguar)} resolution(KB,  rich(Y)) let Query be  rich(Y) for i = 1 to 1 do if there is a fact A  in KB such that A = rich(Y) then true else if there is a rule A  B 1,…,B n in KB such that A = C i then resolution(KB,  B 1,…,B n ) else false if all C i are true then return true else return false

formal models of computation 11 How: Computing with Logic KB={has(john,jaguar) , rich(X)  has(X,jaguar)} resolution(KB,  rich(Y)) let Query be  rich(Y) for i = 1 to 1 do if there is a fact A  in KB such that A = rich(Y) then true else if there is a rule A  B 1,…,B n in KB such that A = rich(Y) then resolution(KB,  B 1,…,B n ) else false if all C i are true then return true else return false Yes, If X = Y then rich(X)  has(X,jaguar)

formal models of computation 12 How: Computing with Logic KB={has(john,jaguar) , rich(X)  has(X,jaguar)} resolution(KB,  rich(Y)) let Query be  rich(Y) for i = 1 to 1 do if there is a fact A  in KB such that A = rich(Y) then true else if there is a rule A  B 1,…,B n in KB such that A = rich(Y) then resolution(KB,  B 1,…,B n ) else false if all C i are true then return true else return false

formal models of computation 13 How: Computing with Logic KB={has(john,jaguar) , rich(X)  has(X,jaguar)} resolution(KB,  rich(Y)) let Query be  rich(Y) for i = 1 to 1 do if there is a fact A  in KB such that A = rich(Y) then true else if there is a rule A  B 1,…,B n in KB such that A = rich(Y) then resolution(KB,  has(Y,jaguar)) else false if all C i are true then return true else return false

formal models of computation 14 How: Computing with Logic KB={has(john,jaguar) , rich(X)  has(X,jaguar)} resolution(KB,  has(Y,jaguar)) let Query be  has(Y,jaguar) for i = 1 to 1 do if there is a fact A  in KB such that A = has(Y,jaguar) then true else if there is a rule A  B 1,…,B n in KB such that A = C i then resolution(KB,  B 1,…,B n ) else false if all C i are true then return true else return false Yes, If Y = john

formal models of computation 15 How: Computing with Logic KB={has(john,jaguar) , rich(X)  has(X,jaguar)} resolution(KB,  rich(Y)) let Query be  rich(Y) for i = 1 to 1 do if there is a fact A  in KB such that A = rich(Y) then true else if there is a rule A  B 1,…,B n in KB such that A = rich(Y) then resolution(KB,  has(john,jaguar)) else false if all C i are true then return true else return false That is, Y = john

formal models of computation 16 How: Computing with Logic KB={has(john,jaguar) , rich(X)  has(X,jaguar)} resolution(KB,  rich(Y)) let Query be  rich(Y) for i = 1 to 1 do if there is a fact A  in KB such that A = rich(Y) then true else if there is a rule A  B 1,…,B n in KB such that A = rich(Y) then resolution(KB,  has(john,jaguar)) else false if rich(Y) is true then return true else return false Yes, and Y = john

formal models of computation 17 How: Computing with Logic resolution(KB,Query):boolean let Query be  C 1,…,C n for i = 1 to n do if there is a fact A  in KB such that A = C i then true else if there is a rule A  B 1,…,B n in KB such that A = C i then resolution(KB,  B 1,…,B n ) else false if all C i are true then return true else return false non-determinism: If there is more than one, which one to choose? unification: Is it possible to find values of variables that would make A and C i equal?