I am doing a prolog question and need to make a single predicate (a rule) for grandfather/2 and grandmother/2 that uses the pre-existing father/2 mother/2 facts. I have got the rest of it working for example:
male(philip).
male(charles).
male(andrew).
male(william).
.....
female(diana).
female(camilla).
female(meghan).
female(kate).
....
married(charles, camilla).
married(harry, meghan).
married(mark, anne).
married(mike, zara).
....
father(philip, charles).
father(philip, andrew).
father(william, george).
father(william, charlotte).
....
mother(elizabeth, charles).
mother(kate, gerge).
mother(anne, zara).
mother(diana, william).
I've been stuck on getting the grandfather/2 and grandmother/2 bit to work for a while now, just wondering if anyone can help me, Thanks :).
grandfather(X, Y) :- father(X, Z), father(Z, Y). grandfather(X, Y) :- father(X, Z), mother(Z, Y).
- Brody2019grandfather(philip,X) - to see who Philip is a grandfather to. grandfather(X,charlotte) - to see who Charlotte's grandfather is.
I dont get anything back. - Brody2019