Recommended books
J.Gersting Mathematical structures for computer science, 4th edition
(Freeman, 1999).
R.P.Grimaldi Discrete and combinatorial mathematics, 4th edition (AddisonWesley, 1999).
J.K.Truss Discrete mathematics for computer scientists, 2nd edition
(Addison-Wesley, 1999).
Syllabus
Set Theory: defining sets by listing, by properties, and by induction;
unions, intersections, complements; Venn diagrams; power sets. Cartesian products.
Relations: definition and examples of unary, binary and tertiary relations.
Representation of binary relations using directed graphs. Building more
useful structures: cartesian products; lists; inductive definition of structures.
Functions: domain, codomain, range of a function; injections, surjections,
bijections; inverse functions; total and partial functions; recursive functions.
Graphs: directed, undirected. Basic properties. Trees, parsing trees.
3
4.1, 4.2
4.34.6
5.1,5.2
5.2ctd.
6.16.4
6.56.8
7.17.4
8.18.5
8.68.9
Homework
Homework
Homework
Homework
1
2
3
4
1 Sets
14
14
23
30
33
42
43
2 Relations
46
46
51
52
53
56
3 Functions
61
61
72
74
79
85
91
92
97
4 Graphs
102
127
139
. 142
162
185
. . . . . . . . . . 187
13
1.1
Sets
Definition and description of a set
A set is a collection of objects (known as the elements) for which membership is decidable.
The definition is a bit mysterious, e.g. what do we mean by the phrase
for which membership is decidable ?
Basically a set is a collection of things. It might be described explicitly,
by listing its elements, but it might be described differently.
Well start by looking at some examples, described in various different
ways.
14
16
But notice that some books exclude 0 from N, call 1 the first natural
number. We call the set {1, 2, 3, . . .}, formed from N by excluding 0,
the positive integers, or Z+.
17
18
20
Both possibilities lead us to nonsense. So in fact, cant be a set; the definition is inconsistent. This strange situation is known as Russells paradox.
22
1.2
24
26
27
28
29
1.3
Commutative laws: A B = B A
Associative laws: A (B C) =
= (A B) C
Distributive laws: A (B C) =
(A B) (A C)
U and :
AU =A
Complements:
A Ac =
De Morgans laws: (A B)c = Ac B c
Idempotent laws: A A = A
(Ac)c = A
AB =BA
A (B C) =
= (A B) C
A (B C) =
(A B) (A C)
A=A
A Ac = U
(A B)c = Ac B c
AA=A
31
Note that rules relating set operations generally come in pairs. Given one
rule we get a second usually distinct rule by swapping with and
with U . The principal of duality makes this work. That says that for any
statement that is true about sets in general, the statement that you get
from that by replacing each by a , each by a , each U by a and
each by a U is also true. The second statement is called the dual of the
first. If the second statement is equal to the first, then the statement is
said to be self-dual; e.g. (Ac)c = A.
Example:. The dual of
is
(A B C)c = Ac B c C c
(A B C)c = Ac B c C c
32
1.4
Venn diagrams
Venn diagrams provide a useful technique to verify rules that hold in set
theory. A Venn diagram for a collection of sets A, B, C, . . . is a diagram
that displays each set as a enclosed region within the plane. Usually
we draw a rectangular region representing the universal set U and then
represent each of the sets A, B, C, . . . as connected regions within the
rectangle. An intersection of two of those sets, such as AB, is displayed
as the region common to both the regions representing the two sets (A
and B).
As examples, well draw the Venn diagrams
(a) for a single set A within the universal set. In that diagram we can
easily identify A and Ac.
33
(b) two subsets A, B of the universal set. In that diagram we can easily
identify A B, A B, A \ B, B \ A, A + B Ac, etc.
34
35
We can use a Venn diagram to verify a general law about sets by drawing
the sets A, B, C, . . . in the most general configuration possible (ie so that
each possible intersection between the sets is represented by a distinct nonempty region), and then using shading to help us construct and compare
the various sets that are involved in the law.
Example: we verify the law
(A B)c = Ac B c
In the first we identify the set (A B)c. We shade A B, and then see
its complement as the unshaded portion of the diagram.
In the second we shade Ac one way, B c another way, and then identify
their union as the total shaded area. The fact that the regions identified
in the two diagrams match up verifies that the two sets are equal.
36
37
38
39
But notice that if now D is a fourth set that contains A, D C need not
be empty!
40
41
1.5
Power sets
The power set of A, known as P(A), or (sometimes) 2A. is the set of all
subsets of A.
Where A has n elements, its power set has 2n.
As examples we write down P({1, 2}) and P({1, 2, 3}) and count their
elements.
42
1.6
Direct products
More generally, the direct product of n sets A1, A2, . . . An is the set
{(a1, a2, . . . an) : a1 A1, a2 A2, . . . an An}.
Order of composition is important, i.e. in general A B is not the same
as B A.
Some examples:-
43
44
45
2.1
Relations
Definition and examples
Often A1, A2, . . . An are all equal to the same set A, in which case we can
say our relation is on A. Where R is an n-ary relation and (x1, . . . xn)
R, we say that R holds at (x1, . . . xn). Sometimes we write R(x1, . . . xn)
rather than (x1, . . . xn) R.
In this course most of the relations we shall meet will be either binary or
unary. A few will be ternary.
We also use the terms property and predicate to mean exactly the same
thing as relation. In particular we usually use the term property for a
unary relation, and well meet the term predicate later when we do some
logic.
Some unary relations :
On Z, x is even, x is positive. We can write the statement x is even
in set theory language, as x EvenInt or in the form EvenInt(x).
47
For the same set the relation IsGreaterT han is the set of pairs
48
49
A ternary relation :
On Z, SumEquals(x, y, z) to mean x + y = z. For the set A =
{1, 2, 3, 4, 5, }, the relation SumEquals on A is the set of triples
50
2.2
Binary relations are particularly useful, and since a binary relation relates
two variables, it is often pleasant to use a different kind of notation to
denote them, which we call infix notation. In this notation, given a binary
relation R, rather than write (a, b) R, or R(a, b) (prefix notation), we
write instead aRb.
There are some very common binary relations, many of which have special
non-alphabet characters as their most natural labels.
= . <, , = on Z, Q, R or any subset of those.
on the set of subsets of some set , i.e. on P().
relating and P().
m on Z, defined (for m Z) by x m y if y x is a multiple of m.
51
2.3
52
2.4
We can examine these properties for some examples, such as <, , m:-.
54
55
2.5
As an example we can draw both the standard diagram and the equivalence
graph of 3 on {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}.
57
58
For a partial order we form the Hasse diagram by deleting all the loops
from the standard diagram of the relation, deleting any directed edge from
the diagram if it joins two vertices that are also connected by a directed
path of two or more edges. Further if a is related to b we draw b higher
up the page than a (and so we dont need an arrow on the edge)..
As an example we can draw both the standard diagram and the Hasse
diagram of on the set of subsets of {1, 2, 3}.
59
60
3.1
Functions
Definition of a function, notation, examples
f (x) = x2
or alternatively
62
f : Z Z,
x 7 x2
X is the set of people in this room, Y the set of all female first names,
f (x) is the first name of the mother of person x.
F alse otherwise. This explains why were using the same notation for
functions as we already (sometimes) used for relations. A function with
codomain {T rue, F alse} is called a Boolean valued function.
The terms mapping and map mean exactly the same as function.
64
For any set X, we can define a special function, which we call the identity
function on X.
Definition 3.2 (Identity function) The identity function iX : X
X. is defined by the rule i(x) = x for all x X.
So iZ is a function with domain and codomain Z, iR a function with
domain and codomain R etc. Each identity function iX has the same
rule: iX (x) = x for each x X.
65
While the codomain of a function tells us where its output should lie (and
so specifies its type) the range specifies the set of outputs completely.
Definition 3.3 (Range) Where f : X Y is a function, the set of
all elements of Y that are of the form f (x) for some x in X is called the
range of f . In set theory, we would describe this set as
{y Y : y = f (x) for some x X}
Some people use the word image instead of range.
For our first example f : Z Z, x 7 x2, the range of f is the set of all
squares, {0, 1, 4, 9, 16, 25, . . .}.
66
3.2
Since a function f is specified by the two sets X, Y and all the pairs
(x, f (x)), it is actually a binary relation on X Y . Each element of X
is related by f to its image f (x) in Y (but careful, the boolean valued
function we associate with that binary relation is not f ). So it is natural to
use a diagram to represent the function, consisting of points and directed
arcs. A cluster of points on the left of the diagram represents the elements
of X, another cluster of points on the right represents the elements of Y .
For each element x of X, a directed arc joins it to its image f (x) in Y .
NB. If X and Y have some points in common we see each common point
twice, once as an element of X, and once as an element of Y .
We call this diagram the directed graph of the function.
67
68
69
70
71
3.3
73
3.4
Composing functions
Sometimes we have more than one function and it makes sense to combine
them.
Definition 3.4 (Function composition) Given functions f : X
Y and g : Z W ,
if Y Z, the composite g f is the function with domain X and
codomain W defined by the rule
g f (x) = g(f (x)).
Note that we cant always compose two functions. We can only define
the composite g f of functions f and g if the codomain of f is in the
domain of g. We might have both of f g and g f defined, we might
74
have either one but not the other defined, and we might have neither
defined. Where both are defined they are probably not equal.
75
Examples:
First let X = {1, 2, 3}, Y = {4, 5, 6, 7}, Z = {4, 5, 6, 7, 8}, W =
{1, 2, 3, 4, 5} and define f : X Y, g : Z W by f (1) = 4
,f (2) = 6,f (3) = 7, g(4) = 2, g(5) = 3, g(6) = 4, g(7) = 5, g(8) = 5.
Draw the directed graphs of f and g and study the composition graphically.
76
77
78
3.5
Inverse functions
80
:f3 : Z Z : x 7 2x.
81
f4 : {0, 1, 2, 3, 4, 5} {0, 1, 2, 3, 4, 5} : x 7 5 x.
f5 : R R : x 7 5 2x.
82
83
84
3.6
86
An injective mapping is called an injection, a surjective mapping a surjection, a bijective mapping a bijection.
Let f : X Y be a function. It turns out that
if f is injective, then there is a function g : Y X for which gf = iX .
g is called a left inverse for f .
if f is surjective, then there is a function h : Y X for which
f h = iY . h is called a right inverse for f .
Actually there could be many left or right inverses.
if f is bijective, then f actually has an inverse, which is both a left
inverse and a right inverse.
So the properties of injectivity and surjectivity together are what we need
to have an inverse.
87
89
90
3.7
3.8
Partial functions
92
93
f (x) =
(x),
1
g(x) = 2
x 1
wherever this makes sense. This is a partial function with domain R \
{1, 1}.
94
y1
x=
2
y1
g : Z 6 Z, y 7
2
is not a total function is that y1
2 is not an integer for all y Z. The
domain of g is the odd integers; it is equal to the range of f .
The partial function g satisfies g f = iZ.
95
Using g its now easy to construct a (total) function that is a left inverse
of f . We simply define h(y) = g(y) whenever g is defined, and h(y) = 0
otherwise. Our construction guarantees that h f = iZ. So h; Z Z is
a left inverse of f .
But f does not have an inverse. It cannot. It is not surjective.
96
3.9
The rule that defines a function is not always given explicitly. Sometimes
it could be given explicitly, but can be given much more simply in another
form, which describes the value of the function at each value of x in
terms of its value at smaller values of x. In many examples, the function
is defined on the positive integers, and its value at x can be defined in
terms of its value at positive integers less than x.
e.g. The factorial function, f act(n), also written n!. This is a function
from N to N, which is defined for any positive integer n to be the product
n(n 1) . . . 1. Its defined very simply recursively by the pair of rules
and
f act(n) = n f act(n 1)
f act(1) = 1
97
So the easiest way to program it is as follows (in C):int factorial(int n) /* n assumed >0
{
if (n==1 ) return 1;
return n*factorial(n-1);
}
*/
f (n) = 2f (n 1)
98
A recursive definition of a function always has two components, the recursive rule (which defines f (n) in terms of some of the earlier values of f )
and initial conditions, which fix the first few values of f , f (1) (or f (0)),
and possibly f (2), f (3), . . .. The number of initial conditions that are
necessary depends on the type of recursion. If the recursion is one step
(that is, the rule defines f (n) in terms of f (n 1) only, then only one
initial condition is necessary. But if the recursion is k-step, defining f (n)
in terms of f (n 1), . . . f (n k), then k initial conditions are necessary.
Examples 3.8 Where f : N N is the function given recursively by
the rule f (n) = 2f (n 1) and f (1) = 2, we have
99
101
4.1
Graphs
Definition and examples, notation
103
We have already met directed graphs, used as diagrams for both relations
and functions (see sections 2 and 3); we can learn a lot about relations
and functions by studying the properties of the associated directed graphs.
104
105
Given any digraph we can form a graph by deleting any loops and connecting by an edge any two vertices connected by 1 or 2 directed edges,
e.g.
106
107
108
109
4.2
110
111
112
4.3
Bipartite graphs
Definition 4.5 A graph (or directed graph) is bipartite if its vertex set
V can be written as a disjoint union of two subsets V1 and V2 in such
a way that any edge in the graph joins a vertex in V1 to a vertex in V2.
More generally a graph (or directed graph) is k-partite if its vertex set V
can be written as a disjoint union of k subsets V1, . . . , Vk in such a way
that every edge joins two vertices in different subsets.
An alternative way of phrasing this is to say that a graph is k-partite if
the vertices can be coloured with k colours in such a way that any edge
joins two vertices of different colours. Of course if a graph is k-partite its
also (k + 1)-partite.
We can draw lots of examples.
113
First some bipartite graphs (Note that the directed graph of a function is
always bipartite.)
114
115
116
It can be proved that any graph that can be drawn on a piece of paper
with no edges crossing can be coloured with 4 colours (and so is 4-partite).
This is the famous four colour theorem.
Another well known theorem in graph theory tells us that a graph can
be drawn on a piece of paper with no edges crossing provided it doesnt
contain a subgroup that deforms to give either K5 or K3,3.
It is easy to check whether or not a graph is bipartite (2-partite). A graph
is bipartite if and only if all its cycles have even length.
117
4.4
119
120
121
4.5
Parsing trees
Trees are also used for parsing, e.g. of arithmetic expressions, such as
h
i2
(x + x (y + z)) + y (x z) or
x (x y)3 + (x + y) (x y) .
We see , + and as binary operations, and exponentiation by n (for
each integer n) as a unary operation. Then any arithmetic expression is
built up using a combination of those binary and unary operations on a set
of constants and variables. We parse such an expression using a rooted
tree in which each vertex has either one or two children.
We form a parsing tree as follows. Each leaf is labelled by a constant
or variable, and each non-leaf by an operation. A non-leaf is then also
associated with the sub-expression that is formed by applying the operation
122
that labels that vertex to the one or two (maximal) subtrees whose root(s)
is/are the children of that vertex.
NB. Note that when we parse an arithmetic expression, we always parse
x + y z as x + (y z), x + y 3 as x + (y 3), and x y 3 as x (y 3), etc.
That is, exponentiation has priority over multiplication and addition, and
multiplication has priority over addition.
123
Examples:
124
4.6
Spanning trees
126
5.1
5.2
Example 5.1 To prove that the sum of the first n positive integers (i.e.
1 + 2 + 3 + . . . + n) is
n(n + 1)
2
Proof:
Base of the induction We prove the statement for n = 1. The sum of the
first 1 positive integers is just the first positive integer, i.e. 1 itself. The
formula n(n + 1)/2 takes the value 1(1 + 1)/2 = 1 when we put n = 1
into it. So the formula gives the correct answer when n = 1. Hence the
base of the induction is proved.
The inductive step Suppose that the sum of the first n positive integers
130
132
The inductive step Now suppose that we know that the result holds for
binary trees with n leaves. We want to deduce from this that the result
holds for binary trees with n + 1 leaves.
Now suppose that T is a binary tree with n + 1 leaves. Then we can
find two leaves in T that are joined by edges to a single vertex v; when
the two vertices and two edges are deleted from T we get a binary tree
133
T with 2 fewer edges and 2 fewer vertices than T . That is, T is formed
from T by adding two edges and two vertices below its leaf T .
(as in diagram)
The vertex v was a leaf of T but is not a leaf in T , but every other
leaf of T is also a leaf of T . So T has n leaves. Then since the result
holds for binary trees with n leaves, T must have 2(n 1) edges.
Now since T has two more edges than T , the number of edges in T is
2(n 1) + 2 = 2n = 2((n + 1) 1).
135
136
137
138
6.1
Propositional logic
Statements, propositions, paradoxes
This point of this section is to set up a framework for reasoning by manipulating statements, in particular special kinds of statements that are
called propositions.
Definition 6.1 (statements, propositions) A statement is a sentence
that is not a question or a command. A proposition is a statement that
is either true or false, but not both. If a proposition is true we say it has
truth-value T rue. Otherwise it has truth-value F alse.
In programming, we usually use 1 to represent T rue and 0 to represent
F alse. In this course well often use T and F .
139
Examples 6.2
1. Some true propositions:
(a) 2 + 3 = 5. (b) Mumbai is in India. (c) Spurs won the FA cup in
1991.
2. Some false propositions.
(a) 10 > 87. (b) Newcastle is south of Leeds.
3. Propositions whose truth-value depends on one or more variables open statements.
(a) n is an even integer. (depends on n). (b) She is taller than me.
(Depends on she and me). (c) x + y > 7. (Depends on x and y).
4. The following are NOT propositions or statements.
(a) Well done! (b) How did you manage that?
140
141
6.2
are connected together. Well learn how to manipulate compound propositions; the language and laws of this manipulation are known as the
propositional calculus.
To stop our explanation of this getting too wordy, well use symbols rather
than the English language.
Well use letters like p, q, r to stand for propositions and call them propositional
variables,
(called conjunction) means and, (disjunction) means or, and
means not. T is a true proposition, F a false proposition,
We call an expression that we build out of these symbols a propositional formula
143
Strict rules define the way in which and, or and not should be interpreted in logic (not necessarily as you might expect in English where the
meanings are not always consistent).
Given propositional formulae f, g,
f g is defined to be true if both f is true and g is true, and is defined
to be false otherwise.
f g is defined to be true if f is true or g is true, including when both
are true, and false otherwise.
f is defined to be true when f is false, and false when f is true.
Note the meaning of as or is defined to be inclusive, as in Would you
like milk or sugar with your tea? rather than exclusive as in Would you
like tea or coffee?.
144
6.3
Theres a row for each possible combination of values for the variables
in the formula.
An iterative process (to be explained) computes the value of the whole
formula, and inserts it into the appropriate column of the truth table.
Two formulae are logically equivalent if and only if their truth tables
match, that is, if the values of the formulae match as the variables run
through all possible sets of values.
146
6.4
The iterative process constructs the truth table for a formula by parsing
the formula, and then combining the truth tables for the basic operations
into which it breaks down.
147
q pq
T T
F F
T F
F F
p
T
T
F
F
q pq
T T
F T
T T
F F
148
p p
T F
F T
The root is labelled , and the two non-leaves are labelled , corresponding to subformulae p q and p r. So we have a truth table with
6 columns, 3 labelled by the variables p, q, r and then 3 more, labelled
p q, and p r, where we store the values of the subformulae p q,
the whole formula and the subformula p r.
150
p
T
T
T
T
F
F
F
F
q
T
T
F
F
T
T
F
F
r (p q) (p r)
T
F
T
F
T
F
T
F
152
We find the truth value for the whole formula in the fourth column of this
table, and compare it with the calues in the fifth column of the other table.
Since the entries in those columns match (and the values of p, q, r have
been enumerated in the same orders), we have proved the equivalence of
the two formulae.
153
6.5
The equivalence weve just proved should look familiar; weve seen the
same equivalence for sets. In fact, using truth tables, we can also verify
all of the following, for propositional formulae f, g, hs.
Commutative laws. f g g f
Associative laws. f (g h) (f g) h)
Distributive laws. f (g h)
(f g) (f h)
f T f
f f F
De Morgans laws. (f g) (f ) (g)
Idempotent laws. f f f
(f ) = f
154
f g gf
f (g h) (f g) h
f (g h)
(f g) (f h)
f F f
f f T
(f g) (f ) (g)
f f f
Its clear that theres a connection between set theory and propositional
calculus. Its like two different languages. Sets translate to propositional
formulae, to , to , U to T and to F . Theres a reason for this,
which will become clearer later in the course.
We see again the duality that we saw with sets, where is paired with
, and T with F .
155
6.6
156
6.7
The work is easy to do and the work is not satisfying. The negative of
this is equivalent to Either the work is not easy to do or it is satisfying.
Soon we shall see that this negative is equivalent to the statement If
the work is easy to do then it is satisfying.
We can build further propositional formulae with the introduction of additional connectives.
158
6.8
161
Predicate logic
do this.
To illustrate this well explain how predicate calculus allows us to deduce
the statement
(3): My cat has blue eyes
from the pair of statements
(1): My cat is a Siamese cat and (2): Every Siamese cat has
blue eyes,
163
Now the logic should be clear. The second statement tells us that Q(x)
holds whenever x is an element of the set Siamese cats. The first
statement tells us that my cat is in that set. Hence Q(my cat) holds.
Predicate calculus gives us a mechanism (including symbols) to express
the second statement properly, and hence to reason in this way.
165
7.1
We use the symbol in predicate logic to mean for all, for every,
for each. x means for all x. Often for all x really means for all
appropriate x, that is, for all x in some set of values which make sense
in the current context. In that case we write x S, where S is that set
of appropriate values. the symbol is known as the universal quantifier.
Hence the statement above can be written in symbols as
x Siamese cats Q(x)
Note that although x appears as a variable in this proposition, it is not free,
that is, the proposition does not make sense if we replace x by a constant
We say that x is a bound variable. Although x cannot be replaced by
a constant, it can be replaced by another variable, without changing the
166
Where P (x) means x loves the underdog, the statement x, P (x) means
everybody loves the underdog.
168
7.2
We use the symbol in predicate logic to mean there exists, there is,
for some. x means there exists an x. We may use x or x S,
for some set S. Just like , the existential quantifier has the effect of
turning a free variable into a bound variable.
Given a set of variables S and a unary predicate P , the proposition
x S P (x)
170
7.3
Multiple quantifiers
171
7.4
Notice that, for any unary predicate P , and for any set S, the following
two identities hold.
(x S P (x)) x S (P (x))
(x S P (x)) x S (P (x))
Examples 7.3
Where P (x) is, as above x is a perfect square. x N (P (x)) translates as there is a natural number which is not a perfect square.
We know this to be true, and we used this fact to prove the statement
x N, P (x) to be false.
x N P (x) is true.
172
7.5
The sum of an odd integer and an even integer is always an odd integer.
translates as
x OddInt y EvenInt x + y OddInt
or as
The principle of mathematical induction uses the fact that the following
is a tautology:(P (1) (n N P (n) P (n + 1))) (n N P (n))
174
7.6
Lets try and be a bit more systematic, and a bit more ambitious. Id like
to be able to express some famous results about natural numbers using
predicate calculus:
The product of two odd integers is odd.
The square root of 2 is irrational. (Hippasus, 600 BC).
The only integer solutions to xn + y n = z n with n > 1 occur when
n = 2 (Fermats last theorem).
Every natural number can be written as the sum of four squares (due
to Lagrange 1770)
An odd prime can be written as the sum of two squares if and only if
it is congruent to 1 mod 4. (Fermat)
175
7.7
Suppose that n N.
n is odd if k Z(n = 2k + 1)
n is even if k Z(n = 2k)
7.8
177
7.9
179
180
k Z, l Z(p = k 2 + l2)
We can translate For any positive integer p, if p is an odd prime and the
sum of two squares, then p is congruent to 1 mod 4 as
p Z+
((p 6= 2) (r, s Z+ \ {1}(p 6= rs)) (l, m Z(p = l2 + m2)))
((k Z(p = 4k + 1)))
183
184
8.1
Boolean algebra
Definition of a Boolean algebra
185
xy =yx
x (y z)
= (x y) z
Distributive laws:
x (y + z)
= (x y) + (x z)
Behaviour of 1 and 0:
x1=x
Behaviour of complements: x x = 0
Commutative laws:
Associative laws:
x+y =y+x
x + (y + z)
= (x + y) + z
x + (y z)
= (x + y) (x + z)
x+0=x
x + x = 1
186
8.2
For any set U , the set of all subsets of U is a Boolean algebra, for
which multiplication is given by , addition by , complementation by
c, 1 by U , and 0 by .
For any set (say {p, q, r} ) of propositional variables, the set of all
propositional formulae in these variables is a Boolean algebra, for which
multiplication is given by , addition by , complementation by , the
zero by FALSE and the unity by TRUE.
The set {0, 1} forms a Boolean algebra, in which 0 is the zero and 1
the unity when we define
0 + 0 = 0, 1 + 1 = 1, 0 + 1 = 1 + 0 = 1,
0 1 = 1 0 = 0 0 = 0, 1 1 = 1, 0 = 1, 1 = 0
187
188
8.3
8.4
The following rules hold in every Boolean algebra. They are straightforward to deduce from the axioms.
(a) Uniqueness of complements: that is
(b) (x) = x.
x + y = 1, x y = 0 y = x
(c) x + 1 = 1 and x 0 = 0.
190
8.5
The extra rules can be deduced from the axioms as follows:(a) Given x + y = 1,
x y = 0 we have
y = 1 y = (x + x) y = x y + x y = 0 + x y = x x + x y
= x (x + y) = x 1 = x
together with
(x y) (x + y ) =
=
=
=
x (y (x + y ))
x ((y x) + (y y )) by distributivity
x ((y x) + 0) = x (y x) = x (x y)
(x x) y = 0 y = 0
193
8.6
Boolean expressions
zero element, and x the complement of x (for any variable, or indeed any
expression, x). This is equivalent to the Boolean algebra of propositional
formulae in a, b, c, d, on the understanding that multiplication represents
and, addition or, 1 true, 0 false, and x the negation of x, and it is
often helpful to remember that.
195
8.7
Using the axioms we can tidy up any element of the Boolean algebra until
it is a sum of products of distinct variables from X together with its set of
complements, where no variable and its complement both appear in the
same product.
Examples. Let X = {a, b, c},
(a + b)(b + c)(c + a) =
=
=
=
(a + b + c)(a + b + c) =
=
(a + b)(bc + ba + cc + ca)
(a + b)(bc + ab + ac)
abc + aab + aac + bbc + bab + bac
abc + bac = abc + abc
a(a + b + c) + b(a + b + c) + c(a + b + c)
aa + ab + ac + ba + bb + bc + ca + cb + cc
196
= ab + ac + ab + bc + ac + bc
= ab + ab + ac + ac + bc + bc
The ordering of the terms, and within the terms, in the final expression,
has been chosen for aesthetic reasons only!
197
8.8
The end result of the first example is already a sum of products of this
type.
The products like this are called the atoms (or sometimes the minterms) of
the Boolean algebra. Any element of the Boolean algebra can be written as
a sum of distinct atoms in one way only. This expression for the element is
known as its disjunctive normal form (d.n.f.) (or minterm normal form).
Its sometimes useful to be able to put an element into this form, e.g. it
allows us to compare elements, in particular to test if two are equal.
More examples.
Let X = {a, b, c, d} To put ab into disjunctive normal form, we write
ab = ab(c + c)(d + d) = abcd + abcd + abcd + abcd
199
200
8.9
takes the values (1, 1, 1, 1), (1, 1, 1, 0), (1, 1, 0, 1), (1, 1, 0, 0).
The truth table for ab + ac has non-zero values on the 6 rows where
(a, b, c, d) takes the values
(1, 0, 1, 1), (1, 0, 1, 0), (1, 0, 0, 1), (1, 0, 0, 0), (1, 1, 0, 1), (1, 1, 0, 0).
202