Fall 2002 CMSC 203 - Discrete Structures 1
Let’s get started with...Let’s get started with...
LogicLogic!!
Fall 2002 CMSC 203 - Discrete Structures 2
LogicLogic• Crucial for mathematical reasoningCrucial for mathematical reasoning• Used for designing electronic circuitryUsed for designing electronic circuitry
• Logic is a system based on Logic is a system based on propositionspropositions..• A proposition is a statement that is either A proposition is a statement that is either
truetrue or or falsefalse (not both). (not both).• We say that the We say that the truth valuetruth value of a of a
proposition is either true (T) or false (F).proposition is either true (T) or false (F).
• Corresponds to Corresponds to 11 and and 00 in digital circuits in digital circuits
Fall 2002 CMSC 203 - Discrete Structures 3
The Statement/Proposition The Statement/Proposition GameGame
““Elephants are bigger than mice.”Elephants are bigger than mice.”
Is this a statement?Is this a statement? yesyes
Is this a proposition?Is this a proposition? yesyes
What is the truth What is the truth value value
of the proposition?of the proposition?truetrue
Fall 2002 CMSC 203 - Discrete Structures 4
The Statement/Proposition The Statement/Proposition GameGame
““520 < 111”520 < 111”
Is this a statement?Is this a statement? yesyes
Is this a proposition?Is this a proposition? yesyes
What is the truth What is the truth value value
of the proposition?of the proposition?falsfals
ee
Fall 2002 CMSC 203 - Discrete Structures 5
The Statement/Proposition The Statement/Proposition GameGame
““y > 5”y > 5”
Is this a statement?Is this a statement? yesyes
Is this a proposition?Is this a proposition? nono
Its truth value depends on the value of Its truth value depends on the value of y, but this value is not specified.y, but this value is not specified.
We call this type of statement a We call this type of statement a propositional functionpropositional function or or open open sentencesentence..
Fall 2002 CMSC 203 - Discrete Structures 6
The Statement/Proposition The Statement/Proposition GameGame
““Today is January 1 and 99 < 5.”Today is January 1 and 99 < 5.”
Is this a statement?Is this a statement? yesyes
Is this a proposition?Is this a proposition? yesyes
What is the truth What is the truth value value
of the proposition?of the proposition?falsfals
ee
Fall 2002 CMSC 203 - Discrete Structures 7
The Statement/Proposition The Statement/Proposition GameGame
““Please do not fall asleep.”Please do not fall asleep.”
Is this a statement?Is this a statement? nono
Is this a proposition?Is this a proposition? nono
Only statements can be propositions.Only statements can be propositions.
It’s a request.It’s a request.
Fall 2002 CMSC 203 - Discrete Structures 8
The Statement/Proposition The Statement/Proposition GameGame
““If elephants were red,If elephants were red,
they could hide in cherry trees.”they could hide in cherry trees.”
Is this a statement?Is this a statement? yesyes
Is this a proposition?Is this a proposition? yesyes
What is the truth What is the truth value value
of the proposition?of the proposition?probably probably
falsefalse
Fall 2002 CMSC 203 - Discrete Structures 9
The Statement/Proposition The Statement/Proposition GameGame
““x < y if and only if y > x.”x < y if and only if y > x.”
Is this a statement?Is this a statement? yesyes
Is this a proposition?Is this a proposition? yesyes
What is the truth What is the truth value value
of the proposition?of the proposition?truetrue
… … because its truth value because its truth value does not depend on does not depend on specific values of x and specific values of x and y.y.
Fall 2002 CMSC 203 - Discrete Structures 10
Combining PropositionsCombining Propositions
As we have seen in the previous examples, As we have seen in the previous examples, one or more propositions can be combined one or more propositions can be combined to form a single to form a single compound propositioncompound proposition..
We formalize this by denoting propositions We formalize this by denoting propositions with letters such as with letters such as p, q, r, s,p, q, r, s, and and introducing several introducing several logical operatorslogical operators. .
Fall 2002 CMSC 203 - Discrete Structures 11
Logical Operators Logical Operators (Connectives)(Connectives)
We will examine the following logical We will examine the following logical operators:operators:
• Negation Negation (NOT)(NOT)• Conjunction Conjunction (AND)(AND)• Disjunction Disjunction (OR)(OR)• Exclusive or Exclusive or (XOR)(XOR)• Implication Implication (if – then)(if – then)• Biconditional Biconditional (if and only if)(if and only if)
Truth tables can be used to show how these Truth tables can be used to show how these operators can combine propositions to operators can combine propositions to compound propositions.compound propositions.
Fall 2002 CMSC 203 - Discrete Structures 12
Negation (NOT)Negation (NOT)
Unary Operator, Symbol: Unary Operator, Symbol:
PP PP
true (T)true (T) false (F)false (F)
false (F)false (F) true (T)true (T)
Fall 2002 CMSC 203 - Discrete Structures 13
Conjunction (AND)Conjunction (AND)
Binary Operator, Symbol: Binary Operator, Symbol:
PP QQ PPQQ
TT TT TT
TT FF FF
FF TT FF
FF FF FF
Fall 2002 CMSC 203 - Discrete Structures 14
Disjunction (OR)Disjunction (OR)
Binary Operator, Symbol: Binary Operator, Symbol:
PP QQ PPQQ
TT TT TT
TT FF TT
FF TT TT
FF FF FF
Fall 2002 CMSC 203 - Discrete Structures 15
Exclusive Or (XOR)Exclusive Or (XOR)
Binary Operator, Symbol: Binary Operator, Symbol:
PP QQ PPQQ
TT TT FF
TT FF TT
FF TT TT
FF FF FF
Fall 2002 CMSC 203 - Discrete Structures 16
Implication (if - then)Implication (if - then)
Binary Operator, Symbol: Binary Operator, Symbol:
PP QQ PPQQ
TT TT TT
TT FF FF
FF TT TT
FF FF TT
Fall 2002 CMSC 203 - Discrete Structures 17
Biconditional (if and only Biconditional (if and only if)if)
Binary Operator, Symbol: Binary Operator, Symbol:
PP QQ PPQQ
TT TT TT
TT FF FF
FF TT FF
FF FF TT
Fall 2002 CMSC 203 - Discrete Structures 18
Statements and OperatorsStatements and OperatorsStatements and operators can be combined in Statements and operators can be combined in
any way to form new statements.any way to form new statements.
PP QQ PP QQ ((P)P)((Q)Q)
TT TT FF FF FF
TT FF FF TT TT
FF TT TT FF TT
FF FF TT TT TT
Fall 2002 CMSC 203 - Discrete Structures 19
Statements and Statements and OperationsOperations
Statements and operators can be combined in Statements and operators can be combined in any way to form new statements.any way to form new statements.
PP QQ PPQQ (P(PQ)Q) ((P)P)((Q)Q)
TT TT TT FF FF
TT FF FF TT TT
FF TT FF TT TT
FF FF FF TT TT
Fall 2002 CMSC 203 - Discrete Structures 20
Equivalent StatementsEquivalent Statements
PP QQ (P(PQ)Q) ((P)P)((Q)Q) (P(PQ)Q)((P)P)((Q)Q)
TT TT FF FF TT
TT FF TT TT TT
FF TT TT TT TT
FF FF TT TT TT
The statements The statements (P(PQ) and (Q) and (P) P) ( (Q) are Q) are logically logically
equivalentequivalent, since , since (P(PQ) Q) ((P) P) ( (Q) is always true.Q) is always true.
Fall 2002 CMSC 203 - Discrete Structures 21
Tautologies and Tautologies and ContradictionsContradictions
A tautology is a statement that is always A tautology is a statement that is always true.true.
Examples: Examples: • RR((R)R) (P(PQ)Q)((P)P)((Q)Q)
If SIf ST is a tautology, we write ST is a tautology, we write ST.T.
If SIf ST is a tautology, we write ST is a tautology, we write ST.T.
Fall 2002 CMSC 203 - Discrete Structures 22
Tautologies and Tautologies and ContradictionsContradictions
A contradiction is a statement that is alwaysA contradiction is a statement that is always
false.false.
Examples: Examples: • RR((R)R) (((P(PQ)Q)((P)P)((Q))Q))
The negation of any tautology is a contra-The negation of any tautology is a contra-
diction, and the negation of any contradiction diction, and the negation of any contradiction is is
a tautology.a tautology.
Fall 2002 CMSC 203 - Discrete Structures 23
ExercisesExercisesWe already know the following tautology: We already know the following tautology:
(P(PQ) Q) ((P)P)((Q)Q)
Nice home exercise: Nice home exercise:
Show that Show that (P(PQ) Q) ((P)P)((Q).Q).
These two tautologies are known as De These two tautologies are known as De Morgan’s laws.Morgan’s laws.
Table 5 in Section 1.2Table 5 in Section 1.2 shows many useful laws. shows many useful laws.
Exercises 1 and 7 in Section 1.2Exercises 1 and 7 in Section 1.2 may help you may help you get used to propositions and operators.get used to propositions and operators.
Fall 2002 CMSC 203 - Discrete Structures 24
Let’s Talk About LogicLet’s Talk About Logic
• Logic is a system based on Logic is a system based on propositionspropositions..
• A proposition is a statement that is either A proposition is a statement that is either truetrue or or falsefalse (not both). (not both).
• We say that the We say that the truth valuetruth value of a of a proposition is either true (T) or false (F).proposition is either true (T) or false (F).
• Corresponds to Corresponds to 11 and and 00 in digital circuits in digital circuits
Fall 2002 CMSC 203 - Discrete Structures 25
Logical Operators Logical Operators (Connectives)(Connectives)
• Negation Negation (NOT)(NOT)• Conjunction Conjunction (AND)(AND)• Disjunction Disjunction (OR)(OR)• Exclusive or Exclusive or (XOR)(XOR)• Implication Implication (if – then)(if – then)• Biconditional Biconditional (if and only if)(if and only if)
Truth tables can be used to show how these Truth tables can be used to show how these operators can combine propositions to operators can combine propositions to compound propositions.compound propositions.
Fall 2002 CMSC 203 - Discrete Structures 26
Tautologies and Tautologies and ContradictionsContradictions
A tautology is a statement that is always A tautology is a statement that is always true.true.
Examples: Examples: • RR((R)R) (P(PQ)Q)((P)P)((Q)Q)
If SIf ST is a tautology, we write ST is a tautology, we write ST.T.
If SIf ST is a tautology, we write ST is a tautology, we write ST.T.
Fall 2002 CMSC 203 - Discrete Structures 27
Tautologies and Tautologies and ContradictionsContradictions
A contradiction is a statement that is alwaysA contradiction is a statement that is alwaysfalse.false.
Examples: Examples: • RR((R)R)• (((P(PQ)Q)((P)P)((Q))Q))
The negation of any tautology is a The negation of any tautology is a contradiction, and the negation of any contradiction, and the negation of any contradiction is a tautology.contradiction is a tautology.
Fall 2002 CMSC 203 - Discrete Structures 28
Propositional FunctionsPropositional Functions
Propositional function (open sentence):Propositional function (open sentence):
statement involving one or more variables,statement involving one or more variables,
e.g.: x-3 > 5.e.g.: x-3 > 5.
Let us call this propositional function P(x), Let us call this propositional function P(x), where P is the where P is the predicatepredicate and x is the and x is the variablevariable..
What is the truth value of P(2) ?What is the truth value of P(2) ? falsefalse
What is the truth value of P(8) ?What is the truth value of P(8) ?
What is the truth value of P(9) ?What is the truth value of P(9) ?
falsefalse
truetrue
Fall 2002 CMSC 203 - Discrete Structures 29
Propositional FunctionsPropositional Functions
Let us consider the propositional function Let us consider the propositional function Q(x, y, z) defined as: Q(x, y, z) defined as:
x + y = z.x + y = z.
Here, Q is the Here, Q is the predicatepredicate and x, y, and z are and x, y, and z are the the variablesvariables..
What is the truth value of Q(2, 3, 5) What is the truth value of Q(2, 3, 5) ??
truetrue
What is the truth value of Q(0, 1, What is the truth value of Q(0, 1, 2) ?2) ?What is the truth value of Q(9, -9, 0) ?What is the truth value of Q(9, -9, 0) ?
falsefalse
truetrue
Fall 2002 CMSC 203 - Discrete Structures 30
Universal QuantificationUniversal Quantification
Let P(x) be a propositional function.Let P(x) be a propositional function.
Universally quantified sentenceUniversally quantified sentence::
For all x in the universe of discourse P(x) is For all x in the universe of discourse P(x) is true.true.
Using the universal quantifier Using the universal quantifier ::
x P(x) x P(x) “for all x P(x)” or “for every x P(x)”“for all x P(x)” or “for every x P(x)”
(Note: (Note: x P(x) is either true or false, so it is a x P(x) is either true or false, so it is a proposition, not a propositional function.)proposition, not a propositional function.)
Fall 2002 CMSC 203 - Discrete Structures 31
Universal QuantificationUniversal Quantification
Example: Example:
S(x): x is a UMBC student.S(x): x is a UMBC student.
G(x): x is a genius.G(x): x is a genius.
What does What does x (S(x) x (S(x) G(x)) G(x)) mean ? mean ?
““If x is a UMBC student, then x is a genius.”If x is a UMBC student, then x is a genius.”
oror
““All UMBC students are geniuses.”All UMBC students are geniuses.”
Fall 2002 CMSC 203 - Discrete Structures 32
Existential QuantificationExistential Quantification
Existentially quantified sentenceExistentially quantified sentence::There exists an x in the universe of discourse There exists an x in the universe of discourse for which P(x) is true.for which P(x) is true.
Using the existential quantifier Using the existential quantifier ::x P(x) x P(x) “There is an x such that P(x).”“There is an x such that P(x).”
“ “There is at least one x such that There is at least one x such that P(x).”P(x).”
(Note: (Note: x P(x) is either true or false, so it is a x P(x) is either true or false, so it is a proposition, but no propositional function.)proposition, but no propositional function.)
Fall 2002 CMSC 203 - Discrete Structures 33
Existential QuantificationExistential Quantification
Example: Example: P(x): x is a UMBC professor.P(x): x is a UMBC professor.G(x): x is a genius.G(x): x is a genius.
What does What does x (P(x) x (P(x) G(x)) G(x)) mean ? mean ?
““There is an x such that x is a UMBC There is an x such that x is a UMBC professor and x is a genius.”professor and x is a genius.”oror““At least one UMBC professor is a genius.”At least one UMBC professor is a genius.”
Fall 2002 CMSC 203 - Discrete Structures 34
QuantificationQuantification
Another example:Another example:
Let the universe of discourse be the real numbers.Let the universe of discourse be the real numbers.
What does What does xxy (x + y = 320)y (x + y = 320) mean ? mean ?
““For every x there exists a y so that x + y = 320.”For every x there exists a y so that x + y = 320.”
Is it true?Is it true?
Is it true for the natural Is it true for the natural numbers?numbers?
yesyes
nono
Fall 2002 CMSC 203 - Discrete Structures 35
Disproof by CounterexampleDisproof by Counterexample
A counterexample to A counterexample to x P(x) is an object c x P(x) is an object c so that P(c) is false. so that P(c) is false.
Statements such as Statements such as x (P(x) x (P(x) Q(x)) can be Q(x)) can be disproved by simply providing a disproved by simply providing a counterexample.counterexample.
Statement: “All birds can fly.”Statement: “All birds can fly.”Disproved by counterexample: Penguin.Disproved by counterexample: Penguin.
Fall 2002 CMSC 203 - Discrete Structures 36
NegationNegation
((x P(x)) is logically equivalent to x P(x)) is logically equivalent to x (x (P(x)).P(x)).
((x P(x)) is logically equivalent to x P(x)) is logically equivalent to x (x (P(x)).P(x)).
See Table 3 in Section 1.3.See Table 3 in Section 1.3.
I recommend exercises 5 and 9 in Section 1.3.I recommend exercises 5 and 9 in Section 1.3.