fork download
  1. :- set_prolog_flag(verbose,silent).
  2. :- prompt(_, '').
  3. :- use_module(library(readutil)).
  4.  
  5. main:-
  6. % Aqeel Alsadiq
  7. % CSCI 305 Lab 4
  8. :- consult('royal.pro').
  9. % M is mother of C if she is a parent of C and if she is female
  10. mother(M,C):- parent(M,C), female(M).
  11. % F is father of C if he is a parent of C and if he is male
  12. father(F,C):- parent(F,C), male(F).
  13. % 2 people are spouses iff they are married to each other
  14. % spouse(x, y) = spouse(y, x)
  15. spouse(X,Z):- married(X,Z); married(Z, X).
  16. % X has a child Y iff Y has a parent X
  17. % We need to protect against the reflective case
  18. child(X, Y):- parent(Y, X), X\=Y.
  19. % Y is a son of X if he is a child of X and male
  20. son(X, Y):- child(X, Y), male(X).
  21. % Y is a daughter of X if she is a child of X and female
  22. daughter(X, Y):- child(X, Y), female(X).
  23. % 2 can share siblings if they share a parent and are not themselves
  24. sibling(X, Y):- child(X, P), child(Y, P), X\=Y.
  25. % Specifying what gender of siblings they have
  26. brother(X, Y):- sibling(X, Y), male(X).
  27. sister(X, Y):- sibling(X, Y), female(X).
  28. % Y has a grand parent X iff P has a child X and Y has a child P
  29. grandparent(X, Y):- child(X, P), child(P, Y).
  30. % Grandfather case:
  31. grandfather(X, Y):- child(X, P), child(P, Y), male(X).
  32. % Grandmother case:
  33. grandmother(X, Y):- child(X, P), child(P, Y), female(X).
  34. % Y is grandchild of X, X has a grandparent Y
  35. grandchild(X, Y):- grandparent(Y, X).
  36. % Y has an ancestor X if X is one of Y's parents, or if one of Y's
  37. % parents has X as an ancestor
  38. ancestor(X, Y):- parent(X, Y).
  39. ancestor(X, Y):- parent(X, Z), ancestor(Z, Y).
  40. % descendant is the inverse of ancestor
  41. descendant(X, Y):- ancestor(Y, X).
  42. % Y has an uncle iff X has parent P and Y is brother to P
  43. % Uncle through blood:
  44. uncle(X, Y):- child(X, P), brother(Y, P).
  45. % Uncle through marriage:
  46. uncle(X, Y):- child(X, P), spouse(Y, P), male(X).
  47. % Y has an aunt iff X has parent P and Y is sister to P
  48. % Aunt through blood:
  49. aunt(X, Y):- child(X, P), sister(Y, P).
  50. % Aunt through marriage:
  51. aunt(X, Y):- child(X, P), spouse(Y, P), female(X).
  52. % X is older than Y if X was born in year A,
  53. % Y was born in year B, and A is greater then B
  54. older(X, Y):- born(X, A), born(Y, B), A<B.
  55. % X is younger than Y if X was born in year A,
  56. % Y was born in year B, and A is less then B
  57. younger(X, Y):- born(X, A), born(Y, B), A>B.
  58. % if Y was born in year A, and regent X reigned from year M
  59. % to N, then M is less than A, and N is greater than A.
  60. % Y was born during the reign of regent X.
  61. regentWhenBorn(X, Y):- born(Y, A), reigned(X, M, N), M<A, N>A.
  62. cousin(X, Y) :-((uncle(Z, Y), parent_of(Z, X)));((aunt(Z, Y), parent_of(Z, X))).
  63. process:-
  64. /* your code goes here */
  65.  
  66. :- main.
Success #stdin #stdout #stderr 0.04s 9196KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/di3aTF/prog:5:6: Syntax error: Operator priority clash
ERROR: /home/di3aTF/prog:67:
	prolog_main:main/0: Undefined procedure: main/1
	  However, there are definitions for:
	        main/0
Warning: /home/di3aTF/prog:67:
	Goal (directive) failed: user:main
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit