Question

Logic Programming An important type of programming language is designed to reason using the rules of predicate logic. Prologenrolled (kiko,math273) enrolled (kiko,cs301) (Lowercase letters have been used for entries because Prolog considers names beGiven the Prolog facts in the Example, what would Prolog return given these queries? a) ?instructor (chan, math273) b) ?instr

0 0
Add a comment Improve this question Transcribed image text
Answer #1

The answer is given below:

Fact:

instructor(chan,math273).
instructor(patel,ee222).
instructor(grossman,cs301).
enrolled(kevin,math273).
enrolled(juana,ee222).
enrolled(juana,cs301).
enrolled(kiko,math273).
enrolled(kiko,cs301).
teaches(P,S) :-instructor(P,C), enrolled(S,C).

The answer for queries is given below:

a)

instructor(chan,math273)

The output returned by above query is true because fact instructor(chan,math273) was provided as input.

It returns:

true

b)

instructor(patel,cs301)

The output returned by above query is false.

It returns:

false

c)

enrolled(X,cs301)

above query will return multiple answers juana and kiko because juana and kiko both enrolled in course cs301.

In query X is a variable, prolog will try to match expression enrolled(X,cs301) with facts from top to bottom and return answer.

it returns:

X = juana

X = kiko

d)

enrolled(kiko,Y)

above query will return multiple answers math273 and cs301 because kiko enrolled in course math273 and cs301.

In query Y is a variable, prolog will try to match expression enrolled(kiko,Y) with facts from top to bottom and return answer.

It returns:

Y = math273

Y = cs301

e)

teaches(grossman,Y)

above query will return multiple answers juana and kiko because professor grossman teaches to student juana and kiko.

In query Y is a variable, prolog will try to match expression teaches(grossman,Y) with facts from top to bottom and return answer.

It return:

Y = juana

Y = kiko

Add a comment
Know the answer?
Add Answer to:
Logic Programming An important type of programming language is designed to reason using the rules of...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT