Question

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

#### Earn Coins

Coins can be redeemed for fabulous gifts.