Languages Of AI (lisp/prolog)
Shagufta Arif (027)
Sania Alyas (020)
Maryam Afza (006)
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
A list is either empty or non-empty.
[a, b, c, d]
Non-empty: head=[a] tail=[b, c, d]
We can implement a function to compute
factorials using recursion:
(defun factorial (N)
"Compute the factorial of N."
(if (= N 1)
(* N (factorial (- N 1)))))
Here are some simple example using the if
CL-USER(): (if (> 3 4)"yes“ "no")
Applications of LISP:
Artificial intelligence and natural language
Expert Systems (diagnosis, identification,
Advantages of LISP:
Common Lisp is :
a general-purpose programming language and an AI
Common Lisp programs are:
easy to test
easy to maintain (depending on programming
Provides clear syntax
LISP expressions are case-insensitive.
the programmer need not bother about type
several data types:
numbers, strings, arrays, lists, char, symbols etc.
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
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
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.
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
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
One important feature of Prolog is find all
possible solutions rather than only one.
mortal(X) :- man(X)
if X is a man.
% Socrates is a man
and then ask Prolog
?- mortal(socrates). % Is Socrates
and it will immediately tell me yes
Applications of PROLOG
Parsing of context free language
Natural language processing
Natural support of
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
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
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