lisp and prolog ai programming language

24
LISP and PROLOG AI Programming Language Submitted To : Dr. Hesham El-Zoka Submitted By: Eng. Ismail Fathalla El-Gayar

Upload: glenda

Post on 23-Feb-2016

131 views

Category:

Documents


10 download

DESCRIPTION

LISP and PROLOG AI Programming Language. Submitted To: Dr . Hesham El- Zoka. Submitted By: Eng. Ismail Fathalla El- Gayar. AI Programming Languages. AI Programming Languages. AI applications are also often written in standard languages like C++ and MATLAB. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: LISP and PROLOG AI Programming Language

LISP and PROLOG AI Programming Language

Submitted To:Dr. Hesham El-Zoka

Submitted By:Eng. Ismail Fathalla El-Gayar

Page 2: LISP and PROLOG AI Programming Language

AI Programming Languages

Page 3: LISP and PROLOG AI Programming Language

Features Year Language support programs that could perform general problem solving, including lists, associations, schemas (frames),

dynamic memory allocation, data types, recursion,, functions as arguments, and cooperative multitasking

Information Processing Language

1956.

IPL

practical mathematical notation for computer programs based on lambda calculus. Linked lists are one of Lisp

languages' major data structures

LISt Processing1958,

LISP

is a hybrid between procedural and logical languages. It gives a procedural interpretation to logical sentences where

implications are interpreted with pattern-directed inference.

MIT 1969 PLANNER

declarative language where programs are expressed in terms of relations, and execution occurs by running queries over these relations. Prolog is particularly useful for symbolic reasoning, database and language parsing applications.

programmation en logique

1970s

PROLOG

language for expressing automated planning problem instances

Stanford Research Institute Problem

Solver1971

STRIPS

AI Programming Languages

Page 4: LISP and PROLOG AI Programming Language

So Why We Learn

Logic Programming

Languages???

AI applications are also often written in standard languages

like C++ and MATLAB.

Page 5: LISP and PROLOG AI Programming Language

System Usability

P R O L O G has many denotation, functional

languagesother than Lisp

Page 6: LISP and PROLOG AI Programming Language

System UsabilityWhy Prolog here?• It is a particularly interesting language

- the “feeling” is completely different fromJava,C,...

- forces to see programming in a different way- programming as writing a “logic theory”

• Recently, renewed interest in Prolog in order to rapidly prototype:

– complex algorithms, reasoning-like computations, dynamic structures, XML-like

features– governing interaction inside system

infrastructures

Page 7: LISP and PROLOG AI Programming Language

System UsabilityWhy Prolog here?Conceptual reasons:• new programming idiom

– programming is NOT writing in Java language• Prolog as an “engine” to study models and languagePractical reasons:• integration between Prolog and Java

– Java as the part handling more “in-the-large” aspects network, graphics, connection with the O.S. and libraries

– Prolog as the engine to handle (complex) algorithms optimization algorithms, reasoning, core logic, data structures

Page 8: LISP and PROLOG AI Programming Language

System UsabilityComparing Java / Prolog• Java (C,C++) forces a procedural and deterministic view over computation• Prolog allows for a more declarative way of programming

– expressing the problem, not the solution!– it works very well when finding solutions is

“exploring a tree”.• Other applications

– dealing with knowledge representation and knowledge inference, typical use in AI

Page 9: LISP and PROLOG AI Programming Language

System Usability

LISP & PROLOG Programming Language

Page 10: LISP and PROLOG AI Programming Language

• Atom: One Component Out Of Listex: x , y , k

• LIST: Brackets Containing Atom ex: ( 2 3 x )

ATOM & LIST

Page 11: LISP and PROLOG AI Programming Language

PROLOG LISP Point Of Comparison

2+3 +(2 3) Add

(5-2) -(5 2) Subtract

(2*3) *(3 2) Multiplication

(6/2) /(6 2) Division

(3( + 3 * 2 + )4) +(3 *( 3 2 )4) braces

Arithmetic Operations

Page 12: LISP and PROLOG AI Programming Language

PROLOG LISP Point Of Comparison

3<4Yes

<(3 4)True

Smaller

2>5no

>(2 5)Nil

Greater

3 =<2no

=<(3 2)Nil

Smaller than or equal

6=>2Yes

=>(6 2)True

Greater than or equal

3 =:= 4no

(= 3 4)Nil

Equal

3 =\= 4yes

=\(3 4)True

Not Equal

Logic Operations

Page 13: LISP and PROLOG AI Programming Language

PROLOG LISP Point Of Comparison

max([1,2,4,6,53,0],X).X=53

( max 1 2 4 6 53 0 )53

Max

min([1,2,46,53,0],X).X = 0

( min 1 2 4 6 53 0 )0

Min

sum(X,Y,Z) plus(A, B, C) C is A + B .

Sum

Functions

the both languages are Object Oriented Programming

Languages

Page 14: LISP and PROLOG AI Programming Language

• Since We Said that Lisp Is A List Processing Language we will talk about how we deals with List:--(list '1 '2 'foo) ( 1 2 Foo )- list 1 2 (list 3 4)) => ( 1 2 (3 4))- ( + 1 2 3 4) 10- (if nil (list 1 2 "foo") (list 3 4"bar")) if (var)=nill Do (1 2 Foo)

else (3 4 bar)

List Processing Language

Page 15: LISP and PROLOG AI Programming Language

• Lambda(to assign A variable)(lambda (arg) (+ arg 1)) =>arg=arg+1

((lambda (arg) (+ arg 1)) 5) =>arg =6

List Processing Language

Page 16: LISP and PROLOG AI Programming Language

• Example :[mia, vincent, jules, yolanda]

• Dealing With List:[Head| Tail] = [mia, vincent, jules, yolanda]

means:-Head = miaTail = [vincent,jules,yolanda]yes

Lists In PROLOG

Page 17: LISP and PROLOG AI Programming Language

Example: Concatenation

list procedure cat(list a, list b){

list t = list u = copylist(a); while (t.tail != nil) t = t.tail;

t.tail = b; return u;

}

In an imperative language

In a declarative language

In a functional language cat(a,b) if b = nil then a

else cons(head(a), cat(tail(a),b))

cat([], Z, Z).cat([H|T], L, [H|Z]) :- cat(T, L, Z).

Page 18: LISP and PROLOG AI Programming Language

Example in PROLOG ( Fact&Rule)

elephant(george).elephant(mary).elephant(X) :- grey(X), mammal(X), hasTrunk(X).

Procedure for elephant

Predicate

Clauses

Rule

Facts

Page 19: LISP and PROLOG AI Programming Language

Example in PROLOG ( Fact&Rule)

?- elephant(george).

yes

?- elephant(jane).

no

Queries

Replies

Page 20: LISP and PROLOG AI Programming Language

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

• Integer calculation, I/O don’t fit well into logical proof search

Page 21: LISP and PROLOG AI Programming Language

Applications of Prolog:-

•Expert systems

•Relational database queries

•Parsing of context-free languages

•Natural language processing

•Teaching programming , as early as in grade school

Page 22: LISP and PROLOG AI Programming Language

LISP Compiler•BEE•POPLOG•LISP WORKS•GNU C LISP

PROLOG Compiler•B-Prolog•GNU Prolog•C# PROLOG•Open Prolog•Strawberry Prolog

Page 23: LISP and PROLOG AI Programming Language

• Paul Brna ,Prolog Programming A First Course.

• Fernando C. N. Pereira , Stuart M. Shieber ,Prolog and Natural Language Analysis.

• Ulf Nilsson , Jan Maluszynski ,Logic Programming and Prolog 2nd edition.

• Amzi ,Adventure in Prolog.

• - Patrick Blackburn, Johan Bos , Kristina Striegnitz , Learn Prolog Now!

• http://en.wikibooks.org/wiki/Prolog/Math,_Functions_and_Equality

• http://en.wikipedia.org/wiki/Prolog

• http://en.wikipedia.org/wiki/Lisp_(programming_language)

References

Page 24: LISP and PROLOG AI Programming Language