Download Discrete mathematics I - Logic

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Discrete mathematics I - Logic
Emil Vatai <[email protected]> (based on hungarian slides by László Mérai)∗
February 21, 2017
Outline
Contents
1 Basics
1
2 Zeroth-order logic
2
3 First-order logic
7
4 Theories
9
1
Basics
Logic: The science of correct reasoning
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).
∗ Financed from the financial support ELTE won from the Higher Education Restructuring
Fund of the Hungarian Government.
1
2
Zeroth-order logic
Zeroth-order logic
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
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
Definition
1. If t ∈ U then t is a term.
2. If f is an n-ary function symbol, and t1 , t2 , . . . , tn are terms, then f (t1 , t2 , . . . , tn )
is a term.
3. 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
2
Predicates
Definition
• 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
Definition
• 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
Conjunction and disjunction
A
>
>
⊥
⊥
B
>
⊥
>
⊥
A∧B
>
⊥
⊥
⊥
A
>
>
⊥
⊥
B
>
⊥
>
⊥
A∨B
>
>
>
⊥
A
>
>
⊥
⊥
B
>
⊥
>
⊥
A⇔B
>
⊥
⊥
>
Implication and equivalence
A
>
>
⊥
⊥
B
>
⊥
>
⊥
A⇒B
>
⊥
>
>
3
Truth-tables
Negation
¬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
Inclusive, exclusive, conflicting1 OR
1. Inclusive or ∨: Those who had good weapons or good reflexes were victorious.
2. Inclusive or ⊕: We have to go left or right.
3. “Conflicting” or: Drink or drive!
A
>
>
⊥
⊥
B
>
⊥
>
⊥
1
>
>
>
⊥
2
⊥
>
>
⊥
3
⊥
>
>
>
Remarks and Questions
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)
1 In
lack of better translation
4
Well-formed formulas
Definition
1. 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.
2. If A and B are well-formed formulas then A ∧ B, A ∨ B, A ⇒ B, A ⇔ B
and ¬A are also well-formed formulas.
3. 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
Definitions
• 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
Examples
• 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.
5
Questions
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
Rules
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
Rules
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
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
6
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
>
>
⊥
⊥
3
B
>
⊥
>
⊥
A∨B
>
>
>
⊥
lhs
>
>
⊥
⊥
rhs
>
>
⊥
⊥
F
>
>
>
>
First-order logic
Well-formed formulas
Definition
1. 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.
2. If A and B are well-formed formulas then A ∧ B, A ∨ B, A ⇒ B, A ⇔ B
and ¬A are also well-formed formulas.
3. If A is a well-formed, x a variable of the domain of discourse, then ∀xA and
∃xA are also well-formed formulas (these are universally and existentially
quantified formulas)
4. Every well-formed formula can be obtained by the finite application of the
previous two rules.
Examples
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
Universal quantifier
• Symbol: ∀
• Read: for all, for each
• ∀xP (x, y) ⇔ P (x1 , y) ∧ P (x2 , y) ∧ · · · (if U = {x1 , x2 , . . .})
Existential quantifier
7
• 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
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
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
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
8
Rules of first order logic
Rules
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)
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.
4
Theories
Axioms, theorems
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°)
9
Related documents