Guest User

Untitled

a guest
Feb 20th, 2018
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. domains
  2.  
  3. list=symbol*
  4.  
  5. predicates
  6.  
  7. more(symbol, symbol)
  8. less(symbol, symbol)
  9. iscity(symbol)
  10. iscmd(symbol)
  11. solve(symbol,symbol,symbol,symbol,symbol,symbol)
  12.  
  13. solvel(list, list, integer)
  14. iscityl(list, integer)
  15. iscmdl(list, integer)
  16. lessl(list, list)
  17. notmorel(list, list)
  18.  
  19. goal
  20.  
  21. /**
  22.  * GOALS. Uncomment your chose.
  23.  */
  24.  
  25. %solve(A,B,C,X,Y,Z).
  26. %solvel(L1, L2, 3).
  27.  
  28. clauses
  29.  
  30. /**
  31.  * CHAPTER 0: Data
  32.  */
  33.  
  34. % List of known references
  35. more(krasnodar, chelyabinsk).
  36. more(samara, chelyabinsk).
  37. more(dinamo, krasnodar).
  38. more(spartak, torpedo).
  39.  
  40. % List of known cities
  41. iscity(krasnodar).
  42. iscity(chelyabinsk).
  43. iscity(samara).
  44.  
  45. % List of known teams' names
  46. iscmd(torpedo).
  47. iscmd(spartak).
  48. iscmd(dinamo).
  49.  
  50. /**
  51.  * CHAPTER 1: Predicates for fixed data.
  52.  */
  53. less(A, B):-A<>B,not(more(A, B)).
  54.  
  55. solve(A,B,C,X,Y,Z):-
  56. iscity(A),iscity(B),iscity(C),
  57. iscmd(X),iscmd(Y),iscmd(Z),
  58. not(more(X, A)),
  59. not(more(X, B)),
  60. not(more(X, C)),
  61. not(more(Y, B)),
  62. not(more(Y, C)),
  63. not(more(Z, C)),
  64.  
  65. not(more(A, X)),
  66. not(more(A, Y)),
  67. not(more(A, Z)),
  68. not(more(B, Y)),
  69. not(more(B, Z)),
  70. not(more(C, Z)),
  71.  
  72. less(A, B),
  73. less(A, C),
  74. less(B, C),
  75. less(X, Y),
  76. less(X, Z),
  77. less(Y, Z).
  78.  
  79. /**
  80.  * CHAPTER 2: Predicates for array data.
  81.  */
  82. iscityl([], 0) :- !.
  83. iscityl([H|T], N) :- Ndec=N-1,iscity(H), iscityl(T, Ndec).
  84.  
  85. iscmdl([], 0) :- !.
  86. iscmdl([H|T], N) :- Ndec=N-1,iscmd(H), iscmdl(T, Ndec).
  87.  
  88. notmorel(_, []).
  89. notmorel([H1|T1], [H2|T2]) :- not(more(H1, H2)), notmorel(T1, T2), notmorel([H1|T1], T2).
  90.  
  91. lessl(_, []).
  92. lessl([H|T], [H|T]) :- lessl([H|T], T).
  93. lessl([H1|T1], [H2|T2]) :- less(H1, H2),lessl(T1, T2),lessl([H1|T1], T2).
  94.  
  95. solvel(LCity, LCmd, N):-
  96. iscityl(LCity, N), iscmdl(LCmd, N),
  97. notmorel(LCity, LCmd),
  98. notmorel(LCmd, LCity),
  99. lessl(LCmd, LCmd),
  100. lessl(LCity, LCity).
Add Comment
Please, Sign In to add comment