Prolog & lisp

7,817
-1

Published on

Published in: Technology
0 Comments
7 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
7,817
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
301
Comments
0
Likes
7
Embeds 0
No embeds

No notes for slide

Prolog & lisp

  1. 1. LISP and PROLOG AIProgramming Language Submitted To: Dr. Hesham El-Zoka Submitted By: Eng. Ismail Fathalla El-Gayar
  2. 2. AI Programming Languages
  3. 3. Language Year Features IPL Information support programs that could perform general problem Processing solving, including lists, associations, schemas Language (frames), dynamic memory allocation, data types, recursion,, functions as arguments, and cooperative multitasking LISP LISt Processing practical mathematical notation for computer programs based on lambda calculus. Linked lists are one of Lisp languages major data structuresPLANNER MIT 1969 is a hybrid between procedural and logical languages. It gives a procedural interpretation to logical sentences where implications are interpreted with pattern-directed inference.PROLOG programmatio declarative language where programs are expressed in terms n en logique of relations, and execution occurs by running queries over 1970s these relations. Prolog is particularly useful for symbolic reasoning, database and language parsing applications. STRIPS Stanford Research language for expressing automated planning problem Institute Problem instances Solver1971
  4. 4. System UsabilityP R O L O G has manydenotation, functional languages other than Lisp
  5. 5. Why Prolog here? System Usability• It is a particularly interesting language - the “feeling” is completely different from Java,C,... - forces to see programming in a different way - programming as writing a “logic theory”• Recently, renewed interest in Prolog in order torapidly prototype: – complex algorithms, reasoning-like computations, dynamic structures, XML-like features – governing interaction inside system infrastructures
  6. 6. 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
  7. 7. System UsabilityComparing Java / Prolog• Java (C,C++) forces a procedural and deterministic viewover 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
  8. 8. System Usability LISP & PROLOGProgramming Language
  9. 9. ATOM & LIST• Atom: One Component Out Of List ex: x , y , k• LIST: Brackets Containing Atom ex: ( 2 3 x )
  10. 10. Arithmetic Operations Point OfComparison 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) + 4 )
  11. 11. Logic Operations Point Of Comparison LISP PROLOG Smaller (< 3 4) 3<4 True Yes Greater (> 2 5) 2>5 Nil noSmaller than or (<= 3 2) 3 =<2 equal Nil noGreater than or (>= 6 2) 6=>2 equal True Yes Equal (= 3 4) 3 =:= 4 Nil no Not Equal (= 3 4) 3==4 True yes
  12. 12. Functions Point OfComparison LISP PROLOG Max ( max 1 2 4 6 53 0 ) max([1,2,4,6,53,0],X). 53 X=53 Min ( min 1 2 4 6 53 0 ) min([1,2,46,53,0],X). 0 X=0 Sum plus(A, B, C) sum(X,Y,Z) C is A + B. the both languages are Object Oriented Programming Languages
  13. 13. List Processing 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)
  14. 14. List Processing Language• Lambda(to assign A variable) (lambda (arg) (+ arg 1)) =>arg=arg+1 ((lambda (arg) (+ arg 1)) 5) =>arg =6
  15. 15. Lists In PROLOG• Example : [mia, vincent, jules, yolanda]• Dealing With List:[Head| Tail] = [mia, vincent, jules, yolanda] means:- Head = mia Tail = [vincent,jules,yolanda] yes
  16. 16. Example: ConcatenationIn an imperative language 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 a functional language cat(a,b) if b = nil then a else cons(head(a), cat(tail(a),b)) In a declarative language cat([], Z, Z). cat([H|T], L, [H|Z]) :- cat(T, L, Z).
  17. 17. Example in PROLOG ( Fact&Rule) Predicate Procedure for elephant Facts elephant(george).Clauses elephant(mary). elephant(X) :- grey(X), mammal(X), hasTrunk(X). Rule
  18. 18. Example in PROLOG ( Fact&Rule) ?- elephant(george).Queries yes ?- elephant(jane).Replies no
  19. 19. 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 logicalproof search
  20. 20. Applications of Prolog:-•Expert systems•Relational database queries•Parsing of context-free languages•Natural language processing•Teaching programming , as early as in grade school
  21. 21. LISP Compiler PROLOG Compiler•BEE •B-Prolog•POPLOG •GNU Prolog•LISP WORKS •C# PROLOG•GNU C LISP •Open Prolog •Strawberry Prolog
  22. 22. References•Paul Brna ,Prolog Programming A First Course.•Fernando C. N. Pereira , Stuart M. Shieber ,Prolog and NaturalLanguage Analysis.• Ulf Nilsson , Jan Maluszynski ,Logic Programming and Prolog 2ndedition.• 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)
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×