lauraberishaj
Programmer
Hi everybody
I have a problem!
I have a file of prolog which I need to extend with some code.
----------------------------------
woman(anna).
woman(mia).
woman(eva).
woman(maja).
woman(nora).
woman(kim).
woman(elfrida).
woman(ana).
man(john).
man(peter).
man(erik).
man(ben).
man(ed).
man(bill).
man(bull).
man(bert).
man(bob).
man(ari).
man(magnus).
happy(anna).
happy(john).
tall(erik).
loves(john,mia).
loves(peter,mia).
loves(erik,eva).
loves(erik,erik).
loves(eva,erik).
married(erik,eva).
married(mia,peter).
married(bill,maja).
childTo(erik, mia, peter).
childTo(eva, ed, elfrida).
childTo(bill, mia, peter).
childTo(maja, bob, ana).
childTo(ben, bob, ana).
childTo(kim, mia, bob).
childTo(nora, mia, peter).
childTo(anna, erik, eva).
childTo(john, eva, erik).
childTo(bull, bill, maja).
childTo(bert, bill, maja).
childTo(ari, ben, kim).
childTo(magnus, ben, nora).
jealous(X,Y) :-
loves(X,Z),loves(Y,Z),
X\==Y,
\+ happy(X)
.
playsAirGuitar(jody).
playsAirGuitar(X) :-
listensToMusic(X),
happy(X)
.
listensToMusic(mia).
listensToMusic(X) :-
(
woman(X) ;
tall(X), man(X)
)
.
---------------------------
Now I need to add for example :
1. person(P): P is an existing person in the database
2.fatherTo(A,B): A is the father to B
3. father(A): A is a father.
4. siblings(A,B): A and B are siblings (both parents in common)
5. halfSiblings(A,B): A and B are half siblings (only one parent in common)
6. cousins(A,B): A and B are cousins
7. grandmotherTo(A,B): A is a grandmother to B
8. noChildren(A): A has no children
9. ancestor(F,CS,N): F is the ancestor of the people in the list CS and N is the length of CS.
I hope someone can help me, and I would appriciate your help.
Thank You,
Laura
I have a problem!
I have a file of prolog which I need to extend with some code.
----------------------------------
woman(anna).
woman(mia).
woman(eva).
woman(maja).
woman(nora).
woman(kim).
woman(elfrida).
woman(ana).
man(john).
man(peter).
man(erik).
man(ben).
man(ed).
man(bill).
man(bull).
man(bert).
man(bob).
man(ari).
man(magnus).
happy(anna).
happy(john).
tall(erik).
loves(john,mia).
loves(peter,mia).
loves(erik,eva).
loves(erik,erik).
loves(eva,erik).
married(erik,eva).
married(mia,peter).
married(bill,maja).
childTo(erik, mia, peter).
childTo(eva, ed, elfrida).
childTo(bill, mia, peter).
childTo(maja, bob, ana).
childTo(ben, bob, ana).
childTo(kim, mia, bob).
childTo(nora, mia, peter).
childTo(anna, erik, eva).
childTo(john, eva, erik).
childTo(bull, bill, maja).
childTo(bert, bill, maja).
childTo(ari, ben, kim).
childTo(magnus, ben, nora).
jealous(X,Y) :-
loves(X,Z),loves(Y,Z),
X\==Y,
\+ happy(X)
.
playsAirGuitar(jody).
playsAirGuitar(X) :-
listensToMusic(X),
happy(X)
.
listensToMusic(mia).
listensToMusic(X) :-
(
woman(X) ;
tall(X), man(X)
)
.
---------------------------
Now I need to add for example :
1. person(P): P is an existing person in the database
2.fatherTo(A,B): A is the father to B
3. father(A): A is a father.
4. siblings(A,B): A and B are siblings (both parents in common)
5. halfSiblings(A,B): A and B are half siblings (only one parent in common)
6. cousins(A,B): A and B are cousins
7. grandmotherTo(A,B): A is a grandmother to B
8. noChildren(A): A has no children
9. ancestor(F,CS,N): F is the ancestor of the people in the list CS and N is the length of CS.
I hope someone can help me, and I would appriciate your help.
Thank You,
Laura