NEED THIS PROGRAM IN PROLOG The program must include the following rules. 1. A b
ID: 3579245 • Letter: N
Question
NEED THIS PROGRAM IN PROLOG
The program must include the following rules.
1. A bird has wings and can fly. Write this rule such that bird(X) is a goal.
2. A fish has fins and can swim. Write this rule such that fish(X) is a goal.
Enter the following facts in your program
· Carp, Eel, Brill and Angelfish have fins.
· Penguin, Eagle, Peacock and Cardinal have wings.
· Carp and Brill can swim
· Eagle and Cardinal can fly.
Now, ask the following questions/queries:
Do penguins fly?
Is Carp a bird?
Is Carp a fish?
Is Eagle a bird?
Is Cardinal a bird?
Explanation / Answer
Please find below the two program written in prolog:
1.
flies(Eagle).
flies(Cardinal).
haswings(Penguin).
haswings(Eagle).
haswings(Peacock),
haswings(Cardinal).
bird(X) :- flies(X), hasfeathers(X).
2.
swims(Carp)
swims(Brill)
hasfins(Carp)
hasfins(Eel)
hasfins(Angelfish)
fish(X) :- swims(X), hasfins(X).
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.