You are on page 1of 3

Prolog

Step 1. Code the following knowledge base about local restaurants in Prolog:

serves predicate:

american restaurants serve


salad, steak, sandwiches, burgers, and fried chicken.

burger_place restaurants serve


burgers, fries, and onion_rings.

chinese restaurants serve


eggrolls, rice, shrimp, soup, and noodles.

indian restaurants serve


papadam, bagan_bharta, rice, tandoori, and naan.

italian restaurants serve


salad, pasta, cioppino, snapper, bread, and garlic_bread.

japanese restaurants serve


sashimi, rice, tempura, and noodles.

mediterranean restaurants serve


gyros, hummus, pita, and falafel.

mexican restaurants serve


tacos, beans, rice, enchiladas, and fish_tacos.

pizza_place restaurants serve


pizza, salad, garlic_bread

thai restaurants serve


rice, noodles, larb, and pad_thai.

Note: There are two ways in which you can define a predicate such as serves. One on hand, you
can enumerate each relationship:

serves(american, salad).

serves(american, steak).

serves(american, sandwiches).

A more concise way is to use lists in an auxiliary predicate, in conjunction with the built-in
member predicate which enumerates the relationships.

servesAll(american, [salad, steak, sandwiches, burgers, fried_chicken]).

serves(Kind, Dish) :- servesAll(Kind, Dishes), member(Dish, Dishes).


dish predicate:

vegetarian dishes:
beans, bagan_bharta, enchiladas, falafel, hummus,
pizza, salad, soup, tempura, onion_rings, and all starch dishes

meat dishes:
burgers, enchiladas, gyros, pad_thai, pizza, steak, sandwiches,
fried_chicken, tacos, tandoori, larb

seafood dishes:
snapper, cioppino, sashimi, shrimp, clams, fish_tacos, tempura

starch dishes:
naan, papadam, bread, rice, noodles, pita, garlic_bread, pasta, fries

cuisine and location predicate:

yans is a chinese restaurant on thayer_street.


pizza_marvin is a pizza_place restaurant on fox_point.
bajas is a mexican restaurant on thayer_street.
andreas is a mediterranean restaurant on thayer_street.
chinatown is a chinese restaurant on thayer_street.
kabob_n_curry is an indian restaurant on thayer_street.
waterman_grille is an american restaurant in wayland.
dolores is a mexican restaurant in fox_point.
tallulahs is a mexican restaurant in fox_point.
red_stripe is an american restaurant in wayland.
pasta_beach is an italian restaurant in wayland.
haruki is a japanese restaurant in wayland.
heng is a thai restaurant on thayer_street.
mikes is a pizza_place restaurant on thayer_street.
east_side_pocokets is a mediterranean restaurant on thayer_street.
bees is a thai restaurant in fox_point.
shake_shack is a burger_place restaurant on thayer_street.
al_forno is an italian restaurant in fox_point.
lims is a thai restaurant in wayland.
Step 2.

Use single Prolog queries to answer the following questions. In some cases, you may find it
helpful to define auxiliary predicates to assist.

1. Which restaurants are in wayland?

2. Which restaurants have italian cuisine?

3. Which kind of restaurants serve snapper?

4. Which kinds of restaurants serves rice ?

5. Where can you get served a vegetarian dish in fox_point?

Harder (Optional)

6. Which restaurants serve both vegetarian and meat dishes?

7. Which areas have both a chinese restaurant and a mexican restaurant?

8. Which restaurants on thayer_street or in wayland serve meat dishes?

9. Which restaurants in wayland don't serve bread?

10. Which areas have more than one restaurant of some type of cuisine?

11. Which areas have more than one restaurant serving noodles?

You might also like