简体   繁体   中英

Error in PROLOG program

In the code below, i'm getting error in sister function that "Illegal character" in **

Blockquote

Person \\= P1** (\\= is for not equal to)

Blockquote

DOMAINS Person = SYMBOL

PREDICATES parent(Person,Person) female(Person) male(Person) mother(Person,Person) father(Person,Person) grandfather(Person,Person) grandmother(Person,Person) sister(Person,Person)

CLAUSES female(merry). female(syndra). female(juliet). female(lisa).

male(parker).
male(peter).
male(herry).
male(bob).
male(paul).

parent(juliet,lisa).
parent(bob,lisa).
parent(bob,paul).
parent(bob,merry).

parent(juliet,paul).
parent(juliet,merry).
parent(peter,herry).
parent(lisa,herry).
parent(merry,parker).
parent(merry,syndra).

father(X,Person):-parent(X,Person) , male(X).
mother(X,Person):-parent(X,Person) , female(X).

grandfather(X,Person):-parent(Y,Person),father(X,Y).
grandmother(X,Person):-parent(Y,Person),mother(X,Y).

sister(X,Person):-parent(Z,X),parent(Z,Person),Person \= P1,female(Person).

not sure about, and I can't try because I don't have Turbo Prolog right now, but I vaguely remember that Variables doesn't need to be declared.

And I suspect that Child should be Person instead (after all, a Child is a Person). Try to simplify in this way

DOMAINS

Person = SYMBOL

PREDICATES

parent(Person,Person)
female(Person)
male(Person)
mother(Person,Person)
...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM