By P. S. Suryateja Asst. Professor, CSE Vishnu Institute of Technology

Slides:



Advertisements
Similar presentations
Some Prolog Prolog is a logic programming language
Advertisements

Chapter 11 :: Logic Languages
Logic Use mathematical deduction to derive new knowledge.
CS 330 Programming Languages 12 / 02 / 2008 Instructor: Michael Eckmann.
ISBN Chapter 16 Logic Programming Languages.
Formal Logic Proof Methods Direct Proof / Natural Deduction Conditional Proof (Implication Introduction) Reductio ad Absurdum Resolution Refutation.
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
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
DEDUCTIVE DATABASE.
CPS 506 Comparative Programming Languages
Notes for Chapter 12 Logic Programming The AI War Basic Concepts of Logic Programming Prolog Review questions.
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.
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”
Logical Agents Logic Propositional Logic Summary
CHAPTER 15 & 16 Functional & Logic Programming Languages.
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.
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.
CS6133 Software Specification and Verification
Prolog Harry R. Erwin, PhD COMM2M University of Sunderland.
C. Varela1 Logic Programming (PLP 11) Predicate Calculus, Horn Clauses, Clocksin-Mellish Procedure Carlos Varela Rennselaer Polytechnic Institute November.
Programming Languages Third Edition Chapter 4 Logic Programming.
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.
Knowledge Based Information System
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”
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
Prolog a declarative language
Logic Programming Languages
CS 3304 Comparative Languages
Resolution in the Propositional Calculus
Logic Programming Languages
Logic Programming Languages
Knowledge Representation and Inference
Prolog a declarative language
Prolog a declarative language
Logic Use mathematical deduction to derive new knowledge.
Prolog a declarative language
Carlos Varela Rensselaer Polytechnic Institute November 10, 2017
Horn Clauses and Unification
Back to “Serious” Topics…
Horn Clauses and Unification
Logic Programming Language
Biointelligence Lab School of Computer Sci. & Eng.
Horn Clauses and Unification
Logic Programming Languages
CS2136: Paradigms of Computation
Logic Programming & Prolog
Propositional Logic CMSC 471 Chapter , 7.7 and Chuck Dyer
UNIT-V Logic Programming Languages & Functional Programming Languages
Representations & Reasoning Systems (RRS) (2.2)
PROLOG.
Presentation transcript:

By P. S. Suryateja Asst. Professor, CSE Vishnu Institute of Technology Logic Programming By P. S. Suryateja Asst. Professor, CSE Vishnu Institute of Technology

Introduction Programs are expressed in the form of symbolic logic and logical inferencing process is used to produce results. Logic programs are declarative rather than procedural. Programs in logic programming languages are collections of facts and rules. Programming that uses a form of symbolic logic as a programming languages is often called logic programming. Example of logic programming language is Prolog.

Predicate Calculus Predicate calculus is the basis of logic programming. A proposition is a logical statement that may or may not be true. Formal logic is a method for describing propositions. Symbolic logic can be used for three basic needs of formal logic: To express propositions To express relationships between propositions To describe how new propositions can be inferred from other propositions that are assumed to be true. The form of symbolic logic that is used for logic programming is called first-order predicate calculus.

Predicate Calculus : Propositions The objects in propositions are represented by constants or variables. A constant is a symbol that represents an object. A variable is a symbol that can represent different objects at different times. The simplest proposition is an atomic proposition which consists of compound terms.

Predicate Calculus : Propositions (cont...) A compound term is composed of two parts: a functor and an ordered list of parameters. A functor is the function symbol that names the relation. A compound term with a single parameter is a 1-tuple, one with two parameters is a 2-tuple and so on. Examples of 1-tuple and 2-tuple compound terms: man(jake) like(bob, steak)

Predicate Calculus : Propositions (cont...) A compound proposition have two or more atomic propositions which are connected by logical connectors, or operators.

Predicate Calculus : Propositions (cont...) Examples of compound propositions: a ∩ b Ɔ c a Ϲ b U c Variables can be used in propositions but only when they are introduced by special symbols called quantifiers.

Predicate Calculus : Clausal Form One problem with predicate calculus is that there are too many different ways of stating propositions that have the same meaning. A standard form for stating propositions is clausal form. A proposition in clausal form has the following syntax: B1 U B2 U ... U Bn Ϲ A1 ∩ A2 ∩ ... ∩ Am

Predicate Calculus : Clausal Form (cont...) The meaning of the clausal form is: if all the A’s are true then at least one of the B’s is true. Characteristics of clausal form: Existential quantifiers are not required and universal quantifiers are implicit. No operators other than conjunction and disjunction are supported. Disjunction should appear on the left hand side and conjunction on the right hand side.

Predicate Calculus : Clausal Form (cont...) The right side of clausal form proposition is called the antecedent and the left side is called consequent. Ex: likes(bob, trout) Ϲ likes(bob, fish) ∩ fish(trout)

Prolog Prolog was developed by Colmerauer and Roussel in 1972. A program in Prolog is made up of several statements. Each statement is made up of terms. A Prolog term is a constant, a variable, or a structure.

Prolog (cont...) A constant is either an atom or an integer. Atoms are symbolic values of Prolog. A variable is a string of letters, digits, and underscores that begins with a uppercase letter or an underscore ( _ ) . A structure represents the atomic propositions of predicate calculus, and their form is: functor(parameter-list)

Prolog (cont...) Prolog has three basic kinds of statements: Fact statements Rule statements Goal statements A fact statement is a proposition that is assumed to be true. A fact statement is represented as a headless Horn clause. Ex: female(shelly). male(bill). father(bill, jake). mother(bill, shelly).

Prolog (cont...) A rule statement specifies rules of implication between propositions. A rule statement is represent as headed Horn clause. The right side is the antecedent or if part and the left side is the consequent of then part. The consequent is a single term and the antecedent can be either a single term or a conjunction.

Prolog (cont...) In Prolog conjunction is specified as a comma. General form of a Prolog rule statement is: consequence :- antecedent Ex: ancestor(mary, shelley) :- mother(mary, shelley)

Prolog (cont...) In Prolog a theorem is in the form of proposition that we want the system to either prove or disprove. Such propositions are called goals or queries. The syntax of a Prolog goal statement is same as that of a fact statement. Ex: man(fred). father(X, mike).

Prolog : Inferencing Process Resolution is an inferencing process that allows inferred propositions to be computed from given propositions. Queries are called goals. When a goal is a compound proposition, each of the facts is called a sub goal. To prove that a goal is true, the inferencing process must find a chain of inference rules or facts in the database that connect the goal to one or more facts in the database.

Prolog : Inferencing Process (cont...) For example, if Q is a goal, then either Q must be a fact in the database or the inferencing process must find a fact P1 and a sequence of propositions P2, P3, ..., Pn such that: P2 :- P1 P3 :- P2 ... Q :- Pn

Prolog : Inferencing Process (cont...) There are two approaches for attempting to match a given goal to a fact in the database: Top-down resolution or backward chaining Bottom-up resolution or forward chaining If the system starts with the goal and attempts to find a sequence of matching propositions that lead to some set of original facts in the database is known as top-down resolution or backward chaining. If the system starts with the facts and rules of the database and attempts to find a sequence of matches that lead to a goal is known as bottom-up resolution or backward chaining.

Prolog : Inferencing Process (cont...) Example: Database: father(bob). man(X) :- father(X). Query: man(bob).

Prolog : Inferencing Process (cont...) Solution search is done in one of the two ways: Depth-first Breadth-first A depth-first search finds the complete sequence of propositions, a proof, for the first sub goal before working on others. A breadth-first search works on all sub goals of a given goal in parallel.

Prolog : Inferencing Process (cont...) Prolog implementations use backward chaining for resolution and depth-first as its search process.

Applications of Logic Programming Relational Database Management Systems RDBMS is similar logic programming. Tables can be represented using Prolog structures and relationships between tables can be described by Prolog rules and the retrieval process is inherent in resolution operation. The goal statements of Prolog provide the queries for the RDBMS. One advantage of using logic programming to implement an RDBMS is that only a single language is required. Another advantage of using logic programming to implement RDMS is that deductive capability is built in. Expert Systems Expert systems are computer systems designed to emulate human expertise in some particular domain. Prolog can be used to construct expert systems. Prolog’s facts, rules and inference mechanism can be used to implement expert systems.

Applications of Logic Programming (cont...) Missing from Prolog is the automatic ability of the system to query the user for additional information when it is needed. Natural Language Processing Natural language interfaces to computer systems can be easily implemented using logic programming languages. For describing language syntax, logic programming is equivalent to context-free grammar. Inferencing process (backward chaining) in logic programming is equivalent to parsing strategies. Some kinds of semantics of natural languages can be made clear by modeling the languages with logic programming.