
In
mathematics
Mathematics is a field of study that discovers and organizes methods, Mathematical theory, theories and theorems that are developed and Mathematical proof, proved for the needs of empirical sciences and mathematics itself. There are many ar ...
and
computer science
Computer science is the study of computation, information, and automation. Computer science spans Theoretical computer science, theoretical disciplines (such as algorithms, theory of computation, and information theory) to Applied science, ...
, a recursive definition, or inductive definition, is used to define the
elements in a
set
Set, The Set, SET or SETS may refer to:
Science, technology, and mathematics Mathematics
*Set (mathematics), a collection of elements
*Category of sets, the category whose objects and morphisms are sets and total functions, respectively
Electro ...
in terms of other elements in the set (
Aczel 1977:740ff). Some examples of recursively definable objects include
factorials,
natural numbers
In mathematics, the natural numbers are the numbers 0, 1, 2, 3, and so on, possibly excluding 0. Some start counting with 0, defining the natural numbers as the non-negative integers , while others start with 1, defining them as the positiv ...
,
Fibonacci numbers
In mathematics, the Fibonacci sequence is a sequence in which each element is the sum of the two elements that precede it. Numbers that are part of the Fibonacci sequence are known as Fibonacci numbers, commonly denoted . Many writers begin the s ...
, and the
Cantor ternary set.
A
recursive definition
A definition is a statement of the meaning of a term (a word, phrase, or other set of symbols). Definitions can be classified into two large categories: intensional definitions (which try to give the sense of a term), and extensional definitio ...
of a
function defines values of the function for some inputs in terms of the values of the same function for other (usually smaller) inputs. For example, the
factorial
In mathematics, the factorial of a non-negative denoted is the Product (mathematics), product of all positive integers less than or equal The factorial also equals the product of n with the next smaller factorial:
\begin
n! &= n \times ...
function is defined by the rules
:
This definition is valid for each natural number , because the recursion eventually reaches the
base case of 0. The definition may also be thought of as giving a procedure for computing the value of the function , starting from and proceeding onwards with etc.
The recursion theorem states that such a definition indeed defines a function that is unique. The proof uses
mathematical induction
Mathematical induction is a method for mathematical proof, proving that a statement P(n) is true for every natural number n, that is, that the infinitely many cases P(0), P(1), P(2), P(3), \dots all hold. This is done by first proving a ...
.
An inductive definition of a set describes the elements in a set in terms of other elements in the set. For example, one definition of the set of
natural number
In mathematics, the natural numbers are the numbers 0, 1, 2, 3, and so on, possibly excluding 0. Some start counting with 0, defining the natural numbers as the non-negative integers , while others start with 1, defining them as the positive in ...
s is:
#0 is in
#If an element ''n'' is in then is in
# is the smallest set satisfying (1) and (2).
There are many sets that satisfy (1) and (2) – for example, the set satisfies the definition. However, condition (3) specifies the set of natural numbers by removing the sets with extraneous members.
Properties of recursively defined functions and sets can often be proved by an induction principle that follows the recursive definition. For example, the definition of the natural numbers presented here directly implies the principle of mathematical induction for natural numbers: if a property holds of the natural number 0 (or 1), and the property holds of whenever it holds of , then the property holds of all natural numbers (Aczel 1977:742).
Form of recursive definitions
Most recursive definitions have two foundations: a base case (basis) and an inductive clause.
The difference between a
circular definition
A circular definition is a type of definition that uses the term(s) being defined as part of the description or assumes that the term(s) being described are already known. There are several kinds of circular definition, and several ways of chara ...
and a recursive definition is that a recursive definition must always have ''base cases'', cases that satisfy the definition ''without'' being defined in terms of the definition itself, and that all other instances in the inductive clauses must be "smaller" in some sense (i.e., ''closer'' to those base cases that terminate the recursion) — a rule also known as "recur only with a simpler case".
In contrast, a circular definition may have no base case, and even may define the value of a function in terms of that value itself — rather than on other values of the function. Such a situation would lead to an
infinite regress.
That recursive definitions are valid – meaning that a recursive definition identifies a unique function – is a theorem of set theory known as the
recursion theorem, the proof of which is non-trivial. Where the domain of the function is the natural numbers, sufficient conditions for the definition to be valid are that the value of (i.e., base case) is given, and that for , an algorithm is given for determining in terms of ,
(i.e., inductive clause).
More generally, recursive definitions of functions can be made whenever the domain is a
well-ordered set, using the principle of
transfinite recursion. The formal criteria for what constitutes a valid recursive definition are more complex for the general case. An outline of the general proof and the criteria can be found in
James Munkres' ''Topology''. However, a specific case (domain is restricted to the positive
integer
An integer is the number zero (0), a positive natural number (1, 2, 3, ...), or the negation of a positive natural number (−1, −2, −3, ...). The negations or additive inverses of the positive natural numbers are referred to as negative in ...
s instead of any well-ordered set) of the general recursive definition will be given below.
Principle of recursive definition
Let be a set and let be an element of . If is a function which assigns to each function mapping a nonempty section of the positive integers into , an element of , then there exists a unique function
such that
:
Examples of recursive definitions
Elementary functions
Addition
Addition (usually signified by the Plus and minus signs#Plus sign, plus symbol, +) is one of the four basic Operation (mathematics), operations of arithmetic, the other three being subtraction, multiplication, and Division (mathematics), divis ...
is defined recursively based on counting as
:
Multiplication
Multiplication is one of the four elementary mathematical operations of arithmetic, with the other ones being addition, subtraction, and division (mathematics), division. The result of a multiplication operation is called a ''Product (mathem ...
is defined recursively as
:
Exponentiation
In mathematics, exponentiation, denoted , is an operation (mathematics), operation involving two numbers: the ''base'', , and the ''exponent'' or ''power'', . When is a positive integer, exponentiation corresponds to repeated multiplication ...
is defined recursively as
:
Binomial coefficients
In mathematics, the binomial coefficients are the positive integers that occur as coefficients in the binomial theorem. Commonly, a binomial coefficient is indexed by a pair of integers and is written \tbinom. It is the coefficient of the te ...
can be defined recursively as
:
Prime numbers
The set of
prime number
A prime number (or a prime) is a natural number greater than 1 that is not a Product (mathematics), product of two smaller natural numbers. A natural number greater than 1 that is not prime is called a composite number. For example, 5 is prime ...
s can be defined as the unique set of positive integers satisfying
*
2 is a prime number,
* any other positive integer is a prime number if and only if it is not divisible by any prime number smaller than itself.
The primality of the integer 2 is the base case; checking the primality of any larger integer by this definition requires knowing the primality of every integer between 2 and , which is well defined by this definition. That last point can be proved by induction on , for which it is essential that the second clause says "if and only if"; if it had just said "if", the primality of, for instance, the number 4 would not be clear, and the further application of the second clause would be impossible.
Non-negative even numbers
The
even numbers can be defined as consisting of
* 0 is in the set of non-negative evens (basis clause),
* For any element in the set , is in (inductive clause),
* Nothing is in unless it is obtained from the basis and inductive clauses (extremal clause).
Well formed formula
The notion of a
well-formed formula
In mathematical logic, propositional logic and predicate logic, a well-formed formula, abbreviated WFF or wff, often simply formula, is a finite sequence of symbols from a given alphabet that is part of a formal language.
The abbreviation wf ...
(wff) in propositional logic is defined recursively as the smallest set satisfying the three rules:
# is a wff if is a propositional variable.
# is a wff if is a wff.
# is a wff if and are wffs and • is one of the logical connectives ∨, ∧, →, or ↔.
The definition can be used to determine whether any particular string of symbols is a wff:
* is a wff, because the propositional variables and are wffs and is a logical connective.
* is a wff, because is a wff.
* is a wff, because and are wffs and is a logical connective.
Recursive definitions as logic programs
Logic programs can be understood as sets of recursive
definition
A definition is a statement of the meaning of a term (a word, phrase, or other set of symbols). Definitions can be classified into two large categories: intensional definitions (which try to give the sense of a term), and extensional definitio ...
s.
[Warren, D.S. and Denecker, M., 2023. A better logical semantics for prolog. In Prolog: The Next 50 Years (pp. 82-92). Cham: Springer Nature Switzerland.] For example, the recursive definition of even number can be written as the logic program:
even(0).
even(s(s(X))) :- even(X).
Here
:- represents ''if'', and
s(X) represents the successor of
X, namely
X+1, as in
Peano arithmetic.
The logic programming language
Prolog
Prolog is a logic programming language that has its origins in artificial intelligence, automated theorem proving, and computational linguistics.
Prolog has its roots in first-order logic, a formal logic. Unlike many other programming language ...
uses
backward reasoning to solve goals and answer queries. For example, given the query
?- even(s(s(0))) it produces the answer
true. Given the query
?- even(s(0)) it produces the answer
false.
The program can be used not only to check whether a query is true, but also to generate answers that are true. For example:
?- even(X).
X = 0
X = s(s(0))
X = s(s(s(s(0))))
X = s(s(s(s(s(s(0))))))
.....
Logic programs significantly extend recursive definitions by including the use of negative conditions, implemented by
negation as failure, as in the definition:
even(0).
even(s(X)) :- not(even(X)).
See also
*
Definition
A definition is a statement of the meaning of a term (a word, phrase, or other set of symbols). Definitions can be classified into two large categories: intensional definitions (which try to give the sense of a term), and extensional definitio ...
*
Logic programming
Logic programming is a programming, database and knowledge representation paradigm based on formal logic. A logic program is a set of sentences in logical form, representing knowledge about some problem domain. Computation is performed by applyin ...
*
Mathematical induction
Mathematical induction is a method for mathematical proof, proving that a statement P(n) is true for every natural number n, that is, that the infinitely many cases P(0), P(1), P(2), P(3), \dots all hold. This is done by first proving a ...
*
Recursive data types
*
Recursion
Recursion occurs when the definition of a concept or process depends on a simpler or previous version of itself. Recursion is used in a variety of disciplines ranging from linguistics to logic. The most common application of recursion is in m ...
*
Recursion (computer science)
In computer science, recursion is a method of solving a computational problem where the solution depends on solutions to smaller instances of the same problem. Recursion solves such recursion, recursive problems by using function (computer sc ...
*
Structural induction
Notes
References
*
*
*
{{DEFAULTSORT:Recursive Definition
Definition
Mathematical logic
Theoretical computer science
Recursion