Reputation: 1
I need a help for create this rule in Prolog.
This is the question: Create fact and rule for Prolog.
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) ; ...
Upvotes: 0
Views: 231
Reputation: 91
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.
Upvotes: 1