Expression Pattern Language (eXPL)

eXPL Axiom Lists

Axiom lists in eXPL are collections of axioms generated during the processing of a query and are made available in the query result. Axiom lists are also accessible during processing which permits a list to be arranged in any desired order. An insertion sort can be found in "Sort Cities Example" of eXPL Calculator.

Format

An Axiom list declaration has format:

list name(source).

Unlike a Value or Term list, there is no type specifier. The source can be a previously declared axiom or template. In the latter case, the list contains the snapshot axioms created on each successful unification step during execution of a query, Note that the name of a template is normally allowed to be the same as the axion with which it unifies, but this is not allowed if the template is the source of an axiom list.

Axiom list indexes start from zero. The list items are Term lists to allow axiom access using a second array index. So given an Axiom list named "city_list",

city_list[0]

is the first axiom in the list and

city_list[0][name]

is a reference to the name of the first city.

Axiom list items are not likely to be used within queries except perhaps for ordering the results. An item can be assigned to a temporary variable during a swap operation, but that is about all that is allowed. To reference an Axiom list the same rules apply as for a Value list item. ie. an integer literal, variable or expression must be used.

Here is an example of a template declaration followed by an Axiom list declaration to capture the result:

// Template for name and altitude of a high city
template high_city(name ? altitude > 5000, altitude);
// Solution is a list named 'city_list' which receives 'high_city' axioms
list city_list(high_city);

The opposite example shows the city_list in action.

High Cities Example

Previous examples involving axioms progressively displayed result on each completed unification. The code for this example delays displaying results until the completion of the query by using an Axiom list. The eXPL script declares the city_list Axiom list and this advertises that query results will be contained in the list.

axiom city()
{"bilene", 1718}
{"addis ababa", 8000}
{"denver", 5280}
{"flagstaff", 6970}
{"jacksonville", 8}
{"leadville", 10200}
{"madrid", 1305}
{"richmond",19}
{"spokane", 1909}
{"wichita", 1305};
// Template for name and altitude of a high city
template high_city(name ? altitude > 5000, altitude);
// Solution is a list named 'city_list' which receives 'high_city' axioms
list city_list(high_city);
query high_cities (city : high_city);

tutorial7 HighCitiesListed code example runs this query. The console output when the query is run displays the contents of city_list list:

high_city(name = flagstaff, altitude = 6970)
high_city(name = addis ababa, altitude = 8000)
high_city(name = denver, altitude = 5280)
high_city(name = leadville, altitude = 10200)
An axiom list can refer to a source that is declared after the axiom list is declared