SlideShare a Scribd company logo
1 of 24
LISP and PROLOG AI
Programming Language
          Submitted To:
       Dr. Hesham El-Zoka

          Submitted By:
   Eng. Ismail Fathalla El-Gayar
AI Programming
   Languages
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 structures
PLANNER       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
System Usability

P R O L O G has many
denotation, functional
      languages
    other than Lisp
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 to
rapidly prototype:
        – complex algorithms, reasoning-like
        computations, dynamic structures, XML-like
               features
        – governing interaction inside system
               infrastructures
System Usability
Why Prolog here?
Conceptual reasons:
• new programming idiom
      – programming is NOT writing in Java language
• Prolog as an “engine” to study models and language
Practical 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
System Usability
Comparing 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
System Usability


   LISP & PROLOG
Programming Language
ATOM & LIST
• Atom: One Component Out Of List
     ex: x , y , k
• LIST: Brackets Containing Atom
     ex: ( 2 3 x )
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) + 4 )
Logic Operations
   Point Of
 Comparison       LISP       PROLOG
    Smaller       (< 3 4)      3<4
                   True        Yes

    Greater       (> 2 5)      2>5
                    Nil        no
Smaller than or   (<= 3 2)    3 =<2
    equal           Nil        no

Greater than or   (>= 6 2)     6=>2
    equal           True        Yes

     Equal        (= 3 4)     3 =:= 4
                    Nil         no

   Not Equal      (= 3 4)    3==4
                    True       yes
Functions


  Point Of
Comparison         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
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)
List Processing Language
• Lambda(to assign A variable)
  (lambda (arg) (+ arg 1)) =>arg=arg+1
  ((lambda (arg) (+ arg 1)) 5) =>arg =6
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
Example: Concatenation

In 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).
Example in PROLOG ( Fact&Rule)


                   Predicate


          Procedure for
            elephant
                                          Facts


               elephant(george).
Clauses        elephant(mary).
               elephant(X) :- grey(X), mammal(X), hasTrunk(X).
  Rule
Example in PROLOG ( Fact&Rule)



                 ?- elephant(george).
Queries
                         yes

                  ?- elephant(jane).
Replies
                         no
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
Applications of Prolog:-

•Expert systems

•Relational database queries

•Parsing of context-free languages

•Natural language processing

•Teaching programming
        , as early as in grade school
LISP Compiler   PROLOG Compiler
•BEE            •B-Prolog
•POPLOG         •GNU Prolog
•LISP WORKS     •C# PROLOG
•GNU C LISP     •Open Prolog
                •Strawberry Prolog
References
•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)
Prolog & lisp

More Related Content

What's hot

What's hot (20)

Sets in python
Sets in pythonSets in python
Sets in python
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
 
Intermediate code generation in Compiler Design
Intermediate code generation in Compiler DesignIntermediate code generation in Compiler Design
Intermediate code generation in Compiler Design
 
ProLog (Artificial Intelligence) Introduction
ProLog (Artificial Intelligence) IntroductionProLog (Artificial Intelligence) Introduction
ProLog (Artificial Intelligence) Introduction
 
Algorithm analysis and efficiency
Algorithm analysis and efficiencyAlgorithm analysis and efficiency
Algorithm analysis and efficiency
 
Lecture 21 problem reduction search ao star search
Lecture 21 problem reduction search ao star searchLecture 21 problem reduction search ao star search
Lecture 21 problem reduction search ao star search
 
Namespaces
NamespacesNamespaces
Namespaces
 
Mc culloch pitts neuron
Mc culloch pitts neuronMc culloch pitts neuron
Mc culloch pitts neuron
 
Informed and Uninformed search Strategies
Informed and Uninformed search StrategiesInformed and Uninformed search Strategies
Informed and Uninformed search Strategies
 
Python introduction
Python introductionPython introduction
Python introduction
 
Knowledge representation In Artificial Intelligence
Knowledge representation In Artificial IntelligenceKnowledge representation In Artificial Intelligence
Knowledge representation In Artificial Intelligence
 
Python-Polymorphism.pptx
Python-Polymorphism.pptxPython-Polymorphism.pptx
Python-Polymorphism.pptx
 
Learn C# Programming - Encapsulation & Methods
Learn C# Programming - Encapsulation & MethodsLearn C# Programming - Encapsulation & Methods
Learn C# Programming - Encapsulation & Methods
 
Little o and little omega
Little o and little omegaLittle o and little omega
Little o and little omega
 
EULER AND FERMAT THEOREM
EULER AND FERMAT THEOREMEULER AND FERMAT THEOREM
EULER AND FERMAT THEOREM
 
Polymorphism in c++(ppt)
Polymorphism in c++(ppt)Polymorphism in c++(ppt)
Polymorphism in c++(ppt)
 
Python: Polymorphism
Python: PolymorphismPython: Polymorphism
Python: Polymorphism
 
Python set
Python setPython set
Python set
 
Algorithmic problem solving
Algorithmic problem solvingAlgorithmic problem solving
Algorithmic problem solving
 
Introduction to Object Oriented Programming
Introduction to Object Oriented ProgrammingIntroduction to Object Oriented Programming
Introduction to Object Oriented Programming
 

Viewers also liked

Expert Systems
Expert SystemsExpert Systems
Expert Systems
osmancikk
 

Viewers also liked (20)

Introduction to Prolog
Introduction to PrologIntroduction to Prolog
Introduction to Prolog
 
LISP: Introduction to lisp
LISP: Introduction to lispLISP: Introduction to lisp
LISP: Introduction to lisp
 
Prolog basics
Prolog basicsProlog basics
Prolog basics
 
Prolog Programming : Basics
Prolog Programming : BasicsProlog Programming : Basics
Prolog Programming : Basics
 
Artificial intelligence Prolog Language
Artificial intelligence Prolog LanguageArtificial intelligence Prolog Language
Artificial intelligence Prolog Language
 
Lisp
LispLisp
Lisp
 
Introduction To Lisp
Introduction To LispIntroduction To Lisp
Introduction To Lisp
 
Learn a language : LISP
Learn a language : LISPLearn a language : LISP
Learn a language : LISP
 
A brief introduction to lisp language
A brief introduction to lisp languageA brief introduction to lisp language
A brief introduction to lisp language
 
PROLOG: Introduction To Prolog
PROLOG: Introduction To PrologPROLOG: Introduction To Prolog
PROLOG: Introduction To Prolog
 
Artificial Intelligence
Artificial IntelligenceArtificial Intelligence
Artificial Intelligence
 
Introduction on Prolog - Programming in Logic
Introduction on Prolog - Programming in LogicIntroduction on Prolog - Programming in Logic
Introduction on Prolog - Programming in Logic
 
LISP Programming Language (Artificial Intelligence)
LISP Programming Language (Artificial Intelligence)LISP Programming Language (Artificial Intelligence)
LISP Programming Language (Artificial Intelligence)
 
Lisp Programming Languge
Lisp Programming LangugeLisp Programming Languge
Lisp Programming Languge
 
Redesigning Common Lisp
Redesigning Common LispRedesigning Common Lisp
Redesigning Common Lisp
 
Game Playing in Artificial Intelligence
Game Playing in Artificial IntelligenceGame Playing in Artificial Intelligence
Game Playing in Artificial Intelligence
 
Expert Systems & Prolog
Expert Systems & PrologExpert Systems & Prolog
Expert Systems & Prolog
 
Expert Systems
Expert SystemsExpert Systems
Expert Systems
 
Artificial Intelligence
Artificial IntelligenceArtificial Intelligence
Artificial Intelligence
 
Artificial Intelligence
Artificial IntelligenceArtificial Intelligence
Artificial Intelligence
 

Similar to Prolog & lisp

Programming Languages - Functional Programming Paper
Programming Languages - Functional Programming PaperProgramming Languages - Functional Programming Paper
Programming Languages - Functional Programming Paper
Shreya Chakrabarti
 
Presentation of GetTogether on Functional Programming
Presentation of GetTogether on Functional ProgrammingPresentation of GetTogether on Functional Programming
Presentation of GetTogether on Functional Programming
Filip De Sutter
 
Logic Programming and ILP
Logic Programming and ILPLogic Programming and ILP
Logic Programming and ILP
Pierre de Lacaze
 
Introduction to r bddsil meetup
Introduction to r bddsil meetupIntroduction to r bddsil meetup
Introduction to r bddsil meetup
Nimrod Priell
 

Similar to Prolog & lisp (20)

Presentation1
Presentation1Presentation1
Presentation1
 
Programming Languages - Functional Programming Paper
Programming Languages - Functional Programming PaperProgramming Languages - Functional Programming Paper
Programming Languages - Functional Programming Paper
 
CPPDS Slide.pdf
CPPDS Slide.pdfCPPDS Slide.pdf
CPPDS Slide.pdf
 
LISP: Introduction To Lisp
LISP: Introduction To LispLISP: Introduction To Lisp
LISP: Introduction To Lisp
 
Intellectual technologies
Intellectual technologiesIntellectual technologies
Intellectual technologies
 
Special topics in finance lecture 2
Special topics in finance   lecture 2Special topics in finance   lecture 2
Special topics in finance lecture 2
 
Prolog 7-Languages
Prolog 7-LanguagesProlog 7-Languages
Prolog 7-Languages
 
Using Language Oriented Programming to Execute Computations on the GPU
Using Language Oriented Programming to Execute Computations on the GPUUsing Language Oriented Programming to Execute Computations on the GPU
Using Language Oriented Programming to Execute Computations on the GPU
 
Introduction to Functional Languages
Introduction to Functional LanguagesIntroduction to Functional Languages
Introduction to Functional Languages
 
Learning and Modern Programming Languages
Learning and Modern Programming LanguagesLearning and Modern Programming Languages
Learning and Modern Programming Languages
 
python programming for beginners and advanced
python programming for beginners and advancedpython programming for beginners and advanced
python programming for beginners and advanced
 
Prolog Programming Language
Prolog Programming  LanguageProlog Programming  Language
Prolog Programming Language
 
PARADIGM IT.pptx
PARADIGM IT.pptxPARADIGM IT.pptx
PARADIGM IT.pptx
 
Presentation of GetTogether on Functional Programming
Presentation of GetTogether on Functional ProgrammingPresentation of GetTogether on Functional Programming
Presentation of GetTogether on Functional Programming
 
Logic Programming and ILP
Logic Programming and ILPLogic Programming and ILP
Logic Programming and ILP
 
Introduction to r bddsil meetup
Introduction to r bddsil meetupIntroduction to r bddsil meetup
Introduction to r bddsil meetup
 
Go Beyond Higher Order Functions: A Journey into Functional Programming
Go Beyond Higher Order Functions: A Journey into Functional ProgrammingGo Beyond Higher Order Functions: A Journey into Functional Programming
Go Beyond Higher Order Functions: A Journey into Functional Programming
 
R language
R languageR language
R language
 
3.5
3.53.5
3.5
 
app4.pptx
app4.pptxapp4.pptx
app4.pptx
 

More from Ismail El Gayar (7)

Neural Networks
Neural NetworksNeural Networks
Neural Networks
 
Why computer engineering
Why computer engineeringWhy computer engineering
Why computer engineering
 
What is ETL?
What is ETL?What is ETL?
What is ETL?
 
Geographic Information System for Egyptian Railway System(GIS)
Geographic Information System for Egyptian Railway System(GIS)Geographic Information System for Egyptian Railway System(GIS)
Geographic Information System for Egyptian Railway System(GIS)
 
System science documentation
System science documentationSystem science documentation
System science documentation
 
Parallel architecture &programming
Parallel architecture &programmingParallel architecture &programming
Parallel architecture &programming
 
Object oriented methodology & unified modeling language
Object oriented methodology & unified modeling languageObject oriented methodology & unified modeling language
Object oriented methodology & unified modeling language
 

Recently uploaded

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Recently uploaded (20)

Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 

Prolog & lisp

  • 1. LISP and PROLOG AI Programming Language Submitted To: Dr. Hesham El-Zoka Submitted By: Eng. Ismail Fathalla El-Gayar
  • 2. AI Programming Languages
  • 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 structures PLANNER 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.
  • 5. System Usability P R O L O G has many denotation, functional languages other than Lisp
  • 6. 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 to rapidly prototype: – complex algorithms, reasoning-like computations, dynamic structures, XML-like features – governing interaction inside system infrastructures
  • 7. System Usability Why Prolog here? Conceptual reasons: • new programming idiom – programming is NOT writing in Java language • Prolog as an “engine” to study models and language Practical 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
  • 8. System Usability Comparing 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
  • 9. System Usability LISP & PROLOG Programming Language
  • 10. ATOM & LIST • Atom: One Component Out Of List ex: x , y , k • LIST: Brackets Containing Atom ex: ( 2 3 x )
  • 11. 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) + 4 )
  • 12. Logic Operations Point Of Comparison LISP PROLOG Smaller (< 3 4) 3<4 True Yes Greater (> 2 5) 2>5 Nil no Smaller than or (<= 3 2) 3 =<2 equal Nil no Greater than or (>= 6 2) 6=>2 equal True Yes Equal (= 3 4) 3 =:= 4 Nil no Not Equal (= 3 4) 3==4 True yes
  • 13. Functions Point Of Comparison 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
  • 14. 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)
  • 15. List Processing Language • Lambda(to assign A variable) (lambda (arg) (+ arg 1)) =>arg=arg+1 ((lambda (arg) (+ arg 1)) 5) =>arg =6
  • 16. 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
  • 17. Example: Concatenation In 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).
  • 18. Example in PROLOG ( Fact&Rule) Predicate Procedure for elephant Facts elephant(george). Clauses elephant(mary). elephant(X) :- grey(X), mammal(X), hasTrunk(X). Rule
  • 19. Example in PROLOG ( Fact&Rule) ?- elephant(george). Queries yes ?- elephant(jane). Replies no
  • 20. 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
  • 21. Applications of Prolog:- •Expert systems •Relational database queries •Parsing of context-free languages •Natural language processing •Teaching programming , as early as in grade school
  • 22. LISP Compiler PROLOG Compiler •BEE •B-Prolog •POPLOG •GNU Prolog •LISP WORKS •C# PROLOG •GNU C LISP •Open Prolog •Strawberry Prolog
  • 23. References •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)