Terms
Terms are the most fundamental concept in Leibniz. All data and all code are represented as terms.
For a first impression of Leibniz terms, look at the term
(which uses the context
The different types of terms
There are three types of terms in Leibniz: standard terms, special terms, and variables.
Standard terms
A standard term is defined as consisting of an operator and zero or more argument terms .
There are four kinds of operators in Leibniz, which differ only in the way they are written, i.e. their syntax. See Operators for the details.
Special terms
There are three types of special terms , which do not have operators:
1. Number literals for Integers, Rational numbers, and Floating-point numbers. They do not have arguments.
2. Literals for Character strings, which do not have arguments either.
3. Array terms (see One-dimensional arrays), whose arguments are the array elements.
Variables
A
variable
looks like a zero-argument operator term, except that its name ends with an underscore, which is not an allowed character in operator names. The underscore is rendered as an underline for better readability, e.g.
Every term has a sort , which is defined by its operator (except for special terms and variables). Sorts define sets of terms. They are very similar to types in programming languages. See Sorts for a detailed discussion.
Examples
Given the operator definitions from
We can also define a term including a variable:
Note that at least one reference to each variable must declare its sort. Alternatively, variable sort declarations can be written before the term: