Fall 2000, CSE 468: Lecture 4 (Sept 1)

Preliminary notions

Classical Logic.

First Order Predicate Calculus


Terms: expressions constructed on Atomic Formulas: Predicate symbols (p, q, r, ...) applied to terms

Example: x, 1, x+1 are terms. x+1 > 0 is an atomic formula. (1 is a constant, + is a function, and > is a predicate.)

Formulas: Expressions built on atomic formulas, the logical connectives, and the quantifiers exists and forall.


The meaning (truth value) of a formula in F.O.L. depends upon: The choice of the domain plays a role also for the interpretation of the quantifiers. Example: The formula
forall x>0 exists y. x*y = 1
is True in the domain of rational numbers, but is False in the domain of integer numbers.

Valid formulas: formulas which are True in every domain, and for every possible interpretation of the function, constant, and predicate symbols.

In general the truth tables are not enough to prove that a fourmula is valid. There are various systems for this purpose; but anyway (for the purposes of the course) we will mostly rely on our intuition. All the laws of classical logic are pretty intuitive except maybe for the Law of the excluded middle:

p or not p
This law, which says that either p is True or its negation is True, brings to curious consequences like the following Smoker's Paradox:
There is a person is this room such that, if this person smokes, then everybody in the room smokes.
This sentence is true in classical logic (provided that the room is not empty). In fact we can formulate it as:
exists x. (smokes(x) -> forall y. smokes(y))
which is equivalent to
(exists x. not smokes(x)) or (forall y. smokes(y))
which is (classically) equivalent to
(not (forall x. smokes(x))) or (forall x. smokes(x))
Notably, the law of excluded middle is not accepted in other logics, like the Intuitionistic Logic. (We, however, will consider only classical logic in this course.)

Priciple of mathematical induction

The principle of mathematical induction is useful to prove properties of the form
forall x. P(x)
where P is an arbritrary formula containing x, and the intended domain is the set of natural numbers.

The principle says that, in order to prove the above formula, it is sufficent to prove the following:

Exercise: prove by induction that

forall x. 1 + 2 + ... + x = x*(x+1)/2

The induction principle can trivially be generalized to start with a base case greater than 0.

Structural Induction

The induction principle seen above is useful for proving properties about natural numbers, but, in this course, we will consider also other kind of sets (in particular, set of strings, namely languages). For proving properties about languages, it will be useful to consider a more general and powerful induction principle, called "Structural induction". This principle applies to sets defined inductively. Let us start by making precise what "set defined inductively" means.

Inductive defintion

Given an universe U, and inductive definition is a specification of a set S (subset of U) of the form:
  1. (Base) e1,...,em are in S
  2. (Inductive rules)
    e is in S -> op1(e) is in S,
    e is in S -> opm(e) is in S
where e1,...,em are elements of U and op1,...,opm are operations on U.

The set S specified by this definition is the smallest subset of U which satisfies points (1) and (2) above (sometimes this qualification of "smallest" is added explicitly to the definition). Note that there might be more than one set satisfying (1) and (2), hence it is important to remember that we intend the smallest one.

This definition can be extended in the obvious way to operations op1,... , opm with more than one argument.

Structural induction

We can now illustrate the principle of structural induction. Given S defined as above, and a property P, the principle says that
In order to prove the formula
for all x in S. P(x)
it is sufficient to prove
The correctness of this principle can be explained as follows: Let S' = {x in U | P(x)}. If we prove the base case and the inductive step for P, then we have proved that S' satisfies (1) and (2) above. But S is the smallest such set. Hence S is contained in (or equal to) S'. Therefore for all x in S, P(x) holds.


Consider the alphabet A = {a,b}, the universe of all strings on this alphabet, and the inductive specification of a subset of strings L as follows:
  1. (Base) a is in L
  2. (Inductive rules)
It should be clear that this set L containns strings like a, aab, aa, aaba, etc.

Suppose we want to prove that for every x in L, the number of a's in x is greater than the number of b's. It is easy to prove this property by structural induction. Let us denote by #a(x) the number of a's in x, and by #b(x) the number of b's in x.

  1. Base case: #a(a) = 1 > 0 = #b(a).
  2. Inductive step:
Note that we could have proved this property also by using the principle of mathematical induction (induction on the length of the string), but it would have been much more "painful". The proof by structural induction, in the case of sets defined inductively, is usually much simpler and more natural because it follows "the structure" of the definition of the set.