Presentation1

30

Transcript of Presentation1

Page 1: Presentation1
Page 2: Presentation1

Topic: Languages Of AI (lisp/prolog)Group Members:Shagufta Arif (027)Sania Alyas (020)Maryam Afza (006)

Page 3: Presentation1

What is LISP??

LISP stands for (LIST PROCESSING). It was invented by John McCarthy in 1958. As its name implies, LISP is a programming language that manipulates LISTS.

Page 4: Presentation1

LISP Discription:A list is either empty or non-empty.

[a, b, c, d]Empty: [] Non-empty: head=[a] tail=[b, c, d]

Page 5: Presentation1

Example:

We can implement a function to compute factorials using recursion:

(defun factorial (N) "Compute the factorial of N." (if (= N 1) 1 (* N (factorial (- N 1)))))

Page 6: Presentation1

Example:

Here are some simple example using the if operator:

CL-USER(): (if (> 3 4)"yes“ "no") ANS: "no“

Page 7: Presentation1

Applications of LISP:

Mathematics Artificial intelligence and natural

language processing. Expert Systems (diagnosis,

identification, design )

Page 8: Presentation1

Advantages of LISP:

Common Lisp is : a general-purpose programming language and

an AI language

Common Lisp programs are:

easy to test easy to maintain (depending on

programming style) intractive

Page 9: Presentation1

Cont… Provides clear syntax LISP expressions are case-insensitive.

runtime typing: the programmer need not bother about type declarations

several data types: numbers, strings, arrays, lists, char, symbols etc.

Page 10: Presentation1

Disadvantages of LISP

The major disadvantage is due to the lack of popularity and lack of widespread support and knowledge.

It is relatively hard to find Lisp programmers.

Page 11: Presentation1

What is PROLOG?

PROLOG is a declarative language where programs are expressed in terms of relations.

A program in PROLOG can use logical reasoning to answer questions that can be inferred from the knowledge base.

Page 12: Presentation1

Cont …

A Prolog language designed in Europe to support natural language processing.

It was created by Alain and Robert 1972 as an alternative to the Lisp programming languages.

Page 13: Presentation1

Conti…

There are three basic stratgies in Prolog: facts, rules, and queries.

A collection of facts and rules which describe some collection of relationships is called a knowledge base.

That is, Prolog programs simply are knowledge bases.

Page 14: Presentation1

Conti…

Prolog includes an inference engine, which is a process for reasoning logically about information. The inference engine includes a pattern matcher, which retrieves stored (known) information by matching answers to questions.One important feature of Prolog is find all possible solutions rather than only one.

Page 15: Presentation1
Page 16: Presentation1
Page 17: Presentation1
Page 18: Presentation1
Page 19: Presentation1
Page 20: Presentation1
Page 21: Presentation1

mortal(X) :- man(X) % Xismortal if X is a man. man(socrates). % Socrates is a man and then ask Prolog ?- mortal(socrates). % Is Socrates mortal?and it will immediately tell me yes

PROLOG Example

Page 22: Presentation1

Applications of PROLOG Expert systems Relational queries Parsing of context free language Natural language processing Natural support of pattern-matching

Page 23: Presentation1

Advantages of PROLOG

The language works well for tasks like proving mathematical theorems

It has built-in list handling, very useful for representing sequences, trees, and so on.

It is easy to read and write programs which build structures.

Page 24: Presentation1

Similarities:

One of the similarities that makes these languages unique is their ability to rewrite themselves as the program is running.

In Lisp, the program itself can be treated as data that the program can manipulate.

The both languages are object oriented programming languages.

Page 25: Presentation1

Differences: The main difference between the two

languages is the way problems are described. In Lisp, the programmer must describe how the

computer will solve the problem (chess game). In Prolog, the developer does not need to

describe how, but rules points the program toward the desired results. (medical symptoms).

Prolog is not a general-purpose theorem prover. LISP is a general purpose theorem

PROLOG has many functional languages other than LISP.

Page 26: Presentation1

LISP & PROLOG PROGRAMMING LANGUAGE

Page 27: Presentation1

Arithmetic Operations

Point of comparison

LISP PROLOG

ADD (+2 3) 2+3

SUBTRACT (-5 2) (5-2)

MULTIPLICATION (* 3 2) (2*3)

DIVISION (/ 6 2) (6/2)

BRACES (+3 (* 3 2 ) 4) (3+ (3 *2)

Page 28: Presentation1

Logical operations

Point of comparison

LISP PROLOG

SMALLER (< 3 4 )True

3 < 4yes

GREATER (> 3 4 )NIL

3 > 4No

Smaller than or equal

(< = 3 2)Nil

3 = < 2No

Greater than or equal

( > = 3 2)true

3 > = 2Yes

Equal ( = 3 4)Nil

3 =:= 4no

Not Equal (\ = 3 4 )True

( 3 == 4)Yes

Page 29: Presentation1

PROLOG Example

age(john,32). age(agnes,41). age(george,72). age(hiba,2). age(thomas,25). QUERIES age(hiba,2). agnes(41).

Page 30: Presentation1

Thanks