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.
forall x>0 exists y. x*y = 1is 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 pThis 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.)
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.
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.
In order to prove the formulaThe 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.for all x in S. P(x)it is sufficient to prove
- Base case: P(e1),...,P(em), and
- Inductive step: P(e) -> P(op1(e)),..., P(e) -> P(opm(e)).
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.