BREAKING NEWS
Iverson bracket

Summary

In mathematics, the Iverson bracket, named after Kenneth E. Iverson, is a notation that generalises the Kronecker delta, which is the Iverson bracket of the statement x = y. It maps any statement to a function of the free variables in that statement. This function is defined to take the value 1 for the values of the variables for which the statement is true, and takes the value 0 otherwise. It is generally denoted by putting the statement inside square brackets:

${\displaystyle [P]={\begin{cases}1&{\text{if }}P{\text{ is true;}}\\0&{\text{otherwise.}}\end{cases}}}$
In other words, the Iverson bracket of a statement is the indicator function of the set of values for which the statement is true.

The Iverson bracket allows using capital-sigma notation without summation index. That is, for any property ${\displaystyle P(k)}$ of the integer ${\displaystyle k}$,

${\displaystyle \sum _{k}f(k)\,[P(k)]=\sum _{P(k)}f(k).}$

By convention, ${\displaystyle f(k)}$ does not need to be defined for the values of k for which the Iverson bracket equals 0; that is, a summand ${\displaystyle f(k)[{\textbf {false}}]}$ must evaluate to 0 regardless of whether ${\displaystyle f(k)}$ is defined. Likewise for products:

${\displaystyle \prod _{k}f(k)^{[P(k)]}=\prod _{P(k)}f(k).}$

The notation was originally introduced by Kenneth E. Iverson in his programming language APL,[1][2] though restricted to single relational operators enclosed in parentheses, while the generalisation to arbitrary statements, notational restriction to square brackets, and applications to summation, was advocated by Donald Knuth to avoid ambiguity in parenthesized logical expressions.[3]

Properties

There is a direct correspondence between arithmetic on Iverson brackets, logic, and set operations. For instance, let A and B be sets and ${\displaystyle P(k_{1},\dots )}$  any property of integers; then we have

{\displaystyle {\begin{aligned}[][\,P\land Q\,]~&=~[\,P\,]\,[\,Q\,]~~;\\[1em][\,P\lor Q\,]~&=~[\,P\,]\;+\;[\,Q\,]\;-\;[\,P\,]\,[\,Q\,]~~;\\[1em][\,\neg \,P\,]~&=~1-[\,P\,]~~;\\[1em][\,P{\scriptstyle {\mathsf {\text{ XOR }}}}Q\,]~&=~{\Bigl |}\,[\,P\,]\;-\;[\,Q\,]\,{\Bigr |}~~;\\[1em][\,k\in A\,]\;+\;[\,k\in B\,]~&=~[\,k\in A\cup B\,]\;+\;[\,k\in A\cap B\,]~~;\\[1em][\,x\in A\cap B\,]~&=~[\,x\in A\,]\,[\,x\in B\,]~~;\\[1em][\,\forall \,m\ :\,P(k,m)\,]~&=~\prod _{m}\,[\,P(k,m)\,]~~;\\[1em][\,\exists \,m\ :\,P(k,m)\,]~&=~\min {\Bigl \{}\;1\,,\,\sum _{m}\,[\,P(k,m)\,]\;{\Bigr \}}=1\;-\;\prod _{m}\,[\,\neg \,P(k,m)\,]~~;\\[1em]\#{\Bigl \{}\;m\,{\Big |}\,P(k,m)\;{\Bigr \}}~&=~\sum _{m}\,[\,P(k,m)\,]~~.\end{aligned}}}

Examples

The notation allows moving boundary conditions of summations (or integrals) as a separate factor into the summand, freeing up space around the summation operator, but more importantly allowing it to be manipulated algebraically.

Double-counting rule

We mechanically derive a well-known sum manipulation rule using Iverson brackets:

{\displaystyle {\begin{aligned}\sum _{k\in A}f(k)+\sum _{k\in B}f(k)&=\sum _{k}f(k)\,[k\in A]+\sum _{k}f(k)\,[k\in B]\\&=\sum _{k}f(k)\,([k\in A]+[k\in B])\\&=\sum _{k}f(k)\,([k\in A\cup B]+[k\in A\cap B])\\&=\sum _{k\in A\cup B}f(k)\ +\sum _{k\in A\cap B}f(k).\end{aligned}}}

Summation interchange

The well-known rule ${\textstyle \sum _{j=1}^{n}\sum _{k=1}^{j}f(j,k)=\sum _{k=1}^{n}\sum _{j=k}^{n}f(j,k)}$  is likewise easily derived:

{\displaystyle {\begin{aligned}\sum _{j=1}^{n}\,\sum _{k=1}^{j}f(j,k)&=\sum _{j,k}f(j,k)\,[1\leq j\leq n]\,[1\leq k\leq j]\\&=\sum _{j,k}f(j,k)\,[1\leq k\leq j\leq n]\\&=\sum _{j,k}f(j,k)\,[1\leq k\leq n]\,[k\leq j\leq n]\\&=\sum _{k=1}^{n}\,\sum _{j=k}^{n}f(j,k).\end{aligned}}}

Counting

For instance, the Euler phi function that counts the number of positive integers up to n which are coprime to n can be expressed by

${\displaystyle \varphi (n)=\sum _{i=1}^{n}[\gcd(i,n)=1],\qquad {\text{for }}n\in \mathbb {N} ^{+}.}$

Simplification of special cases

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

${\displaystyle \sum _{1\leq k\leq n \atop \gcd(k,n)=1}\!\!k={\frac {1}{2}}n\varphi (n)}$

is valid for n > 1 but is off by 1/2 for n = 1. To get an identity valid for all positive integers n (i.e., all values for which ${\displaystyle \phi (n)}$  is defined), a correction term involving the Iverson bracket may be added:

${\displaystyle \sum _{1\leq k\leq n \atop \gcd(k,n)=1}\!\!k={\frac {1}{2}}n(\varphi (n)+[n=1])}$

Common functions

Many common functions, especially those with a natural piecewise definition, may be expressed in terms of the Iverson bracket. The Kronecker delta notation is a specific case of Iverson notation when the condition is equality. That is,

${\displaystyle \delta _{ij}=[i=j].}$

The indicator function, often denoted ${\displaystyle \mathbf {1} _{A}(x)}$ , ${\displaystyle \mathbf {I} _{A}(x)}$  or ${\displaystyle \chi _{A}(x)}$ , is an Iverson bracket with set membership as its condition:

${\displaystyle \mathbf {I} _{A}(x)=[x\in A].}$

The Heaviside step function, sign function,[1] and absolute value function are also easily expressed in this notation:

{\displaystyle {\begin{aligned}H(x)&=[x>0],\\\operatorname {sgn}(x)&=[x>0]-[x<0],\end{aligned}}}

and

{\displaystyle {\begin{aligned}|x|&=x[x>0]-x[x<0]\\&=x([x>0]-[x<0])\\&=x\cdot \operatorname {sgn}(x).\end{aligned}}}

The comparison functions max and min (returning the larger or smaller of two arguments) may be written as

${\displaystyle \max(x,y)=x[x>y]+y[x\leq y]}$

and
${\displaystyle \min(x,y)=x[x\leq y]+y[x>y].}$

The floor and ceiling functions can be expressed as

${\displaystyle \lfloor x\rfloor =\sum _{n}n\cdot [n\leq x

and
${\displaystyle \lceil x\rceil =\sum _{n}n\cdot [n-1

where the index ${\displaystyle n}$  of summation is understood to range over all the integers.

The ramp function can be expressed

${\displaystyle R(x)=x\cdot [x\geq 0].}$

The trichotomy of the reals is equivalent to the following identity:

${\displaystyle [ab]=1.}$

The Möbius function has the property (and can be defined by recurrence as[4])

${\displaystyle \sum _{d|n}\mu (d)\ =\ [n=1].}$

Formulation in terms of usual functions

In the 1830s, Guglielmo dalla Sommaja used the expression ${\displaystyle 0^{0^{x}}}$  to represent what now would be written ${\displaystyle [x>0]}$ ; he also used variants, such as ${\displaystyle \left(1-0^{0^{-x}}\right)\left(1-0^{0^{x-a}}\right)}$  for ${\displaystyle [0\leq x\leq a]}$ .[3] Following one common convention, those quantities are equal where defined: ${\displaystyle 0^{0^{x}}}$  is 1 if x > 0, is 0 if x = 0, and is undefined otherwise.

Notational variations

In addition to the now-standard square brackets [ · ] , and the original parentheses ( · ) , wiggly brackets have also been used, e.g. ⧙ · ⧘ , as well as other unusual forms of bracketing marks available in the publisher's typeface, accompanied by a marginal note.