Axioms are used collectively to transfer data, record by record, in and out of program modules, but single axioms also have parts to play. An example is an axiom which collects aggregate data and is exported to the query solution as additional data.
Axiom Creation
A single axiom is declared using the same format as for an axiom list but with the keyword "list"" omitted. Here is an example of an axiom for the color aqua:
Dynamic axiom creation uses variables and expressions to form term values. The format is geared for placement in an expression:
axiom [ name ] { term, term... }
Note the axiom name is optional. A term consists of either the name of a variable or an assignment "identifier = expression", the identifier being the term name and the expression evaluating to the term value. Here is an example of an anonymous axiom created on the fly to be placed in a list to contain school marks:
subjects += axiom { subject="English", mark=alpha_marks[english] }
Note that "mark[english]" is an expression that references an item in a list of marks ranked alphabetically. The axion term names are specified as "subject" and "mark"
Term Lists
A term list mostly has the characteristics of a basic list, but it must be bound to an axiom when it is created as terms only exist in axioms. Term lists therefore are considered a feature of axioms Some other departures from basic lists are:
- Each list item can be of any type
- The -> operator selects an axiom term by name
The format to declare an axiom term list is:
list<term> name ( axiom )
A term list can be used to modify it's bound axiom, either changing the value of axiom terms or appending new terms. As an axiom is exportable these changes can be passed to the query solution.
Axiom Lists
An axiom list was introduced is high_cities.taq. An axiom list is recognizably a table with rows and columns. An axiom list consists entirely of literal terms which are expected to never change as it is meant to represent a set of facts. However, an axiom list can be generated dynamically at runtime and this is made possible by declaring it using expressions for term values in place of literals.
Evaluated Term Values
gaming.taq demonstrates an axiom list with evaluated term values. It is used as an axiom source for a fruity poker machine query which plays one turn at a time. The play is framed as a 3 x 4 matrix realized as an axiom list. Unpredictability is provided by using generated random numbers as parameters for setting term values. This is the list declaration, including random parameters:
term r1 = random(4)
term r2 = random(4)
term r3 = random(4)
list<axiom> crank
{ 3^r1, 2^r1, 0^r1, 1^r1 }
{ 0^r2, 1^r2, 2^r2, 3^r2 }
{ 2^r3, 1^r3, 3^r3, 0^r3 }
When you run the Gaming application, you will see unpredictable fruit combinations displayed in the console. It may come as a disappointment there is no jackpot.
Dynamic Lists
Dynamic axiom lists are initially empty and grow by concatenation during program execution. high-cities-dynamic.taq shows a dynamic list used to export the result of high cities query. The "high_city" template has an axiom list named "high_cities". This list grows by concatenating dynamically created axioms: The 'export' keyword in the list declaration means it will appear in the query solution. Note that a list can only be declared in the template scope as can be seen in this case.
{ export list<axiom> high_cities }
(
high_cities +=
Return Lists
Another manifestation of a dynamic axiom list is a query declaration starting with query<axiom>. In this case, the solution is an axiom list with the same name as the query name.