expensive(chevrolet). safe(chevrolet). safe(volvo). nice(porsche). fast(porsche). neg buy(X) :- name(e(X)), not buy(X), expensive(X). % (1) buy(X) :- name(s(X)), not neg buy(X), safe(X). % (2) buy(X) :- name(n(X)), not neg buy(X), nice(X). % (3) buy(X) :- name(f(X)), not neg buy(X), fast(X). % (4) neg buy(Y) :- name(sp(X,Y)), safe(X), buy(X), neq(X,Y). % (2') neg buy(Y) :- name(np(X,Y)), nice(X), buy(X), neq(X,Y). % (3') neg buy(Y) :- name(fp(X,Y)), fast(X), buy(X), neq(X,Y). % (4') buy(X) :- name(x1(X)), % (1.5) not neg buy(X), not neg safe(X), nice(X), fast(X). neg buy(Y) :- name(x2(X,Y)), % (1.5') not neg safe(X), nice(X), fast(X), buy(X), neq(X,Y). x1(X) < e(X1). x2(X,Y) < e(X1). s(X) < x1(X1). sp(X,Y) < x1(X1). s(X) < x2(X1,Y1). sp(X,Y) < x2(X1,Y1). n(X) < s(X1). np(X,Y) < s(X1). n(X) < sp(X1,Y1). np(X,Y) < sp(X1,Y1). f(X) < n(X1). fp(X,Y) < n(X1). f(X) < np(X1,Y1). fp(X,Y) < np(X1,Y1). neq(chevrolet,volvo). neq(chevrolet,porsche). neq(volvo,chevrolet). neq(volvo,porsche). neq(porsche,chevrolet). neq(porsche,volvo).