# Boolean Function
**A binary variable [[function]] defined by a Boolean equation.**
A Boolean equation contains *literals* and *terms* as operands of [[Boolean Algebra#Logical operations|logical operations]]. Boolean functions can be simplified by applying [[Boolean algebra]].
Boolean functions are typically expressed in *standard form*.
> [!Literal]
> A *literal* is a unique occurrence of a variable in a function, including complements separately.
>
> The following equation contains $5$ literals.
> $B(A+D)+AC$
^2dba35
> [!Term]
> A *term* is an occurrence of a literal or either a conjunction or disjunction of literals in a function.
>
> Alternatively, terms are any combination of literals separated by a logical operation.
>
> The previous equation contains $8$ terms; $A$ (counted twice), $B$, $C$, $D$, $A+D$, $AC$, $B(A+D)$.
^5aa5f5
## Standard forms
There are two pairs of [[Duality#Boolean Algebra|dual]] *standard* or *canonical* forms of Boolean functions, both of which contain only [[minterms and maxterms]].
Standard forms are a more desirable form for circuit implementation.
### Minterm or maxterm canonical form
The *minterm* or *maxterm canonical form* of a Boolean function consists entirely of minterms or maxterms for which the function has a value of $1$ or $0$, respectively.
> [!NOTE] Minterm canonical form
> The *minterm canonical form* of a Boolean function consists of [[Disjunction|disjunctions]] of only [[Minterms and Maxterms#Minterms|minterms]] for which the function value is $1$.
> [!NOTE] Maxterm canonical form
> The *maxterm canonical form* of a Boolean function consists of [[Conjunction|conjunctions]] of only [[Minterms and Maxterms#Maxterms|maxterms]] for which the function value is $0$.
The maxterm canonical form can be derived by applying [[De Morgan's laws]] to the minterm canonical form of the *complement* of the Boolean function.
These forms are denoted by a $\Sigma$ or $\Pi$ symbol followed by an $m$ or $M$ for minterm or maxterm canonical form respectively, then a list of the *rows of the truth table* corresponding to the minterms and maxterms.
#### Examples
> [!Example]- Minterm canonical form
> For the Boolean function defined by the truth table
>
> | $X$ | $Y$ | $Z$ | | $F$ |
| :---: | :---: | :---: | --- | :---: |
| $0$ | $0$ | $0$ | | $1$ |
| $0$ | $0$ | $1$ | | $0$ |
| $0$ | $1$ | $0$ | | $1$ |
| $0$ | $1$ | $1$ | | $0$ |
| $1$ | $0$ | $0$ | | $0$ |
| $1$ | $0$ | $1$ | | $1$ |
| $1$ | $1$ | $0$ | | $0$ |
| $1$ | $1$ | $1$ | | $1$ |
>
> Its minterm canonical form is
>
$\begin{align*} F(X,Y,Z)&=\sum{m(0,2,5,7)} \\ &=\bar{X}\bar{Y}\bar{Z}+\bar{X}Y\bar{Z}+X\bar{Y}Z+XYZ\end{align*}$
> [!Example]- Maxterm canonical form
> For the same Boolean function in the above example, the maxterm canonical form is
>
> $\begin{align*} F(X,Y,Z)&=\prod M(1,3,4,6) \\ &= (X+Y+\bar{Z})(X+\bar{Y}+\bar{Z})(\bar{X}+Y+Z)(\bar{X}+\bar{Y}+Z) \end{align*}$
### Sum-of-products or product-of-sums form
The *sum-of-products* or *product-of-sums* canonical form of a Boolean function are simplified forms of minterm and maxterm canonical forms. They *do not* necessarily have all variables in every term.
Sum-of-products or product-of-sum forms can be directly implemented as a *two-level circuit*.
> [!NOTE] Sum-of-products canonical form
> The *sum-of-products canonical form* of a Boolean function consists of a [[disjunction]] of [[conjunction]] terms for which the function value is $1$.
> [!NOTE] Product-of-sums canonical form
> The *product-of-sums canonical form* of a Boolean function consists of a [[conjunction]] of [[disjunction]] terms for which the function value is $0$.
#### Examples
> [!Example]- Sum-of-products form
$F=\bar{Y}+\bar{X}Y\bar{Z}+XY$
>
![[SumOfProductsCircuit.svg|500]]
> [!Example]- Product-of-sums form
$F=X(\bar{Y}+Z)(X+Y+\bar{Z})$
>
![[ProductOfSumsCircuit.svg|500]]
## Complement of a Boolean function
The complement of a function can be found either using [[De Morgan's laws]] or complementing each literal of its [[Duality#Boolean Algebra|dual]].
> [!Example]- De Morgan's laws
> $F=\bar{X}Y\bar{Z}+\bar{X}\bar{Y}Z$
> $\begin{flalign}
\bar{F}&=\overline{\bar{X}Y\bar{Z}+\bar{X}\bar{Y}Z} &\\
&=\overline{(\bar{X}Y\bar{Z})}\overline{(\bar{X}\bar{Y}Z)} &\\
&=(X+\bar{Y}+Z)(X+Y+\bar{Z})
\end{flalign}$
> [!Example]- Dual of a function
> $F=\bar{X}Y\bar{Z}+\bar{X}\bar{Y}Z$
> $\begin{flalign}
F_{\text{dual}} &= (\bar{X}+Y+\bar{Z})(\bar{X}+\bar{Y}+Z) &\\
\therefore \bar{F} &= (X+\bar{Y}+Z)(X+Y+\bar{Z})
\end{flalign}$