Now we’re going on to the second of the five lessons in this section. I will introduce arity, which you’ve already seen, and we’ll delve into it in more detail.
Arity, as you know, refers to the number of argument places that a particular predicate or function has. There are two ways to express the arity of a particular predicate or function in the CycL language.
First of all, we have a predicate, #$arity, which you can apply to any relation – in other words, any predicate or function – in conjunction with a numeric value to denote how many arguments that relation accepts. For example, (#$arity #$GroupFn 1) denotes that the #$GroupFn function accepts only one argument. The #$mother predicate has an arity of two; thus it takes two arguments at a time.
The second method of expressing arity in CycL is through the inheritance of collection attributes, specifically the arity attribute. There are several pre-defined collections with specific arity attributes. For example, the collection #$UnaryPredicate is the collection of all predicates whose arity is one. #$BinaryFunction is the collection of all functions whose arity is two. So, instead of directly stating the arity of a particular function (for example #$GroupFn), you could say that #$GroupFn is an instance of the collection #$UnaryFunction, thus assigning #$GroupFn an arity of one. Another example would be to say that #$mother is an instance of the #$BinaryPredicate collection, thus assigning #$mother an arity of two.
Most relations in CycL have low arities; in fact, most have just one or two as their arity. There are some relations that take three or four arguments, a few that take five arguments, and a slight few that take more than five arguments. Seven is probably the highest arity used, although in principle arity could be any number. Try to keep them on the low side.
In a sense, there is an exception to the statement that most predicates and functions have an arity of one or two. So far, there are very few instances of #$UnaryPredicate in CycL. There are a lot of unary functions, but very few unary predicates. The reason for this has to do with the Cyc Inference Engine and certain facts about how it works most efficiently. There are alternative ways to express what you might think of intuitively as a unary property. Where you could do it with a unary predicate, we usually do it in one of these other ways.
The first way has to do with using collections to express concepts that could have been expressed using the unary predicate. For example, consider the concept of a dog. We could apply the unary predicate, #$dog, to the name, #$Lassie.” This would allow us to say “Lassie is a dog.” Instead, we assert that #$Lassie is an instance of the collection called #$Dog. So, to say that Lassie or Rover is a dog, we do so with an #$isa statement, relating the particular dog to the collection of all dogs.
An alternate way to represent unary properties, without doing so in terms of a predicate, is with what we call an attribute, or #$AttributeValue. For example, if we wanted to express the concept of something having the color tan, we could do that with a predicate like #$tanColored and say (#$tanColored #$Rover), but instead we do it with an attribute value. In other words, we treat tan color as a type of attribute that a thing can possess, and then we have certain predicates that relate individual things to attributes that they possess. An example of one of these predicates is #$objectHasColor. You could use this predicate to say that Rover has the color of tan. Tan is being represented as an attribute value rather than as a unary predicate.
CycL has some predicates and functions which are called “variable arity.” This means that they can take a variable number of arguments; in other words, a variable arity relation doesn’t always take, say, just two arguments at a time, or just three arguments at a time -- it might take two or three or four, depending on the situation.
The collection of all of these variable-arity relations is called #$VariableArityRelation. Here are a couple of examples. The predicate #$different is variable-arity, so it is defined in such a way that it can take two or more arguments. In other words, it has to have at least two, but it can have three, four, or more arguments. When you apply the #$different predicate to two or more things, the resulting sentence means that all of those things are different from each other. You can see why it’s convenient to have variable-arity. Otherwise we’d have to have a bunch of different predicates, depending on the number of things we wanted to differentiate from each other -- this way we can do it all with one.
An example of a variable-arity function is #$JoinListsFn. This function takes as its arguments two or more lists, and concatenates them into one list. You can also apply that function to three or four lists, and it will do the same thing. So, again, it’s a convenient way of doing something that would otherwise require a bunch of functions to do.
Every relation has an arity, as we’ve seen. You have to apply a given relation to the proper number of arguments, according to its arity, if the result is going to be what we call “syntactically well-formed.”
Take for example the predicate #$objectHasColor. We’ve seen this predicate before and we know that it’s binary, or a two-place predicate. So if I form an expression with only one argument, I’ve violated its arity. Even though, strictly speaking, (#$objectHasColor #$Rover) is a term in CycL, it’s a syntactically malformed term and basically meaningless.
The second example does apply #$objectHasColor to the right number of arguments for its arity, so it is syntactically well-formed. You’ll notice that what is says is that Rover is blue. Assuming that Rover is a dog, it is very unlikely that Rover really is blue, so you can see that it’s a false sentence, but still it’s syntactically well-formed.
- The number of argument places a predicate or function has is its “arity”
Two ways to specify arity
- Collections that denote arity
- Representing unary properties in CycL
- Variable-arity predicates and functions
This concludes the lesson on arity of predicates and denotational functions.