Template-Axiom-Query (TAQ)

Archetypes

An archetype is a blueprint setting out the names, types and order of the terms for a structure. It provides the basis on which 2 structures can be found to be logically equivalent. An archetype is uniquely identified by a combination of name and namespace, which is known as a qualified name. Every axiom is assigned an qualified name when it is created and this determines it's archetype. As for templates, both a template and it's archetype are uniquely identified by qualified name.

Unification

Archetypes play a pivotal role in unification. When a template encounters an axiom with an archetype it has never seen before, it creates a term mapping by comparing it's own archetype with that of the axiom. who-is_vaxxed.taq is a simple example with three queries to answer who, from three groups of people, has completed a course of vaccination jabs for a the latest pandemic. TAQ has to map axiom terms (name, is_vaxxed) to template terms (is_vaxxed, name). The mapping in this case is the number sequence (1, 0). meaning the first template term is paired to axiom term with index 1 leaving the second template term to be paired with the first axiom term with index 0. This simple mapping is stored ready for unifying any further axioms with the same archetype. Here is the program

boolean is_vaxxed = true

template vaxxed
(
. is_vaxxed,
name
)

query<axiom> vaxxed_patents(patients:vaxxed)
query<axiom> vaxxed_staff(staff:vaxxed)
query<axiom> vaxxed_contacts(contacts:vaxxed)

axiom list patients(name, is_vaxxed)
{ "John", "false" }
{ "Caroline", "true" }

axiom list staff(name, is_vaxxed)
{ "Paul", "yes" }
{ "Judy", "no" }

axiom list contacts(name, is_vaxxed)
{ "Simon", 1 }
{ "Jill", 0 }

The "is_vaxxed" term of the "vaxxed" template has a literal value of true. The query results show that this matches string "true" (Caroline) and "yes" (Paul) but not 1 (Simon). The first two matches are supported type conversions from string to boolean. There is no type conversion for integer to boolean.

Axiom Anomalies

Once an axiom with a new archetype has completed construction, the archetype is made non-mutable so that all axioms created using that archetype share the same structure. The term types included in the archetype are normally enforced, but there are two exceptions.

Axiom Congruence

When a dynamically created axiom is appended to a non-empty axiom list and the axiom archetype is different to the the lis's archetype, then the axiom undergoes a congruence check. This just ensures the axiom has the same term names is the same order as the list's archetype. Type checking is not part of the congruence check, but this should not be necessary in this context,

Unspecified Type

A question mark '?' can act as a place holder when only the term name is known but the type may become apparent when another axiom is created with the same archetype. This meets the needs when there are information gaps that are anticipated and need to be worked around. Classification schemes are an example where hierarchies fragment information across different categories. Consider birds. They are classified into order, family and species according to particular features such as size and diet. The aim of birds.taq to create a list of the distinguishing characteristics of birds belonging the "waterfowl" order. The input data consists of 3 lists, with each row containing a question mark '?' place holder every time a feature is "not applicable" for the current category. Here is the first row of the "bird_order" list:

axiom list bird_order (order, nostrils, live, bill, feet, eats)
{"waterfowl", ?, ?, "flat", "webbed", ?}
...

As the query percolates through the data, place holders are filled in, if possible. This is he statement to add items to the exported "species" axiom list:

species += axiom waterfowl
{
bird, family, color, size, flight, throat, voice, eats, tail

}

Note that all the variables for bird features seen here have been previously declared as strings. It is important to use typed variables with place holders. The solution is displayed on the console and the number of features shown per species varies because place holders are omitted. Here is how the species "pintail" is displayed:

bird=pintail, family=duck, flight=agile, voice=short whistle

A place holder is a literal with an empty string value and "to be specified" type which disables the normal archetype type checking for that term.