Suppose I had an atom name and age pair:
person(bob,42).
person(jeff,12).
person(adam,23).
...
And I wanted to find through a query (not predicate) the youngest person.
How would I make such a query?
Suppose I had an atom name and age pair:
person(bob,42).
person(jeff,12).
person(adam,23).
...
And I wanted to find through a query (not predicate) the youngest person.
How would I make such a query?
You can formulate a multi-part query with a universal quantifier, like this:
person(X,AgeX), forall(person(Y,AgeY), X=Y;AgeX<AgeY).
Essentially, this query says that X
must be such that for each known person
Y
in the database it should either be the same person (X=Y
part) or the other person must be older (AgeX<AgeY
part)