Template-Axiom-Query (TAQ)

Axioms

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:

axiom aqua ( red, green, blue ) { 0, 255, 255 }

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:

list<axiom> subjects,
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.

Changing a term value is demonstrated in black-is-white.taq. This shows how to change a axiom containing the name and red-green-blue components of the color black into one for the color white. There are three queries to include "axiom in a list" scenarios. The query "color_query" works with a single "color_axiom" axiom

axiom color_query
(name, red, green, blue)
{"black", 0, 0, 0}

This is the "inverse" template

template inverse
{ list<term> term_list = list color_axiom }
(
// Set inverse name
. term_list->name = "white",
// Invert colors
. term_list->red ^= 255,
. term_list->green ^= 255,
. term_list->blue ^= 255,
term color_axiom
)

Note the ease with which an axiom can be accessed as a term list by using keyword list. Here is the console output showing black has been turned into white

color_query((name="white", red=255, green=255, blue=255))
Return Term List

A query or a template can return a single axiom result wrapped in a term list using notation <term> following the query or template keyword. The term list name is the same as the query or template. When a template is declared as returning a term list, then the list is available to all templates that follow in the program.