QUESTIONS ON PROLOG LANGUAGE

Jan 14 • Resources • 13884 Views • 5 Comments on 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 ColmerauerRobert 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:

  1. intelligent data base retrieval
  2. natural language understanding
  3. expert systems
  4. specification language
  5. machine learning
  6. robot planning
  7. automated reasoning
  8. problem solving

Q4. WHY WE USE PROLOG PROGRAMMING LANGUAGE?

ANS. FOLLOWING ARE SOME POINTS FOR USING PROLOG MORE:

  1.  SWI-Prolog is free, open-source, and very well maintained.
  2. It’s much much easier to distribute SWI-Prolog applications than Java ones
  3.  Prolog is much less verbose,which is helpful when during development.
  4. Prolog allows one to define any word or collection of “symbol characters” (e.g. >>, +, /, , //, :===/===: ) as an infix, postfix, or prefix operator.
  5. In Prolog, you can treat data as programs.
  6. 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.

  1. ATOM :    An atom is a general-purpose name with no inherent meaning.
  2. NUMBERS :    Numbers are like integers,float etc.
  3. VARIABLES :   Are denoted  string consisting of letters, numbers, underscore characters, and beginning with an upper-case letter or underscore.
  4. 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:

  1. prolog has assign-once variables.
  2. 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.

 

 

Tell us Your Queries, Suggestions and Feedback

Your email address will not be published.

5 Responses to QUESTIONS ON PROLOG LANGUAGE

  1. henok says:

    Enter your any educational query or doubt software engineering

  2. ANKITA SINGH says:

    I AM NOT UNDERSTAND ARTIFICIAL INTELLIGENCE EASILY SO PLEASE PROVIDE ME EASY ANSWER OF AKTU SYLLABUS

  3. Pallavi sinha says:

    PROLOG is a general purpose programming language with many free commercial implementations available…….wan to know a list of information abt it go thru this link

  4. patlakshi Jha says:

    The above detalis shows all the information related to prolog language. For those who are interested in learning more go through the details.

  5. Shilpa Ranjan says:

    About PROLOG programming language. Go through the article if you want to learn more !!!!!

« »