# Elementary recursive function

In recursion theory, an elementary recursive function, also called an elementary function, or a Kalmár elementary function, is a restricted form of a primitive recursive function, allowing bounded applications of exponentiation (for example, $O(2^{2^{n}})$).
The name was coined by László Kalmár, in the context of recursive functions and undecidability; most elementary recursive functions are far from elementary. Not all primitive recursive problems are elementary; for example, tetration is not elementary. The corresponding class of decision problems is denoted ${\mathsf {ELEMENTARY}}$.

## Definition

The definitions of elementary recursive functions are the same as for primitive recursive functions, except that primitive recursion is replaced by bounded summation and bounded product. All functions work over the natural numbers. The basic functions, all of them elementary recursive, are:
* Zero function. Returns zero: f(x) = 0.
* Successor function: f(x) = x + 1. Often this is denoted by S, as in S(x). Via repeated application of a successor function, one can achieve addition.
* Projection functions: these are used for ignoring arguments. For example, f(a, b) = a is a projection function.
* Subtraction function: f(x, y) = x − y if y < x, or 0 if y ≥ x. This function is used to define conditionals and iteration.
From these basic functions, we can build other elementary recursive functions.
* Composition: applying values from some elementary recursive function as an argument to another elementary recursive function. In f(x$_1$, ..., x$_n$) = h(g$_1$(x$_1$, ..., x$_n$), ..., g$_m$(x$_1$, ..., x$_n$)) is elementary recursive if h is elementary recursive and each g$_i$ is elementary recursive.
* Bounded summation: $f(m,x_{1},\ldots ,x_{n})=\sum \limits _{i=0}^{m}g(i,x_{1},\ldots ,x_{n})$ is elementary recursive if g is elementary recursive.
* Bounded product: $f(m,x_{1},\ldots ,x_{n})=\prod \limits _{i=0}^{m}g(i,x_{1},\ldots ,x_{n})$ is elementary recursive if g is elementary recursive.

## Basis for ELEMENTARY

The class of elementary functions coincides with the closure with respect to composition of the projections and one of the following function sets: $\{n+1,n\,{\stackrel {.}{-}}\,m,\lfloor n/m\rfloor ,n^{m}\}$, $\{n+m,n\,{\stackrel {.}{-}}\,m,\lfloor n/m\rfloor ,2^{n}\}$, $\{n+m,n^{2},n\,{\bmod {\,}}m,2^{n}\}$, where $n\,{\stackrel {.}{-}}\,m=\max\{n-m,0\}$ is the subtraction function defined above.

## Lower elementary recursive functions

Lower elementary recursive functions follow the definitions as above, except that bounded product is disallowed. That is, a lower elementary recursive function must be a zero, successor, or projection function, a composition of other lower elementary recursive functions, or the bounded sum of another lower elementary recursive function.
Lower elementary recursive functions are also known as Skolem elementary functions.
Whereas elementary recursive functions have potentially more than exponential growth, the lower elementary recursive functions have polynomial growth.
The class of lower elementary functions has a description in terms of composition of simple functions analogous to that we have for elementary functions. Namely, a polynomial-bounded function is lower elementary if and only if it can be expressed using a composition of the following functions: projections, $n+1$, $nm$, $n\,{\stackrel {.}{-}}\,m$, $n\wedge m$, $\lfloor n/m\rfloor$, one exponential function ($2^{n}$ or $n^{m}$) with the following restriction on the structure of formulas: the formula can have no more than two floors with respect to an exponent (for example, $xy(z+1)$ has 1 floor, $(x+y)^{yz+x}+z^{x+1}$ has 2 floors, $2^{2^{x}}$ has 3 floors). Here $n\wedge m$ is a bitwise AND of n and m.

## Descriptive characterization

In descriptive complexity, ELEMENTARY is equal to the class HO of languages that can be described by a formula of higher-order logic. This means that every language in the ELEMENTARY complexity class corresponds to as a higher-order formula that is true for, and only for, the elements on the language. More precisely, ${\mathsf {NTIME}}\left(2^{2^{\cdots {2^{O(n)}}}}\right)=\exists{\mathsf {HO}}^{i}$, where ⋯ indicates a tower of i exponentiations and $\exists{\mathsf {HO}}^{i}$ is the class of queries that begin with existential quantifiers of ith order and then a formula of (i − 1)th order.