fork download
  1. :- set_prolog_flag(verbose,silent).
  2. :- prompt(_, '').
  3. :- use_module(library(readutil)).
  4.  
  5. main:-
  6. process,
  7.  
  8. process:-
  9. predicates
  10.  
  11. male(symbol).
  12. female(symbol).
  13. father(symbol,symbol).
  14. husband(symbol,symbol).
  15. brother(symbol,symbol).
  16. sister(symbol,symbol).
  17. listbrothers(symbol).
  18. listsisters(symbol).
  19. mother(symbol,symbol).
  20. grandfather(symbol).
  21. grandmother(symbol).
  22. uncle(symbol).
  23. aunt(symbol).
  24. cousin(symbol).
  25. listgrandsons(symbol).
  26. listgranddaughters(symbol).
  27. printmenu.
  28. action(integer).
  29.  
  30.  
  31. clauses
  32.  
  33. male(mukesh).
  34. male(alok).
  35. male(navlok).
  36. male(krishnan).
  37. male(vidhi).
  38.  
  39. female(meenakshi).
  40. female(shweta).
  41. female(nidhi).
  42.  
  43. father(mukesh,alok).
  44. father(mukesh,navlok).
  45. father(vidhi,mukesh).
  46.  
  47. husband(mukesh,meenakshi).
  48. husband(vidhi,nidhi).
  49. husband(krishnan,shweta).
  50.  
  51. mother(X,Y):- husband(Z,X),
  52. father(Z,Y).
  53.  
  54. brother(X,Y):- father(Z,X),
  55. father(Z,Y),
  56. X<>Y,
  57. male(X).
  58.  
  59. sister(X,Y):- father(Z,X),
  60. father(Z,Y),
  61. X<>Y,
  62. female(X).
  63.  
  64. listbrothers(X) :- brother(Z,X),
  65. write(Z).
  66.  
  67. listsisters(X):- sister(Z,X),
  68. write(Z).
  69.  
  70. grandfather(X):- father(Y, Z),
  71. father(Z,X),
  72. write(Y, " is the grandfather of ",X,"\n").
  73.  
  74. grandmother(X):- husband(Z,X),
  75. father(Z,V),
  76. father(V,Y),
  77. write(Y, " is the grandmother of ",X,"\n").
  78.  
  79.  
  80. listgrandsons(X):- father(X,Z),
  81. father(Z,Y),
  82. male(Y),
  83. write(Y,"\n"),
  84.  
  85. listgrandsons(X):- husband(Y,X),
  86. father(Y,V),
  87. father(V,Z),
  88. male(Z),
  89. write(Z,"\n"),
  90.  
  91. listgranddaughters(X):- father(X,Z),
  92. father(Z,Y),
  93. female(Y),
  94. write(Y,"\n"),
  95.  
  96. listgranddaughters(X):- husband(Y,X),
  97. father(Y,V),
  98. father(V,Z),
  99. female(Z),
  100. write(Z,"\n"),
  101.  
  102. uncle(X):- brother(Z,Y),
  103. father(Z,X),
  104. male(Y),
  105. write(Y,"\n"),
  106.  
  107. aunt(X):- husband(Z,Y),
  108. brother(Z,V),
  109. father(V,X),
  110. write(Y,"\n"),
  111.  
  112. cousin(X):- father(Z,X),
  113. father(V,Y),
  114. Z<>V,
  115. brother(V,Z),
  116. write(Y,"\n").
  117.  
  118.  
  119.  
  120. action(1):- write("\nEnter name of person whose father is to be found : "),
  121. readln(X),
  122. write("\n"),
  123. write("Father of ",X," is:"),
  124. father(Z,X),
  125. write(Z,"\n"),
  126.  
  127. action(2):- write("\nEnter name of person whose mother is to be found : "),
  128. readln(X),
  129. write("\n"),
  130. write("Mother of ",X," is:"),
  131. mother(Z,X),
  132. write(Z,"\n"),
  133.  
  134. action(3):- write("\nEnter name of person whose brothers are to be found : "),
  135. readln(X),
  136. write("\n"),
  137. write("Brothers of ",X," are:\n"),
  138. listbrothers(X),
  139. write("\n"),
  140.  
  141. action(4):- write("\nEnter name of person whose sisters are to be found : "),
  142. readln(X),
  143. write("\n"),
  144. write("Sisters of ",X," are:\n"),
  145. listsisters(X),
  146. write("\n"),
  147.  
  148. action(5):- write("\nEnter name of person whose grandsons are to be found : "),
  149. readln(X),
  150. write("\n"),
  151. write("Grandsons of ",X," are:\n"),
  152. listgrandsons(X),
  153. write("\n"),
  154.  
  155.  
  156. action(6):- write("\nEnter name of person whose granddaughters are to be found : "),
  157. readln(X),
  158. write("\n"),
  159. write("Granddaughters of ",X," are:\n"),
  160. listgranddaughters(X),
  161. write("\n"),
  162.  
  163. action(7):- write("\nEnter name of person whose uncles are to be found : "),
  164. readln(X),
  165. write("\n"),
  166. write("Uncles of ",X," are:\n"),
  167. uncle(X),
  168. write("\n"),
  169. action(8):- write("\nEnter name of person whose aunties are to be found : "),
  170. readln(X),
  171. write("\n"),
  172. write("Aunties of ",X," are:\n"),
  173. aunt(X),
  174. write("\n"),
  175.  
  176.  
  177. action(9):- write("\nEnter name of person whose cousins are to be found : "),
  178. readln(X),
  179. write("\n"),
  180. write("Cousins of ",X," are:\n"),
  181. cousin(X),
  182. write("\n"),
  183.  
  184. action(0).
  185.  
  186. printmenu :-
  187. write("\n1. Display Father of?\n"),
  188. write("2. Display Mother of?\n"),
  189. write("3. List all brothers of?\n"),
  190. write("4. List all sisters of?\n"),
  191. write("5. List all grandson of?\n"),
  192. write("6. List all granddaughter of?\n"),
  193. write("7. List all uncles of?\n"),
  194. write("8. List all aunty of?\n"),
  195. write("9. list all cousins of?\n"),
  196. write("0. exit\n"),
  197. write("Enter your choice : "),
  198. readInt(Choice),
  199. action(Choice),
  200. write("\n"),
  201.  
  202. goal
  203. makewindow(1,2,3,"Family Tree",0,0,25,80),
  204. printmenu.
  205.  
  206.  
  207. :- main.
  208.  
Success #stdin #stdout #stderr 0.05s 7124KB
stdin
1
alok
stdout
Standard output is empty
stderr
ERROR: /home/KhMVQS/prog:12:3: Syntax error: Operator expected
ERROR: /home/KhMVQS/prog:30:
	No permission to modify static procedure `repeat/0'
ERROR: /home/KhMVQS/prog:35:3: Syntax error: Operator expected
Warning: /home/KhMVQS/prog:41:
	Clauses of female/1 are not together in the source-file
	  Earlier definition at /home/KhMVQS/prog:13
	  Current predicate: male/1
	  Use :- discontiguous female/1. to suppress this message
Warning: /home/KhMVQS/prog:45:
	Clauses of father/2 are not together in the source-file
	  Earlier definition at /home/KhMVQS/prog:14
	  Current predicate: female/1
	  Use :- discontiguous father/2. to suppress this message
Warning: /home/KhMVQS/prog:49:
	Clauses of husband/2 are not together in the source-file
	  Earlier definition at /home/KhMVQS/prog:15
	  Current predicate: father/2
	  Use :- discontiguous husband/2. to suppress this message
Warning: /home/KhMVQS/prog:53:
	Clauses of mother/2 are not together in the source-file
	  Earlier definition at /home/KhMVQS/prog:20
	  Current predicate: husband/2
	  Use :- discontiguous mother/2. to suppress this message
ERROR: /home/KhMVQS/prog:58:4: Syntax error: Operator expected
ERROR: /home/KhMVQS/prog:63:4: Syntax error: Operator expected
Warning: /home/KhMVQS/prog:66:
	Clauses of listbrothers/1 are not together in the source-file
	  Earlier definition at /home/KhMVQS/prog:18
	  Current predicate: mother/2
	  Use :- discontiguous listbrothers/1. to suppress this message
Warning: /home/KhMVQS/prog:69:
	Clauses of listsisters/1 are not together in the source-file
	  Earlier definition at /home/KhMVQS/prog:19
	  Current predicate: listbrothers/1
	  Use :- discontiguous listsisters/1. to suppress this message
Warning: /home/KhMVQS/prog:72:
	Clauses of grandfather/1 are not together in the source-file
	  Earlier definition at /home/KhMVQS/prog:21
	  Current predicate: listsisters/1
	  Use :- discontiguous grandfather/1. to suppress this message
Warning: /home/KhMVQS/prog:76:
	Clauses of grandmother/1 are not together in the source-file
	  Earlier definition at /home/KhMVQS/prog:22
	  Current predicate: grandfather/1
	  Use :- discontiguous grandmother/1. to suppress this message
Warning: /home/KhMVQS/prog:82:
	Clauses of listgrandsons/1 are not together in the source-file
	  Earlier definition at /home/KhMVQS/prog:26
	  Current predicate: grandmother/1
	  Use :- discontiguous listgrandsons/1. to suppress this message
Warning: /home/KhMVQS/prog:95:
	Clauses of listgranddaughters/1 are not together in the source-file
	  Earlier definition at /home/KhMVQS/prog:27
	  Current predicate: listgrandsons/1
	  Use :- discontiguous listgranddaughters/1. to suppress this message
Warning: /home/KhMVQS/prog:108:
	Clauses of uncle/1 are not together in the source-file
	  Earlier definition at /home/KhMVQS/prog:23
	  Current predicate: listgranddaughters/1
	  Use :- discontiguous uncle/1. to suppress this message
Warning: /home/KhMVQS/prog:114:
	Clauses of aunt/1 are not together in the source-file
	  Earlier definition at /home/KhMVQS/prog:24
	  Current predicate: uncle/1
	  Use :- discontiguous aunt/1. to suppress this message
ERROR: /home/KhMVQS/prog:122:4: Syntax error: Operator expected
ERROR: /home/KhMVQS/prog:127:
	No permission to modify static procedure `repeat/0'
ERROR: /home/KhMVQS/prog:128:
	No permission to modify static procedure `repeat/0'
Warning: /home/KhMVQS/prog:130:
	Clauses of action/1 are not together in the source-file
	  Earlier definition at /home/KhMVQS/prog:29
	  Current predicate: aunt/1
	  Use :- discontiguous action/1. to suppress this message
Warning: /home/KhMVQS/prog:205:
	Clauses of printmenu/0 are not together in the source-file
	  Earlier definition at /home/KhMVQS/prog:28
	  Current predicate: action/1
	  Use :- discontiguous printmenu/0. to suppress this message
ERROR: /home/KhMVQS/prog:224:3: Syntax error: Operator expected
ERROR: /home/KhMVQS/prog:227:
	No permission to modify static procedure `true/0'
ERROR: /home/KhMVQS/prog:229:
	main/0: Undefined procedure: process/0
Warning: /home/KhMVQS/prog:229:
	Goal (directive) failed: user:main
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit