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
example abs(2 + (3 - 5))
(which uses the context example Absolute value). Click on the term to get an inspector, and look at the "Tree", "Normal form" and "Syntax" tabs. Then look at the "Sort" tab after reading the page Sorts.

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. example var:s.

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 example Operators/example, we can compose terms such as
example noArg
example prefix(noArg, noArg)
example noArg infix noArg[prefix(noArg, noArg infix noArg)]

We can also define a term including a variable:
example prefix(anyS:s, anyS)
Note that at least one reference to each variable must declare its sort. Alternatively, variable sort declarations can be written before the term:
example anyS:s, prefix(anyS, anyS)