1-1 Introduction Logic programming languages, sometimes called declarative programming languages Express programs in a form of symbolic logic Use a logical.

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

Logic: The Big Picture Propositional logic: atomic statements are facts –Inference via resolution is sound and complete (though likely computationally.
Discrete Math Methods of proof 1.
CS 330 Programming Languages 12 / 02 / 2008 Instructor: Michael Eckmann.
Chapter 12 - Logic Programming
ISBN Chapter 16 Logic Programming Languages.
Programming Languages Third Edition
CSE 452: Programming Languages
Logic Programming Languages. Objective To introduce the concepts of logic programming and logic programming languages To introduce a brief description.
Inference and Resolution for Problem Solving
Logical Agents Chapter 7. Why Do We Need Logic? Problem-solving agents were very inflexible: hard code every possible state. Search is almost always exponential.
CSE 452: Programming Languages
CSC3315 (Spring 2009)1 CSC 3315 Programming Paradigms Prolog Language Hamid Harroud School of Science and Engineering, Akhawayn University
ISBN Chapter 16 Logic Programming Languages.
Predicates and Quantifiers
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
Discrete Mathematics and Its Applications
Notes for Chapter 12 Logic Programming The AI War Basic Concepts of Logic Programming Prolog Review questions.
Logic Specification and Z Schema 3K04 McMaster. Basic Logic Operators Logical negation ( ¬ ) Logical conjunction ( Λ or & ) Logical disjunction ( V or.
MATH 224 – Discrete Mathematics
CS 330 Programming Languages 12 / 04 / 2007 Instructor: Michael Eckmann.
Chapter 16 Logic Programming Languages. Copyright © 2012 Addison-Wesley. All rights reserved.1-2 Chapter 16 Topics Introduction A Brief Introduction to.
Declarative vs Procedural Programming  Procedural programming requires that – the programmer tell the computer what to do. That is, how to get the output.
1 COSC3306: Programming Paradigms Lecture 8: Declarative Programming Specifications Haibin Zhu, Ph.D. Computer Science Nipissing University (C) 2003.
Introduction to Prolog Asst. Prof. Dr. Senem Kumova Metin Revised lecture notes of “Concepts of Programmig Languages, Robert W. Sebesta, Ch. 16”
ARTIFICIAL INTELLIGENCE Lecture 3 Predicate Calculus.
CHAPTER 15 & 16 Functional & Logic Programming Languages.
CS Introduction to AI Tutorial 8 Resolution Tutorial 8 Resolution.
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.
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.
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.
Ch. 13 Ch. 131 jcmt CSE 3302 Programming Languages CSE3302 Programming Languages (notes?) Dr. Carter Tiernan.
CS6133 Software Specification and Verification
C. Varela1 Logic Programming (PLP 11) Predicate Calculus, Horn Clauses, Clocksin-Mellish Procedure Carlos Varela Rennselaer Polytechnic Institute November.
© Kenneth C. Louden, Chapter 12 - Logic Programming Programming Languages: Principles and Practice, 2nd Ed. Kenneth C. Louden.
Propositional Logic Predicate Logic
Programming Languages Third Edition Chapter 4 Logic Programming.
Chapter 2 Symbolic Logic. Section 2-1 Truth, Equivalence and Implication.
CS 330 Programming Languages 11 / 25 / 2008 Instructor: Michael Eckmann.
Logic Programming Tarik Booker. What will we cover?  Introduction  Definitions  Predicate Calculus  Prolog  Applications.
ISBN Chapter 16 Logic Programming Languages.
Dr. Muhammed Al-Mulhem ICS An Introduction to Prolog.
1-1 An Introduction to Logical Programming Sept
Artificial Intelligence CIS 342 The College of Saint Rose David Goldschmidt, Ph.D.
ARTIFICIAL INTELLIGENCE Lecture 2 Propositional Calculus.
Introduction to Prolog Asst. Prof. Dr. Senem Kumova Metin Revised lecture notes of “Concepts of Programmig Languages, Robert W. Sebesta, Ch. 16”
Logical Agents Chapter 7. Outline Knowledge-based agents Propositional (Boolean) logic Equivalence, validity, satisfiability Inference rules and theorem.
Section 1.4. Propositional Functions Propositional functions become propositions (and have truth values) when their variables are each replaced by a value.
1-1 An Introduction to Prolog Sept Prolog statements Like other programming languages, Prolog consists of collection of statements. Prolog.
Logical Agents. Outline Knowledge-based agents Logic in general - models and entailment Propositional (Boolean) logic Equivalence, validity, satisfiability.
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
Horn Clauses and Unification
Logic Programming Language
Logic Programming Languages
Logic Programming & Prolog
Presentation transcript:

1-1 Introduction Logic programming languages, sometimes called declarative programming languages Express programs in a form of symbolic logic Use a logical inferencing process to produce results Declarative rather that procedural: –Only specification of results are stated (not detailed procedures for producing them)

1-2 Proposition A logical statement that may or may not be true –Consists of objects and relationships of objects to each other

1-3 Symbolic Logic Logic which can be used for the basic needs of formal logic: –Express propositions –Express relationships between propositions –Describe how new propositions can be inferred from other propositions Particular form of symbolic logic used for logic programming called predicate calculus

1-4 Forms of a Proposition Propositions can be stated in two forms: –Fact: proposition is assumed to be true –Query: truth of proposition is to be determined Compound proposition: –Have two or more atomic propositions –Propositions are connected by operators

1-5 Logical Operators NameSymbolExampleMeaning negation   anot a conjunction  a  ba and b disjunction  a  ba or b equivalence  a  ba is equivalent to b implication  a  b a  b a implies b b implies a

1-6 Quantifiers NameExampleMeaning universal  X.PFor all X, P is true existential  X.PThere exists a value of X such that P is true

1-7 Overview of Logic Programming Declarative semantics –There is a simple way to determine the meaning of each statement –Simpler than the semantics of imperative languages Programming is nonprocedural –Programs do not state now a result is to be computed, but rather the form of the result

1-8 The Origins of Prolog University of Aix-Marseille –Natural language processing University of Edinburgh –Automated theorem proving

1-9 Example Problem We are given three colors – red, yellow and blue – with which to color all the countries on a map. The colors must be chosen so that no two countries that share a border have the same color. The shapes of the countries are arbitrary, but a country must consist of a single piece. Countries that meet a corner are not considered a border. Is it possible?

1-10 Three Color Mapping Problem Not always possible to solve

1-11 Three Color Mapping Problem From the viewpoint of logic, it is easy to set down the parameters of the problem, that is, to assert what properties a solution, if it exist, must have. Take the map on the right, our solution should be a list of colors, A, B, C, D, E, F such that –A is different from B, C, D and F –B is different from C, E –C is different from D and E –D is different from E –E is different from F

1-12 Three Color Mapping Problem To render the problem in Prolog, we must first state the fact that the colors red, yellow and blue are different, and assert the conditions just stated about this particular map. different(yellow, red) different(yellow, blue) different(blue, yellow) different(blue, red) different(red, yellow) different(red, blue)

1-13 Three Color Mapping Problem ->map-coloring(A, B, C, D, E, F):- different(A, B), different(A, C), different(A, D), different(A, F), different(B, C), different(B, E), different(C, E), different(C, D), different(D, E), different(E, F) yellow blue red blue yellow blue Satisfied

1-14 Execution of Prolog Programs Prove that goal is satisfiable Search of facts/rules is top-down Execution of sub-goals is left to right Closed-world assumption: –Anything not in database is false

1-15 Applications of Prolog Relational database queries Expert systems Parsing of context-free languages Natural language processing Teaching programming

1-16 Other Examples ancestor(mary,shelley):- mother(mary,shelley). Can use variables (universal objects) to generalize meaning: parent(X,Y):- mother(X,Y). parent(X,Y):- father(X,Y). grandparent(X,Z):- parent(X,Y), parent(Y,Z). sibling(X,Y):- mother(M,X), mother(M,Y), father(F,X), father(F,Y).

1-17 Goal Statements Can you prove or disprove the following statements? Fact: father(fred,Mike) Query: parent(fred,Mike) man(fred)

1-18 Backtracking With a goal with multiple subgoals, if fail to show truth of one of subgoals, reconsider previous subgoal to find an alternative solution: backtracking Begin search where previous search left off Can take lots of time and space because may find all possible proofs to every subgoal

1-19 List Structures Other basic data structure (besides atomic propositions we have already seen): list List is a sequence of any number of elements Elements can be atoms, atomic propositions, or other terms (including other lists) [apple, prune, grape, kumquat] [] ( empty list) [X | Y] ( head X and tail Y)

1-20 Append Example append([], List, List). append([Head | List_1], List_2, [Head | List_3]) :- append (List_1, List_2, List_3).

1-21 Reverse Example reverse([], []). reverse([Head | Tail], List) :- reverse (Tail, Result), append (Result, [Head], List).