Advertisement
Andites

Экспертные системы лаба 1

Sep 20th, 2023
1,642
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Prolog 1.17 KB | None | 0 0
  1. man(igor).
  2. man(nikolayg).
  3. man(nikolay).
  4. man(mihail).
  5. woman(elena).
  6. woman(mariya).
  7.  
  8. father(igor, mihail).
  9. father(igor, nikolay).
  10. mother(elena, mihail).
  11. mother(elena, mihail).
  12. mother(mariya, igor).
  13.  
  14. brother(mihail, nikolay).
  15. brother(nikolay, mihail).
  16.  
  17. grandmother(mariya, nikolay).
  18. grandmother(mariya, mihail).
  19. grandfather(nikolayg, nikolay).
  20. grandfather(nikolayg, mihail).
  21.  
  22. %?-parent(X, Y), write(X), write(" - "), write(Y), nl, fail.
  23. %?-grandmother(X,Y), write(X), write(" - "), write(Y), nl, fail.
  24.  
  25. older(mariya, igor).
  26. older(mariya, elena).
  27. older(mariya, mihail).
  28. older(mariya, nikolay).
  29. older(elena, mihail).
  30. older(elena, nikolay).
  31. older(igor, elena).
  32. older(igor, nikolay).
  33. older(igor, mihail).
  34. older(nikolay, mihail).
  35.  
  36. older(X,Z):- older(X,Y), older(Y,Z).
  37. married(X,Z):- mother(X,Y), father(Z,Y).
  38. parent2(X,Z):- mother(X,Z) ; father(X,Z).
  39. havesameparent(X,Z):- (father(Y,X) ; mother(Y,X)), (father(Y,Z) ; mother(Y,Z)), X \= Z.
  40. dontbrorsist(X,Z):- \havesameparent(X,Z), X\=Z.
  41.  
  42.  
  43. %?-havesameparent(X,Z), write(X), write(" - "), write(Z), fail.
  44. ?-dontbrorsist(X,Z), write(X), write(" - "), write(Z), nl, fail.
  45.  
  46.  
  47.  
  48. %?-older(elena, X), write(X), nl.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement