Axiom variables hold axiom lists and like other variables can be set by assignment in an expression or by unification. In addition, axiom variables can grow by concatenation, accepting both axiom lists and axiom term lists. Concatenation is allowed only if the axiom list of the axiom variable is empty or contains the same number of terms as the list participating on the other side. Note the concatenation operator is +=, the same as for strings.
Format
An Axiom variable declaration has format:
axiom name = axiom-initializer.
An axiom-initializer can be:
- axiom-list-expression, for example, a variable containing an axiom list generated in a previous operation
- axiom-term-list-expression, in which case the axiom variable adapts to access terms instead of axioms
- axiom-list-literal, which is described in more detail below. An empty list is indicated by empty {} braces
Note that the axiom-initializer is required whenever a variable is explicitly typed as an "axiom". An untyped variable, when assigned an axiom list as a value, will adapt to behave the same as an Axiom variable.
Two important features particular to Axiom variables:
- When an Axiom variable references a list containing a single axiom, then an array index can used to reference axiom terms by name. See "expand" axiom in Regex Groups Example for an example
- The axiom list value is automatically included in the query result. The list is referenced in code using the name of the Axiom variable.
Axiom List Literal
Axiom List Literals declare one or more axioms to assign to an axiom variable. Each axiom must have the same number of terms, but terms need not have literal values. The terms can be variables which are set in a unification+evaluation step. Each axiom is enclosed in {} braces and there is no separator between axioms. Axiom terms are comma-separated.
Here is an example of an Axiom variable initialized with a Axiom List Literal containing 3 axioms. The variable is used to pass the marks in 3 school subjects, with a character grading system replacing a numeric score:
{ "English", mark[(english)] }
{ "Math", mark[(math)] }
{ "History", mark[(history)] }
