New primitive SemanticFn: Filter
"Find all cities with more teachers than farmers"
This is a highly requested semantic function. One way to answer the question above in the original set of semantic function is
(mark x (and (type city) (: (and (!num_teachers (var x)) (> (!num_farmers (var x)))))))
where the special relation : returns an empty set when the argument is empty, and * otherwise. The relation : has not been implemented.
The proposed semantic function looks like this:
(filter (type city) (lambda x (and (!num_teachers (var x)) (> (!num_farmers (var x))))))
While it is equally long, I think it is a little clearer about what it does. (filter S F) is equivalent to {x in S : F(x) not empty}. Filter is also easier to execute than the generic mark since filter is similar to superlatives (i.e., try plugging each value in S into the function F and see what works).
Please refer to tables/grammars/combined.grammar of how it could be used in the grammar.