Boolean Properties

Not all properties have a value. Sometimes you just want to state a boolean property of an individual. The schema and instance syntax for stating boolean properties are illustrated by the following example:

Person [| => adult |].
Greg [ adult ].
John [ \neg adult ].

Here, we use the \neg operator (explicit negation) to assert that John is not an adult (see Negation). Note the placement of the => arrow before the property name. You cannot specify cardinalities on these boolean method specifications.

It is also possible to use the built-in boolean type:

Person [| adult => \boolean |].
Greg [ adult -> \true ].
John [ adult -> \false ].

but this is not recommended for most cases. The former syntax is more compact when querying or referencing the property in a rule. For example, to query for all adults using the two styles, we would write:

?x [adult].            // first style
?x [adult -> \true].   // second style

\true is shorthand for “true”^^\boolean, and similarly for \false.

Note that from the perspective of writing queries, the two types of boolean property are not equivalent. The query written in the first style will not succeed if the facts are asserted with the built-in boolean style, and vice versa.

Also, it is possible to specify cardinalities with the built-in boolean style. For example,

Person [| adult{0..1} => \boolean |].

Here cardinality is not particulary meaningful since only {0..1} or {1..1} would make sense for a boolean property.