# Difference between revisions of "Boolean Algebra"

Boolean algebra is the branch of algebra in which the values of the variables and constants have exactly two values: true and false, usually denoted 1 and 0 respectively. This description borrows from the Wikipedia article on Boolean Algebra.

The basic operators in Boolean algebra are and, or, and not. The and of two values is true only whenever both values are true. The or of two values is true whenever either or both values are true. The not of a true value is false, and the not of a false value is true. The secondary operators are exclusive or (often called xor) and equivalence . The xor of two values is true whenever the values are different; the equivalence of two values is true when both values are the same. Just as algebra has basic rules for simplifying and evaluating expressions, so does Boolean algebra.

## Why is Boolean Algebra Important for ACSL Students?

Boolean algebra is important to programmers, computer scientists, and the general population.

• For programmers, Boolean expressions are used for conditionals and loops. For example, the following snippet of code sums the even numbers that are not also multiples of 3, stopping when the sum hits 100:
s = 0
x = 1
while (s < 100):
if (x % 2 == 0) and (x % 3 != 0):
s = s + x
x = x + 1


Both s < 100 and (x % 2 == 0) and (x % 3 != 0) are Boolean expressions.

• For computer scientists, Boolean algebra is the basis for digital circuits that make up a computer's hardware. The Digital Electronics category concerns a graphical representation of a circuit. That circuit is typically easiest to understand and evaluate by converting it to its Boolean algebra representation.
• The general population uses Boolean algebra, probably without knowing that they are doing so, when they enter search terms in Internet search engines. For example, the search expression "red sox -yankees" is the Boolean expression "red" and "sox" and not "yankees" that will returns web pages that contain the words "red" and "sox", as long as it does not contain the word "yankees". The search expression "jaguar speed -car" returns pages about the speed of the jaguar animal, not the Jaguar car.

## Operations

### Basic operations

The basic operations of Boolean algebra are and, or, and not.

• and (conjunction) is denoted as $x \text{ AND } y$, $x \& y$, $xy$, or $x \cdot y$. The and of two values is true only when both values are true.
• or (disjunction) is denoted as $x \text{ OR } y$, or $x + y$ . The or of two values is true whenever one or both values are true.
• not (negation) is denoted as $\text{ NOT } x$, $\neg x$, or $\bar{x}$ . The not of a value is its opposite; that is, the not of a true value is false whereas the not" of a false value is true.

The values of and, or, and not for all possible inputs is shown in the following truth table:

$x$ $y$ $x y$ $x + y$ $\bar{x}$
0 0 0 0 1
1 0 0 1 0
0 1 0 1 1
1 1 1 1 0

### Secondary operations

The secondary Boolean operators are exclusive or and equivalence. They are secondary in the sense that they can be composed from the basic operations of and, or, and not.

• exclusive or or xor is denoted as $x \oplus y$, or $x \text{ xor } y$. The xor of two values is true when the values are different. It can also be represented by ands and ors:
$x \oplus y = (x \cdot \bar{y}) + (\bar{x} \cdot y)$
• equivalence is denoted as $x \equiv y$, $x \odot y$, or $x \text{ equ } y$ The equivalence of two values is true when the values are the same; it is the not of the xor function, or from ands and ors:
$x \odot y = x \cdot y + \bar{x} \cdot \bar{y}$

Here is the truth table of xor and equivalence for all four possible inputs.

$x$ $y$ $x \oplus y$ $x \odot y$
0 0 0 1
1 0 1 0
0 1 1 0
1 1 0 1

## Laws

A law of Boolean algebra is an identity such as $x + (y + z) = (x + y) + z$ between two Boolean terms, where a Boolean term is defined as an expression built up from variables and the constants 0 and 1 using the operations and, or, and not.

### Monotone laws

Boolean algebra satisfies many of the same laws as ordinary algebra when one matches up or with addition and and with multiplication. In particular the following laws are common to both kinds of algebra:

 Associativity of or: $x + (y + z)$ $= (x + y) + z$ Associativity of and: $x \wedge (y \cdot z)$ $= (x \cdot y) \wedge z$ Commutativity of or: $x + y$ $= y + x$ Commutativity of and: $x \cdot y$ $= y \cdot x$ Distributivity of and over or: $x \cdot (y + z)$ $= (x \cdot y) + (x \cdot z)$ Identity for or: $x + 0$ $= x$ Identity for and: $x \cdot 1$ $= x$ Annihilator for and: $x \cdot 0$ $= 0$

The following laws hold in Boolean Algebra, but not in ordinary algebra:

 Annihilator for or: $x +1$ $= 1$ Idempotence of or: $x +x$ $= x$ Idempotence of and: $x \cdot x$ $= x$ Absorption 1: $x \cdot (x + y)$ $= x$ Absorption 2: $x + (x \cdot y)$ $= x$ Distributivity of or over and: $=(x + y) \cdot (x +z)$

### Nonmonotone laws

The complement operation is defined by the following two laws.

\begin{align} &\text{Complementation 1} & x \cdot \neg x & = 0 \\ &\text{Complementation 2} & x + \neg x & = 1 \end{align}

All properties of negation including the laws below follow from the above two laws alone.<ref name="givhal"/>

In both ordinary and Boolean algebra, negation works by exchanging pairs of elements, whence in both algebras it satisfies the double negation law (also called involution law)

\begin{align} &\text{Double negation} & \neg{(\neg{x})} & = x \end{align}

### De Morgan's Laws

Boolean algebra satisfies De Morgan's laws:

\begin{align} &\text{De Morgan 1} & \neg x \cdot \neg y & = \neg{(x + y)} \\ &\text{De Morgan 2} & \neg x +\neg y & = \neg{(x \cdot y)} \end{align}