Since function constants and relation constants denote functions and relations and since functions and relations are objects in our universe of discourse, it is natural to allow function and relation constants to appear as as arguments in terms and sentences.
Unfortunately, in order to avoid paradoxes, it is sometimes essential for there to be a difference between the interpretation of a function or relation constant and its semantic value. We can sidestep these potential difficulties by writing axioms that define function and relation constants, used in argument position, in terms of the setof operator.
As described in chapter 4, the semantic value of a function constant is the set of lists of objects corresponding to the function denoted by . The following axiom schema expresses this property.
(= (setofall (listof ... ) (= ( ... ) ))
Similarly, the semantic value of a relation constant is the set of lists of objects that satisfy the relation denoted by . Again, we have an axiom schema corresponding to this property.
(= (setofall (listof ... ) ( ... )))
The use of function and relation constants in argument position weakens the distinction between object constants on the one hand and function and relation constants on the other.
The distinction between function and relation constants can also be weakened, since functions are a special class of relations. Any position that requires a relation constant can also be filled by a function constant. When this happens, the function denoted by the function constant is treated as a relation (which it is). For instance, in the following sentence, the first occurrence of + plays the role of a relation constant, while in the second occurrence, it plays the role of a function constant. (In both cases, + denotes the same entity.)
(and (+ 2 3 5)
(= (+ 2 3 5) 10))
In KIF, all function constants are treated as relation constants, and all relation constants (and hence all function constants) are treated as object constants. An object constant is still prohibited from occurring as the first item of a term or a sentence, and a relation constant that is not a function constant cannot occupy the first position in a term.
The convenience afforded by the ability to use function and relation constants as arguments and to use function constants in relational position often causes concern over grammatical ambiguity. The expression (+ 5 2 3) is both a term and a sentence. Fortunately, this ambiguity is always resolved when such expressions occur within well-formed databases. Any expression that occurs at top level cannot be a term. An expression embedded in a non-operator expression must be a term. An expression embedded in an operator expression can be either a term or a sentence, but in either case the type of the expression is known from the operator's syntax.