Search code examples
prologfirst-order-logic

first order logic & prolog


I am trying to understand how prolog represent first order logic. how can I represent for example, in a list of types of animals:

dog(spot).

cat(nyny).

fly(harry)

that all animals are mammals or insect?


Solution

  • I think what you're referring to is just the following:

    mammal(X) :- dog(X).
    mammal(X) :- cat(X).
    insect(X) :- fly(X).
    

    That is, a mammal is either something that is a dog or a cat. You have to explicitly specify the categories that fall into that mammal category. Same for insects.

    Connecting this with your first-order logic question, the first entries of mammal would read: for every X where X is a dog, X is also a mammal (same for cat), and so on.