Lecture Notes: Discrete Mathematics For Computer Science: Part 1. Logical Notation

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

Lecture Notes:

Discrete Mathematics for Computer Science


Vladimir Lifschitz
University of Texas at Austin

Part 1. Logical Notation


Propositional Connectives and Quantifiers
Logical notation uses symbols of two kinds: propositional connectives, such as
(and),

(or),

(not),

and quantifiers
(for all),

(there exists).

The symbol , called conjunction, and the symbol , called disjunction, are binary
connectives, because each of them is used to form a compound proposition from two
propositions. The negation symbol is a unary connective.
The symbol is called the universal quantifier; the symbol is the existential quantifier.

Examples of Logical Formulas


In this class, we use x, y, z as variables for real numbers,
and i, j, k, l, m, n as variables for integers.
(x > 5) (x < 6)
(2x > 1) (2x < 1)
(x > 1)

has the same meaning as


has the same meaning as
has the same meaning as

5 < x < 6;
2x 6= 1;
x 1.

The logical formula


x(x2 + 2x + 2 = (x + 1)2 + 1)
expresses the assertion that the equality x2 + 2x + 2 = (x + 1)2 + 1 holds for all real
numbers x.
The logical formula
x(x2 + 2x + 2 = 0)
expresses the (incorrect) assertion that the equation x2 + 2x + 2 = 0 has at least one
solution.
The assertion there exists a negative number x such that its square is 2 can be
written as
x(x < 0 x2 = 2).
(Do not write x < 0(x2 = 2); this is not considered a valid logical formula.)
1

Truth Tables
The truth tables for propositional connectives show how we can determine whether a
compound proposition is true if we know which of its component propositions are true.
Here is the truth table for conjunction and disjunction:
p
F
F
T
T

pq
F
F
F
T

q
F
T
F
T

pq
F
T
T
T

The symbols T and F here stand for true and false. They are called truth values.
The truth table for negation looks like this:
p
T
F

p
F
T

Witnesses and Counterexamples


How can we argue that a logical formula beginning with x is true? This can be done
by specifying a value of x that satisfies the given condition. Such a value is called a
witness. For instance, to argue that the assertion
x(4 < x2 < 5)
is true, we can use the value x = 2.1 as a witness.
How can we argue that a logical formula beginning with x is false? This can be
done by specifying a value of x that does not satisfy the given condition. Such a value
is called a counterexample. For instance, to argue that the assertion
x(x2 x)

(1)

is false, we can use the value x = 12 as a counterexample.


The assertion that formula (1) is false can be expressed in two ways: by the negation
of formula (1):
x(x2 x)
and also by saying that there exists a counterexample:
x(x2 x).
This is an instance of a general fact: the combinations of symbols
x

and x
2

have the same meaning.


In the following example we use the notation m | n to express that the integer m
divides the integer n (or, in other words, that n is a multiple of m). We want to show
that the assertion
n(2 | n 3 | n)
(every integer is a multiple of 2 or a multiple of 3) is false. What value of n can be
used as a counterexample? We want the formula 2 | n3 | n to be false. According to the
truth table for disjunction, this formula is false only when both 2 | n and 3 | n are false.
In other words, n should be neither a multiple of 2 nor a multiple of 3. The simplest
counterexample is n = 1.
The formula
mn(m2 + n2 = 10)
(2)
expresses that 10 can be represented as the sum of two complete squares. It is different
from the formulas with quantifiers that we have seen before in that the existential
quantifier is followed here by two variables, not one. To give a witness justifying this
claim, we need to find a pair of values m, n such that m2 + n2 = 10. For instance, the
pair of values m = 3, n = 1 provides a witness.
Note that when we write can be represented in logical notation, the existential
quantifier is used.

Implication
The binary propositional connective is called implication. It represents the combination if . . . then. For instance, the logical formula
n(4 | n 2 | n)

(3)

says: for all n, if n is a multiple of 4 then n is even. The assertion the cube of any
positive number is positive also can be written as
x(x > 0 x3 > 0).

(4)

(Do not write x > 0(x3 > 0); this is not considered a valid logical formula.) The
formula to the left of (in this example, x > 0) is called the antecedent. The formula
to the right of (in this example, x3 > 0) is called the consequent.
In the truth table below, the column for implication is added to the columns for
conjunction and disjunction:
p
F
F
T
T

q
F
T
F
T

pq
F
F
F
T

pq
F
T
T
T

pq
T
T
F
T

You see that an implication is false in only one case: when its antecedent is true but its
consequent is false.
For example, consider the formula
x(x > 5 2x > 20).
This formula is false, because we can find a number x such that the antecedent x > 5
is true but the consequent 2x > 20 is false. For instance, x = 6 can be used as a
counterexample.
Consider the formula
xy(x > 0 y < 0 x + y = 0).

(5)

This formula is false, because we can find a pair of numbers x, y such that the antecedent
x > 0 y < 0 is true but the consequent x + y = 0 is false. According to the truth
table for conjunction, to make the antecedent true we should make each of the formulas
x > 0, y < 0 true. In other words, to give a counterexample we need to find a pair of
numbers x, y such that x is positive, y is negative, and x + y is different from 0. For
instance, the pair x = 1, y = 2 is a counterexample.
The converse of an implication is obtained by swapping its antecedent with its consequent. The converse of a true implication may be true or may be false. For instance,
the converse of (3) is
n(2 | n 4 | n);
this formula is false. (The value n = 2 can be used as a counterexample.) The converse
of (4) is
x(x3 > 0 x > 0);
this formula is true.

Equivalence
The binary propositional connective is called equivalence. It represents the combination if and only if (sometimes abbreviated as iff). For instance, the logical
formula
n(6 | n 2 | n 3 | n)
(6)
expresses that an integer is a multiple of 6 iff it is both a multiple of 2 and a multiple
of 3.
The last column in the truth table below shows that an equivalence is true whenever
its left-hand side and its right-hand side have the same truth value.
p
F
F
T
T

q
F
T
F
T

pq
F
F
F
T

pq
F
T
T
T
4

pq
T
T
F
T

pq
T
F
F
T

The equivalence p q has the same meaning as the conjunction of two implications
(p q) (q p).
For instance, the assertion x3 is positive iff x is positive can be written either as an
equivalence
x(x3 > 0 x > 0)
or as the conjunction of two implications:
x((x3 > 0 x > 0) (x > 0 x3 > 0)).
To provide a counterexample for an equivalence, we need to make one of its two sides
true while the other is false. For instance, the formula
x(x2 > 0 x > 0)
is false, and x = 1 can be used as a counterexample: for this value of x, the left-hand
side is true, and the right-hand side is false.

Proofs by Exhaustion
The implication
n(1 n 1 n3 = n)
is easy to prove, because only three values of n satisfy its antecedent 1 n 1,
and we can check for each of them individually that it satisfies the consequent n3 = n
as well. This kind of reasoning is called proof by exhaustion. It is not applicable
if the antecedent is satisfied for infinitely many values of variables. For instance, the
implication
x(1 x 1 1 x3 1)
cannot be proved by exhaustion, because there are infinitely many real numbers between
1 and 1.

Free and Bound Variables


When a formula begins with x or x, we say that the variable x is bound in it. If a
quantifier is followed by several variables then all of them are bound. When a variable
is not bound then we say that it is free in the formula. For instance, in the formula
i(j = i2 )

(7)

the variable i is bound, and the variable j is free. In the formula


ij(i2 + j 2 = 29)
both i and j are bound.
5

(8)

The difference between free and bound variables is important because the truth
value of a formula depends on the values of its free variables, but does not depend on
the values of its bound variables. For instance, formula (7) expresses that j is a complete
square; whether or not it is true depends on the value of its free variable j. Formula (8)
expresses that 29 can be represented as the sum of two squares; we dont need to specify
the values of any variables before we ask whether this formula is true.
Replacing a bound variable by a new variable does not change the meaning of a
formula. For instance, the formula k(j = k 2 ) has the same meaning as (7): it says
that j is a complete square.

Digression: Bound Variables in Algebra and Calculus


Quantifiers are not the only mathematical symbols that bind variables. Sigma notation
for sums of numbers creates bound variables as well. For instance, the sum of the squares
of the numbers from 1 to 4 can be written as
4
X

n2 .

n=1

Here n is a bound variable. The value of this expression is 30; it does not depend on n.
Replacing n by a different variable does not change the meaning of the expression. For
instance, the value of the expression
4
X
i2
i=1

is 30 as well.
The expression

n
X

i2

i=1

denotes the sum of the squares of the numbers from 1 to n. In this expression, n is free,
and i is bound. The value of this expression depends on n, but not on i.
In the expression
2n + 1
lim
n n + 1
the variable n is bound. The value of the limit is 2; it does not depend on n.
In the definite integral
Z
1

x2 dx

the variable x is bound. The value of the integral is 13 ; it does not depend on x. In the
expression
Z x
t2 dt
0

t is bound and x is free. The value of the integral is


6

x3
3 ;

it depends on x, but not on t.

Nested Quantifiers
Some logical formulas include nested quantifiers, where one quantifier is within the
scope of another:
mn(m2 + n2 = 10),
(9)
xy(x > 0 y < 0 x + y = 0),

(10)

xy(y > x).

(11)

If both quantifiers are existential, as in (9), or both are universal, as in (10), then the
second quantifier can be dropped, and the formula will not change its meaning. For
instance, formula (9) has the same meaning as (2), and (10) has the same meaning
as (5). But using a combination of a universal quantifier with an existential quantifier,
as in (11), we can express more complex ideas than with just one quantifier. For instance,
formula (11) says that for every real number x we can find a real number y that is greater
than x. This formula is true: we can take y = x + 1 as a witness. This equality shows
how to calculate a witness y for any given value of x.
Note that the order of quantifiers in (11) is essential. The formula
yx(y > x),
which differs from (11) by the order of quantifiers, says that there exists a single value
of y that is greater than all real numbers. This formula is false.
On the other hand, the formula
yx(y > sin x)
is true. Indeed, y = 2 can be taken as a witness.

You might also like