# 21.2 Syllogisms in Prolog: Answer

## Answer for "Syllogisms in Prolog"

The program could look like this:

```syll(   all(M,P),
all(S,M),
all(S,P)).
// This is barbara in the 1st figure.

syll(   no(M,P),
all(S,M),
no(S,P)).
// This is celarent in the 1st figure.

syll(   all(M,P),
some(S,M),
some(S,P)).
// This is darii in the 1st figure.

syll(   no(M,P),
some(S,M),
some_not(S,P)).
// This is ferio in the 1st figure.

syll(   all(M,P),
all(S,M),
some(S,P)).
// This is barbarix in the 1st figure.

syll(   no(M,P),
all(S,M),
some_not(S,P)).
// This is feraxo in the 1st figure.

syll(   no(P,M),
all(S,M),
no(S,P)).
// This is cesare in the 2nd figure.

syll(   all(P,M),
no(S,M),
no(S,P)).
// This is camestres in the 2nd figure.

syll(   no(P,M),
some(S,M),
some_not(S,P)).
// This is festino in the 2nd figure.

syll(   all(P,M),
some_not(S,M),
some_not(S,P)).
// This is baroco in the 2nd figure.

syll(   all(P,M),
no(S,M),
some_not(S,P)).
// This is camestrop in the 2nd figure.

syll(   all(P,M),
some_not(S,M),
some_not(S,P)).
// This is cesarox in the 2nd figure.

syll(   all(M,P),
all(M,S),
some(S,P)).
// This is darapti in the 3rd figure.

syll(   some(M,P),
all(M,S),
some(S,P)).
// This is disamis in the 3rd figure.

syll(   all(M,P),
some(M,S),
some(S,P)).
// This is datisi in the 3rd figure.

syll(   no(M,P),
all(M,S),
some_not(S,P)).
// This is felapton in the 3rd figure.

syll(   some_not(M,P),
all(M,S),
some_not(S,P)).
// This is bocardo in the 3rd figure.

syll(   no(M,P),
some(M,S),
some_not(S,P)).
// This is ferison in the 3rd figure.

syll(   all(P,M),
all(M,S),
some(S,P)).
// This is bramantip in the 4th figure.

syll(   all(P,M),
no(M,S),
no(S,P)).
// This is camenes in the 4th figure.

syll(   some(P,M),
all(M,S),
some(S,P)).
// This is dimaris in the 4th figure.

syll(   no(P,M),
all(M,S),
some_not(S,P)).
// This is fesapo in the 4th figure.

syll(   no(P,M),
some(M,S),
some_not(S,P)).
// This is fresison in the 4th figure.

syll(   no(P,M),
some(M,S),
some_not(S,P)).
// This is camenop in the 4th figure.

deduction(P1,P2,C):- syll(P1,P2,C).
deduction(P1,P2,C):- syll(P2,P1,C).

```

The suggested way of encoding the syllogisms are as follows:

• Some dogs are not cat-haters
• All dogs are mammals
```?- deduction(some_not(dogs, cat_hater), all(dogs, mammals), C).

{C = some_not(mammals, cat_hater)}
```
• Therefore: Some mammals are not cat-haters.

• All dogs are canines
• All canines are mammals
```?- deduction(all(dogs, canines), all(canines, mammals), C).

{C = some(mammals, dogs)}
{C = all(dogs, mammals)}
{C = some(dogs, mammals)}
```
• Therefore: Some mammals are dogs, all dogs are mammals, and some dogs are mammals.

• All dogs are dependent on people
• No cats are dependent on people
```?- deduction(all(dogs, dependent_on_people),
no(cats, dependent_on_people), C).

{C = no(cats, dogs)}
{C = some_not(cats, dogs)}
{C = no(dogs, cats)}
```
• Therefore: No cats are dogs, some cats are not dogs, no dogs are cats.

• Some bears are animals of very little brain
• All animals of very little brain are humble animals
```?- deduction(some(bears, animals_of_very_little_brain),
all(animals_of_very_little_brain, humble_animals), C).

{C = some(humble_animals, bears)}
{C = some(bears, humble_animals)}
```
• Therefore: Some humble animals are bears, and some bears are humble animals.

(For those that are wondering: Winnie-the-Pooh always refers to himself as a "Bear of very little brain", and he is certainly humble.)

Prev: 21 Syllogisms
Up: 21 Syllogisms
Next: 22 A Murder Mystery