Post on 19-Jan-2018
description
transcript
Spring 2003 CMSC 203 - Discrete Structures 1
Let’s get started with...Let’s get started with...
LogicLogic!!
Spring 2003 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
Spring 2003 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
Spring 2003 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?
falsfalsee
Spring 2003 CMSC 203 - Discrete Structures 5
The Statement/Proposition The Statement/Proposition GameGame
““y > 5”y > 5”Is this a statement?Is this a statement? yesyesIs this a proposition?Is this a proposition? nonoIts 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..
Spring 2003 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?
falsfalsee
Spring 2003 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? nonoOnly statements can be propositions.Only statements can be propositions.
It’s a request.It’s a request.
Spring 2003 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? yesyesIs 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
Spring 2003 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? yesyesIs 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.
Spring 2003 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. .
Spring 2003 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.
Spring 2003 CMSC 203 - Discrete Structures 12
Negation (NOT)Negation (NOT)Unary Operator, Symbol: Unary Operator, Symbol:
PP PPtrue (T)true (T) false (F)false (F)false (F)false (F) true (T)true (T)
Spring 2003 CMSC 203 - Discrete Structures 13
Conjunction (AND)Conjunction (AND)Binary Operator, Symbol: Binary Operator, Symbol:
PP QQ PPQQTT TT TTTT FF FFFF TT FFFF FF FF
Spring 2003 CMSC 203 - Discrete Structures 14
Disjunction (OR)Disjunction (OR)Binary Operator, Symbol: Binary Operator, Symbol:
PP QQ PPQQTT TT TTTT FF TTFF TT TTFF FF FF
Spring 2003 CMSC 203 - Discrete Structures 15
Exclusive Or (XOR)Exclusive Or (XOR)Binary Operator, Symbol: Binary Operator, Symbol:
PP QQ PPQQTT TT FFTT FF TTFF TT TTFF FF FF
Spring 2003 CMSC 203 - Discrete Structures 16
Implication (if - then)Implication (if - then)Binary Operator, Symbol: Binary Operator, Symbol:
PP QQ PPQQTT TT TTTT FF FFFF TT TTFF FF TT
Spring 2003 CMSC 203 - Discrete Structures 17
Biconditional (if and only Biconditional (if and only if)if)
Binary Operator, Symbol: Binary Operator, Symbol: PP QQ PPQQTT TT TTTT FF FFFF TT FFFF FF TT
Spring 2003 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 FFTT FF FF TT TTFF TT TT FF TTFF FF TT TT TT
Spring 2003 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 FFTT FF FF TT TTFF TT FF TT TTFF FF FF TT TT
Spring 2003 CMSC 203 - Discrete Structures 20
Equivalent StatementsEquivalent StatementsPP QQ (P(PQ)Q) ((P)P)((Q)Q) (P(PQ)Q)((P)P)((Q)Q)
TT TT FF FF TTTT FF TT TT TTFF TT TT TT TTFF 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.
Spring 2003 CMSC 203 - Discrete Structures 21
Tautologies and Tautologies and ContradictionsContradictions
A tautology is a statement that is always true.A tautology is a statement that is always 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.
Spring 2003 CMSC 203 - Discrete Structures 22
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 contra-The negation of any tautology is a contra-diction, and the negation of any contradiction is diction, and the negation of any contradiction is a tautology.a tautology.
Spring 2003 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.
Spring 2003 CMSC 203 - Discrete Structures 24
Propositional FunctionsPropositional FunctionsPropositional 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) ? falsefalseWhat 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) ?
falsefalsetruetrue
Spring 2003 CMSC 203 - Discrete Structures 25
Propositional FunctionsPropositional FunctionsLet 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) ??
truetrueWhat 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) ?
falsefalsetruetrue
Spring 2003 CMSC 203 - Discrete Structures 26
Universal QuantificationUniversal QuantificationLet 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 true.For all x in the universe of discourse P(x) is 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.)
Spring 2003 CMSC 203 - Discrete Structures 27
Universal QuantificationUniversal QuantificationExample: 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.”
Spring 2003 CMSC 203 - Discrete Structures 28
Existential QuantificationExistential QuantificationExistentially 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.)
Spring 2003 CMSC 203 - Discrete Structures 29
Existential QuantificationExistential QuantificationExample: 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.”
Spring 2003 CMSC 203 - Discrete Structures 30
QuantificationQuantificationAnother 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
Spring 2003 CMSC 203 - Discrete Structures 31
Disproof by CounterexampleDisproof by CounterexampleA counterexample to A counterexample to x P(x) is an object c so x P(x) is an object c so that P(c) is false. 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.
Spring 2003 CMSC 203 - Discrete Structures 32
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.
Spring 2003 CMSC 203 - Discrete Structures 33
Logical EquivalencesLogical Equivalences• Identity Laws: pIdentity Laws: p TT p and p p and p FF p. p.• Domination Laws: pDomination Laws: p TT TT and p and p FF FF..• Idempotent Laws: pIdempotent Laws: p p p p and p p and p p p p. p. • Double Negation Law: Double Negation Law: (( p) p) p. p.• Commutative Laws:Commutative Laws:
(p(p q) q) (q (q p) and (pp) and (p q) q) (q (q p).p).• Associative Laws: Associative Laws: (p(p q)q) r r p p (q(q r) r)
and (pand (p q)q) r r p p (q(q r).r).
Spring 2003 CMSC 203 - Discrete Structures 34
Logical EquivalencesLogical Equivalences• Distributive Laws: Distributive Laws:
pp ( (qq r) r) (p (p q)q) (p(p r) andr) andpp ( (qq r) r) (p (p q)q) (p(p r).r).
• DeMorgan’s Laws:DeMorgan’s Laws:((pp q) q) ( ( p p q) andq) and
((pp q) q) ( ( p p q).q).• Absorption Laws: Absorption Laws:
pp ( (pp q) q) p p and and pp ( (pp q) q) p. p.• Negation Laws: pNegation Laws: p p p TT and and pp p p F.F.
Spring 2003 CMSC 203 - Discrete Structures 35
ExamplesExamples• Find the truth table of Find the truth table of [[p p (q (q r)]. r)].• (An important Theorem) Show that:(An important Theorem) Show that:
p p q q p p q. q.• Show the Corollary: Show the Corollary: ((p p q) q) p p q.q.• Using the tables on page 24, verify the Using the tables on page 24, verify the
Absorption Laws:Absorption Laws:p p (p(p q) q) p, and p, and
pp (p (p q) q) p. p.
Spring 2003 CMSC 203 - Discrete Structures 36
ExamplesExamples
• Negate: Negate: (a) For each integer, n, if 4 divides n, then(a) For each integer, n, if 4 divides n, then
2 divides n.2 divides n.
(b) (b) xxR, R, yyR R [x [x y] y] [y [y (x + 1)]. (x + 1)].