0% found this document useful (0 votes)
436 views5 pages

Questions On Prolog Language

Prolog is a logic programming language used primarily for artificial intelligence applications. It was one of the first AI languages developed in the 1970s. Prolog uses logic rules and relational databases to solve problems through logical inferences rather than through procedural code. Some common uses of Prolog include expert systems, natural language processing, databases, robotics, and more. It represents problems through relationships between objects, properties, and rules.

Uploaded by

Om K
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
436 views5 pages

Questions On Prolog Language

Prolog is a logic programming language used primarily for artificial intelligence applications. It was one of the first AI languages developed in the 1970s. Prolog uses logic rules and relational databases to solve problems through logical inferences rather than through procedural code. Some common uses of Prolog include expert systems, natural language processing, databases, robotics, and more. It represents problems through relationships between objects, properties, and rules.

Uploaded by

Om K
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

QUESTIONS ON PROLOG

LANGUAGE
 
Q1. WHAT IS PROLOG PROGRAMMING LANGUAGE?

ANS. Prolog (programming logic) rose within the realm of


Artificial Intelligence. It was one of the first logic programming
languages. It became popular with AI researchers, who know
more about “what” and “how” intelligent behaviour is achieved.
The idea behind it deals with the logical and declarative aspects.
This language represents a fundamentally new approach to
computing and became a serious competitor to LISP.  Following
are the developers of PROLOG:

Alain Colmerauer Robert Kowalski


Q2. WHAT ARE THE FEATURES OF PROLOG LANGUAGE?

ANS. FOLLOWING ARE THE FEATURES OF PROLOG LANGUAGE:


 Intelligent Systems – programs which perform useful tasks
by utilizing artificial intelligence techniques.
 Expert Systems – intelligent systems which reproduce
decision-making at the level of a human expert.
 Natural Language Systems – which can analysis and respond
to statements made in ordinary language as opposed to
approved keywords or menu selections.
 Relational Database Systems.
Q3. NAME THE AREAS IN WHICH PROLOG PROGRAMMING
LANGUAGE IS USED?

ANS. Following are some areas in which prolog is used:


 intelligent data base retrieval
 natural language understanding
 expert systems
 specification language
 machine learning
 robot planning
 automated reasoning
 problem solving
Q4. WHY WE USE PROLOG PROGRAMMING LANGUAGE?

ANS. FOLLOWING ARE SOME POINTS FOR USING PROLOG MORE:


  SWI-Prolog is free, open-source, and very well maintained.
 It’s much much easier to distribute SWI-Prolog applications
than Java ones
  Prolog is much less verbose,which is helpful when during
development.
 Prolog allows one to define any word or collection of “symbol
characters” (e.g. >>, +, /, , //, :===/===: ) as an infix,
postfix, or prefix operator.
 In Prolog, you can treat data as programs.
 Prolog is interactive.
Q5. WRITE AN SAMPLE PROGRAM IN PROLOG LANGUAGE?

ANS. Here is an example. of  Sample programming language by


displaying the message “Hello”:

SOURCE CODE

// the main program (this is a comment)

Hello:-

nl,

write(‘Hello !’ ).
}

Q6. NAME SOME DATA TYPES IN PROLOG PROGRAMMING


LANGUAGE?
ANS. FOLLOWING ARE THE DATA TYPES SUPPORTED BY
PROLOG :Prolog’s single data type is the term. Terms are
either atoms, numbers, variables or compound terms.
 ATOM :    An atom is a general-purpose name with no inherent
meaning.
 NUMBERS :    Numbers are like integers,float etc.
 VARIABLES :   Are denoted  string consisting of letters,
numbers, underscore characters, and beginning with an upper-
case letter or underscore.
 COMPOUND TERMS :    A compound term is composed of an
atom called a “functor” and a number of “arguments”, which
are again terms. They are written by separating them by
commas.

Q7.HOW PROLOG LANGUAGE CAN BE STATED AS


PROCEDURAL LANGUAGE?

ANS. In Prolog, procedures are called predicate. Following are the


two reasons because of which it is also known as procedural
language. The two unusual aspects of Prolog are:
 prolog has assign-once variables.
 Prolog is non deterministic.

Q8. HOW VARIABLES ARE USED IN PROLOG?

ANS. HERE IS AN EXAMPLE:

Suppose we want to ask, “What course does ROBIN teach”?,then


we can write it in prolog as

” Is there a course,x,that ROBIN teaches? “

HERE,

here x stands for an object that the questioner does not know


about yet,so to answer the prolog has to find the value of x.If we
know the value of variable then it is known as BOUND, if we don’t
know then known as UNBOUND.

Q9. HOW BACKTRACKING IN PROLOG IS DONE?

ANS. BACKTRACKING IS DONE AS FOLLOWS IN PROLOG:

example:

Who does ROBIN teach?


?- lectures(ROBIN, Course), studies(Student, Course).
Course = 9311
Student = jack ;

Course = 9314
Student = jill ;

Course = 9314
Student = henry ;
Prolog solves this problem by proceeding left to right and then
backtracking.
When given the initial query, Prolog starts by trying to solve
lectures(ROBIN, Course).
There are six lectures clauses, but only two have ROBIN as their
first argument.
Prolog uses the first clause that refers to ROBIN: lectures(ROBIN,
9311).
With Course = 9311, it tries to satisfy the next goal,
studies(Student, 9311).
It finds the fact studies(jack, 9311). and hence the first solution:
(Course = 9311, Student = jack).

Q10. GIVE AN EXAMPLE OF USING STRUCTURES IN


PROLOG?

ANS. Functional terms can be used to construct complex data


structures.Here is the example. of using structure in PROLOG:
 How do we ask, “What books does John own that were written
by someone called LeGuin”?
 ?- owns(john, book(Title, author(leguin, GivenName))).
 Title = 'Tehanu'
GivenName = ursula
 What books does John own?
 ?- owns(john, Book).
Book = book('Tehanu', author(leguin, ursula))
 What books does John own?
 ?- owns(john, book(Title, Author)).
 Title = 'Tehanu'
Author = author(leguin, ursula)
 Prolog performs a complex matching operation between the
structures in the query and those in the clause head.

You might also like