# Variable

## What variables are

In Dyna, variables are used in inference rules and patterns.

Dyna variables are true to their name. A variable in an inference rule, or a pattern query, is a placeholder that genuinely varies over all terms.

This is exactly the sense in which both Failed to parse (Missing texvc executable; please see math/README to configure.): i

and Failed to parse (Missing texvc executable; please see math/README to configure.): n
are variables in


Failed to parse (Missing texvc executable; please see math/README to configure.): f(n) = \sum_i z^{-ni}

whereas Failed to parse (Missing texvc executable; please see math/README to configure.): z

is not a variable there.  The same definition would be rendered


in Dyna with capitalized variable names:

f(N)  = z**(-N*I) if in_range(I).    % you must explicitly define in_range


Except for the fact that right now, Dyna doesn't have arbitrary mathematical expressions like this

## What variables are not

In Dyna terminology, "variable" does not have either of the following meanings:

• Many programming languages use "variable" to mean a named bucket, which holds a single value at any given time. (Dyna also has such buckets, but calls them items.)
• Mathematicians occasionally use "variable" to mean "unknown," i.e., a single value that one wishes to find. (Dyna's items can be regarded as playing this role as well, since Dyna can be regarded as an equation solver that tries to find the true value of each item.)

## Anonymous variables

If a variable is only used once in an inference rule, query, or constraint, then you can avoid giving it a name if you prefer. You can use the special anonymous variable _. Multiple instances of _ are treated as distinct variables, so the following are equivalent:

foo(X)  = bar(X,_,_).
foo(X)  = bar(X,Y,Z).    % not bar(X,Y,Y)