This site is supported by donations to The OEIS Foundation.

# Iverson bracket

The Iverson bracket, named after Kenneth E. Iverson, is a notation that denotes a number that is 1 if the condition in square brackets is satisfied, and 0 otherwise. More exactly,

${\begin{array}{l}\displaystyle {[P]={\begin{cases}1&{\text{if }}P{\text{ is true,}}\\0&{\text{otherwise.}}\end{cases}}}\end{array}}$ where
 P
is a predicate (i.e. a [​first-order logic​] statement that can be true or false). This notation was introduced by Kenneth E. Iverson in his programming language APL (named after the book A Programming Language), while the specific restriction to square brackets was advocated by Donald Knuth to avoid ambiguity in parenthesized logical expressions.

## Uses

The notation is useful in expressing sums or integrals without boundary conditions. For example

 1  ≤  i   ≤  10 ∑ 1  ≤  i   ≤  10

i  2  =
 i ∑ i

i  2 [1 ≤ i ≤ 10] .
In the first sum, the index
 i
is limited to be in the range 1 to 10. The second sum is allowed to range over all integers, but where
 i
is strictly less than 1 or strictly greater than 10, the summand is 0, contributing nothing to the sum. Such use of the Iverson bracket can permit easier manipulation of these expressions. (add an example of such a manipulation)

Another use of the Iverson bracket is to simplify equations with special cases. For example, the formula

 ∑ 1  ≤  k   ≤  n(k, n)   = 1

k  =
 n φ (n) 2
,
which is valid only for
 n > 1
, and may be written
 ∑ 1  ≤  k   ≤  n(k, n)   = 1

k  =
 n (φ (n) + [n = 1] ) 2
,
which is valid for all positive integers
 n
.

## Special cases

The Kronecker delta notation is a specific case of Iverson notation when the condition is equality

 δi j  =  [i = j ] .
The indicator function
 IA (x)
(or characteristic function
 χA (x)
) of a set
 A
, another specific case, has set membership as its condition
 IA (x)  =  χA (x)  =  [x ∈ A] .

The sign function and Heaviside step function are also easily expressed in this notation

 sgn (x)  =  [x > 0] − [x < 0] ,
H (x)  =  [x > 0] +
 1 2
[x = 0] .

And the trichotomy of the reals can be expressed

 [a < b] + [a = b] + [a > b]  =  1.