0
votes

Given the predicates

  • hasAccount(Person,Bank,Amount) – the Person has an account at the Bank with the balance Amount

  • lives(Person,City) – the Person lives in the City

  • created(Person,Bank,Month,Year) – the Person opened an account at the Bank in Month of the Year

how would you find someone who has the oldest account at the same bank using only the following "- , < =< > >= not" operators? I'm deeply lost!

1
Try to phrase it in another way: The oldest account is an account where the following property does not hold: There is an account that is older ('<' year or '=' year and '<' month). - danielp
My query is something like created(Who,somebank,Month1,Year1), created(Someone,somebank,Month2,Year2) and comparing Month1&2 and Year1&2. Is this a right approach? - user1830954
Yes, but you must negate the second part (see my answer below) - danielp

1 Answers

0
votes

Based on your comment, \+ is used for not (not proveable):

created(Who,Somebank,Month1,Year1),
\+ ( created(_,Somebank,Month2,Year2), older(Month2,Year2,Month1,Year1) )

with older/4 defined as:

older(_Month2,Year2,_Month1,Year1) :- Year2 < Year1.
older(Month2,Year,Month1,Year) :- Month2 < Month1.