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

Knowledge Representation & Reasoning
Knowledge Representation & ReasoningKnowledge Representation & Reasoning
Knowledge Representation & Reasoning
Sajid Marwat
 
Logic programming (1)
Logic programming (1)Logic programming (1)
Logic programming (1)
Nitesh Singh
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
Nikhil Sharma
 

What's hot (20)

Artificial Intelligence Searching Techniques
Artificial Intelligence Searching TechniquesArtificial Intelligence Searching Techniques
Artificial Intelligence Searching Techniques
 
Prolog
PrologProlog
Prolog
 
Planning
PlanningPlanning
Planning
 
Language models
Language modelsLanguage models
Language models
 
Knowledge Representation & Reasoning
Knowledge Representation & ReasoningKnowledge Representation & Reasoning
Knowledge Representation & Reasoning
 
PROLOG: Introduction To Prolog
PROLOG: Introduction To PrologPROLOG: Introduction To Prolog
PROLOG: Introduction To Prolog
 
Heuristic Search Techniques {Artificial Intelligence}
Heuristic Search Techniques {Artificial Intelligence}Heuristic Search Techniques {Artificial Intelligence}
Heuristic Search Techniques {Artificial Intelligence}
 
Advanced data structures & algorithms important questions
Advanced data structures & algorithms important questionsAdvanced data structures & algorithms important questions
Advanced data structures & algorithms important questions
 
peas description of task environment with different types of properties
 peas description of task environment with different types of properties peas description of task environment with different types of properties
peas description of task environment with different types of properties
 
Logic programming (1)
Logic programming (1)Logic programming (1)
Logic programming (1)
 
Semantic Networks
Semantic NetworksSemantic Networks
Semantic Networks
 
Machine Learning in 5 Minutes— Classification
Machine Learning in 5 Minutes— ClassificationMachine Learning in 5 Minutes— Classification
Machine Learning in 5 Minutes— Classification
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
 
Artificial intelligence Prolog Language
Artificial intelligence Prolog LanguageArtificial intelligence Prolog Language
Artificial intelligence Prolog Language
 
Lecture: Context-Free Grammars
Lecture: Context-Free GrammarsLecture: Context-Free Grammars
Lecture: Context-Free Grammars
 
LR Parsing
LR ParsingLR Parsing
LR Parsing
 
AI Lecture 3 (solving problems by searching)
AI Lecture 3 (solving problems by searching)AI Lecture 3 (solving problems by searching)
AI Lecture 3 (solving problems by searching)
 
Lisp
LispLisp
Lisp
 
Specification-of-tokens
Specification-of-tokensSpecification-of-tokens
Specification-of-tokens
 
First order logic
First order logicFirst order logic
First order logic
 

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
 
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
 
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
 
AI & gaming: letters from the land of lisp.
AI & gaming: letters from the land of lisp. AI & gaming: letters from the land of lisp.
AI & gaming: letters from the land of lisp.
 
AI in gaming
AI in gaming AI in gaming
AI in gaming
 
Introduction toprolog
Introduction toprologIntroduction toprolog
Introduction toprolog
 
Gentle Introduction To Lisp
Gentle Introduction To LispGentle Introduction To Lisp
Gentle Introduction To Lisp
 
Lisp
LispLisp
Lisp
 
LISP Update
LISP UpdateLISP Update
LISP Update
 

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
 
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
 
Python 培训讲义
Python 培训讲义Python 培训讲义
Python 培训讲义
 

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

Structuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessStructuring Teams and Portfolios for Success
Structuring Teams and Portfolios for Success
UXDXConf
 

Recently uploaded (20)

What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024
 
Structuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessStructuring Teams and Portfolios for Success
Structuring Teams and Portfolios for Success
 
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomSalesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdf
 
Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024
 
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
 
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
 
Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024
 
AI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekAI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří Karpíšek
 
Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John Staveley
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
 
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
 
Top 10 Symfony Development Companies 2024
Top 10 Symfony Development Companies 2024Top 10 Symfony Development Companies 2024
Top 10 Symfony Development Companies 2024
 
WebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceWebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM Performance
 
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
 
AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101
 
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
 
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdfLinux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
 
Syngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdfSyngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdf
 
ECS 2024 Teams Premium - Pretty Secure
ECS 2024   Teams Premium - Pretty SecureECS 2024   Teams Premium - Pretty Secure
ECS 2024 Teams Premium - Pretty Secure
 

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)