Documente Academic
Documente Profesional
Documente Cultură
Preliminaries
A preliminary step for an abstraction is to introduce a proper notation that will symbolically represent the objects in which
we are interest. In particular, we will see that formal languages heavily rely on such symbolic representations. In this chapter we
begin with introducing such notational convention.
To follow the discussions presented in this book, we need the capacity for logical reasoning, which will in turn be enhanced
through the course. Often the book leaves out the routine and tedious details of a proof that can be completed by following one
of the conventional proof techniques, such as proof by induction. This doesn’t mean that proofs can be ignored. Thus, this
chapter presents an overview of proof techniques with easy examples and helps the reader build confidence in validating and
presenting his or her own proofs. Studying this chapter, the reader will see that “acquired proof-phobia” is curable.
1.1 Notation 2
Symbols, Strings, Composite symbols
Sets and set operations
1.2 Propositions and logical connectives 6
1.3 Proof techniques 10
Proof by contrapositive, Proof by cases, Proof by contradiction
Proof by example, Proof by generalization
Proof by induction, Proof by pigeonhole principle
Proof by counting, Diagonalization technique
Rumination 22
Exercises 26
1
Preliminary
1.1 Notation
In this book, with no further explanation, we shall use the following notation.
• The leading English alphabet letters, a, b, c, .…, will be used as symbols to denote
an object.
• A string is a finite sequence of symbols, for which we shall use the trailing
English alphabet, .., u, v, w, x, y, z.
• For two strings x and y, xy denotes the concatenated string of x and y.
• Epsilon (ε ) denotes the null string, which, for any string x, has the property
ε x = xε = x.
• For a string x, by |x| we denote the length of x, i.e., the number of symbols in x.
• For a string x, x0 = ε , xi+1 = xxi, and xR denotes the reverse of the string x.
Example: (ab)3 = ababab, (ab)0 = ε , (abcd)R = dcba.
• We shall use capital letters to denote the sets.
2
Preliminary
Notation
• Set specification: There are two ways to specify the sets; in curly brackets, either by
explicitly showing all the members or by describing the set properties.
(a) Explicit. Examples: A = {2, 8}, Σ = {a, b, c}
In particular, the empty (or null) set is denoted by Φ.
(b) By set properties of the form { x | property list of x}.
Examples: A = {n | n is a even number} = { 2, 4, 6, . . . },
B = {xxR | x is a binary string } = {00, 11, 0110, 1001, 1111, . .},
C = {anbncn | n ≥ 0} = {ε , abc, aabbcc, aaabbbccc, . . . }
3
Preliminary
Set operations
• Operations on the sets of strings: Let A = {aa, ab, abc) and B = {aa, bc}.
(a) union(∪) : A ∪ B = {aa, ab, bc, abc}, A ∪ Φ = A
(b) intersection( ∩) : A ∩ B = { aa }, A ∩ Φ = Φ
(c) subtraction(−) : A – B = { ab, abc}
(d) exclusive or (⊕) : A ⊕ B = {ab, abc, bc}
(e) product : AB = { aaaa, aabc, abaa, abbc, abcaa, abcbc}
AΦ = ΦA = Φ
(f) complement : Let U be the universal set, i.e., the set of all possible
elements. Then the complement of set A, denoted by A is
A=U–A
(g) DeMorgan’s law: A ∪ B = A ∩ B A∩B=A∪B
4
Preliminary
Set operations
(h) Closure (star, or Kleene closure): For a set A, define A0 = {ε }, and for i >
1, Ai = AAi-1 . The closure of the set A is defined as follows.
∞
A = i∪
*
=0
(A i
) = A0
∪ A1
∪ A 2
....
The closure A* is the set of all strings that we can get by picking arbitrary number of
strings in A (you are allowed to pick the same string arbitrary number of times) and
concatenating them in any order. For example, for the binary alphabet Σ , the closure
Σ * = {0, 1}* is the set of all binary strings including the null string ε . If Σ is the
English alphabet, Σ * is the set of ε and all strings over the alphabet Σ . Every closure
contains the null string ε . Kleene plus, A+, denotes the closure without ε , i.e., A+ =
A* - {ε }.
(i) For a set A the power set, denoted by 2A, is the set of all subsets of A.
Example: Let A = {a, b, c}. Then,
2A = {Φ, {a}, {b}, {c}, {a, b}, {b, c}, {a, c}, {a, b, c}}
5
Preliminary
1.2 Propositions and Logical Connectives
A proposition is a declarative statement that can be either true or false. By
combining propositions using the logical connectives, such as and, or, and not,
which are symbolically denoted by ∧, ∨, and ¬, respectively, we can form another
proposition. Let p and q be two propositions. The three compound propositions p ∧
q, p ∨ q, and ¬p, respectively, have the truth values defined by the truth tables as
shown below.
p q p ∧q p q p ∧q
T T T T T T p ¬p
T F F T F T T F
F T F F T T F T
F F F F F F
6
Preliminary
Propositions
Another commonly used logical connective is the conditional (or if-then), denoted
by the symbol →. The truth table for the proposition p → q (read if p, then q) is
defined as shown below. Notice that the truth tables for p → q and ¬p ∨q are
identical. Thus p → q is a short notation for the proposition ¬p ∨q.
Notice that though we use the term conditional, implying an antecedent-
consequent relation, this conditional connective does not necessarily carry such
relational meaning.
p q p → q ¬p ∨q
T T T T
T F F F
F T T T
F F T T
For example, let p be “Elephants fly,” and q be “The earth is flat.” By the definition,
the compound statement p → q is (vacuously) true, with no regard to the truth values
of statement q, and without extending to their meanings.
7
Preliminary
Propositions
p q p → q ¬p ∨q
T T T T
T F F F
F T T T
F F T T
8
Preliminary
Propositions
Often we come across a problem that asks us to justify a statement of the form “p
implies q” (denoted by p ⇒q), meaning that q is true in each case in which p is true.
Notice that the statement p ⇒q, in particular, refers to the first row of the truth table of
the proposition p → q . In other words, if p → q is true whenever p is true, we say p
implies q. The implication p ⇒q is not a proposition, which would have a truth value,
but an assertion about the relationship of two propositions.
If p ⇒ q and p ⇐ q, we write p ⇔ q and say that p and q are equivalent. Consider the
truth tables of p → q, ¬p ∨q and ¬q → ¬p, which are all identical, as shown below.
Clearly, we have (p → q) ↔ (¬p ∨q) ↔ (¬q → ¬p) for every pair of values of p and q.
Since ¬p ∨q and ¬q → ¬p are true for every case in which p → q is true and vice versa,
we can also say (p → q) ⇔ (¬p ∨q ) ⇔ (¬q → ¬p).
p q p → q ¬p ∨q ¬q → ¬p
T T T T T
T F F F F
F T T T T
F F T T T
9
Preliminary
10
Preliminary
Proof techniques
Example: Let p and q be, respectively, the statements “it rained” and “the lawn is
wet.” Then instead of proving that p → q (i.e., “if it rained, then the lawn is wet”) is
true, we can prove that ¬q → ¬p (i.e., “if the lawn is not wet, it did not rain”) is true.
11
Preliminary
Proof techniques
3. Proof by contradiction: This proof technique shows that if p ⇒ q does not hold,
i.e., the statement p → q is false, then it contradicts some statement, possibly
including p, that we know to be true. Recall that the implication p ⇒ q presupposes
that p is true. So, if we can show that p is false from the supposition that p → q is
false, we also have a contradiction.
Example: Suppose that the statement “everyone who studies automata and formal
languages gets a good job” is a proven fact. Let p be the statement “Tom failed to get a
good job,” and let q be the statement “Tom did not study the automata and formal
languages.” To justify the statement p ⇒ q (i.e., p→ q is true), we suppose that p→ q
is false, and show that it contradicts to the above fact.
Recall that (p → q) ⇔ (¬p ∨q). If p → q is false, ¬p ∨q must be false. It follows that
both ¬p and q should be false, i.e., (p ∧¬q) is true, implying that Tom failed to get a
good job and he studied the automata and formal languages. This contradicts to the
proven fact that everybody, who studied the automata and formal languages, gets a
good job.
The proof by contradiction is quite popular in computer science. We will see more
interesting examples in other chapters.
12
Preliminary
Proof techniques
(a) Proof by example: Let ∃ x [p(x)] denote a statement with the existential
quantification bound to variable x. To prove such statements are true it is enough to
show an example.
Example: We can justify the statement “Among the students who took this course,
there exists a student who got a grade of A” by showing a student, say Mary, who got
an A from the course.
13
Preliminary
Proof techniques
(b) Proof by generalization: We apply this technique to justify a statement of the form
∀x [p(x)]. If the domain of the variable x is small, we may examine the statement for
each case of x. Otherwise, we need to come up with a generalization, possibly using
other proven facts.
Example: Suppose that we want to justify the statement “all the students who take
the language course are from abroad.” If possible, it is a good strategy to find some
information, like the curriculum of the school, showing that only foreign students are
admitted to the course, for example, to learn English as their second language.
Notice that if you want to disprove a statement of the form ∀x [P(x)] (or the form
∃ x [p(x)]), you may use the same strategy (i.e., to show an example against the
statement, called counter example) as for proving a statement of the form ∃ x [p(x)]
(respectively, ∀x [P(x)] ).
14
Preliminary
Proof techniques
The stern faced Personnel Officer told an applicant that they needed an individual who is totally responsible.
"I sure qualify then." replied the applicant. "Everywhere I've worked, whenever something went wrong, I was
responsible."
- Jim -
15
Preliminary
Proof techniques
n
Example: Prove that ∀ n ≥ 0 [ ∑ i=0 i = n(n+1) /2 ].
n
Proof. (1) Basis (n = 0): we show that for n = 0, the equality ∑ i=0 i = n(n+1) /2 holds.
0
The left side of the equation is ( ∑ i=0 i) = 0, and the right side is 0(0 + 1)/ 2 = 0.
Obviously, the statement is true.
m
(2) Induction hypothesis: suppose that ∀ m < n, [ ∑ i=0 i = m(m+1) /2].
n
(3) Induction: we show that for n = m+1, the equality ∑ i=0 i = (n)(n+1) /2 holds.
n m+1 m
The left side of the equation is ∑ i=0 i = ∑ i=0 i=∑ i=0 i + (m+1). Since by the
m
induction hypothesis, ∑ i=0 i = m (m+1)/2, we get the right side as follows.
m
∑ i=0 i + (m+1) = m(m+1)/2 + (m+1) = m(m+1)/2 + (m+1) =
(m+1)(m+2)/2 = n(n+1)/2
In the rumination section at the end of this chapter, we discuss this proof technique
further with another example.
16
Preliminary
Proof techniques
17
Preliminary
Proof techniques
1 2 n
.....
1 2 ... m
18
Preliminary
Proof techniques
Application example: Using the pigeonhole principle, show that in a directed graph
with n nodes, any path of length greater than or equal to n involves a cycle.
Proof: Let n be the number of nodes of the graph. We know that on any path of the
graph, the number of nodes visited is greater than the path length, i.e., the number of
edges. (Notice that we count the starting node of a path as visited.)
Let the nodes of the graph correspond to pigeonholes and visiting a node
corresponds to putting a letter in it (see the figure below). If the path length is greater
than or equal to n, then more than n nodes are visited. In view of the pigeonholes,
this implies that we are putting m (> n) letters into the n pigeonholes. According to
the principle, there is a pigeonhole (i.e., a node) containing more than one letter (i.e.,
visited more than once). This implies that the path contains a cycle.
19
Preliminary
Proof techniques
8. Proof by counting: Many theorems are involved with the number of entities
that satisfy certain property. One way to prove such a theorem is by figuring out
the number or its range that satisfies the theorem. (The technique does not
necessarily count. The name is somewhat misleading.)
Example: Prove that ∀n > 0 [it is impossible to put all the binary numbers of
length n in the rows and columns of n × n bit (0/1) matrix].
1 1 0 1
0 1 0 1
1 0 1 1
Proof: We prove the statement in two cases: (1) when n > 2, and (2) when n = 1 or 2.
Case (1), when n > 2: There are 2n binary numbers of length n, and the total number
of columns and rows is 2n. Since 2n > 2n, for every n > 2, the statement is true.
Case (2), when n = 1 or 2: We leave the proof as an exercise for the reader.
20
Preliminary
Proof techniques
Clearly, v does not appear in any row or column of M. This is true, because for
any i, the number appearing in the i-th row or column contains a number whose i-
th bit is mii , which is the complement of the i-th bit of v.
21
Preliminary
Rumination (1): Conditional connective and implication
Note that the truth table of the conditional connective (if-then) is not the antecedent-consequent (or cause-effect)
relationship, but a logical definition. It is, however, very useful template to use for deducing a proposition (i.e.,
consequent) from another (i.e., antecedent), only if they are related. Otherwise, we will end up with a nonsense.
For example, let p be the statement “I watch TV” and q be “Our soccer team wins.” Then, by simple manipulations,
we get the following.
(p ∨¬p) ∨(q ∨¬q) = (¬p ∨q) ∨(¬q ∨p)
Since (p ∨¬p) ∨(q ∨¬q) is true, either (¬p ∨q) or (¬q ∨p) must be true, i.e.,
(p → q) is true, or (q → p) is true.
A verbal interpretation of this last symbolic statement would be as follows.
“It is true that if I watch TV, then our soccer team wins, or if our soccer team wins, then I watch TV.”
p q p→q
T T T
T F F
F T T
F F T
22
Preliminary
The proof by induction logically works the same way. By the basis step, (1) it shows that the statement is true for the lower bound
n0 of the quantified variable n. By the induction hypothesis, (2) we suppose that the statement is true for all m (n0 ≤ m < n), and
by the induction step, (3) we show the statement is true for m + 1.
Notice that because the statement is true for n0 (by the basis step), it is also true for n0 + 1 by the induction step. Since it is true
for n0 + 1, it is also true for n0 + 2, and so on. We can claim that the statement is true for all n ≥ n0. (Sometimes the proof is
described in two steps with the hypothesis included in the induction step.) The next slide shows how the “walking up a stairway”
and the proof by induction correspond.
23
Preliminary
Rumination: Proof by Induction
n n A
Prove that ∀ n ≥ 0 [ ∑ i=0 i = n(n+1) /2 ] N
I
0 + 1 + 2 + . . . .. . . + m + (m+1)
As another application example of the proof by induction technique, here we will justify the pigeonhole principle, which is
repeated below.
Pigeonhole Principle: Suppose that there are n pigeonholes and m (> n) letters. If we distribute all the letters (in any way) into
the pigeonholes, there will be at least one pigeonhole that contains more than one letter.
Proof: (1) Basis: The pigeonhole principle makes sense when there is at least one
pigeonhole. Hence the lower bound n0 = 1. In this case, if we put all the m > 1 letters in
the pigeonhole, that pigeonhole clearly contains more than one letter. The principle is
true.
(2) Hypothesis: Suppose that for some number of pigeonholes n’ < n, the principle is true.
(3) Induction: We prove that the principle is true for n’+1 pigeonholes and m (> n’+1) letters.
As shown in the figure bellow, we examine the problem divided into two cases depending on the number of letters
contained in one particular pigeonhole, say hole n’+1.
(a) When pigeonhole n’+1 has one or no letter: In the remaining n’ pigeonholes at least m - 1 > n’ letters are distributed.
According to the induction hypothesis, among the n’ pigeonholes there is at least one pigeonhole that contains more than
one letter. The principle is true.
(b) When pigeonhole n’+1 has two or more letters: Obviously this pigeonhole has more than one letter. Again, the
principle is true.
1 2 n’ n’+1
.....
1 2 m
25
Preliminary
Exercises
1.1 What does each of the following expressions denote? If your answer is a finite set, show all the members. If it is
infinite, use set property notation.
(a) a5 (b) |aba7b| (c) |ε | (d) xR, where x = abab (e) AB, where A = {a, b, c}, B = {aaaa, bbbb, cccc}
(f) A*BA*, where A and B are the sets shown in part (e) above.
1.2 Among the strings given in (1) – (7) below, identify all the members that belong to each of the following sets.
(1) aaaabbbb (2) aaaa (3) aaaacccaaaa (4) bbbaaaa (5) abcccccba (6) aaaaab (7) abaaba
1.3 For the sets of strings given below, show the result of each of the following set operations. Write your answer in set
property notation. Try to make it as simple as possible.
26
Exercises Preliminary
1.4 Show that the following statement is true for a pair of integers a and b.
1.5 Prove that for all positive integers n ≤ 2, it is impossible to put all binary numbers of length n in the n rows and n
columns of n × n bit matrix.
1.6 Let G be a directed graph with n ≥ 2 nodes, with each node labeled with either 1 or 2. Let P12 be a path in G which
starts at a node with label 1 and ends in a node with label 2. An edge is said “good” if it links two nodes with different
labels (i.e., 1 → 2 or 2 → 1). (The figure below shows a path with 7 good edges.) Prove that in any path P12 the number of
good edges is always odd.
6
1
2 7 A path P12
5 8
2
1 2 2 1 2 1 2 2 1 2
1 1 4 1
2 9 3
7 good edges
2
2
1
1.7 Let’s change the definition of good edges (in problem 1.6) the other way around, i.e., an edge is “good” if it links two
nodes with the same label. Can you claim the same property on the number of good edges? Justify your answer.
27
Exercises Preliminary
1.8 Using the pigeonhole principle we proved that the following statement is true.
[ In a directed graph with n nodes, any path of length greater than or equal to n involves a cycle. ]
Here, we want to justify the statement using the proof-by-induction technique. Answer each of the following questions.
(1) What is the basis of the statement? In particular, identify the lower bound (n0). Show that the statement is true for the lower
bound.
(2) Write the induction hypothesis.
(3) For the argument in the induction step, you may use the figures below, each showing a typical case of a path whose length is
greater than or equal to n. Figures (a) – (c) are the cases where there is a node which the path does not go through, and figure
(d) is the case where the path goes through every node. Complete this step answering the following questions.
(i) How can you argue that in cases (a), (b) and (c), the path involves a cycle? (Hint: use the hypothesis.)
(ii) Why does the path involve a cycle in case (d)?