Discrete mathematics I

Discrete
mathematics I Logic
Emil Vatai
Basics
Zeroth-order logic
First-order logic
Discrete mathematics I - Logic
Theories
Emil Vatai
May 5, 2015
Outline
Discrete
mathematics I Logic
Emil Vatai
Basics
Zeroth-order logic
1 Basics
First-order logic
Theories
2 Zeroth-order logic
3 First-order logic
4 Theories
Logic: The science of correct reasoning
Discrete
mathematics I Logic
Emil Vatai
Basics
Zeroth-order logic
First-order logic
Theories
Definition
Logic (from the Ancient Greek: logike) is the use and study of
valid reasoning.
Independently of the object of discussion.
Logic discusses statements which have a unique truth value.
Truth values
Truth values can be either true (↑, 1, >) or false (↓, 0, ⊥).
L = {>, ⊥}.
Propositional variables are variables which range over truth
values, (they must be either true or false, but never both).
Zeroth-order logic
Discrete
mathematics I Logic
Emil Vatai
Basics
Zeroth-order logic
First-order logic
Theories
Definition
In mathematical logic, a propositional calculus or logic (also
called sentential calculus or sentential logic) is a formal system
in which formulas of a formal language may be interpreted to
represent propositions.
It is formal, i.e. it uses (well-formed) formulas to approximate
reality.
It deals only with statements which are either true or false (not
both).
Mathematical logic does not address the contents of the
statement, only it’s truth-value.
Propositional logic discusses the properties and rules of logical
operations.
Domain of discourse
Discrete
mathematics I Logic
Emil Vatai
Basics
Zeroth-order logic
First-order logic
Theories
Definition
The domain of discourse, also called the universe of discourse
(or simply universe),
is the set of entities over which certain variables of interest in
some formal treatment may range.
It is the set of "things we are discussing".
Usually it is denoted by U
Examples
U = the students in this class
U=N
Terms
Discrete
mathematics I Logic
Emil Vatai
Definition
Basics
Zeroth-order logic
First-order logic
1
2
Theories
3
If t ∈ U then t is a term.
If f is an n-ary function symbol, and t1 , t2 , . . . , tn are terms,
then f (t1 , t2 , . . . , tn ) is a term.
Every term can be obtained by the finite application of the
previous two rules.
Examples
f (t) = the nearest student to t
f (n, m) = n + m (note we can think of + as a +(·, ·) binary
function
Predicates
Discrete
mathematics I Logic
Emil Vatai
Definition
Basics
Zeroth-order logic
First-order logic
Theories
A predicate takes an entity or entities in the domain of discourse
as input and outputs either True or False.
P is an n-ary predicate if P : U n → L.
Predicates are statements about the entities of the domain of
discourse.
Examples
F (t): t is female
D(m, n): m divides n
Logical operators
Discrete
mathematics I Logic
Definition
Emil Vatai
Basics
Zeroth-order logic
First-order logic
Theories
Logical operators are map of the form Ln → L (for some
positive integer n).
They come from well-known everyday logical operations, e.g.
and, or, if. . . then, if and only if, not
They connect predicated i.e. statements to form larger
statements
Examples
Binary logical operators: ∧ (and, conjunction), ∨ (/inclusive or,
disjunction), ⇒ (if..then, implication), ⇔ (if and only if, iff,
equivalence).
Unary logical operator: ¬ (not, negation)
Truth-tables
Discrete
mathematics I Logic
Conjunction and disjunction
Emil Vatai
Basics
Zeroth-order logic
First-order logic
Theories
A
>
>
⊥
⊥
B
>
⊥
>
⊥
A∧B
>
⊥
⊥
⊥
A
>
>
⊥
⊥
B
>
⊥
>
⊥
A∨B
>
>
>
⊥
A
>
>
⊥
⊥
B
>
⊥
>
⊥
A⇔B
>
⊥
⊥
>
Implication and equivalence
A
>
>
⊥
⊥
B
>
⊥
>
⊥
A⇒B
>
⊥
>
>
Truth-tables
Discrete
mathematics I Logic
Emil Vatai
Basics
Negation
Zeroth-order logic
First-order logic
Theories
A
>
⊥
¬A
⊥
>
Number of unary and binary operators
What is the number of unary operators?
What is the number of binary operators?
Different OR’s
Discrete
mathematics I Logic
Emil Vatai
Basics
Zeroth-order logic
Inclusive, exclusive, conflicting1 OR
1
First-order logic
Theories
2
3
Inclusive or ∨: Those who had good weapons or good reflexes
were victorious.
Inclusive or ⊕: We have to go left or right.
"Conflicting" or: Drink or
A
>
>
⊥
⊥
1 In
lack of better translation
drive!
B 1
> >
⊥ >
> >
⊥ ⊥
2
⊥
>
>
⊥
3
⊥
>
>
>
Remarks and Questions
Discrete
mathematics I Logic
Emil Vatai
Basics
Zeroth-order logic
First-order logic
Theories
Remarks
The variables A and B in the truth-tables above are
propositional variables, i.e. A ∈ L (and not ∈ U).
These propositional variables denote some predicates, i.e.
A = P(t) or B = D(m, n).
Note the distinction between the entities in the domain of
discourse and the operations on them, versus the predicates (i.e.
statements) and the logical operations connection them.
Questions
Is the following a valid statement, and is it true?
"If 1 = 2 then I am the Pope!"
Remarks and Questions
Discrete
mathematics I Logic
Emil Vatai
Basics
Zeroth-order logic
First-order logic
Theories
Remarks
The variables A and B in the truth-tables above are
propositional variables, i.e. A ∈ L (and not ∈ U).
These propositional variables denote some predicates, i.e.
A = P(t) or B = D(m, n).
Note the distinction between the entities in the domain of
discourse and the operations on them, versus the predicates (i.e.
statements) and the logical operations connection them.
Questions
Is the following a valid statement, and is it true?
"If 1 = 2 then I am the Pope!"
Yes, it is a valid statement. It is also true, because "false implies
everything". (Check the truth-tables)
Well-formed formulas
Discrete
mathematics I Logic
Emil Vatai
Basics
Definition
1
Zeroth-order logic
First-order logic
Theories
2
3
If P is a n-ary predicate, and t1 , t2 , . . . , tn are terms, then
P(t1 , t2 , . . . , tn ) is called an atomic formula and it is a
well-formed formula.
If A and B are well-formed formulas then A ∧ B, A ∨ B, A ⇒ B,
A ⇔ B and ¬A are also well-formed formulas.
Every well-formed formula can be obtained by the finite
application of the previous two rules.
Example
Both F (x ) and F (y ) are well-formed formulas,
Then F (x ) ∨ F (y ) and (F (x ) ∧ F (y )) ⇒ F (y ).
Interpretation, Satisfiability, Validity
Discrete
mathematics I Logic
Emil Vatai
Definitions
Basics
Zeroth-order logic
First-order logic
Theories
An interpretation of a formula is an assignment of meaning to
the variables in the formula, i.e. substituting the variables with
concrete values from U.
A formula is satisfiable if it is possible to find an interpretation
which makes the formula true.
A formula is valid if all interpretations of the formula make it
true.
Valid formulas are also called tautologies or rules.
The opposite concepts are unsatisfiable (always false) and
invalid (some interpretations make it false).
Interpretation, Satisfiability, Validity
Discrete
mathematics I Logic
Examples
Emil Vatai
Basics
Zeroth-order logic
First-order logic
Theories
Let M(t) mean that t is male (over the students of ELTE) and
let A = M(x ) ∧ M(y ) be a formula.
Possible interpretations of A are:
The interpretation A(x /Attila, y /Istvan) yields
M(Attila) ∧ M(Istvan) which is true.
The interpretation A(x /Attila, y /Anna) yields
M(Attila) ∧ M(Anna) which is false.
A is satisfiable, because of the first interpretation.
A is invalid, because the second interpretation makes it false
(i.e. it is not always true).
B = M(x ) ∧ M(y ) ⇒ M(x ) is a valid formula, because it is
always true. It is a tautology.
¬B is an unsatisfiable fromula.
Questions
Discrete
mathematics I Logic
Emil Vatai
Basics
Zeroth-order logic
First-order logic
Theories
Questions
For each of the bellow points determine if the statement or "vice
versa" is true, or both or neither are true:
All satisfiable statements are valid formulas.
All satisfiable formulas are invalid.
Some satisfiable formulas are invalid.
All valid formulas are not unsatisfiable.
Some rules of propositional logic
Discrete
mathematics I Logic
Emil Vatai
Rules
Basics
Zeroth-order logic
First-order logic
Theories
A ∧ B ⇔ B ∧ A, A ∨ B ⇔ B ∨ A
(A ∧ B) ∧ C ⇔ A ∧ (B ∧ C)
(A ∨ B) ∨ C ⇔ A ∨ (B ∨ C)
A ∧ (B ∨ C) ⇔ (A ∧ B) ∨ (A ∧ C),
A ∨ (B ∧ C) ⇔ (A ∨ B) ∧ (A ∨ C)
A ∧ (A ∨ B) ⇔ A, A ∨ (A ∧ B) ⇔ A
A ∧ A ⇔ A, A ∨ A ⇔ A
A ∨ ¬A
¬(A ∧ ¬A)
¬(¬(A)) ⇔ A
commutativity
associativity
associativity
distributivity
distributivity
absorption
idempotency
Some rules of propositional logic
Discrete
mathematics I Logic
Emil Vatai
Rules
Basics
Zeroth-order logic
First-order logic
Theories
A∧>⇔A
A∧ ⊥⇔⊥
A∨>⇔>
A∨ ⊥⇔ A
¬(A ∧ B) ⇔ ¬A ∨ ¬B
¬(A ∨ B) ⇔ ¬A ∧ ¬B
A ⇒ B ⇔ ¬B ⇒ ¬A
(A ⇒ B) ∧ A ⇒ B
(A ⇒ B) ∧ ¬B ⇒ ¬A
(A ⇒ B) ∧ (B ⇒ C) ⇒ (A ⇒ C)
((A ⇒ B) ∧ (B ⇒ A)) ⇔ (A ⇔ B)
DeMorgan
DeMorgan
Proof
Discrete
mathematics I Logic
Emil Vatai
Basics
Zeroth-order logic
First-order logic
Theories
Proof of A ∧ (A ∨ B) ⇔ A
Let F = A ∧ (A ∨ B) ⇔ A and lhs = A ∧ (A ∨ B) (left hand side),
rhs = A (right hand side).
If A =⊥ then lhs is false because of the definition of conjunction. If
A = > then A ∨ B is true because of the definition of disjunction, so
lhs is A ∧ > which is >. In both cases the rhs equals lhs, so by the
definition of equivalence the formula is always true, i.e. valid.
Proof using truth-tables is done by filling out the first two columns of
the table as given bellow, and then the rest using the definitions of
the logical operations:
A
>
>
⊥
⊥
B
>
⊥
>
⊥
A∨B
>
>
>
⊥
lhs
>
>
⊥
⊥
rhs
>
>
⊥
⊥
F
>
>
>
>
Well-formed formulas
Discrete
mathematics I Logic
Emil Vatai
Definition
Basics
Zeroth-order logic
1
First-order logic
Theories
2
3
4
If P is a n-ary predicate, and t1 , t2 , . . . , tn are terms, then
P(t1 , t2 , . . . , tn ) is called an atomic formula and it is a
well-formed formula.
If A and B are well-formed formulas then A ∧ B, A ∨ B, A ⇒ B,
A ⇔ B and ¬A are also well-formed formulas.
If A is a well-formed, x a variable of the domain of discourse,
then ∀x A and ∃x A are also well-formed formulas (these are
universally and existentially quantified formulas)
Every well-formed formula can be obtained by the finite
application of the previous two rules.
Examples
Discrete
mathematics I Logic
Emil Vatai
Basics
Zeroth-order logic
First-order logic
Theories
Example
Continuing with the example from propositional logic:
∃xF (x ) and ∃x ¬F (y ) are well-formed formulas.
∀x ∃y (F (x ) ∧ ¬F (y )).
Quantifiers
Discrete
mathematics I Logic
Emil Vatai
Basics
Zeroth-order logic
First-order logic
Theories
Universal quantifier
Symbol: ∀
Read: for all, for each
∀xP(x , y ) ⇔ P(x1 , y ) ∧ P(x2 , y ) ∧ · · · (if U = {x1 , x2 , . . .})
Existential quantifier
Symbol: ∃
Read: exists, there is
∃xP(x , y ) ⇔ P(x1 , y ) ∨ P(x2 , y ) ∨ · · · (if U = {x1 , x2 , . . .})
∃!x denotes "there exists a unique x " or "there is exactly one x "
Scope, Free and bound occurrences
Discrete
mathematics I Logic
Emil Vatai
Basics
Zeroth-order logic
First-order logic
Theories
Definition
If Q is a quantifier (∀ or ∃) and x is a variable then the scope of
Q is the narrowest sub-formula after Qx .
All the occurrences of x in the scope of Q are quantified by Q.
Let A be a formula and x a variable, then
An occurrence of x is a free occurrence if it is not quantified.
An occurrence of x is a bound occurrence if it is quantified.
Free and bound variables, closed and open formulas
Discrete
mathematics I Logic
Emil Vatai
Basics
Zeroth-order logic
First-order logic
Theories
Definitions
The variable x is a bound variable in A, if its every occurrence is
bound.
The variable x is a free variable in A, if its every occurrence is
free.
The variable x has mixed occurrence if it has both free and
bound occurrences.
The formula A is a closed formula (or a sentence) if all of its
variables are bound.
The formula A is an open formula if it has at least one
The formula A is quantifierless if all of its variables are free.
Examples
Discrete
mathematics I Logic
Emil Vatai
Basics
Zeroth-order logic
First-order logic
Theories
Examples
A = ∀x (P(x ) ∧ Q(x , y )) ⇒ ∃x ∀zR(x , y , z)
The scope of the first universal quantifier is (P(x ) ∧ Q(x , y ), the
scope of the existential quantifier is ∀zR(x , y , z), the scope of
the second universal quantifier is R(x , y , z).
The free variable is y
Rules of first order logic
Discrete
mathematics I Logic
Rules
Emil Vatai
1
¬∀xP(x ) ⇔ ∃x ¬P(x )
2
¬∃xP(x ) ⇔ ∀x ¬P(x )
3
∀x ∀yP(x , y ) ⇔ ∀y ∀xP(x , y )
4
∃x ∃yP(x , y ) ⇔ ∃y ∃xP(x , y )
5
∃x ∀yP(x , y ) ⇒ ∀y ∃xP(x , y )
Basics
Zeroth-order logic
First-order logic
Theories
Example to remember the last rule
If U = {1, 2} then consider the following two formulas:
∃x ∀y (x = y ) is false because it is: ∃x (x = 1 ∧ x = 2) which is
(1 = 1 ∧ 1 = 2) ∨ (2 = 1 ∧ 2 = 2)
∀y ∃x (x = y ) is true because it is: ∀y (1 = y ∨ 2 = y ) which is
(1 = 1 ∨ 2 = 1) ∧ (1 = 2 ∨ 2 = 2)
And by the definition of implication > ⇒⊥ is false and ⊥⇒ > is
true.
Axioms, theorems
Discrete
mathematics I Logic
Emil Vatai
Basics
Zeroth-order logic
First-order logic
Theories
Definition
Axioms (or postulates) are formulas in a theory which we
consider trivially true.
Theorems are formulas derived from axioms using the rules of
logic.
Example
In euclidean geometry one of the postulates (axioms) is: A
straight line segment can be drawn joining any two points. A
theorem is that the sum of angles in a triangle is π radians (or
180°)