0
PREDICATES

nondeterm male(symbol)
nondeterm female(symbol)
nondeterm wife(symbol,symbol)

nondeterm mother(symbol,symbol)
nondeterm father(symbol,symbol)
nondeterm brother(symbol,symbol)
nondeterm sister(symbol,symbol)
nondeterm sonInLaw(symbol,symbol)
nondeterm brotherInLaw(symbol,symbol)
nondeterm uncle(symbol,symbol)
nondeterm sibling(symbol,symbol)
nondeterm grandson(symbol,symbol)
nondeterm grandfather(symbol,symbol)

Clauses

male(mark).
male(ahmed).
male(zeeshan).
male(summer).

female(sara).
female(sana).

wife(sara,mark).
wife(sana,ahmed).

mother(X,Y):-female(X),father(Z,Y),wife(X,Z),X<>Y.
mother(sara,sana).

father(X,Y):-male(X),mother(Z,Y),wife(Z,X),X<>Y.

brother(X,Y):-male(X),father(Z,X),father(Z,Y),X<>Y.

sister(X,Y):-female(X),father(Z,X),father(Z,Y),X<>Y.

sonInLaw(X,Y):-male(X),father(Y,Z),wife(Z,X) ; male(X),mother(Y,Z),wife(Z,X),X<>Y.

brotherInLaw(X,Y):-male(X),sister(Z,X),wife(Z,Y).

sibling(X,Y):-brother(X,Y);sister(X,Y),X<>Y.

uncle(X,Y):- sibling(X,Z),father(Z,Y),X<>Y.

grandfather(X,Y):- father(X,Z), father(Z,Y);father(X,Z), mother(Z,Y),X<>Y.

grandson(X,Y):- father(Z,X), father(Y,Z);father(Z,X), mother(Y,Z),X<>Y.

Goal

uncle(mark,sana).

Prolog でエラー 1010 が表示されます。

4

1 に答える 1

0

これは動作するはずです WIP7 ではこれが動作します

class predicates
    male:(symbol) procedure (x).
    female:(symbol) procedure (x).
    wife:(symbol,symbol)  procedure (x,y).
    mother:(symbol,symbol)  procedure (x,y).
    father:(symbol,symbol)  procedure (x,y).
    brother:(symbol,symbol)  procedure (x,y).
    sister:(symbol,symbol)  procedure (x,y).
    sonInLaw:(symbol,symbol)  procedure (x,y).
    brotherInLaw:(symbol,symbol)  procedure (x,y).
    uncle:(symbol,symbol)  procedure (x,y).
    sibling:(symbol,symbol)  procedure (x,y).
    grandson:(symbol,symbol)  procedure (x,y).
    grandfather:(symbol,symbol)  procedure (x,y).

clauses
    male(mark).
    male(ahmed).
    male(zeeshan).
    male(summer).

    female(sara).
    female(sana).

    wife(sara,mark).
    wife(sana,ahmed).

    mother(X,Y):-female(X),father(Z,Y),wife(X,Z),X<>Y.
    mother(sara,sana).

    father(X,Y):-male(X),mother(Z,Y),wife(Z,X),X<>Y.

    brother(X,Y):-male(X),father(Z,X),father(Z,Y),X<>Y.

    sister(X,Y):-female(X),father(Z,X),father(Z,Y),X<>Y.

    sonInLaw(X,Y):-male(X),father(Y,Z),wife(Z,X);male(X),mother(Y,Z), wife(Z,X),X<>Y.

    brotherInLaw(X,Y):-male(X),sister(Z,X),wife(Z,Y).

    sibling(X,Y):-brother(X,Y);sister(X,Y),X<>Y.

    uncle(X,Y):- sibling(X,Z),father(Z,Y),X<>Y.

    grandfather(X,Y):-father(X,Z),father(Z,Y);father(X,Z),mother(Z,Y), X<>Y.

    grandson(X,Y):- father(Z,X), father(Y,Z);father(Z,X), mother(Y,Z),X<>Y.
clauses
    run():-
        console::init(),
    uncle(mark,sana),
    programControl::sleep(1000).

VIP 5.1で入れられると思います

check_determ
于 2015-04-28T13:24:11.083 に答える