kass(miisu). kass(tipi). koer(muki). koer(muri). emane(miisu). emane(muki). lemmikloom(X):- kass(X); koer(X). isane(X):- \+emane(X). ____ kass(miisu). kass(tipi). koer(muki). koer(muri). emane(miisu). emane(muki). lemmikloom(X):- kass(X); koer(X). isane(X):- \+emane(X). 1 kass(miisu). 2 kass(tipi). 3 ​ 4 koer(muki). 5 koer(muri). 6 ​ 7 emane(miisu). 8 emane(muki). 9 ​ 10 lemmikloom(X):- 11 kass(X); koer(X). 12 ​ 13 isane(X):- 14 \+emane(X). kass(X). X = miisu X = tipi koer(X). X = muki X = muri lemmikloom(X). X = miisu X = tipi X = muki X = muri lemmikloom(X), emane(X). X = miisu X = muki lemmikloom(X), isane(X). X = tipi X = muri _________ laps(toomas, jaagup). laps(paula, jaagup). laps(jaagup, pille). laps(jaagup, vello). laps(pille, aleksander). naine(pille). naine(paula). lapselaps(A, B):- laps(A, X), laps(X, B). inimene(X):- laps(X, _); laps(_, X). koikinimesed(Isik):- setof(X, inimene(X), Y), member(Isik, Y). %leidke kõik vanaisad vanaisa(A, B):- laps(A, X), laps(X, B), mees(B). vanaisa(B):- vanaisa(_, B). koikvanaisad(Isik):- setof(X, vanaisa(X), Y), member(Isik, Y). vanaisa2(C):- laps(_, X), laps(X, B), setof(B, mees(B), Hulk), member(C, Hulk). vanaisa3(C):- setof(B, vanaisa(_, B), Y), member(C, Y). %defineerige funktsioon meeste leidmiseks mees(X):- \+naine(X). %kuvage kõik mehed mehed(X):- koikinimesed(X), mees(X). ____ laps(X, jaagup). X = toomas X = paula laps(X, _). X = toomas X = paula lapselaps(X, Y). X = toomas, Y = pille X = toomas, Y = vello X = paula, Y = pille X = paula, Y = vello inimene(X). X = toomas X = paula X = jaagup X = jaagup X = jaagup X = jaagup X = pille X = vello inimene(X), mees(X). X = toomas X = jaagup X = jaagup X = jaagup X = jaagup X = vello koikinimesed(X, Y). Syntax error: Operator priority clash procedure `koikinimesed(A,B)' does not exist koikinimesed(X, Y). Y = [jaagup, paula, pille, toomas, vello] koikinimesed(Y). Y = [jaagup, paula, pille, toomas, vello] member(X, koikinimesed(Y)). false koikinimesed(Y), member(X, Y). X = jaagup, Y = [jaagup, paula, pille, toomas, vello] X = paula, Y = [jaagup, paula, pille, toomas, vello] X = pille, Y = [jaagup, paula, pille, toomas, vello] X = toomas, Y = [jaagup, paula, pille, toomas, vello] X = vello, Y = [jaagup, paula, pille, toomas, vello] koikinimesed(A). A = jaagup A = paula A = pille A = toomas A = vello mehed(A). A = jaagup A = toomas A = vello vanaisa(A, B). A = toomas, B = vello A = paula, B = vello A = jaagup, B = aleksander false vanaisa(_, B). B = vello B = vello B = aleksander false vanaisa(B). Singleton variables: [A] B = vello vanaisa(B). B = vello B = vello B = aleksander vanaisa2(B). B = vello B = vello B = aleksander vanaisa(A, B), setof(B, B, Y), member(Isik, Y). Sandbox restriction! Could not derive which predicate may be called from setof(C,C,D) setof(B, vanaisa(A, B), Y), member(Isik, Y). A = jaagup, Isik = aleksander, Y = [aleksander] A = paula, Isik = vello, Y = [vello] A = toomas, Isik = vello, Y = [vello] vanaisa3(C). 0: Syntax error: Operator expected procedure `vanaisa3(A)' does not exist vanaisa3(C). Singleton variables: [A] C = aleksander C = vello C = vello vanaisa3(C). C = aleksander C = vello C = vello vanaisa(C). Singleton variables: [A] C = vello vanaisa(C). C = vello C = vello C = aleksander koikvanaisad(C). C = aleksander C = vello koikvanaisad(C). C = aleksander C = vello C = vello koikvanaisad(C). C = aleksander C = vello setof(X, vanaisa(X), Y), member(Isik, Y). Isik = aleksander, Y = [aleksander, vello] Isik = vello, Y = [aleksander, vello] setof(X, vanaisa(_, X), Y), member(Isik, Y). Isik = aleksander, Y = [aleksander] Isik = vello, Y = [vello] Isik = vello, Y = [vello] ____ laps(toomas, jaagup). laps(paula, jaagup). laps(toomas, kaire). laps(paula, kaire). laps(jaagup, pille). laps(jaagup, vello). laps(pille, aleksander). laps(viivi, aleksander). naine(pille). naine(paula). naine(kaire). mees(X):- \+naine(X). sugulus1(A, B, ):- laps(A, B), naine(B), Kuidas=ema. sugulus1(A, B, Kuidas):- laps(A, B), mees(B), Kuidas=isa. %kuvage sugulus õeks olemise kohta sugulus1(A, B, Kuidas):- laps(A, X), laps(B, X), naine(B), A\=B, Kuidas=ode, !. ____________ :- use_module(library(clpfd)). arvuta1(A, B):- between(1, 9, A), B is A+2. %küsige käsu abil korrutustabelist tehteid korruta(A, B, C):- between(1, 9, A), between(1, 9, B), C is A * B. tabel1(A, B, C, D, E, F, G, H):- between(1, 20, A), between(1, 20, B), between(1, 20, C), between(1, 20, D), H is A + B, G is C + D, E is A + C, F is B + D. %between(1, 100, A), C=[A, 3], sumlist(C, V), V=7. %between(1, 100, A), between(1, 100, B), % C=[A, 3, B], sumlist(C, V), V=7. %Loetelu=[[1, 2], [3, 4]], length(Loetelu, X), transpose(Loetelu, Vastus). reasummad(L, V):- member(Rida, L), findall(Summa, sumlist(Rida, Summa), V).