SlideShare a Scribd company logo
1 of 7
Prolog programming exercises
1.
How many facts, rules, clauses, and predicates are there in the following
knowledge base? What are the heads of the rules, and what are the goals they
contain?
woman(vincent).fact
woman(mia). fact
man(jules). fact
person(X) :- man(X); woman(X).Rule
loves(X,Y) :- knows(Y,X). Rule
father(Y,Z) :- man(Y), son(Z,Y). Rule
father(Y,Z) :- man(Y), daughter(Z,Y). Rule

2.
Represent the following in Prolog:
1. Butch is a killer.
Killer(Butch)
2. Mia and Marcellus are married.
Married(Mia, Marcellus).
3. Zed is dead.
Dead(Zed)
4. Marcellus kills everyone who gives Mia a foot massage.
Kills(Marcellus, gives(Mia, foot massage))
5. Mia loves everyone who is a good dancer.
Loves(Mia,X :- good dancer(X ))
6. Jules eats anything that is nutritious or tasty.
Eats(Jules,X):- nutritious(X); tasty(X)

3.
Suppose we are working with the following knowledge base:
wizard(ron).
hasWand(harry).
quidditchPlayer(harry).
wizard(X) :- hasBroom(X),hasWand(X).
hasBroom(X) :- quidditchPlayer(X).
How does Prolog respond to the following queries?
1. wizard(ron).true
2. witch(ron).false
3. wizard(hermione). false
4. witch(hermione). false
5. wizard(harry). false
6. wizard(Y). true
7. witch(Y). true

4.
Which of the following pairs of terms match? Where relevant, give the
Variable instantiations that lead to successful matching.
1. bread = bread

yes

2. ’Bread’ = bread

No

3. ’bread’ = bread
4. Bread = bread

Yes
Yes, Bread = bread

5. bread = sausage

No

6. food(bread) = bread

No

7. food(bread) = X

Yes,

8. food(X) = food(bread)

Yes,

X = food(bread)
X = bread

9. food(bread,X) = food(Y,sausage)

Yes, X = sausage, Y = bread

10. food(bread,X,beer) = food(Y,sausage,X) No
11. food(bread,X,beer) = food(Y,kahuna_burger)
12. food(X) = X

No

Yes, X = food(**)

13. meal(food(bread),drink(beer)) = meal(X,Y)
Yes, X = food(bread),
Yes, X = food(bread),

14. meal(food(bread),X) = meal(X,drink(beer)) No

5.
Exercise 2.2 We are working with the following knowledge base:
house_elf(dobby).
witch(hermione).
witch(’McGonagall’).
witch(rita_skeeter).
magic(X):-house_elf(X).
magic(X):-wizard(X).
magic(X):-witch(X).

Which of the following queries are satisfied? Where relevant, give all the variable
instantiations that lead to success.
1. ?- magic(house_elf). No, Error: undefined procedure wizard/1
2. ?- wizard(harry). No, Error: undefined procedure wizard/1
3. ?- magic(wizard). No, Error: undefined procedure wizard/1
4. ?- magic(’McGonagall’). No, Error: undefined procedure wizard/1
5. ?- magic(Hermione). Yes, Error: undefined procedure wizard/1

6.
Here is a tiny lexicon and mini grammar with only one rule which defines
a sentence as consisting of five words: an article, a noun, a verb, and again an
article and a noun.
word(article,a).
word(article,every).
word(noun,criminal).
word(noun,’big kahuna burger’).
word(verb,eats).
word(verb,likes).
sentence(Word1,Word2,Word3,Word4,Word5) :word(article,Word1),
word(noun,Word2),
word(verb,Word3),
word(article,Word4),
word(noun,Word5).

What query do you have to pose in order to find out which sentences the grammar
can generate? List all sentences that this grammar can generate in the order Prolog
will generate them. Make sure that you understand why Prolog generates them in this
order.
a
a
a
a
a

criminal
criminal
criminal
criminal
criminal

eats a criminal
eats a big kahuna burger
eats every criminal
eats every big kahuna burger
likes a criminal
a criminal likes a big kahuna burger
a criminal likes every criminal
a criminal likes every big kahuna burger
a big kahuna burger eats a criminal
a big kahuna burger eats a big kahuna burger
a big kahuna burger eats every criminal
a big kahuna burger eats every big kahuna burger
a big kahuna burger likes a criminal
a big kahuna burger likes a big kahuna burger
a big kahuna burger likes every criminal
a big kahuna burger likes every big kahuna burger
every criminal eats a criminal
every criminal eats a big kahuna burger
every criminal eats every criminal
every criminal eats every big kahuna burger
every criminal likes a criminal
every criminal likes a big kahuna burger
every criminal likes every criminal
every criminal likes every big kahuna burger
every big kahuna burger eats a criminal
every big kahuna burger eats a big kahuna burger
every big kahuna burger eats every criminal
every big kahuna burger eats every big kahuna burger
every big kahuna burger likes a criminal
every big kahuna burger likes a big kahuna burger
every big kahuna burger likes every criminal
every big kahuna burger likes every big kahuna burger

7.
Write natural language sentences that represent what these Prolog facts might convey to a
human reader. (Remember that, to the computer, these facts are simple pieces of information
that can be used for matching answers to questions.)
1.

likes(jeff, painting).

2.

male(john).

3.

building("Empire State Building", new_york).

4.

person(roslin, jeanie, "1429 East Sutter St.",
"Scotts Valley", "CA", 95066).

Write Prolog programming exercises facts that represent the following natural language
statements:
Helen likes pizza.
San Francisco is in California.
Amy's telephone number is 476-0299.
Len's father is Alphonso Grenaldi.

8.
Write natural-language sentences corresponding to the following Prolog programming
exercises rules:
eats(Who, What):- food(What), likes(Who, What).
pass_class(Who):- did_homework(Who), good_attendance(Who).
does_not_eat(toby, Stuff):- food(Stuff), greasy(Stuff).
owns(Who, What):- bought(Who, What).

Write Prolog programming exercises rules that convey the meaning of these natural-language
sentences:
a.

A person is hungry if that person's stomach is empty.

b.

Everybody likes a job if it's fun and it pays well.

c.

Sally likes french fries if they're cooked.

d.

Everybody owns a car who buys one, pays for it, and keeps it.

9.
Create an elementary Prolog knowledge base, describing following relations:
1.
2.
3.
4.
5.

John, Fred and Harry are men, Mary, Julie, Susan and Anne are women.
John has blonde hair while Fred and Harry have dark hair.
Julie and Susan are blonde, Mary and Anne are brunette.
Rich is each person who owns the gold - Fred and Julie in our example.
Male like only female and vice versa. Moreover, John and Harry like rich
persons, John likes blonde and Fred likes brunette.
6. Both Mary and Julie like dark hair persons, Julie likes rich persons at the same
time.
7. Anne owns a house and John owns a car.
and ask it:
a. Who is male ?
b. Who does John like ?
c. Who does Mary like ?
d. Does Julie like anyone ?
e. Is there a couple who like each other ?
10.
What is the difference between the following two rules?
!

blah :- a(X) , b(X).
blah :- a(_) , b(_).

11.

Towers of Hanoi
The solution to the Towers of Hanoi puzzle is a classic example of recursion. The
ancient puzzle of the Towers Of Hanoi consists of a number of wooden disks mounted
on three poles, which are in turn attached to a baseboard. The disks each have
different diameters and a hole in the middle large enough for the poles to pass
through. In the beginning, all the disks are on the left pole as shown in:

The object of the puzzle is to move all the disks over to the right pole, one at a time,
so that they end up in the original order on that pole. You can use the middle pole as a
temporary resting place for disks, but at no time is a larger disk to be on top of a
smaller one. It's easy to solve the Towers of Hanoi with two or three disks, but the
process becomes more difficult with four or more disks.
12.

Hardware Simulation
Every logical circuit can be described with a Visual Prolog predicate, where the
predicate indicates the relationship between the signals on the input and output
terminals of the circuit. The fundamental circuits are described by giving a table of
corresponding truth values (see the and_, or_, and not_ predicates in Program 4).
Fundamental circuits can be described by indicating the relationships between the
internal connections, as well as the terminals. To see how this works, construct an
exclusive OR circuit from AND, OR, and NOT circuits, and then check its operation
with a Visual Prolog program. The circuit is shown in:

More Related Content

What's hot

Demystify eBPF JIT Compiler
Demystify eBPF JIT CompilerDemystify eBPF JIT Compiler
Demystify eBPF JIT CompilerNetronome
 
previous question solve of operating system.
previous question solve of operating system.previous question solve of operating system.
previous question solve of operating system.Ibrahim Khalil Shakik
 
Introduction to prolog
Introduction to prologIntroduction to prolog
Introduction to prologHarry Potter
 
Memory management ppt
Memory management pptMemory management ppt
Memory management pptManishaJha43
 
MS.Net Interview Questions - Simplified
MS.Net Interview Questions - SimplifiedMS.Net Interview Questions - Simplified
MS.Net Interview Questions - SimplifiedMohd Manzoor Ahmed
 
Multithreading In Java
Multithreading In JavaMultithreading In Java
Multithreading In Javaparag
 
chapter 1 introduction to operating system
chapter 1 introduction to operating systemchapter 1 introduction to operating system
chapter 1 introduction to operating systemAisyah Rafiuddin
 
Bash shell scripting
Bash shell scriptingBash shell scripting
Bash shell scriptingVIKAS TIWARI
 
Lecture Notes-Are Natural Languages Regular.pdf
Lecture Notes-Are Natural Languages Regular.pdfLecture Notes-Are Natural Languages Regular.pdf
Lecture Notes-Are Natural Languages Regular.pdfDeptii Chaudhari
 
Regular expressions
Regular expressionsRegular expressions
Regular expressionsShiraz316
 
Critical section problem in operating system.
Critical section problem in operating system.Critical section problem in operating system.
Critical section problem in operating system.MOHIT DADU
 
Push Down Automata (PDA) | TOC (Theory of Computation) | NPDA | DPDA
Push Down Automata (PDA) | TOC  (Theory of Computation) | NPDA | DPDAPush Down Automata (PDA) | TOC  (Theory of Computation) | NPDA | DPDA
Push Down Automata (PDA) | TOC (Theory of Computation) | NPDA | DPDAAshish Duggal
 
directory structure and file system mounting
directory structure and file system mountingdirectory structure and file system mounting
directory structure and file system mountingrajshreemuthiah
 
Operating System Process Synchronization
Operating System Process SynchronizationOperating System Process Synchronization
Operating System Process SynchronizationHaziq Naeem
 
2. Characteristics of Algorithm.ppt
2. Characteristics of Algorithm.ppt2. Characteristics of Algorithm.ppt
2. Characteristics of Algorithm.pptNoumanali748226
 
PROLOG: Cuts And Negation In Prolog
PROLOG: Cuts And Negation In PrologPROLOG: Cuts And Negation In Prolog
PROLOG: Cuts And Negation In PrologDataminingTools Inc
 

What's hot (20)

Demystify eBPF JIT Compiler
Demystify eBPF JIT CompilerDemystify eBPF JIT Compiler
Demystify eBPF JIT Compiler
 
previous question solve of operating system.
previous question solve of operating system.previous question solve of operating system.
previous question solve of operating system.
 
Introduction to prolog
Introduction to prologIntroduction to prolog
Introduction to prolog
 
Memory management ppt
Memory management pptMemory management ppt
Memory management ppt
 
MS.Net Interview Questions - Simplified
MS.Net Interview Questions - SimplifiedMS.Net Interview Questions - Simplified
MS.Net Interview Questions - Simplified
 
Multithreading In Java
Multithreading In JavaMultithreading In Java
Multithreading In Java
 
chapter 1 introduction to operating system
chapter 1 introduction to operating systemchapter 1 introduction to operating system
chapter 1 introduction to operating system
 
Bash shell scripting
Bash shell scriptingBash shell scripting
Bash shell scripting
 
Lecture Notes-Are Natural Languages Regular.pdf
Lecture Notes-Are Natural Languages Regular.pdfLecture Notes-Are Natural Languages Regular.pdf
Lecture Notes-Are Natural Languages Regular.pdf
 
Thread
ThreadThread
Thread
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
Lets Auto It
Lets Auto ItLets Auto It
Lets Auto It
 
Critical section problem in operating system.
Critical section problem in operating system.Critical section problem in operating system.
Critical section problem in operating system.
 
Push Down Automata (PDA) | TOC (Theory of Computation) | NPDA | DPDA
Push Down Automata (PDA) | TOC  (Theory of Computation) | NPDA | DPDAPush Down Automata (PDA) | TOC  (Theory of Computation) | NPDA | DPDA
Push Down Automata (PDA) | TOC (Theory of Computation) | NPDA | DPDA
 
OS - Deadlock
OS - DeadlockOS - Deadlock
OS - Deadlock
 
directory structure and file system mounting
directory structure and file system mountingdirectory structure and file system mounting
directory structure and file system mounting
 
Operating System Process Synchronization
Operating System Process SynchronizationOperating System Process Synchronization
Operating System Process Synchronization
 
Input-Output Modules
Input-Output ModulesInput-Output Modules
Input-Output Modules
 
2. Characteristics of Algorithm.ppt
2. Characteristics of Algorithm.ppt2. Characteristics of Algorithm.ppt
2. Characteristics of Algorithm.ppt
 
PROLOG: Cuts And Negation In Prolog
PROLOG: Cuts And Negation In PrologPROLOG: Cuts And Negation In Prolog
PROLOG: Cuts And Negation In Prolog
 

Viewers also liked

Post Show Report ENGIMACH-13
Post Show Report ENGIMACH-13Post Show Report ENGIMACH-13
Post Show Report ENGIMACH-13Rajesh Parmar
 
How do Orion Midlands listeners spend their weekends?
How do Orion Midlands listeners spend their weekends?How do Orion Midlands listeners spend their weekends?
How do Orion Midlands listeners spend their weekends?davidlloydradio
 
Gem listeners - Education
Gem listeners - EducationGem listeners - Education
Gem listeners - Educationdavidlloydradio
 
Radio listeners - Leisure habits - Orion Media (East Mids)
Radio listeners - Leisure habits - Orion Media (East Mids)Radio listeners - Leisure habits - Orion Media (East Mids)
Radio listeners - Leisure habits - Orion Media (East Mids)davidlloydradio
 
Microsoft office cheap
Microsoft office cheapMicrosoft office cheap
Microsoft office cheapdavadtech
 

Viewers also liked (7)

Post Show Report ENGIMACH-13
Post Show Report ENGIMACH-13Post Show Report ENGIMACH-13
Post Show Report ENGIMACH-13
 
How do Orion Midlands listeners spend their weekends?
How do Orion Midlands listeners spend their weekends?How do Orion Midlands listeners spend their weekends?
How do Orion Midlands listeners spend their weekends?
 
Vehicles amb energies
Vehicles amb energiesVehicles amb energies
Vehicles amb energies
 
IICA and Canada - 40 Years
IICA and Canada - 40 YearsIICA and Canada - 40 Years
IICA and Canada - 40 Years
 
Gem listeners - Education
Gem listeners - EducationGem listeners - Education
Gem listeners - Education
 
Radio listeners - Leisure habits - Orion Media (East Mids)
Radio listeners - Leisure habits - Orion Media (East Mids)Radio listeners - Leisure habits - Orion Media (East Mids)
Radio listeners - Leisure habits - Orion Media (East Mids)
 
Microsoft office cheap
Microsoft office cheapMicrosoft office cheap
Microsoft office cheap
 

Similar to اجابات البرولوج

ASSIGNMENT 1 7.4 EXERCISES Using the predicates listed for each.docx
ASSIGNMENT 1 7.4 EXERCISES Using the predicates listed for each.docxASSIGNMENT 1 7.4 EXERCISES Using the predicates listed for each.docx
ASSIGNMENT 1 7.4 EXERCISES Using the predicates listed for each.docxtrippettjettie
 
Lec 7 genetic algorithms
Lec 7 genetic algorithmsLec 7 genetic algorithms
Lec 7 genetic algorithmsEyob Sisay
 
Diagnosing cancer with Computational Intelligence
Diagnosing cancer with Computational IntelligenceDiagnosing cancer with Computational Intelligence
Diagnosing cancer with Computational IntelligenceSimon van Dyk
 
Let F(x,y) be the statement x can fool y,where the domainconsi.pdf
Let F(x,y) be the statement x can fool y,where the domainconsi.pdfLet F(x,y) be the statement x can fool y,where the domainconsi.pdf
Let F(x,y) be the statement x can fool y,where the domainconsi.pdfamitagrawal1410
 
First order logic.ppt
First order logic.pptFirst order logic.ppt
First order logic.pptvisnuyaathav1
 
Otter 2017-12-18-01-ss
Otter 2017-12-18-01-ssOtter 2017-12-18-01-ss
Otter 2017-12-18-01-ssRuo Ando
 
Artificial Intelligence Lab File
Artificial Intelligence Lab FileArtificial Intelligence Lab File
Artificial Intelligence Lab FileKandarp Tiwari
 
45 genetic-algorithms
45 genetic-algorithms45 genetic-algorithms
45 genetic-algorithmsgrskrishna
 
An introduction to Prolog language slide
An introduction to Prolog language slideAn introduction to Prolog language slide
An introduction to Prolog language slide2021uam4641
 
BACK TO THE DRAWING BOARD - The Myth of Data-Driven NLU and How to go Forward...
BACK TO THE DRAWING BOARD - The Myth of Data-Driven NLU and How to go Forward...BACK TO THE DRAWING BOARD - The Myth of Data-Driven NLU and How to go Forward...
BACK TO THE DRAWING BOARD - The Myth of Data-Driven NLU and How to go Forward...Walid Saba
 
Title under construction_quiz
Title under construction_quizTitle under construction_quiz
Title under construction_quizArun Balan
 

Similar to اجابات البرولوج (20)

Prolog basics
Prolog basicsProlog basics
Prolog basics
 
ASSIGNMENT 1 7.4 EXERCISES Using the predicates listed for each.docx
ASSIGNMENT 1 7.4 EXERCISES Using the predicates listed for each.docxASSIGNMENT 1 7.4 EXERCISES Using the predicates listed for each.docx
ASSIGNMENT 1 7.4 EXERCISES Using the predicates listed for each.docx
 
lect14-semantics.ppt
lect14-semantics.pptlect14-semantics.ppt
lect14-semantics.ppt
 
Lec 7 genetic algorithms
Lec 7 genetic algorithmsLec 7 genetic algorithms
Lec 7 genetic algorithms
 
Diagnosing cancer with Computational Intelligence
Diagnosing cancer with Computational IntelligenceDiagnosing cancer with Computational Intelligence
Diagnosing cancer with Computational Intelligence
 
Let F(x,y) be the statement x can fool y,where the domainconsi.pdf
Let F(x,y) be the statement x can fool y,where the domainconsi.pdfLet F(x,y) be the statement x can fool y,where the domainconsi.pdf
Let F(x,y) be the statement x can fool y,where the domainconsi.pdf
 
Statistics Homework Help
Statistics Homework HelpStatistics Homework Help
Statistics Homework Help
 
artficial intelligence
artficial intelligenceartficial intelligence
artficial intelligence
 
First order logic.ppt
First order logic.pptFirst order logic.ppt
First order logic.ppt
 
Sat preparation
Sat preparationSat preparation
Sat preparation
 
Otter 2017-12-18-01-ss
Otter 2017-12-18-01-ssOtter 2017-12-18-01-ss
Otter 2017-12-18-01-ss
 
Artificial Intelligence Lab File
Artificial Intelligence Lab FileArtificial Intelligence Lab File
Artificial Intelligence Lab File
 
Probability Homework Help
Probability Homework HelpProbability Homework Help
Probability Homework Help
 
Prolog PPT_merged.pdf
Prolog PPT_merged.pdfProlog PPT_merged.pdf
Prolog PPT_merged.pdf
 
45 genetic-algorithms
45 genetic-algorithms45 genetic-algorithms
45 genetic-algorithms
 
An introduction to Prolog language slide
An introduction to Prolog language slideAn introduction to Prolog language slide
An introduction to Prolog language slide
 
BACK TO THE DRAWING BOARD - The Myth of Data-Driven NLU and How to go Forward...
BACK TO THE DRAWING BOARD - The Myth of Data-Driven NLU and How to go Forward...BACK TO THE DRAWING BOARD - The Myth of Data-Driven NLU and How to go Forward...
BACK TO THE DRAWING BOARD - The Myth of Data-Driven NLU and How to go Forward...
 
Title under construction_quiz
Title under construction_quizTitle under construction_quiz
Title under construction_quiz
 
Fol
FolFol
Fol
 
Chapter 4 (final)
Chapter 4 (final)Chapter 4 (final)
Chapter 4 (final)
 

Recently uploaded

Contact:- 8860008073 Call Girls in Karnal Escort Service Available at Afforda...
Contact:- 8860008073 Call Girls in Karnal Escort Service Available at Afforda...Contact:- 8860008073 Call Girls in Karnal Escort Service Available at Afforda...
Contact:- 8860008073 Call Girls in Karnal Escort Service Available at Afforda...Apsara Of India
 
Call Girls In Goa 9316020077 Goa Call Girl By Indian Call Girls Goa
Call Girls In Goa  9316020077 Goa  Call Girl By Indian Call Girls GoaCall Girls In Goa  9316020077 Goa  Call Girl By Indian Call Girls Goa
Call Girls In Goa 9316020077 Goa Call Girl By Indian Call Girls Goasexy call girls service in goa
 
1681275559_haunting-adeline and hunting.pdf
1681275559_haunting-adeline and hunting.pdf1681275559_haunting-adeline and hunting.pdf
1681275559_haunting-adeline and hunting.pdfTanjirokamado769606
 
Kolkata Call Girl Airport Kolkata 👉 8250192130 ❣️💯 Available With Room 24×7
Kolkata Call Girl Airport Kolkata 👉 8250192130 ❣️💯 Available With Room 24×7Kolkata Call Girl Airport Kolkata 👉 8250192130 ❣️💯 Available With Room 24×7
Kolkata Call Girl Airport Kolkata 👉 8250192130 ❣️💯 Available With Room 24×7Riya Pathan
 
↑Top Model (Kolkata) Call Girls Howrah ⟟ 8250192130 ⟟ High Class Call Girl In...
↑Top Model (Kolkata) Call Girls Howrah ⟟ 8250192130 ⟟ High Class Call Girl In...↑Top Model (Kolkata) Call Girls Howrah ⟟ 8250192130 ⟟ High Class Call Girl In...
↑Top Model (Kolkata) Call Girls Howrah ⟟ 8250192130 ⟟ High Class Call Girl In...noor ahmed
 
(KRITI) Pimpri Chinchwad Call Girls Just Call 7001035870 [ Cash on Delivery ]...
(KRITI) Pimpri Chinchwad Call Girls Just Call 7001035870 [ Cash on Delivery ]...(KRITI) Pimpri Chinchwad Call Girls Just Call 7001035870 [ Cash on Delivery ]...
(KRITI) Pimpri Chinchwad Call Girls Just Call 7001035870 [ Cash on Delivery ]...ranjana rawat
 
Kolkata Call Girls Service +918240919228 - Kolkatanightgirls.com
Kolkata Call Girls Service +918240919228 - Kolkatanightgirls.comKolkata Call Girls Service +918240919228 - Kolkatanightgirls.com
Kolkata Call Girls Service +918240919228 - Kolkatanightgirls.comKolkata Call Girls
 
Fun Call Girls In Goa 7028418221 Escort Service In Morjim Beach Call Girl
Fun Call Girls In Goa 7028418221 Escort Service In Morjim Beach Call GirlFun Call Girls In Goa 7028418221 Escort Service In Morjim Beach Call Girl
Fun Call Girls In Goa 7028418221 Escort Service In Morjim Beach Call GirlApsara Of India
 
Housewife Call Girls Sonagachi - 8250192130 Booking and charges genuine rate ...
Housewife Call Girls Sonagachi - 8250192130 Booking and charges genuine rate ...Housewife Call Girls Sonagachi - 8250192130 Booking and charges genuine rate ...
Housewife Call Girls Sonagachi - 8250192130 Booking and charges genuine rate ...Riya Pathan
 
Low Rate Call Girls Gulbarga Anika 8250192130 Independent Escort Service Gulb...
Low Rate Call Girls Gulbarga Anika 8250192130 Independent Escort Service Gulb...Low Rate Call Girls Gulbarga Anika 8250192130 Independent Escort Service Gulb...
Low Rate Call Girls Gulbarga Anika 8250192130 Independent Escort Service Gulb...Riya Pathan
 
Call Girls in Barasat | 7001035870 At Low Cost Cash Payment Booking
Call Girls in Barasat | 7001035870 At Low Cost Cash Payment BookingCall Girls in Barasat | 7001035870 At Low Cost Cash Payment Booking
Call Girls in Barasat | 7001035870 At Low Cost Cash Payment Bookingnoor ahmed
 
VIP Call Girls in Gulbarga Aarohi 8250192130 Independent Escort Service Gulbarga
VIP Call Girls in Gulbarga Aarohi 8250192130 Independent Escort Service GulbargaVIP Call Girls in Gulbarga Aarohi 8250192130 Independent Escort Service Gulbarga
VIP Call Girls in Gulbarga Aarohi 8250192130 Independent Escort Service GulbargaRiya Pathan
 
↑Top Model (Kolkata) Call Girls Behala ⟟ 8250192130 ⟟ High Class Call Girl In...
↑Top Model (Kolkata) Call Girls Behala ⟟ 8250192130 ⟟ High Class Call Girl In...↑Top Model (Kolkata) Call Girls Behala ⟟ 8250192130 ⟟ High Class Call Girl In...
↑Top Model (Kolkata) Call Girls Behala ⟟ 8250192130 ⟟ High Class Call Girl In...noor ahmed
 
GV'S 24 CLUB & BAR CONTACT 09602870969 CALL GIRLS IN UDAIPUR ESCORT SERVICE
GV'S 24 CLUB & BAR CONTACT 09602870969 CALL GIRLS IN UDAIPUR ESCORT SERVICEGV'S 24 CLUB & BAR CONTACT 09602870969 CALL GIRLS IN UDAIPUR ESCORT SERVICE
GV'S 24 CLUB & BAR CONTACT 09602870969 CALL GIRLS IN UDAIPUR ESCORT SERVICEApsara Of India
 
(DIVYA) Dhanori Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(DIVYA) Dhanori Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(DIVYA) Dhanori Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(DIVYA) Dhanori Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
Hot Call Girls In Goa 7028418221 Call Girls In Vagator Beach EsCoRtS
Hot Call Girls In Goa 7028418221 Call Girls In Vagator Beach EsCoRtSHot Call Girls In Goa 7028418221 Call Girls In Vagator Beach EsCoRtS
Hot Call Girls In Goa 7028418221 Call Girls In Vagator Beach EsCoRtSApsara Of India
 
VIP Call Girls Darjeeling Aaradhya 8250192130 Independent Escort Service Darj...
VIP Call Girls Darjeeling Aaradhya 8250192130 Independent Escort Service Darj...VIP Call Girls Darjeeling Aaradhya 8250192130 Independent Escort Service Darj...
VIP Call Girls Darjeeling Aaradhya 8250192130 Independent Escort Service Darj...Neha Kaur
 
VIP Call Girls Service Banjara Hills Hyderabad Call +91-8250192130
VIP Call Girls Service Banjara Hills Hyderabad Call +91-8250192130VIP Call Girls Service Banjara Hills Hyderabad Call +91-8250192130
VIP Call Girls Service Banjara Hills Hyderabad Call +91-8250192130Suhani Kapoor
 
VIP Call Girls Nagpur Megha Call 7001035870 Meet With Nagpur Escorts
VIP Call Girls Nagpur Megha Call 7001035870 Meet With Nagpur EscortsVIP Call Girls Nagpur Megha Call 7001035870 Meet With Nagpur Escorts
VIP Call Girls Nagpur Megha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
Verified Call Girls Esplanade - [ Cash on Delivery ] Contact 8250192130 Escor...
Verified Call Girls Esplanade - [ Cash on Delivery ] Contact 8250192130 Escor...Verified Call Girls Esplanade - [ Cash on Delivery ] Contact 8250192130 Escor...
Verified Call Girls Esplanade - [ Cash on Delivery ] Contact 8250192130 Escor...anamikaraghav4
 

Recently uploaded (20)

Contact:- 8860008073 Call Girls in Karnal Escort Service Available at Afforda...
Contact:- 8860008073 Call Girls in Karnal Escort Service Available at Afforda...Contact:- 8860008073 Call Girls in Karnal Escort Service Available at Afforda...
Contact:- 8860008073 Call Girls in Karnal Escort Service Available at Afforda...
 
Call Girls In Goa 9316020077 Goa Call Girl By Indian Call Girls Goa
Call Girls In Goa  9316020077 Goa  Call Girl By Indian Call Girls GoaCall Girls In Goa  9316020077 Goa  Call Girl By Indian Call Girls Goa
Call Girls In Goa 9316020077 Goa Call Girl By Indian Call Girls Goa
 
1681275559_haunting-adeline and hunting.pdf
1681275559_haunting-adeline and hunting.pdf1681275559_haunting-adeline and hunting.pdf
1681275559_haunting-adeline and hunting.pdf
 
Kolkata Call Girl Airport Kolkata 👉 8250192130 ❣️💯 Available With Room 24×7
Kolkata Call Girl Airport Kolkata 👉 8250192130 ❣️💯 Available With Room 24×7Kolkata Call Girl Airport Kolkata 👉 8250192130 ❣️💯 Available With Room 24×7
Kolkata Call Girl Airport Kolkata 👉 8250192130 ❣️💯 Available With Room 24×7
 
↑Top Model (Kolkata) Call Girls Howrah ⟟ 8250192130 ⟟ High Class Call Girl In...
↑Top Model (Kolkata) Call Girls Howrah ⟟ 8250192130 ⟟ High Class Call Girl In...↑Top Model (Kolkata) Call Girls Howrah ⟟ 8250192130 ⟟ High Class Call Girl In...
↑Top Model (Kolkata) Call Girls Howrah ⟟ 8250192130 ⟟ High Class Call Girl In...
 
(KRITI) Pimpri Chinchwad Call Girls Just Call 7001035870 [ Cash on Delivery ]...
(KRITI) Pimpri Chinchwad Call Girls Just Call 7001035870 [ Cash on Delivery ]...(KRITI) Pimpri Chinchwad Call Girls Just Call 7001035870 [ Cash on Delivery ]...
(KRITI) Pimpri Chinchwad Call Girls Just Call 7001035870 [ Cash on Delivery ]...
 
Kolkata Call Girls Service +918240919228 - Kolkatanightgirls.com
Kolkata Call Girls Service +918240919228 - Kolkatanightgirls.comKolkata Call Girls Service +918240919228 - Kolkatanightgirls.com
Kolkata Call Girls Service +918240919228 - Kolkatanightgirls.com
 
Fun Call Girls In Goa 7028418221 Escort Service In Morjim Beach Call Girl
Fun Call Girls In Goa 7028418221 Escort Service In Morjim Beach Call GirlFun Call Girls In Goa 7028418221 Escort Service In Morjim Beach Call Girl
Fun Call Girls In Goa 7028418221 Escort Service In Morjim Beach Call Girl
 
Housewife Call Girls Sonagachi - 8250192130 Booking and charges genuine rate ...
Housewife Call Girls Sonagachi - 8250192130 Booking and charges genuine rate ...Housewife Call Girls Sonagachi - 8250192130 Booking and charges genuine rate ...
Housewife Call Girls Sonagachi - 8250192130 Booking and charges genuine rate ...
 
Low Rate Call Girls Gulbarga Anika 8250192130 Independent Escort Service Gulb...
Low Rate Call Girls Gulbarga Anika 8250192130 Independent Escort Service Gulb...Low Rate Call Girls Gulbarga Anika 8250192130 Independent Escort Service Gulb...
Low Rate Call Girls Gulbarga Anika 8250192130 Independent Escort Service Gulb...
 
Call Girls in Barasat | 7001035870 At Low Cost Cash Payment Booking
Call Girls in Barasat | 7001035870 At Low Cost Cash Payment BookingCall Girls in Barasat | 7001035870 At Low Cost Cash Payment Booking
Call Girls in Barasat | 7001035870 At Low Cost Cash Payment Booking
 
VIP Call Girls in Gulbarga Aarohi 8250192130 Independent Escort Service Gulbarga
VIP Call Girls in Gulbarga Aarohi 8250192130 Independent Escort Service GulbargaVIP Call Girls in Gulbarga Aarohi 8250192130 Independent Escort Service Gulbarga
VIP Call Girls in Gulbarga Aarohi 8250192130 Independent Escort Service Gulbarga
 
↑Top Model (Kolkata) Call Girls Behala ⟟ 8250192130 ⟟ High Class Call Girl In...
↑Top Model (Kolkata) Call Girls Behala ⟟ 8250192130 ⟟ High Class Call Girl In...↑Top Model (Kolkata) Call Girls Behala ⟟ 8250192130 ⟟ High Class Call Girl In...
↑Top Model (Kolkata) Call Girls Behala ⟟ 8250192130 ⟟ High Class Call Girl In...
 
GV'S 24 CLUB & BAR CONTACT 09602870969 CALL GIRLS IN UDAIPUR ESCORT SERVICE
GV'S 24 CLUB & BAR CONTACT 09602870969 CALL GIRLS IN UDAIPUR ESCORT SERVICEGV'S 24 CLUB & BAR CONTACT 09602870969 CALL GIRLS IN UDAIPUR ESCORT SERVICE
GV'S 24 CLUB & BAR CONTACT 09602870969 CALL GIRLS IN UDAIPUR ESCORT SERVICE
 
(DIVYA) Dhanori Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(DIVYA) Dhanori Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(DIVYA) Dhanori Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(DIVYA) Dhanori Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
Hot Call Girls In Goa 7028418221 Call Girls In Vagator Beach EsCoRtS
Hot Call Girls In Goa 7028418221 Call Girls In Vagator Beach EsCoRtSHot Call Girls In Goa 7028418221 Call Girls In Vagator Beach EsCoRtS
Hot Call Girls In Goa 7028418221 Call Girls In Vagator Beach EsCoRtS
 
VIP Call Girls Darjeeling Aaradhya 8250192130 Independent Escort Service Darj...
VIP Call Girls Darjeeling Aaradhya 8250192130 Independent Escort Service Darj...VIP Call Girls Darjeeling Aaradhya 8250192130 Independent Escort Service Darj...
VIP Call Girls Darjeeling Aaradhya 8250192130 Independent Escort Service Darj...
 
VIP Call Girls Service Banjara Hills Hyderabad Call +91-8250192130
VIP Call Girls Service Banjara Hills Hyderabad Call +91-8250192130VIP Call Girls Service Banjara Hills Hyderabad Call +91-8250192130
VIP Call Girls Service Banjara Hills Hyderabad Call +91-8250192130
 
VIP Call Girls Nagpur Megha Call 7001035870 Meet With Nagpur Escorts
VIP Call Girls Nagpur Megha Call 7001035870 Meet With Nagpur EscortsVIP Call Girls Nagpur Megha Call 7001035870 Meet With Nagpur Escorts
VIP Call Girls Nagpur Megha Call 7001035870 Meet With Nagpur Escorts
 
Verified Call Girls Esplanade - [ Cash on Delivery ] Contact 8250192130 Escor...
Verified Call Girls Esplanade - [ Cash on Delivery ] Contact 8250192130 Escor...Verified Call Girls Esplanade - [ Cash on Delivery ] Contact 8250192130 Escor...
Verified Call Girls Esplanade - [ Cash on Delivery ] Contact 8250192130 Escor...
 

اجابات البرولوج

  • 1. Prolog programming exercises 1. How many facts, rules, clauses, and predicates are there in the following knowledge base? What are the heads of the rules, and what are the goals they contain? woman(vincent).fact woman(mia). fact man(jules). fact person(X) :- man(X); woman(X).Rule loves(X,Y) :- knows(Y,X). Rule father(Y,Z) :- man(Y), son(Z,Y). Rule father(Y,Z) :- man(Y), daughter(Z,Y). Rule 2. Represent the following in Prolog: 1. Butch is a killer. Killer(Butch) 2. Mia and Marcellus are married. Married(Mia, Marcellus). 3. Zed is dead. Dead(Zed) 4. Marcellus kills everyone who gives Mia a foot massage. Kills(Marcellus, gives(Mia, foot massage)) 5. Mia loves everyone who is a good dancer. Loves(Mia,X :- good dancer(X )) 6. Jules eats anything that is nutritious or tasty. Eats(Jules,X):- nutritious(X); tasty(X) 3. Suppose we are working with the following knowledge base: wizard(ron). hasWand(harry). quidditchPlayer(harry). wizard(X) :- hasBroom(X),hasWand(X). hasBroom(X) :- quidditchPlayer(X).
  • 2. How does Prolog respond to the following queries? 1. wizard(ron).true 2. witch(ron).false 3. wizard(hermione). false 4. witch(hermione). false 5. wizard(harry). false 6. wizard(Y). true 7. witch(Y). true 4. Which of the following pairs of terms match? Where relevant, give the Variable instantiations that lead to successful matching. 1. bread = bread yes 2. ’Bread’ = bread No 3. ’bread’ = bread 4. Bread = bread Yes Yes, Bread = bread 5. bread = sausage No 6. food(bread) = bread No 7. food(bread) = X Yes, 8. food(X) = food(bread) Yes, X = food(bread) X = bread 9. food(bread,X) = food(Y,sausage) Yes, X = sausage, Y = bread 10. food(bread,X,beer) = food(Y,sausage,X) No 11. food(bread,X,beer) = food(Y,kahuna_burger) 12. food(X) = X No Yes, X = food(**) 13. meal(food(bread),drink(beer)) = meal(X,Y) Yes, X = food(bread), Yes, X = food(bread), 14. meal(food(bread),X) = meal(X,drink(beer)) No 5. Exercise 2.2 We are working with the following knowledge base: house_elf(dobby).
  • 3. witch(hermione). witch(’McGonagall’). witch(rita_skeeter). magic(X):-house_elf(X). magic(X):-wizard(X). magic(X):-witch(X). Which of the following queries are satisfied? Where relevant, give all the variable instantiations that lead to success. 1. ?- magic(house_elf). No, Error: undefined procedure wizard/1 2. ?- wizard(harry). No, Error: undefined procedure wizard/1 3. ?- magic(wizard). No, Error: undefined procedure wizard/1 4. ?- magic(’McGonagall’). No, Error: undefined procedure wizard/1 5. ?- magic(Hermione). Yes, Error: undefined procedure wizard/1 6. Here is a tiny lexicon and mini grammar with only one rule which defines a sentence as consisting of five words: an article, a noun, a verb, and again an article and a noun. word(article,a). word(article,every). word(noun,criminal). word(noun,’big kahuna burger’). word(verb,eats). word(verb,likes). sentence(Word1,Word2,Word3,Word4,Word5) :word(article,Word1), word(noun,Word2), word(verb,Word3), word(article,Word4), word(noun,Word5). What query do you have to pose in order to find out which sentences the grammar can generate? List all sentences that this grammar can generate in the order Prolog will generate them. Make sure that you understand why Prolog generates them in this order. a a a a a criminal criminal criminal criminal criminal eats a criminal eats a big kahuna burger eats every criminal eats every big kahuna burger likes a criminal
  • 4. a criminal likes a big kahuna burger a criminal likes every criminal a criminal likes every big kahuna burger a big kahuna burger eats a criminal a big kahuna burger eats a big kahuna burger a big kahuna burger eats every criminal a big kahuna burger eats every big kahuna burger a big kahuna burger likes a criminal a big kahuna burger likes a big kahuna burger a big kahuna burger likes every criminal a big kahuna burger likes every big kahuna burger every criminal eats a criminal every criminal eats a big kahuna burger every criminal eats every criminal every criminal eats every big kahuna burger every criminal likes a criminal every criminal likes a big kahuna burger every criminal likes every criminal every criminal likes every big kahuna burger every big kahuna burger eats a criminal every big kahuna burger eats a big kahuna burger every big kahuna burger eats every criminal every big kahuna burger eats every big kahuna burger every big kahuna burger likes a criminal every big kahuna burger likes a big kahuna burger every big kahuna burger likes every criminal every big kahuna burger likes every big kahuna burger 7. Write natural language sentences that represent what these Prolog facts might convey to a human reader. (Remember that, to the computer, these facts are simple pieces of information that can be used for matching answers to questions.) 1. likes(jeff, painting). 2. male(john). 3. building("Empire State Building", new_york). 4. person(roslin, jeanie, "1429 East Sutter St.", "Scotts Valley", "CA", 95066). Write Prolog programming exercises facts that represent the following natural language statements: Helen likes pizza. San Francisco is in California. Amy's telephone number is 476-0299. Len's father is Alphonso Grenaldi. 8. Write natural-language sentences corresponding to the following Prolog programming exercises rules: eats(Who, What):- food(What), likes(Who, What). pass_class(Who):- did_homework(Who), good_attendance(Who).
  • 5. does_not_eat(toby, Stuff):- food(Stuff), greasy(Stuff). owns(Who, What):- bought(Who, What). Write Prolog programming exercises rules that convey the meaning of these natural-language sentences: a. A person is hungry if that person's stomach is empty. b. Everybody likes a job if it's fun and it pays well. c. Sally likes french fries if they're cooked. d. Everybody owns a car who buys one, pays for it, and keeps it. 9. Create an elementary Prolog knowledge base, describing following relations: 1. 2. 3. 4. 5. John, Fred and Harry are men, Mary, Julie, Susan and Anne are women. John has blonde hair while Fred and Harry have dark hair. Julie and Susan are blonde, Mary and Anne are brunette. Rich is each person who owns the gold - Fred and Julie in our example. Male like only female and vice versa. Moreover, John and Harry like rich persons, John likes blonde and Fred likes brunette. 6. Both Mary and Julie like dark hair persons, Julie likes rich persons at the same time. 7. Anne owns a house and John owns a car. and ask it: a. Who is male ? b. Who does John like ? c. Who does Mary like ? d. Does Julie like anyone ? e. Is there a couple who like each other ? 10. What is the difference between the following two rules? ! blah :- a(X) , b(X). blah :- a(_) , b(_). 11. Towers of Hanoi The solution to the Towers of Hanoi puzzle is a classic example of recursion. The ancient puzzle of the Towers Of Hanoi consists of a number of wooden disks mounted on three poles, which are in turn attached to a baseboard. The disks each have
  • 6. different diameters and a hole in the middle large enough for the poles to pass through. In the beginning, all the disks are on the left pole as shown in: The object of the puzzle is to move all the disks over to the right pole, one at a time, so that they end up in the original order on that pole. You can use the middle pole as a temporary resting place for disks, but at no time is a larger disk to be on top of a smaller one. It's easy to solve the Towers of Hanoi with two or three disks, but the process becomes more difficult with four or more disks.
  • 7. 12. Hardware Simulation Every logical circuit can be described with a Visual Prolog predicate, where the predicate indicates the relationship between the signals on the input and output terminals of the circuit. The fundamental circuits are described by giving a table of corresponding truth values (see the and_, or_, and not_ predicates in Program 4). Fundamental circuits can be described by indicating the relationships between the internal connections, as well as the terminals. To see how this works, construct an exclusive OR circuit from AND, OR, and NOT circuits, and then check its operation with a Visual Prolog program. The circuit is shown in: