Indicator functions for predicates
Use predicate indicators to count selected cases, gate algebraic terms, and express piecewise rules without losing boundary conditions.
Predicates as Indicator Inputs
A set indicator is already a truth test written as a number: \(\mathbf{1} A(x)\) equals \(1\) when \(x\in A\), and equals \(0\) when \(x\notin A\). In cases form, \[\mathbf{1} A(x)=\begin{cases}1,&\text{if }x\in A,\\0,&\text{if }x\notin A.\end{cases}\]
Iverson bracket notation removes the need for the condition to be set membership. For any predicate \(P\), the expression \(\mathbf{1}[P]\) turns the truth value of \(P\) into a zero-one value: \[\mathbf{1}[P]=\begin{cases}1,&\text{if }P\text{ is true},\\0,&\text{if }P\text{ is false}.\end{cases}\]
This means \(\mathbf{1} A(x)\) can be read as the special case \(\mathbf{1}[x\in A]\), but the bracket form also works for inequalities and other logical statements. For example, \(\mathbf{1}[3 2]=1\), \(\mathbf{1}[5\leq4]=0\), and \(\mathbf{1}[7\in\{2,5,7\}]=1\).
The output is not measuring how true the statement is; it is only recording true as \(1\) and false as \(0\).
Evaluating a Predicate Indicator
For a predicate \(P\), the indicator \(\mathbf{1}[P]\) converts truth into a number: it returns \(1\) when \(P\) is true and \(0\) when \(P\) is false. In this example, the whole predicate inside the brackets is the comparison \(9 7\).
Because \(9\) is greater than \(7\), the statement \(9 7\) is true. The indicator is not asking for the difference \(9-7\), or for the larger number; it only records the truth value of the comparison.
So the evaluation is \[\mathbf{1}[9 7]=1.\] The pattern is: decide whether the bracketed statement is true or false, then replace the indicator with \(1\) or \(0\).
Set Notation and Bracket Notation
Bracket notation generalizes the set indicator you already know. The set indicator \(\mathbf{1} A(x)\) is the special case where the bracketed predicate is membership in \(A\): \[\mathbf{1} A(x)=\mathbf{1}[x\in A].\]
Both sides make the same zero-one decision. If \(x\in A\), then \(\mathbf{1} A(x)=1\) and \(\mathbf{1}[x\in A]=1\). If \(x\notin A\), then \(\mathbf{1} A(x)=0\) and \(\mathbf{1}[x\in A]=0\). The notation changes, but the membership test and its value do not.
The advantage of \(\mathbf{1}[\cdot]\) is that the condition inside the brackets does not have to mention a set. It can be any predicate, including an inequality. For example, \(\mathbf{1}[x<0]\) is the indicator of the statement that \(x\) is negative: