Top Banner
Prolog Logic Programming Language Prepared by : Chin Joo Ee & Tan Geok Fah
20
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Prolog (present)

Prolog

Logic Programming Language

Prepared by : Chin Joo Ee & Tan Geok Fah

Page 2: Prolog (present)

PROLOG(PROGRAMMING IN LOGIC)

A computer programming language based on mathematical logic.

Used for writing programs that model human logic and decision making.

PROLOG has an elegant formulation.Prolog is a logical and declarative

programming language.

Page 3: Prolog (present)

HISTORY: The first of the huge family of logic

programming languages. Invented by Alain Colmerauer and

Phillipe Roussel at the University of Aix-Marseille in 1971.

Alain Colmerauer

Page 4: Prolog (present)

It was first implemented 1972 in ALGOL-W. Early implementations →included C-Prolog, ESLPDPRO, Frolic, LM-Prolog, Open Prolog, SB-Prolog, UPMAIL Tricia Prolog. In 1998, the most common Prologs in

use are Quintus Prolog, SICSTUS Prolog, LPA Prolog, SWI Prolog, AMZI Prolog, SNI Prolog.

Page 5: Prolog (present)

Prolog was designed originally for natural-language processing but has become one of the most widely used languages for artificial.

The first versions had no user-defined functions and no control structure other than the built-in depth-first search with backtracking.

Early collaboration between Marseille and Robert Kowalski at University of Edinburgh continued until about 1975.

Robert Kowalski

Page 6: Prolog (present)

SIGNIFICANT LANGUAGE FEATURES: A rich collection of data structures in the

language and human reasoning A powerful notation for encoding end-

user applications It has its logical and declarative aspects,

interpretive nature, compactness, and inherent modularity.

Page 7: Prolog (present)

In a logic language ✎consisting of Horn Clauses ✎enter into database by the programmer Unlike most common programming languages. In a declarative language ✎the programmer specifies a goal to be achieved ✎the Prolog system works out how to achieve it

Page 8: Prolog (present)

HORN CLAUSE To simplify the resolution process in

Prolog, statements must be expressed in a simplified form, called Horn clauses.

Each statement (clause) has (at most) one term on the left hand side of an implication symbol ( :- ).

Each statement has a conjunction of zero or more terms on the right hand side.

Page 9: Prolog (present)

BASIC CONSTRUCT STRUCTURE Facts Rules Queries A collection of facts and rules is called a

knowledge base (database) A collection of facts and queries which

describe some collection of relationship.

Page 10: Prolog (present)

Example facts: male(adam). female(anne). parent(adam,barney).

Example rules: 1. son(X,Y) :- parent(Y,X) , The first rule is read as follows: →For all X and Y, X is the son of Y if there exists X & Y (X,Y) →such that Y is the parent of X and X is male.

2. male(X), daughter(X,Y) :- parent(Y,X) , female(X) The second rule is read as follows: →For all X and Y, X is the daughter of Y if there exists X & Y →such that Y is the parent of X and X is female.

Page 11: Prolog (present)

To make things crystal clear, let’s first precise about the basic characters at disposal.

The upper-case letters are A, B, …, Z The lower-case letters are a, b, …, z The digits are 0, 1, 2, …, 9 In addition, the _ symbol, which is

called underscore, & some special characters, which include characters such as +, -,*, /, <, >, =,:, &, ~.

The blank space is also a character, but a rather unusual one, being invisible.

Page 12: Prolog (present)

HOW TO EXECUTE A PROLOG PROGRAM?

To run a Prolog program, the user must ask a question (goal) by stating a theorem

( asserting a predicate) which the prolog interpreter try to prove. If the predicate contains variables, the

interpreter prints the values of the variables used to make the predicate true.

The interpreter uses backward chaining to prove a goal. It begins with the thing it is try to prove, and work backwards looking for things that would imply it, until it gets the facts.

Page 13: Prolog (present)

IMPORTANCE OF PROLOG

Logical relationships are asserted, and Prolog is used to determine whether or not certain statements are true, and if true, what variable bindings make them true.

This leads to a very declarative style of programming.

It is a program that is efficient to use if one want to work out problems by representing objects symbolically according to a type of relationships.

It can used in software engineering.

Page 14: Prolog (present)

APPLICATIONS OF PROLOG:

intelligent data base retrieval natural language understanding expert systems specification language machine learning robot planning automated reasoning problem solving adventure game customer order entry business

application

Page 15: Prolog (present)

Intelligent Systems

Expert Systems

Natural Language Systems

programs which perform useful tasks by utilizing artificial intelligence techniques

intelligent systems which reproduce decision-making at the level of a human expert

which can analyses and respond to statements made in ordinary language as opposed to approved keywords or menu selections.

Page 16: Prolog (present)

MAIN ADVANTAGES:ease of representing knowledge

natural support of non-determinism

natural support of pattern-matching

natural support of meta-programming

Page 17: Prolog (present)

OTHER ADVANTAGES:meaning of programs is independent of how they are executed

simple connection between programs & computed answers & specifications

no need to distinguish programs from databases

Page 18: Prolog (present)

DISADVANTAGES: Initially, due to insufficient investment in

complimentary technologies, users were poorlyserved.

In the beginning, poor facilities for supporting arithmetic, types, etc. had a discouragingeffect on the programming community.

There is no adequate way of representing computational concepts found in built-inmechanisms of state variables (as is usually found in conventional languages).

Some programmers always have, & always will prefer the overtly operational nature of machine operated programs, since they prefer the active control over the 'moving parts'.

Page 19: Prolog (present)

THE PROLOG PROGRAMMING LANGUAGE

HELLO WORLD! EXAMPLE PROGRAM

DescriptionThis program demonstrates the text output function of the Sample programming language by displaying the message "Hello world!”Source Code// the main program (this is a comment)Hello:-

nl,write('Hello world!' ).

}

Page 20: Prolog (present)

THANK YOU …

Bye Bye ~