aussage(a).
aussage(e).
aussage(i).
aussage(o).

affirmativ(a).
affirmativ(i).
negativ(e).
negativ(o).

universell(subjekt, a).
universell(_, e).
universell(praedikat, o).

partikulaer(praedikat, a).
partikulaer(_, i).
partikulaer(subjekt, o).

figur(1).
figur(2).
figur(3).
figur(4).

mitte(1, maior, subjekt).
mitte(1, minor, praedikat).

mitte(2, _, praedikat).

mitte(3, _, subjekt).

mitte(4, maior, praedikat).
mitte(4, minor, subjekt).

anderer_term(subjekt, praedikat).
anderer_term(praedikat, subjekt). 

syllogismus(F, X, Y, Z) :- figur(F),
  aussage(X), aussage(Y), aussage(Z),
  legal(F, X, Y, Z).

legal(F, X, Y, Z) :-
  mitte(F, maior, U), partikulaer(U, X),
  mitte(F, minor, V), partikulaer(V, Y), !, fail.

legal(F, X, Y, Z) :-
  mitte(F, maior, U), anderer_term(U, V),
  partikulaer(V, X), universell(praedikat, Z), !, fail.

legal(F, X, Y, Z) :-
  mitte(F, minor, U), anderer_term(U, V),
  partikulaer(V, Y), universell(subjekt, Z), !, fail.

legal(F, X, Y, Z) :-
  affirmativ(X), affirmativ(Y), negativ(Z), !, fail.

legal(F, X, Y, Z) :-
  negativ(X), affirmativ(Z), !, fail.

legal(F, X, Y, Z) :-
  negativ(Y), affirmativ(Z), !, fail.

legal(F, X, Y, Z) :-
  negativ(X), negativ(Y), !, fail.

legal(F, X, Y, Z) :- true.


?- syllogismus(F, X, Y, Z), 
   writef("Figur "), write(F), writef(": "),
   write(X), writef("-"), write(Y), writef("-"),
   write(Z), nl, fail. 



