You are on page 1of 4

Boolean Functions and Truth Tables

Introduction
The study of building a computer begins with digital logic design. Nearly every computer is built
using digital logic. There may be an occasional unusual computer (say, neural networks), but
most of those are usually found in universities and research labs.
Compared to an electrical engineering curriculum, we'll study digital logic design in a fraction of
the time. How can we study it so quickly? Two reasons. First, we'll go over the material quicker
than in an electrical engineering course. Second, we'll leave out some topics (most notably,
circuit minimization and race conditions).
Just like the study of mathematical logic is done in two steps (propositional logic, followed by
predicate calculus), we'll also study digital logic in two steps. First, we talk about combinational
logic, then sequential logic.
I like to think of combinational logic circuits as implementations of Boolean functions. Think of
Boolean functions as an abstraction, and combinational logic circuits are the implementation of
that abstraction.
Of course, you can also think of combinational logic circuits as an abstraction, too, and the actual
silicon as the implementation. This goes to show you that there can be many levels of
abstraction, even in hardware.
We begin by discussing Boolean functions.

Boolean Functions
To understand Boolean functions, you need a basic understanding of set theory. At least, as much
set theory, as you'd see in a introductory level discrete math course.
First, let's define the set B = {0, 1}, where B is the set of Boolean values.
Instead of using true and false, we'll use 0 (for false) and 1 (for true). While this choice may
appear to be purely representational (i.e., we're using 0 and 1 as shorthand for false and true),
using numerals 0 and 1 also serves a second practical purpose: we can treat the 0's and 1's as
numbers in a representation system, and eventually do math with the 0's and 1's.
We define

Bk = B1 x B2 x ... x Bk
where Bi = B. This is the Cartesian cross product of k sets.
Bk is set of all k-tuples (b1, b2, ..., bk) such that bi is either 0 or 1 for all 1 <= i <= k. A k-tuple is
basically a k-dimensional coordinate.
Now that sounds mathematical doesn't it? However, you can also think of Bk as the set of all kbit bitstrings. That should make this set much easier to understand. As you should know by now,
Bk has size, 2k, since it's basically the set of all possible k-bit bitstring.
Now was can write a definition for Boolean functions.
Definition A Boolean function is Bk -> Bm, which is the set of all functions that map k bit inputs
to m bit outputs, where k >= 0 and m > 0.
Recall what a function is, from your discrete math courses.
A function consists of:
a domain (the set being mapped from),
a codomain (the set being mapped to),
a mapping from the domain to the codomain.
Usually, for each element in the domain, the mapping assigns one element of the codomain. If
this happens, the function is said to be total.

Sometimes, there are some elements in a domain that are not assigned at all. Thus, the mapping
for these elements are unknown. Such functions are said to be partial because not every element
in the domain is mapped. For finite domains and codomains, we can draw pictures.
Here are a few observations on the above diagram.
Each dot represents an element in the set.
Each dot in the domain has exactly one outgoing arrow. More than one outgoing arrow
per dot is not permitted.
If there is at least one dot with zero outgoing arrows in the domain, the function is partial.
However, each dot in the codomain can have any number of arrows pointing to it,
including no arrows (0, 1, or more).
The domain and codomain do not have to have the same number of elements.
The domain and codomain can be the same set. They do not have to be different sets.
k
B -> Bm is the set of all functions that map k-bit bitstrings (which is the domain of a single
function in the set) to m-bit bitstrings (which is the codomain of a single function in this set).
Remember Bk -> Bm this is a set of functions, not one single function.
This set is quite large, as you might imagine. The total number of functions is 22km. The way we
come up with this answer is based on truth tables.

Truth Tables
When you study programming, you learn about functions. In a programming language, a
function usually computes the output, given an input. The idea of computation is so ingrained,
that it's hard to imagine a function being defined without computation.
Yet, fundamentally, a (mathematical) function is simply something that maps inputs to outputs.
There's no need to explain how this mapping is done. Of course, in reality, we worry about how
to perform this mapping using computation because it gives us a compact way to represent the
mapping. Furthermore, it's also its own study. Algorithms is the study of efficient computatble
functions that solve problems.
You may think "I've never seen a mapping before", but you have. Truth tables! Truth tables are
one way to define a Boolean function.
Let's look at an example of a truth table. We're going to follow the following convention. Input
variables start with the letter x, possibly with some numeric subscripts. Output variables start
with the letter z, possibly with some numeric subscripts.
x2 x1 x0 z2 z1 z0
0 0 0 0 0 0
0 0 1 1 0 0
0 1 0 0 1 0
0 1 1 1 1 0
1 0 0 0 0 1
1 0 1 1 0 1
1 1 0 0 1 1

1 1 1 1 1 1
Since there are 3 input variables (i.e., 3 bits), there are 23 = 8 possible 3-bit patterns. Thus, there
are 8 rows.
This truth table is a function of the following type B3 -> B3. That is, it's a function which is an
element of the set of functions from 3-bit inputs to 3-bit outputs.
Number of Boolean Functions
The number of boolean functions is 22km. This is a very large number of functions, whose size
primarily depends on the number of input variables.
Let's look at the previous truth table.
x2 x1 x0 z2 z1 z0
0 0 0

0 0 1

0 1 0

0 1 1

1 0 0

1 0 1

1 1 0

1 1 1

The rows with the numbers are all possible 3-bit input values. A function maps each one of the
rows to some 3-bit output value. I've replaced the outputs with dashes. Pick any combination of
0's and 1's to replace the dashes. Each combination represents a function.
The question is how many possible ways are there of filling out the dashes with 0's and 1's?
To answer this we need to count the number of dashes. This turns out to be the number of rows
times the number of columns.
How many rows are there? The number of rows is 2k given k input bits. That makes sense
because we are attempting to map every possible k-bit value to an m-bit value, so the total
number of k-bit values is 2k.
How many columns are there? There are as many columns as bits used for the output. In this
case, there are m bits used for the output.
Therefore, there are 2km slots with dashes in them. Each of those can be filled with either a 0 or
a 1. So, think of all those slots as one very large bitstring. That is, a bitstring with 2km bits.
And how many possible bitstring patterns are there for n bits? There are 2n. In this case, n = 2km,
so plug it in, and you get: 22km

Summary
Here are some concluding facts:
Boolean functions map k-bit bitstrings to m-bit bitstrings, where k >= 0 and m >= 1. If k
== 0, that just means it is a function without any arguments. Effectively, this means the
Boolean function is a constant, i.e., it always returns 0, or it returns 1.

Functions map a k-bit value to a m-bit value. This mapping does not have to be unique.
That is, many different k-bit bitstrings can map to the same m-bit bitstring. If it is
unique, the function is said to be one-to-one.
Truth tables are one way of specifying a Boolean function.
There are 22km possible functions with k-bit inputs and m-bit outputs.
Combinational logic circuits implement Boolean functions. These are circuits with k-bit
inputs and have m-bit outputs.

Graph Optimization: graph optimization is a technique where the problem can


represent graphically and solve the complex problem perfectly without power
consumption, delay and less cost effectively.
Logic Level Synthesis: Logic level synthesis is the process where we can divide
the elements or device in different step for analyzing and solving the problem
smoothly and precisely

You might also like