diff --git a/PR03/prax03.pl b/PR03/prax03.pl new file mode 100755 index 0000000..83d6f57 --- /dev/null +++ b/PR03/prax03.pl @@ -0,0 +1,63 @@ +#!/usr/bin/swipl +married(marta, mart). +married(liisa, joosep). +married(anne, vello). + +mother(evelin,anne). +mother(mikk, anne). +mother(juku, anne). +mother(anne, liisa). +mother(mart, liisa). + +female(marta). +female(anne). +female(evelin). +female(liisa). + +male(vello). +male(mikk). +male(juku). +male(mart). + +father(Laps, Isa):- + mother(Laps, Ema), + married(Ema, Isa), + male(Isa). + +brother(Laps, Vend):- + mother(Laps, Ema), + mother(Vend, Ema), + Laps \= Vend, + male(Vend). + +sister(Laps, Ode):- + mother(Laps, Ema), + mother(Ode, Ema), + Laps \= Ode, + female(Ode). + +uncle(Laps, Uncle):- + (mother(Laps, Vanem); father(Laps, Vanem)), + brother(Vanem, Uncle). + +aunt(Laps, Aunt):- + (mother(Laps, Vanem); father(Laps, Vanem)), + sister(Vanem, Aunt). + +grandmother(Laps, GM):- + (mother(Laps, Vanem); father(Laps, Vanem)), + mother(Vanem, GM). + +grandfather(Laps, GF):- + (mother(Laps, Vanem); father(Laps, Vanem)), + father(Vanem, GF). + +ancestor(C, G):- mother(C, G). +ancestor(C, F):- father(C, F). +ancestor(C, G):- + (mother(C, Anc);father(C, Anc)), + ancestor(Anc, G). + + +male_ancestor(C, A):- ancestor(C, A), male(A). +female_ancestor(C, A):- ancestor(C, A), female(A).