Question

PROLOG Exercise 7 Consider the following program. a(X):- b(X), c(X), d(X). a(X):- c(X), d(X). a(X):- d(X)....

PROLOG

Exercise 7

Consider the following program.

a(X):- b(X), c(X), d(X).

a(X):- c(X), d(X).

a(X):- d(X).

b(1).

b(a).

b(2).

b(3).

d(10).

d(11).

c(3).

c(4).

Given the query ?- a(X). Write out the variable bindings that the variable X would get when the above query is run.

Exercise 4

Indicate whether the following are syntactically correct Rules.

a :- b, c, d:- e f. % Is this syntactically correct?

happy(X):- a , b. % Is this syntactically correct?

happy(X):- hasmoney(X) & has_friends(X). % Is this syntactically correct?

fun(fish):- blue(betty), bike(yamaha). % Is this syntactically correct?

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

Exercise 4

Answer

NO
YES
NO
YES

Explanation

a :- b, c, d:- e f.Is this syntactically correct?

NO

first note there is comma missing in between e and f

--

happy(X):- a , b.

YES

rule is syntactically correct
but look at the X
X is not at all used with in the body of rule

--

happy(X):- hasmoney(X) & has_friends(X).

NO

Please note that the & symbol will not recognized by prolog
You can use comma instead of that

--

fun(fish):- blue(betty), bike(yamaha)

YES

Syntactically correct

even though there is no meaning

--

all the best

Add a comment
Know the answer?
Add Answer to:
PROLOG Exercise 7 Consider the following program. a(X):- b(X), c(X), d(X). a(X):- c(X), d(X). a(X):- d(X)....
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