## Classical Logic.

### Propositional calculus

#### Syntax

Formulas are expressions built on
• Propositional letters, p, q, r, ...
• Connectives: not, and, or, implies (->), logical equivalence (<->), ...

#### Meaning

The letters range on the set of boolean values B = {True, False} The connectives are functions on B. For instance: "p implies q" is the function (of p and q) which returns False when p is True and q is False, and True in all other cases.

Truth tables: a way to represent the meaning of each connective. The meaning (truth value) of more complex formulas can be derived by composing the truth tables.

Tautology: A formula which is True for all the possible truth values of the letters contained in it.

Examples:

• p -> p is a tautology
• p -> (p -> p) is a tautology
• (p -> p) -> p is not a tautology
• (p and q) -> p is a tautology
There are variuos systems to derive tautologies (i.e. to prove that a certain formula is a tautology), but usually the simplest method is to use the truth tables.

### First Order Logic

#### Syntax

Terms: expressions constructed on
• Variables x, y, z, ...
• Symbols of functions (and constants) f,g, ... a, b, ...
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.

#### Meaning

The meaning (truth value) of a formula in F.O.L. depends upon:
• The choice of the universe (domain), i.e. the set where the variables are assumed to range.
• The values of the variables (in the domain).
• The interpretation of functions and constants symbols (interpreted as functions and elements of the domain).
• The interpretation of the predicates (interpreted as relations on the domain).
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 use it.)

## Induction principle

The induction principle 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:

• Base case: P(0)
• Inductive step: forall n. P(n) -> P(n+1)

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.

Exercise: Find the mistake in the following reasoning, which proves (erroneously) that all people have the same height:

• Statement: for every n, in any group of n people everybody has the same height.
• Proof:
• Base case: (n=0) in a empty group, the statement is trivially true
• Inductive step: Take a group of n+1 people. Send away one person (say, John). By inductive hypothesis, the remaining people have the same height. Call back John and send away another person (say, Jack). The new group contains John and is again of n people, therefore John has the same height as everybody else (and as Jack).