Logic Programming Tarik Booker. What will we cover?  Introduction  Definitions  Predicate Calculus  Prolog  Applications.

Slides:



Advertisements
Similar presentations
First Order Logic Logic is a mathematical attempt to formalize the way we think. First-order predicate calculus was created in an attempt to mechanize.
Advertisements

Chapter 11 :: Logic Languages
1 Introduction to Prolog References: – – Bratko, I., Prolog Programming.
CS 330 Programming Languages 12 / 02 / 2008 Instructor: Michael Eckmann.
Logic Programming Languages featuring Prolog, your new favorite language.
ISBN Chapter 16 Logic Programming Languages.
Propositional Calculus A propositional calculus formula is composed of atomic propositions, which area simply statements that are either true or false.
Introduction to Prolog What is Prolog? Application Areas of Prolog How does Prolog work? (Syntax of Prolog) Program Structure.
CSE 452: Programming Languages
Logic Programming Languages. Objective To introduce the concepts of logic programming and logic programming languages To introduce a brief description.
CSE 452: Programming Languages
ISBN Chapter 16 Logic Programming Languages.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 15 Logic Programming Q: How many legs does.
(9.1) COEN Logic Programming  Logic programming and predicate calculus  Prolog statements  Facts and rules  Matching  Subgoals and backtracking.
Logic Programming Tasanawan Soonklang. Programming paradigms Imperative Object-oriented Functional Logic Procedural programming Non-procedural programming.
ISBN Chapter 16 Logic Programming Languages.
Logic Programming Languages
CPS 506 Comparative Programming Languages
Notes for Chapter 12 Logic Programming The AI War Basic Concepts of Logic Programming Prolog Review questions.
CS 330 Programming Languages 12 / 04 / 2007 Instructor: Michael Eckmann.
1 Lecture 15: Introduction to Logic Programming with Prolog (Section 11.3) A modification of slides developed by Felix Hernandez-Campos at UNC Chapel Hill.
Chapter 16 Logic Programming Languages. Copyright © 2012 Addison-Wesley. All rights reserved.1-2 Chapter 16 Topics Introduction A Brief Introduction to.
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.
Introduction to Prolog Asst. Prof. Dr. Senem Kumova Metin Revised lecture notes of “Concepts of Programmig Languages, Robert W. Sebesta, Ch. 16”
CHAPTER 15 & 16 Functional & Logic Programming Languages.
1 Prolog and Logic Languages Aaron Bloomfield CS 415 Fall 2005.
Programming Languages Tucker and Noonan – 2e Chapter 15 – Part 1 Logic Programming “Q: How many legs does a dog have if you call its tail a leg? A: Four.
1 Logic Programming Foundations; Prolog In Text: Chapter 15.
Prolog Kyle Marcotte. Outline What is Prolog? Origins of Prolog (History) Basic Tutorial TEST!!! (sort of…actually not really at all) My example Why Prolog?
By: Cory Canter CSC 415 Programming Languages. History  Created by Alain Colmerauer, Phillipe Roussel and Robert Kowalski in 1971  Started as a natural.
Dr. Muhammed Al-Mulhem ICS An Introduction to Logical Programming.
Logic Programming Languages Session 13 Course : T Programming Language Concept Year : February 2011.
CS 363 Comparative Programming Languages Logic Programming Languages.
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.
Introduction to Prolog. Outline What is Prolog? Prolog basics Prolog Demo Syntax: –Atoms and Variables –Complex Terms –Facts & Queries –Rules Examples.
Prolog Harry R. Erwin, PhD COMM2M University of Sunderland.
© Kenneth C. Louden, Chapter 12 - Logic Programming Programming Languages: Principles and Practice, 2nd Ed. Kenneth C. Louden.
Programming Languages Third Edition Chapter 4 Logic Programming.
Programming Language Concepts Lecture 17 Prepared by Manuel E. Bermúdez, Ph.D. Associate Professor University of Florida Logic Programming.
ISBN Chapter 16 Logic Programming Languages.
Functional Programming Languages Logic Programming Languages
Dr. Muhammed Al-Mulhem ICS An Introduction to Prolog.
Knowledge Based Information System
1-1 An Introduction to Logical Programming Sept
In The Name Of Allah Lab 03 1Tahani Aldweesh. objectives Searching for the solution’s. Declaration. Query. Comments. Prolog Concepts. Unification. Disjunction.
Artificial Intelligence CIS 342 The College of Saint Rose David Goldschmidt, Ph.D.
Introduction to Prolog Asst. Prof. Dr. Senem Kumova Metin Revised lecture notes of “Concepts of Programmig Languages, Robert W. Sebesta, Ch. 16”
1-1 An Introduction to Prolog Sept Prolog statements Like other programming languages, Prolog consists of collection of statements. Prolog.
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.
Copyright 1999Paul F. Reynolds, Jr. Foundations of Logic Programming.
Section 16.5, 16.6 plus other references
Logic Programming Languages
By P. S. Suryateja Asst. Professor, CSE Vishnu Institute of Technology
Prolog a declarative language
Logic Programming Languages
CS 3304 Comparative Languages
Logic Programming Languages
Logic Programming Languages
Prolog a declarative language
Prolog a declarative language
Prolog a declarative language
Logic Programming Language
Programming Languages 2nd edition Tucker and Noonan
Logic Programming Languages
Logic Programming & Prolog
UNIT-V Logic Programming Languages & Functional Programming Languages
PROLOG.
Presentation transcript:

Logic Programming Tarik Booker

What will we cover?  Introduction  Definitions  Predicate Calculus  Prolog  Applications

What is Logic Programming?  Simply programming that uses a form of symbolic logic (predicate calculus) as a programming language  Languages based on this type of programming are called Logic Programming Languages  (Also known as declarative languages)

Definitions (1) Predicate Calculus:  Proposition – a logical statement that may or may not be true  Atomic – consist of compound terms  Compound Terms – element of a mathematical relation  Functor – function symbol that names the relation  Ordered list – parameters man(bob) like(bob, steak)

Definitions (2) Clausal Form: B 1  B 2  B 3  A 1  A 2  A 3  Antecedent – right side of a clausal form  Consequent – left side of a clausal form  Declarative Semantics – there is a simple way to determine the meaning of each statement

Prolog  Logic Programming Language  Definitions:  Term – a constant, variable or structure  Constant – only an atom (synbolic value) or an integer  Variable – any string of letters, digits, or underscores that begins with an uppercase letter  Structure – atomic propositions of predicate calculus  Ex: mystruct(parameter list)  Instantiation – a binding of a value to a variable

Sample Prolog (Fact Statements) Fact Statements:  male(bill).  male(jack).  father(bill, jack). Which is Correct?  Bill is Jack’s father?  Jack is Bill’s father?

(Answer)  Either way!  There are no intrinsic semantics in Prolog (just like Predicate Calculus)  Can be interpreted by the programmer in any way he/she likes.

Sample Prolog (Rule Statements)  Consequence_1 :- Antecedent_expression  Examples:  female(shelley), child(shelley).  ancestor(mary, shelley) :- mother(mary, shelley). (If Mary is the mother of Shelley, then Mary is the ancestor of Shelley)

Goal Statements  Queries are known as goals in Prolog.  Example: father(jason, freddy). father(X, freddy).

Inferencing  You want a goal.  When the goal is a compound proposition, each of the facts (structures) is called a subgoal  To prove a goal is true, the inferencing process muse connect the goal to one or more facts in the database  Proving a subgoal is known as satisfying the subgoal

Inferencing Example  Database contains:  father(bob).  man(X) :- father(X).  Your goal (query):  man(bob).  Forward Chaining – bottom-up resolution (start with facts, find goal)  Backward Chaining – top-down resolution(start with goal, find facts)

Inferencing (2)  Forward Chaining: better when the number of possible correct answers is large  Backward Chaining: better when there is a reasonable small set of candidate answers  When goal has more than one structure, we must search:  Depth-first – finds a proof for the first subgoal beforw working on the others  Breadth-first – works on all subgoals in parallel  Prolog uses depth-first, because it utilizes fewer resources  Backing up in a goal to a previously proven subgoal is known as backtracking

Applications of Logic Programming  Relational Database Management Systems  Expert Systems – emulate human expertise in some particular domain  Natural Language Processing

Resources Used Sebesta, Robert W. Concepts of Programming Languages (4 th Edition)