I need some help with the following query:
With given relations:
hiker(HN, Name), mountain(MN, Height), climbed(HN, MN, Date).
Height > 5000m
hiker(Name): - moutain(MN, Height), climbed(HN, MN, Date), Height > 5000
The 'some' question is easy to express in language like Datalog and SQL because you only have to find one mountain per hiker. It doesn't matter whether the hiker has hiked one, two, or more mountains. Datalog rules are perfect for this.
result(Name) :- hiker(H, Name), climbed(H, M, _), mountain(M, Height), Height > 5000.
The 'every' question is harder to answers because you need to now confirm that the hiker has climbed every single mountain, not just one of them.
Assuming a closed world database, the 'every' question can be translated in a double negation though, which is easy to express. You need to search for hikers for whom there does not exist a mountain > 5000m that they have not climbed.
I'll help you a little bit with the first part of this query, and then you can probably find the answer.
// this is just for convenience high_mountain(M) :- mountain(M, Height), Height > 5000. // there exists a mountain hiker H has not climbed. some_not_climbed(H) :- hiker(H, _), high_mountain(M), !climbed(H, M). // for hiker H there is no mountain that he has not climbed. result(H) :- hiker(H, _), ...