Advertisement
Guest User

Untitled

a guest
Feb 18th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. parent(ojciec, syn1).
  2. parent(matka, corka1).
  3. parent(matka, corka2).
  4. parent(matka, syn1).
  5. parent(dziadek, matka).
  6. man(ojciec).
  7. man(dziadek).
  8. man(syn1).
  9. woman(matka).
  10. woman(corka1).
  11. woman(corka2).
  12.  
  13. ismother(X) :-
  14. woman(X), parent(X, _).
  15.  
  16. isfather(X) :-
  17. man(X), parent(X, _).
  18.  
  19. isson(X) :-
  20. man(X), parent(_, X).
  21.  
  22. aresisters(X, Y) :-
  23. woman(X), woman(Y), X \= Y, parent(Z, X), parent(Z, Y).
  24.  
  25. isgrandpaof(X, Y) :-
  26. man(X), parent(X, Z), parent(Z, Y).
  27.  
  28. aresiblings(X, Y) :-
  29. X \= Y, parent(Z, X), parent(Z, Y).
  30.  
  31.  
  32.  
  33. on(b1, b4).
  34. on(b4, b3).
  35.  
  36. above(X, Y) :- on(X, Y).
  37.  
  38. above(X, Y) :-
  39. on(X, Z),
  40. above(Z, Y).
  41.  
  42.  
  43. onleft(eggtimer, pencil).
  44. onleft(butterfly, eggtimer).
  45. onleft(fish, butterfly).
  46. ontop(pencil, bicycle).
  47. ontop(butterfly, camera).
  48.  
  49. moreleftedfrom(X, Y) :- onleft(X, Y).
  50.  
  51. moreleftedfrom(X, Y) :-
  52. onleft(X, Z),
  53. moreleftedfrom(Z, Y).
  54.  
  55. morerightedfrom(X, Y) :- moreleftedfrom(Y, X).
  56.  
  57. higherthan(X, Y) :- ontop(X, Y).
  58.  
  59. higherthan(X, Y) :-
  60. ontop(X, Z),
  61. higherthan(Z, Y).
  62.  
  63. belowthan(X, Y) :- higherthan(Y, X).
  64.  
  65. higher(X, Y) :-
  66. higherthan(Z, Y),
  67. (moreleftedfrom(X, Z); morerightedfrom(X, Z)).
  68.  
  69.  
  70. le(1,5).
  71. le(1,7).
  72. le(5,35).
  73. le(7,35).
  74. le(7,14).
  75.  
  76.  
  77. wiekszyod(X,Y) :- le(X,Y).
  78.  
  79. wiekszyod(X, Y) :-
  80. le(X, Z),
  81. wiekszyod(Z, Y).
  82.  
  83. maksymalny(X) :-
  84. \+ le(X,A),
  85. le(B,X).
  86.  
  87. najw(X) :-
  88. maksymalny(X),
  89. le(Y, X),
  90. ((le(Y,Z), (\+ najw(Z))); true).
  91.  
  92. minimalny(X) :-
  93. \+ le(A,X),
  94. le(X,B).
  95.  
  96. divisible(X,Y) :- X mod Y =:= 0.
  97. divisible(X,Y) :- sqrt(X) >= Y+2, divisible(X, Y+2).
  98.  
  99. isPrime(X) :- X =:= 2; X =:= 3; (X > 3, X mod 2 =:= 1, \+ divisible(X, 3)).
  100.  
  101.  
  102. prime(LO, HI, N) :-
  103. between(LO, HI, N),
  104. isPrime(N).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement