Terms
Everything written in AIDDL proper (i.e. the language) is a Term.
The following table provides an overview of all basic types of terms with a short description and example.
Name | Reference | Description | Examples |
|---|---|---|---|
Term |
| Every AIDDL expression is a term. | see below |
Symbolic |
| Non-numerical constants. |
|
Boolean |
| Boolean constants |
|
Variable |
| Named variables beginning with |
|
String |
| Any string of characters in quotes. |
|
Numerical |
| Different types of numerical values. | see below |
Integer |
| Positive or negative integers. |
|
Rational |
| Positive or negative rational numbers. |
|
Real |
| Positive or negative real numbers. |
|
Infinity |
| Positive or negative infinity. |
|
NaN |
| Not a Number |
|
Collection |
| Collections of terms. | see below |
Set |
| A set of terms. Cannot be matched to other terms. |
|
List |
| A list of terms. |
|
Tuple |
| A tuple of terms. Unlike lists, we assume tuples will not be extended. |
|
Reference |
| A reference to an entry in a specific module. |
|
Function Reference |
| Reference to a function. Allows using functions as data. |
|
| |||
Key Value Pair |
| A key and a value term. The key must not be a Key-value pair itself. |
|
Grammar
Every AIDDL file represents a module and consists of a module specification and an arbitrary number of entries. Each entry consists of a type, a name and a value (all terms).
Reference Terms
There are two type of reference terms in AIDDL: entry references and function references.
Entry Reference Terms
Entry reference terms point to entries in the same or in other modules. This is useful when the referenced entry may change or when trying to break down large models into smaller pieces that can then be assembled. In general, references can be written as
where name is again an entry name and alias is the local name of the module in which the entry can be found. References to the same module can be written more compactly as
where name is the name of an entry in the current module. This is equivalent to writing
if self is the self alias of the current module established by the #mod entry of a module:
Other aliases are established through #req entries that load other modules as requirements. For example, after loading the module req-uri with
we can refer to an entry named name with
Resolving References
In any AIDDL core there exists a function that allows to resolve any references in a term recursively given a container.
Note that the result of this may change if the referenced entries change. So any term that includes a reference term may represent a different term depending on when it is resolved.
Further, entry references may refer to their own entry. In such cases some care is required when resolving references in terms. For instance
Defines S as a set that contains S. Attempting to fully resolve this term is not possible because the result is an infinetly nested set.
Function Reference Terms
Function reference terms signal that a symbol references a function. This allows to pass functions as arguments (i.e. higher-order functions) and to use these functions as building blocks (e.g., a heuristic function can be provided to a search algorithm). Function references are preceded by the ^ symbol and consist of a symbolic term, or a reference term.
In the latter case, the alias will be resolved to the URI of the referenced module. The following two entries, for instance, are equivalent if M is an alias for org.aiddl.my-module:
Function references assume that their functions are registered (in the container or function registry) when they are first used. The actual functions may be implemented in any programming langage with an AIDDL core library or via #def or #type entries.