Functions vs. Predicates
Return to Table of ContentsThis document should provide insight into the discussion of when to use functions and when to use predicates.
Given a real-world relationship between N items that is functional in at least one of those items, should one create a #$Predicate or a #$Function-Denotational to represent that relationship? If the relationship is not at all functional, of course a Predicate must be used. But if at least one of the "arguments" is functional, the relationship could be represented with either a function or a predicate. For example, one could represent the "successor" relationship with either a #$BinaryPredicate,
(#$successor 1 2)or with a #$UnaryFunction,
(#$SuccessorFn 1) which returns 2.Which is better?
(#$implies (#$termOfUnit ?X (#$GovernmentFn ?C) (#$government ?C ?X))
(#$government ?C ?G)to bind ?G to the government of ?C, but we would only find bindings in cases where someone had bothered to introduce, by hand, a term corresponding to the government of ?C.
Named functions are more desirable than Skolem functions, partly due to clarity.
(#$plus 2 2 ?X)It is possible to make a predicate an instance of #$EvaluatableRelationship, but the current system only supports an #$evaluationDefn which expects all arguments to be fully-bound. So if "plus" were an evaluatable predicate, we could answer the question
(#$plus 2 2 4)
as True, but we couldn't use the defn to find bindings for ?X as in the expression further above.
(#$HeightFn #$Karen)-- to generate that Distance. However, this would only be useful in certain cases. If we want to declare that Karen has a particular height, this is best accomplished with a Predicate:
(#$heightOfObject #$Karen (#$Foot-UnitOfMeasure 5.3)),
(#$greaterThan (#$HeightFn #$Karen) (#$HeightFn #$Muffet))
(#$atomicNumber #$Helium 2)which is functional in both of its arguments. Or, we could have
(#$AtomicNumberFn #$Helium) -> 2 (#$AtomicNumberOfFn 2) -> #$Helium
Go to Top