SHARE
TWEET

Untitled

a guest Apr 20th, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. facts
  2.  
  3. dmin_year(partner,age)
  4. demptyPartners(client).
  5. dclientAgeNation(client).
  6. dpartnerNoHabits(client,partner).
  7. dclientNoChildrenReqYes(client).
  8. clients(client).
  9.  
  10. domains
  11. client = c(surname, name, dadname, characteristic, requirements, partnerlist)
  12.  
  13. characteristic,requirements = charact(age, education, nationality, month_cash, area, children, habits)
  14. partner=p(surname, name, dadname, characteristic)
  15. partnerlist=partner*
  16. surname,name,dadname,education,nationality,habits,children,area=symbol
  17. age,month_cash,k=integer
  18. clientlist=client*
  19. predicates
  20.  
  21. ageOfP(partner,age).
  22. ageOfC(client,age).
  23. surnameOf(client,surname).
  24. nationalityOf(client,nationality).
  25. habitsOf(partner,habits).
  26. childrenOfC(client,children).
  27. likePartnerWithChildren(client).
  28. partnerOf(client,partner).
  29. partnerOfList(partnerlist,partner).
  30. emptyPartners(client).
  31. writeln(partnerlist).
  32. writeln(clientlist).
  33. solve1.
  34. solve1_1.
  35. solve2.
  36. %solve2_1.
  37. solve3(nationality,age).
  38. %solve3_1(nationality,age).
  39. solve4(client).
  40. %solve4_1(client).
  41. solve4BySurname(surname).
  42. solve5.
  43. %solve5_1.
  44. bigsolve.
  45. clauses
  46. %Íà÷àëüíûå óñëîâèÿ
  47. dmin_year(p(a,a,a,charact(1000000,a,a,0,no,no,no)),1000000).
  48.  
  49. %êëèåíòû:
  50. clients(c(äàíèëèí,äàíèë,äàíèëîâè÷,charact(23,âûñøåå,ðóññêèé,30000,no,no,no),charact(18,âûñøåå,ðóññêèé,15000,yes,no,yes),[])).
  51.  
  52. clients(c(êàáàåâà,òàòüÿíà,ìèõàéëîâíà,charact(18,âûñøåå,ðóññêèé,20000,yes,no,yes),charact(20,âûñøåå,ðóññêèé,0,no,yes,no),
  53. [p(äàíèëèí,äàíèë,äàíèëîâè÷,charact(23,âûñøåå,ðóññêèé,30000,no,no,no)),
  54. p(ìàðòûíîâ,èëüÿ,ñåðãååâè÷,charact(25,îáùåå,ðóññêèé,85000,yes,yes,yes))])).
  55.  
  56. clients(c(ìíàöàêàíÿí,òèãðàí,àðòóðîâè÷,charact(17,ñðåäíåå,àðìÿíèí,42000,yes,yes,yes),charact(20,âûñøåå,ðóññêèé,0,no,yes,yes),
  57. [p(êàáàåâà,òàòüÿíà,ìèõàéëîâíà,charact(18,âûñøåå,ðóññêèé,20000,yes,no,yes))])).
  58.  
  59. clients(c(õîõëîâ,òàðàñ,äìèòðèåâè÷,charact(25,âûñøåå,óêðàèíåö,0,no,yes,no),charact(25,âûñøåå,ðóññêèé,25000,yes,no,yes),
  60. [p(øèáàåâà,àëåêñàíäðà,ìèõàéëîâíà,charact(19,âûñøåå,ðóññêèé,0,no,yes,no)),
  61. p(ìóöàðàåâà,åêàòåðèíà,äìèòðèåâíà,charact(45,íåò,÷å÷åí,50000,yes,yes,yes))])).
  62.  
  63. clients(c(èâàíîâà,èðèíà,ñòåïàíîâíà,charact(37,âûñøåå,ðóññêèé,150000,yes,yes,no),charact(30,âûñøåå,ïîëÿê,80000,no,no,no),
  64. [p(ïàâëîâ,åâãåíèé,àíòîíîâè÷,charact(43,ñðåäíåå,øâåä,100000,yes,yes,yes))])).
  65. %îòäåëüíûå ïðåäèêàòû
  66. writeln([H|T]):-write(H),nl,writeln(T).
  67. writeln([]).
  68.  
  69. ageOfP(p(_,_,_,charact(Age,_,_,_,_,_,_)),Age).
  70. ageOfC(c(_,_,_,charact(Age,_,_,_,_,_,_),_,_),Age).
  71. habitsOf(p(_,_,_,charact(_,_,_,_,_,_,Habits)),Habits).
  72. surnameOf(c(Name,_,_,_,_,_),Name).
  73. nationalityOf(c(_,_,_,charact(_,_,Nationality,_,_,_,_),_,_),Nationality).
  74. childrenOfC(c(_,_,_,charact(_,_,_,_,_,Children,_),_,_),Children).
  75. partnerOf(c(_,_,_,_,_,Partnerlist), Partner):-partnerOfList(Partnerlist,Partner).
  76. partnerOfList([T|_],T).
  77. partnerOfList([_|H],Partner):-partnerOfList(H,Partner).
  78.  
  79. emptyPartners(c(_,_,_,_,_,[])).
  80. likePartnerWithChildren(c(_,_,_,_,charact(_,_,_,_,_,yes,_),_)).
  81. %ïðåäèêàòû ðåøåíèé
  82. solve1_1:-clients(Client),partnerOf(Client,Partner),ageOfP(Partner,Age),dmin_year(PartnerFromDB,AgeFromDB),Age<AgeFromDB,retract(dmin_year(PartnerFromDB,AgeFromDB)),
  83. assert(dmin_year(Partner,Age)),fail.
  84. solve1:-solve1_1;findall(Partner,dmin_year(Partner,_),List),write("1)Ñàìûé ìîëîäîé: "), writeln(List).
  85.  
  86. solve2:-clients(c(S,N,D,charact(_,_,_,_,_,_,_),charact(_,_,_,_,_,_,_),L)), L=[], write("2)áåç ïàðòíåðîâ:", S," ",N," ",D," "), nl,fail.
  87.  
  88. solve3(F,Age):- clients(c(S,N,D,charact(A,_,F,_,_,_,_),charact(_,_,_,_,_,_,_),_)), Age>A, write("3)Óçàç. íàö-òü, óêàç-é âîçðàñò: ", S," ",N," ",D," "), nl, fail.
  89.  
  90. solve4(Client):- partnerOf(Client,Partner),habitsOf(Partner,no),Partner=p(S,N,D,_),write("4)Ïàðòíåðû áåç âðåäíûõ ïðèâû÷åê: ", S," ",N," ",D," "),nl, fail.
  91.  
  92. solve4BySurname(Name):-clients(Client),surnameOf(Client,Name),solve4(Client).
  93.  
  94. solve5:-clients(c(S,N,D,charact(_,_,_,_,_,no,_),charact(_,_,_,_,_,yes,_),_)), write("5)Ó êîòîðûõ íåò äåòåé, ïîäõîäèò ïàðòíåð, èìåþùèé äåòåé: "), nl, write( S," ",N," ",D," "),nl.
  95.  
  96. bigsolve:-solve1,fail;solve2,fail;solve3(ðóññêèé,30),fail;solve4BySurname(õîõëîâ),fail;solve5.
  97.  
  98. goal
  99. bigsolve.
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top