2.1 Create facts for the entres: entre(X, Y) where X is the occasion and Y is th
ID: 3821612 • Letter: 2
Question
2.1 Create facts for the entres: entre(X, Y) where X is the occasion and Y is the entre.
Create facts for the side: side(X, Y) where X is the occasion and Y is the side.
Create facts for the ingredients : ingredient(X, Y) where X is the side and Y is the ingredient. [5]
2.2 Create a rule meal(X, Y) where X is the occasion and Y is the food that will be served. For example, meal(thanksgiving, X) should return turkey, bread, and pumpkinpie. [5]
2.3 Create a rule shoppinglist(X, Y) where X is the occasion and Y is the ingredient needed. For example, shoppinglist(thanksgiving, X) should return egg, flour, pumpkin, and pie. [5]
Consider the following database that will be used to determine meals for halloween and thanksgiving with the ingredients needed for the given sides. [15 points halloween thanksgiving entree: chocolate entre: turkey sides sides bread candy sugar egg foodcoloring four soda pumpkinpie pumpkin Water pieExplanation / Answer
2.1 A fact must start with a predicate (which is an atom) and end with a fullstop.
#1: entre(halloween,chocolate)
entre(thanksgiving,turkey)
#2: side(halloween,candy)
side(halloween,soda)
side(thanksgiving,bread)
side(thanksgiving,pumpkinpie)
#3: ingredient(candy,sugar)
ingredient(candy,foodcoloring)
ingredient(soda,water)
ingredient(soda,syrup)
ingredient(bread,egg)
ingredient(bread,floor)
ingredient(pumpkinpie,pumpkin)
ingredient(pumpkinpie,pie)
===============================================================================
2.2: meal(X,Y):- entre(X,Y)
meal(X,Y):- side(X,Y)
Any pair will fall in meal if either it belongs to side or entre.
==================================================================================
2.3: shoppinglist(X,Y):- meal(X,Z) , ingredient(Z,Y)
Description: Any pair will be valid in shopping list, if that ingredient belongs to a meal for that occasion.
Comma here denotes the logical AND operator
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.