You are on page 1of 7

Lab # 01

Exercise: 1.

1: Write the latest release of prolog?

Ans: Current stable version is gprolog-1.5.0

2: List down Some logic programming languages?

∙ Prolog++
∙ ASP (Answer Set Programming)
∙ Alma-0
∙ Prolog
∙ F-logic
∙ Alice

3: What is the difference between a procedural and declarative language?

PROCEDURAL DECLARATIVE

It is also known as Interpretive knowledge. It is also known as Descriptive knowledge.


While Declarative Knowledge means basic
knowledge about something.
Procedural Knowledge means how a
particular thing can be accomplished.

Procedural Knowledge is generally not used

means it is not more popular. Declarative Knowledge is more popular.


Declarative Knowledge can be easily
Procedural Knowledge can’t be easily communicate.
communicate.
Declarative Knowledge is data oriented in
Procedural Knowledge is generally process nature.
oriented in nature.
In Declarative Knowledge debugging and
In Procedural Knowledge debugging and validation is easy.
validation is not easy.
Declarative Knowledge is more effective in
Procedural Knowledge is less effective in competitive programming.
competitive programming.
Let me give you a real-world example: I need a cup of tea
PROCEDURAL DECLARATIVE
1. Go to kitchen
2. Get sugar, milk, and tea,
3. Mix them, and heat over the fire till it
boils
4. Put that in a cup and bring it to me
In a declarative language, you just set the
In a procedural language, you define the command or order, and let it be on the system
whole process and provide the steps how to how to complete that order. You just need
do it. You just provide orders and define how your result without digging into how it should
the process will be served. be done.
1. Get me a cup of tea.

4. Relationships can also depict rules. Give 2 examples (other than those specified in Lab
1).

Example: 01
Two people are sisters if
are both female and
they have the same parents.

Example:02

Two people are in same university if


are both male and
they have the same Class.

Q5: Write 5 examples of ownership relationship.

1. Ramesh has a latest window System.


2. TIEST has own dress code.
3. Ramesh has Smart watch.
4. Khatri has bundles of Robotics books.
5. Khatri have their own Car and Farmhouse.
LAB 2
Q1: What are the advantages and limitations of Prolog?

Advantages of Prolog:
∙ This compiler is working fast and hustle-free.

∙ The prolog programming has powerful interfaces between the prolog and C programming

language.

∙ The user of prolog programmer creates their constraints with customization. ∙

The prolog language does not use complex algorithms and coding.

∙ The prolog programming language maintains and operates data lists with easy coding.

Limitations of Prolog:

∙ The prolog programming does not support graphics features. If you need graphics then

you must use turbo prolog.

∙ The prolog order affects the efficiency of the programming language.

∙ The prolog programming language does not support the “OR” logical conditions. This

language does not support multiple true statements.

∙ The prolog programming language does not support the “NOT” logical condition. This

language does not support negative statements.

∙ The LISP language dominates and overcomes input and output features.
Q2: Enter the above program into Prolog and execute the queries shown below:

Facts & Rules

ring(Person, Number) :- location(Person, Place), phone_number(Place,

Number). location(Person, Place) :- at(Person, Place).

location(Person,Place) :- visiting(Person, Someone), location(Someone,

Place). phone_number(rm303g, 5767).

phone_number(rm303a, 5949).
at(dr_jones, rm303g).

at(dr_mike, rm303a).

visiting(dr_mike, dr_jones).

Queries.

?- location(dr_bottaci, Pl).

?- ring(dr_mike, Number).

?- ring(Person, 5767).

?- ring(Person, Number).

?- ring(dr_jones, 999).
Prolog Program : -

LAB 3
Q1: Write a prolog program to create a family tree by creating facts and rules based on
the information given below:

Parveen is the parent of Babar.

Talib is the parent of Babar.

Talib is the parent of Lubna.

Parveen is the parent of Lubna.

Talib is male.

Babar is male.

Parveen is female.

Lubna is female.
FACTS & RULES: -

female(parveen).

female(lubna).

male(talib).

male(baber).

parent(talib,baber).

parent(parveen,lubna).

parent(talib,lubna).

parent(parveen,baber).

son(X,Y):-male(X) ,parent(Y,X).

daughter(X, Y):- female(X) ,parent(Y ,X).


Q2: - Write a prolog program to create an administration tree by creating facts and rules
based your imagination [Hint: Consider the administrative positions of different people
around you].

Facts and Rules: -


Prolog Programming: -

You might also like