0
votes

I need a help for create this rule in Prolog.

This is the question: Create fact and rule for Prolog.

  • burger is a food.
  • sandwich is a food.
  • pizza is a food.
  • sandwich is a lunch.
  • pizza is a dinner.
  • every food is a meal OR Anything is a meal if it is a food.

ps. it's not homework, it's myself assignment i want know how to create this rule correctly.

food(burger).
food(sandwich).
lunch(sandwich).

dinner(pizza).

meal(X) :- food(X) ; ...
1
every food is a meal and Anything is a meal if it is a food. say the same thing.lurker

1 Answers

1
votes

First, translate the English sentences to first-order logic sentences.

every food is a meal
=> forall X (food(X) -> meal(X))
anything is a meal if it is a food
=> if it is a food, it is a meal
=> if X is a food, X is a meal
=> forall X (food(X) -> meal(X))

Then, translate the first-order logic sentences to Prolog Horn clauses:

meal(X) :- food(X).
meal(X) :- food(X).

which is redundant and can be written just once instead.