程序错误1010 Prolog

时间:2015-04-28 10:30:29

标签: visual-prolog

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。

1 个答案:

答案 0 :(得分: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