April 20, 2015


Quantified CycL expressions (discussed below) contain one or more variables which stand for constants whose identities are not specified. A variable may appear (nearly) anywhere a constant can appear.

2.2.1.  Variable Names

Variable names must contain uppercase alphanumeric characters only, must start with either one or two question marks, and the character after the first or second question mark must be a letter. valid-el-var-name? can be used to check that a string meets these requirements.

2.2.2.  Naming Conventions

In sentences in which only one variable is used, it is common to use a single-letter variable, such as “?X”. However, when a sentence contains more than one variable, it will be much more readable if you give the variables mnemonic names. Here’s an example:

              (#$isa ?TRANSFER #$TransferringPossession)
              (#$fromPossessor ?TRANSFER ?FROM))
           (#$isa ?FROM #$SocialBeing))

“The initial possessor in a possession transfer is a social being.”

2.2.3.  “Don’t-Care” Variables

Variables beginning with two question marks instead of just one, for instance ??WHATEVER, are called “don’t-care” variables.

This is just a naming convention indicating that we don’t care about the bindings for that variable; operationally, it currently makes no difference.

Consider a rule like

         (#$hasDegreeIn ?PERSON ?DEGREE)
         (#$hasAttribute ?PERSON #$CollegeGraduate))

Here, ?DEGREE is not otherwise mentioned, which is a pragmatically infrequent occurrence (but not logically incorrect). We can communicate that this is nevertheless intentional by saying


so that diagnostics etc. know not to complain about the anomaly.

Finally, consider the difference between these queries

   (#$isa ?X #$Person)
   (((?X . #$BritneySpears)) ((?X . #$HenryKissinger)) ...lots more...)

     (#$thereExists ?X (#$isa ?X #$Person))
   (((T . T)))

In the second case, we don’t care who ?X is, just if at least one exists at all. One proof is as good as any, so it could likely quit with the first one rather than compute all of them. In this case, ?X is acting as a don’t care variable in the query.

The explicit existential closure makes this intent clear. However, it might be nice to have the shorthand

       (#$isa ??X #$Person)

as a tipoff to a query interface that we desire ??X to be a don’t care variable, and thus it is free to existentially close it. For example, a query interface like the HTML interface may choose to automatically existentially close “don’t care” variables so that their bindings aren’t displayed.

Aside : This is analogous to using “pragmas” or “declarations” in software engineering to give hints to the compiler about the code. In this case, it’s like explicitly labelling the unused variable Y in the function

      (define foo (x y))
       (ignore y)
         (ret x))

with IGNORE so that the compiler won’t complain about Y never being used. The ignore has no effect on the compiled code — it’s a message to the compiler.