71
Discrete Structures 1 Let’s get started Let’s get started with... with... Logic Logic ! !

Discrete Structures1 Let’s get started with... Logic !

Embed Size (px)

Citation preview

Page 1: Discrete Structures1 Let’s get started with... Logic !

Discrete Structures 1

Let’s get started with...Let’s get started with...

LogicLogic!!

Page 2: Discrete Structures1 Let’s get started with... Logic !

Discrete Structures 2

LogicLogic• Crucial for mathematical reasoningCrucial for mathematical reasoning• Important for program designImportant for program design• Used for designing electronic circuitryUsed for designing electronic circuitry

• (Propositional )Logic is a system based on (Propositional )Logic is a system based on propositionspropositions..

• A proposition is a (declarative) statement A proposition is a (declarative) statement that is either that is either truetrue or or falsefalse (not both). (not both).

• We say that the We say that the truth valuetruth value of a proposition of a proposition is either true (is either true (TT) or false () or false (FF).).

• Corresponds to Corresponds to 11 and and 00 in digital circuits in digital circuits

Page 3: Discrete Structures1 Let’s get started with... Logic !

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

Page 4: Discrete Structures1 Let’s get started with... Logic !

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

Page 5: Discrete Structures1 Let’s get started with... Logic !

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..

Page 6: Discrete Structures1 Let’s get started with... Logic !

Discrete Structures 6

The Statement/Proposition The Statement/Proposition GameGame

““Today is January 27 and 99 < 5.”Today is January 27 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

Page 7: Discrete Structures1 Let’s get started with... Logic !

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.

Page 8: Discrete Structures1 Let’s get started with... Logic !

Discrete Structures 8

The Statement/Proposition The Statement/Proposition GameGame

““If the moon is made of cheese,If the moon is made of cheese,

then I would be not mortal.”then I would be not mortal.”

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?true, why???true, why???

Page 9: Discrete Structures1 Let’s get started with... Logic !

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.

Page 10: Discrete Structures1 Let’s get started with... Logic !

Discrete Structures 10

Combining PropositionsCombining Propositions

As we have seen in the previous As we have seen in the previous examples, one or more propositions can examples, one or more propositions can be combined to form a single be combined to form a single compound compound propositionproposition..

We formalize this by denoting We formalize this by denoting propositions with letters such as propositions with letters such as p, q, r, p, q, r, s,s, and introducing several and introducing several logical logical operators or logical connectivesoperators or logical connectives. .

Page 11: Discrete Structures1 Let’s get started with... Logic !

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 operators Truth tables can be used to show how these operators can combine propositions to compound propositions.can combine propositions to compound propositions.

Page 12: Discrete Structures1 Let’s get started with... Logic !

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)

Page 13: Discrete Structures1 Let’s get started with... Logic !

Discrete Structures 13

Conjunction (AND)Conjunction (AND)

Binary Operator, Symbol: Binary Operator, Symbol:

PP QQ P QP Q

TT TT TT

TT FF FF

FF TT FF

FF FF FF

Page 14: Discrete Structures1 Let’s get started with... Logic !

Discrete Structures 14

Disjunction (OR)Disjunction (OR)

Binary Operator, Symbol: Binary Operator, Symbol:

PP QQ P P QQ

TT TT TT

TT FF TT

FF TT TT

FF FF FF

Page 15: Discrete Structures1 Let’s get started with... Logic !

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

Page 16: Discrete Structures1 Let’s get started with... Logic !

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

Page 17: Discrete Structures1 Let’s get started with... Logic !

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

Page 18: Discrete Structures1 Let’s get started with... Logic !

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)(Q)(P)(Q)

TT TT FF FF FF

TT FF FF TT TT

FF TT TT FF TT

FF FF TT TT TT

Page 19: Discrete Structures1 Let’s get started with... Logic !

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 PQPQ (PQ)(PQ) (P)(Q)(P)(Q)

TT TT TT FF FF

TT FF FF TT TT

FF TT FF TT TT

FF FF FF TT TT

Page 20: Discrete Structures1 Let’s get started with... Logic !

Discrete Structures 20

ExercisesExercises•To take discrete mathematics, you must To take discrete mathematics, you must

have taken calculus or a course in have taken calculus or a course in computer science.computer science.

•When you buy a new car from Acme Motor When you buy a new car from Acme Motor Company, you get $2000 back in cash or a Company, you get $2000 back in cash or a 2% car loan.2% car loan.

•School is closed if more than 2 feet of School is closed if more than 2 feet of snow falls or if the wind chill is below -100.snow falls or if the wind chill is below -100.

Page 21: Discrete Structures1 Let’s get started with... Logic !

Discrete Structures 21

ExercisesExercises

– P: take discrete mathematicsP: take discrete mathematics

– Q: take calculusQ: take calculus

– R: take a course in computer scienceR: take a course in computer science

•P P Q Q R R

•Problem with proposition RProblem with proposition R

– What if I want to represent “take CS285”?What if I want to represent “take CS285”?

•To take discrete mathematics, you must To take discrete mathematics, you must have taken calculus or a course in have taken calculus or a course in computer science.computer science.

Page 22: Discrete Structures1 Let’s get started with... Logic !

Discrete Structures 22

ExercisesExercises

– P: buy a car from Acme Motor CompanyP: buy a car from Acme Motor Company

– Q: get $2000 cash backQ: get $2000 cash back

– R: get a 2% car loanR: get a 2% car loan

•P P Q Q R R

•Why use XOR here? – example of Why use XOR here? – example of ambiguity of natural languagesambiguity of natural languages

•When you buy a new car from Acme Motor When you buy a new car from Acme Motor Company, you get $2000 back in cash or a Company, you get $2000 back in cash or a 2% car loan.2% car loan.

Page 23: Discrete Structures1 Let’s get started with... Logic !

Discrete Structures 23

ExercisesExercises

– P: School is closed P: School is closed

– Q: 2 feet of snow fallsQ: 2 feet of snow falls

– R: wind chill is below -100R: wind chill is below -100

•Q Q R R P P

•Precedence among operators:Precedence among operators:, , , , , , , ,

•School is closed if more than 2 feet of School is closed if more than 2 feet of snow falls and if the wind chill is below -snow falls and if the wind chill is below -100.100.

Page 24: Discrete Structures1 Let’s get started with... Logic !

Discrete Structures 24

Equivalent StatementsEquivalent Statements

PP QQ (PQ)(PQ) (P)(Q)(P)(Q) (PQ)(PQ)(P)(Q)(P)(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 equivalentlogically equivalent, since they , since they

have the same truth table, or put it in another way, have the same truth table, or put it in another way, (P(PQ) Q) ((P) P) ( (Q) is Q) is

always true.always true.

Page 25: Discrete Structures1 Let’s get started with... Logic !

Discrete Structures 25

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)

A contradiction is a statement that is always false.A contradiction is a statement that is always false.Examples: Examples:

– RR((R)R) (((P (P Q) Q) ((P) P) ( (Q))Q))

The negation of any tautology is a contradiction, The negation of any tautology is a contradiction, and the negation of any contradiction is a and the negation of any contradiction is a tautology.tautology.

Page 26: Discrete Structures1 Let’s get started with... Logic !

Discrete Structures 26

EquivalenceEquivalence

Definition: two propositional Definition: two propositional statements S1 and S2 are said to be statements S1 and S2 are said to be (logically) equivalent, denoted S1 (logically) equivalent, denoted S1 S2 ifS2 if

– They have the same truth table, orThey have the same truth table, or– S1 S1 S2 is a tautologyS2 is a tautology

Equivalence can be established byEquivalence can be established by– Constructing truth tablesConstructing truth tables– Using equivalence laws (see next slide)Using equivalence laws (see next slide)

Page 27: Discrete Structures1 Let’s get started with... Logic !

Discrete Structures 27

EquivalenceEquivalenceEquivalence lawsEquivalence laws

– Identity laws, Identity laws, P P T T P, P,

– Domination laws, Domination laws, P P F F F, F,

– Idempotent laws, Idempotent laws, P 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, P,

– Associative laws, Associative laws, P P (Q (Q R) R) ( (P P Q) Q) R R,,

– Distributive laws, Distributive laws, P P (Q (Q R) R) ( (P P Q) Q) (P (P R) R),,

– De Morgan’s laws, De Morgan’s laws, (P(PQ) Q) (( P) P) ( ( Q)Q)– Law with implicationLaw with implication P P Q Q P P Q Q

Page 28: Discrete Structures1 Let’s get started with... Logic !

Discrete Structures 28

ExercisesExercises•Show that Show that P P Q Q P P Q Q: by truth table : by truth table

•Show that Show that (P (P Q) Q) (P (P R) R) P P (Q (Q R) R): : by equivalence laws (q20, p27):by equivalence laws (q20, p27):

– Law with implication on both sidesLaw with implication on both sides– Distribution law on RHSDistribution law on RHS

Page 29: Discrete Structures1 Let’s get started with... Logic !

Discrete Structures 29

Summary, Sections 1.1, 1.2Summary, Sections 1.1, 1.2•PropositionProposition

– Statement, Truth value, Statement, Truth value, – Proposition, Propositional symbol, Open propositionProposition, Propositional symbol, Open proposition

•Operators Operators – Define by truth tablesDefine by truth tables– Composite propositionsComposite propositions– Tautology and contradictionTautology and contradiction

•Equivalence of propositional statementsEquivalence of propositional statements– Definition Definition – Proving equivalence (by truth table or equivalence Proving equivalence (by truth table or equivalence

laws)laws)

Page 30: Discrete Structures1 Let’s get started with... Logic !

Discrete Structures 30

Propositional Functions & Propositional Functions & PredicatesPredicates

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

truetrueWhen a variable is given a value, it is said When a variable is given a value, it is said to be instantiatedto be instantiated

Truth value depends on value of Truth value depends on value of variablevariable

Page 31: Discrete Structures1 Let’s get started with... Logic !

Discrete Structures 31

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) ?

falsefalsetruetrue

A propositional function (predicate) becomes a A propositional function (predicate) becomes a proposition when proposition when allall its variables are its variables are instantiatedinstantiated..

Page 32: Discrete Structures1 Let’s get started with... Logic !

Discrete Structures 32

Propositional FunctionsPropositional FunctionsOther examples of propositional functions Other examples of propositional functions

Person(x), Person(x), which is true if x is a personwhich is true if x is a personPerson(Socrates) = T Person(Socrates) = T

CSCourse(x),CSCourse(x), which is true if x is a which is true if x is a computer science coursecomputer science course

CSCourse(CS285) = TCSCourse(CS285) = T

Person(dolly-the-sheep) = FPerson(dolly-the-sheep) = F

CSCourse(MATH155) = FCSCourse(MATH155) = F

How do we sayHow do we sayAll humans are mortalAll humans are mortalOne CS courseOne CS course

Page 33: Discrete Structures1 Let’s get started with... Logic !

Discrete Structures 33

Universal QuantificationUniversal Quantification

Let P(x) be a predicate (propositional function).Let P(x) be a predicate (propositional function).

Universally quantified sentenceUniversally quantified sentence::

For all x in the For all x in the universe of discourseuniverse of discourse P(x) is 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.)

Page 34: Discrete Structures1 Let’s get started with... Logic !

Discrete Structures 34

Universal QuantificationUniversal Quantification

Example: Let the universe of discourse be all Example: Let the universe of discourse be all peoplepeople

S(x): x is a PSU student.S(x): x is a PSU 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 PSU student, then x is a genius.” orIf x is a PSU student, then x is a genius.” or““All PSU students are geniuses.”All PSU students are geniuses.”

If the universe of discourse is all PSU students, If the universe of discourse is all PSU students, then the same statement can be written asthen the same statement can be written as

x G(x)x G(x)

Page 35: Discrete Structures1 Let’s get started with... Logic !

Discrete Structures 35

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.)

Page 36: Discrete Structures1 Let’s get started with... Logic !

Discrete Structures 36

Existential QuantificationExistential Quantification

Example: Example: P(x): x is a PSU professor.P(x): x is a PSU 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 PSU professor There is an x such that x is a PSU professor and x is a genius.”and x is a genius.”oror““At least one PSU professor is a genius.”At least one PSU professor is a genius.”

Page 37: Discrete Structures1 Let’s get started with... Logic !

Discrete Structures 37

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

Page 38: Discrete Structures1 Let’s get started with... Logic !

Discrete Structures 38

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.

Page 39: Discrete Structures1 Let’s get started with... Logic !

Discrete Structures 39

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 2 in Section 1.3.See Table 2 in Section 1.3.

This is de Morgan’s law for quantifiersThis is de Morgan’s law for quantifiers

Page 40: Discrete Structures1 Let’s get started with... Logic !

Discrete Structures 40

NegationNegation

ExamplesExamples

Not all roses are redNot all roses are red x (Rose(x)x (Rose(x) Red(x) Red(x)))

x (Rose(x)x (Rose(x) Red(x)Red(x)))

Nobody is perfectNobody is perfect x (Person(x)x (Person(x) Perfect(x) Perfect(x)))

x (Person(x)x (Person(x) Perfect(x)Perfect(x)))

Page 41: Discrete Structures1 Let’s get started with... Logic !

Discrete Structures 41

Nested QuantifierNested QuantifierA predicate can have more than one A predicate can have more than one

variables.variables.– S(x, y, z): z is the sum of x and yS(x, y, z): z is the sum of x and y– F(x, y): x and y are friendsF(x, y): x and y are friends

We can quantify individual variables in We can quantify individual variables in different waysdifferent ways x, y, z (S(x, y, z) x, y, z (S(x, y, z) (x <= z (x <= z y <= z)) y <= z)) x x y y z (F(x, y) z (F(x, y) F(x, z) F(x, z) (y != z) (y != z) F(y, z)F(y, z)

Page 42: Discrete Structures1 Let’s get started with... Logic !

Discrete Structures 42

Nested QuantifierNested Quantifier

Exercise: translate the following Exercise: translate the following English sentence into logical English sentence into logical expressionexpression““There is a rational number in between There is a rational number in between

every pair of distinct rational numbers”every pair of distinct rational numbers”

Use predicate Use predicate Q(x)Q(x), which is true when , which is true when x is a rational numberx is a rational number

x,y (x,y (QQ(x) (x) QQ (y) (y) (x < y) (x < y)

u (Q(u) u (Q(u) (x < u) (x < u) (u < y))) (u < y)))

Page 43: Discrete Structures1 Let’s get started with... Logic !

Discrete Structures 43

Summary, Sections 1.3, 1.4Summary, Sections 1.3, 1.4

• Propositional functions (predicates)Propositional functions (predicates)• Universal and existential quantifiers, and Universal and existential quantifiers, and

the duality of the twothe duality of the two• When predicates become propositionsWhen predicates become propositions

– All of its variables are instantiatedAll of its variables are instantiated– All of its variables are quantifiedAll of its variables are quantified

• Nested quantifiersNested quantifiers– Quantifiers with negationQuantifiers with negation

• Logical expressions formed by Logical expressions formed by predicates, operators, and quantifierspredicates, operators, and quantifiers

Page 44: Discrete Structures1 Let’s get started with... Logic !

Discrete Structures 44

Let’s proceed to…Let’s proceed to…

Mathematical Mathematical ReasoningReasoning

Page 45: Discrete Structures1 Let’s get started with... Logic !

Discrete Structures 45

Mathematical ReasoningMathematical Reasoning

We need We need mathematical reasoningmathematical reasoning to to

• determine whether a mathematical argument is determine whether a mathematical argument is correct or incorrect and correct or incorrect and• construct mathematical arguments.construct mathematical arguments.

Mathematical reasoning is not only important for Mathematical reasoning is not only important for conducting conducting proofsproofs and and program verificationprogram verification, , but also for but also for artificial intelligenceartificial intelligence systems systems (drawing logical inferences from knowledge and (drawing logical inferences from knowledge and facts).facts).

We focus on We focus on deductivedeductive proofs proofs

Page 46: Discrete Structures1 Let’s get started with... Logic !

Discrete Structures 46

TerminologyTerminologyAn An axiomaxiom is a basic assumption about is a basic assumption about mathematical structure that needs no proof.mathematical structure that needs no proof.

- Things known to be true (facts or proven theorems)Things known to be true (facts or proven theorems)- Things believed to be true but cannot be provedThings believed to be true but cannot be proved

We can use a We can use a proofproof to demonstrate that a to demonstrate that a particular statement is true. A proof consists of a particular statement is true. A proof consists of a sequence of statements that form an argument.sequence of statements that form an argument.

The steps that connect the statements in such a The steps that connect the statements in such a sequence are the sequence are the rules of inferencerules of inference..

Cases of incorrect reasoning are called Cases of incorrect reasoning are called fallaciesfallacies..

Page 47: Discrete Structures1 Let’s get started with... Logic !

Discrete Structures 47

TerminologyTerminology

A A theoremtheorem is a statement that can be shown is a statement that can be shown to be true.to be true.

A A lemmalemma is a simple theorem used as an is a simple theorem used as an intermediate result in the proof of another intermediate result in the proof of another theorem.theorem.

A A corollarycorollary is a proposition that follows is a proposition that follows directly from a theorem that has been proved.directly from a theorem that has been proved.

A A conjectureconjecture is a statement whose truth is a statement whose truth value is unknown. Once it is proven, it value is unknown. Once it is proven, it becomes a theorem.becomes a theorem.

Page 48: Discrete Structures1 Let’s get started with... Logic !

Discrete Structures 48

ProofsProofs

A A theoremtheorem often has two parts often has two parts- Conditions (premises, hypotheses)Conditions (premises, hypotheses)- ConclusionConclusion

A A correct (deductive) proofcorrect (deductive) proof is to establish that is to establish that - If the conditions are true then the conclusion is trueIf the conditions are true then the conclusion is true- I.e., Conditions I.e., Conditions Conclusion is a Conclusion is a tautologytautology

Often there are missing pieces between Often there are missing pieces between conditions and conclusion. Fill it by an conditions and conclusion. Fill it by an argumentargument

- Using conditions and axiomsUsing conditions and axioms- Statements in the argument connected by proper Statements in the argument connected by proper

rules of inferencerules of inference

Page 49: Discrete Structures1 Let’s get started with... Logic !

Discrete Structures 49

Rules of InferenceRules of Inference

Rules of inferenceRules of inference provide the justification of provide the justification of the steps used in a proof.the steps used in a proof.

One important rule is called One important rule is called modus ponensmodus ponens or the or the law of detachmentlaw of detachment. It is based on the . It is based on the tautology tautology (p (p (p (p q)) q)) q. We write it in the following q. We write it in the following way:way:

ppp p q q________ qq

The two The two hypotheseshypotheses p and p q are p and p q are

written in a column, and the written in a column, and the conclusionconclusionbelow a bar, where means below a bar, where means “therefore”.“therefore”.

Page 50: Discrete Structures1 Let’s get started with... Logic !

Discrete Structures 50

Rules of InferenceRules of Inference

The general form of a rule of inference is:The general form of a rule of inference is:

pp11

pp22 .. .. .. ppnn________ qq

The rule states that if pThe rule states that if p11 andand p p22 andand … … andand p pnn are all true, then q is true as are all true, then q is true as well.well.

Each rule is an established tautology Each rule is an established tautology ofof pp11 p p22 … p … pnn q q

These rules of inference can be used These rules of inference can be used in any mathematical argument and do in any mathematical argument and do not not require any proof.require any proof.

Page 51: Discrete Structures1 Let’s get started with... Logic !

Discrete Structures 51

Rules of InferenceRules of Inference

pp__________ ppqq AdditionAddition

pqpq__________ pp SimplificatioSimplificatio

nn

pp qq__________ pqpq

ConjunctionConjunction

qq p q p q __________ pp

Modus Modus tollenstollens

p qp q q r q r __________ p r p r

Hypothetical Hypothetical syllogismsyllogism((chainingchaining))

pqpq pp__________ q q

Disjunctive Disjunctive syllogismsyllogism((resolutionresolution))

Page 52: Discrete Structures1 Let’s get started with... Logic !

Discrete Structures 52

ArgumentsArguments

Just like a rule of inference, an Just like a rule of inference, an argument argument consists of one or more hypotheses (or consists of one or more hypotheses (or premises) and a conclusion. premises) and a conclusion.

We say that an argument isWe say that an argument is valid valid, if whenever , if whenever all its hypotheses are true, its conclusion is all its hypotheses are true, its conclusion is also true.also true.

However, if any hypothesis is false, even a However, if any hypothesis is false, even a valid argument can lead to an incorrect valid argument can lead to an incorrect conclusion. conclusion.

Proof: show that Proof: show that hypotheses hypotheses conclusion conclusion is is true using rules of inferencetrue using rules of inference

Page 53: Discrete Structures1 Let’s get started with... Logic !

Discrete Structures 53

ArgumentsArgumentsExample:Example:

““If 101 is divisible by 3, then 101If 101 is divisible by 3, then 10122 is divisible is divisible by 9. 101 is divisible by 3. Consequently, 101by 9. 101 is divisible by 3. Consequently, 10122 is divisible by 9.”is divisible by 9.”

Although the argument is Although the argument is validvalid, its conclusion , its conclusion is is incorrectincorrect, because one of the hypotheses is , because one of the hypotheses is false (“101 is divisible by 3.”).false (“101 is divisible by 3.”).

If in the above argument we replace 101 with If in the above argument we replace 101 with 102, we could correctly conclude that 102102, we could correctly conclude that 10222 is is divisible by 9.divisible by 9.

Page 54: Discrete Structures1 Let’s get started with... Logic !

Discrete Structures 54

ArgumentsArgumentsWhich rule of inference was used in the last Which rule of inference was used in the last argument?argument?

p: “101 is divisible by 3.”p: “101 is divisible by 3.”

q: “101q: “10122 is divisible by 9.” is divisible by 9.”

pp p q p q __________ qq

Modus Modus ponensponens

Unfortunately, one of the hypotheses (p) is Unfortunately, one of the hypotheses (p) is false.false.Therefore, the conclusion q is incorrect.Therefore, the conclusion q is incorrect.

Page 55: Discrete Structures1 Let’s get started with... Logic !

Discrete Structures 55

ArgumentsArguments

Another example:Another example:

““If it rains today, then we will not have a If it rains today, then we will not have a barbeque today. If we do not have a barbeque barbeque today. If we do not have a barbeque today, then we will have a barbeque today, then we will have a barbeque tomorrow.tomorrow.Therefore, if it rains today, then we will have a Therefore, if it rains today, then we will have a barbeque tomorrow.”barbeque tomorrow.”

This is a This is a validvalid argument: If its hypotheses are argument: If its hypotheses are true, then its conclusion is also true.true, then its conclusion is also true.

Page 56: Discrete Structures1 Let’s get started with... Logic !

Discrete Structures 56

ArgumentsArguments

Let us formalize the previous argument:Let us formalize the previous argument:

p: “It is raining today.”p: “It is raining today.”

q: “We will not have a barbeque today.”q: “We will not have a barbeque today.”

r: “We will have a barbeque tomorrow.”r: “We will have a barbeque tomorrow.”

So the argument is of the following form:So the argument is of the following form:

p qp q q r q r ____________ p r p r

Hypothetical Hypothetical syllogismsyllogism

Page 57: Discrete Structures1 Let’s get started with... Logic !

Discrete Structures 57

ArgumentsArguments

Another example for a proof:Another example for a proof:

1. Ahmed is either intelligent or a good doctor.1. Ahmed is either intelligent or a good doctor.2. If Ahmed is intelligent, then he can count 2. If Ahmed is intelligent, then he can count from 1 to 10.from 1 to 10.3. Ahmed can only count from 1 to 3.3. Ahmed can only count from 1 to 3.Therefore, Ahmed is a good doctor.Therefore, Ahmed is a good doctor.

i: “Ahmed is intelligent.”i: “Ahmed is intelligent.”d: “Ahmed is a good doctor.”d: “Ahmed is a good doctor.”c: “Ahmed can count from 1 to 10.”c: “Ahmed can count from 1 to 10.”

Page 58: Discrete Structures1 Let’s get started with... Logic !

Discrete Structures 58

ArgumentsArguments

i: “Ahmed is intelligent.”i: “Ahmed is intelligent.”d: “Ahmed is a good doctor.”d: “Ahmed is a good doctor.”c: “Ahmed can count from 1 to 10.”c: “Ahmed can count from 1 to 10.”

Step 1:Step 1: c c Hypothesis 3Hypothesis 3Step 2:Step 2: i i c c Hypothesis 2Hypothesis 2Step 3:Step 3: i i Modus tollens Steps 1 & 2Modus tollens Steps 1 & 2Step 4:Step 4: d d i i Hypothesis 1Hypothesis 1Step 5:Step 5: d d Disjunctive SyllogismDisjunctive Syllogism

Steps 3 & 4Steps 3 & 4

Conclusion: Conclusion: dd (“Ahmed is a good doctor.”) (“Ahmed is a good doctor.”)

Page 59: Discrete Structures1 Let’s get started with... Logic !

Discrete Structures 59

ArgumentsArguments

Yet another example:Yet another example:

1. If you listen to me, you will pass CS285.1. If you listen to me, you will pass CS285.2. You passed CS285.2. You passed CS285. Therefore, you have listened to me.Therefore, you have listened to me.

Is this argument valid? Is this argument valid? NoNo, it assumes ((p , it assumes ((p q) q) q) q) p. p.

This statement is This statement is notnot a tautology. It is a tautology. It is falsefalse if p if p is false and q is true.is false and q is true.Such an incorrect reasoning (that assumes non-Such an incorrect reasoning (that assumes non-tautological statements) is called a tautological statements) is called a fallacyfallacy..

Page 60: Discrete Structures1 Let’s get started with... Logic !

Discrete Structures 60

Rules of Inference for Quantified Rules of Inference for Quantified StatementsStatements

x P(x)x P(x)____________________ P(c) if P(c) if ccUU

Universal Universal instantiationinstantiation

P(c) for an arbitrary cUP(c) for an arbitrary cU______________________________________ x P(x)x P(x)

Universal Universal generalizatiogeneralizationn

x P(x)x P(x)____________________________________________ P(c) for some element cUP(c) for some element cU

Existential Existential instantiationinstantiation

P(c) for some element cUP(c) for some element cU________________________________________ x P(x) x P(x)

Existential Existential generalizatiogeneralizationn

Page 61: Discrete Structures1 Let’s get started with... Logic !

Discrete Structures 61

Rules of Inference for Quantified Rules of Inference for Quantified StatementsStatements

Example:Example:

Every PSU student is a genius. Every PSU student is a genius. Hamza is a PSU student.Hamza is a PSU student.Therefore, Hamza is a genius.Therefore, Hamza is a genius.

U(x): “x is a PSU student.”U(x): “x is a PSU student.”G(x): “x is a genius.”G(x): “x is a genius.”

Page 62: Discrete Structures1 Let’s get started with... Logic !

Discrete Structures 62

Rules of Inference for Quantified Rules of Inference for Quantified StatementsStatements

The following steps are used in the argument:The following steps are used in the argument:

Step 1:Step 1: x (U(x) x (U(x) G(x)) G(x)) HypothesisHypothesisStep 2:Step 2: U(Hamza) U(Hamza) G(Hamza) G(Hamza)Univ. instantiation Univ. instantiation

using Step 1using Step 1

x P(x)x P(x)____________________ P(c) if cUP(c) if cU

Universal Universal instantiationinstantiation

Step 3:Step 3: U( U(Hamza)) HypothesisHypothesisStep 4:Step 4: G( G(Hamza)) Modus ponensModus ponens

using Steps 2 & 3using Steps 2 & 3

Page 63: Discrete Structures1 Let’s get started with... Logic !

Discrete Structures 63

Proving TheoremsProving Theorems

Direct proof:Direct proof:

An implication p An implication p q can be proved by showing q can be proved by showing that if p is true, then q is also true.that if p is true, then q is also true.

Example:Example: Give a direct proof of the theorem Give a direct proof of the theorem “If n is odd, then n“If n is odd, then n22 is odd.” is odd.”

Idea:Idea: Assume that the hypothesis of this Assume that the hypothesis of this implication is true (n is odd). Then use rules of implication is true (n is odd). Then use rules of inference and known theorems of math to inference and known theorems of math to show that q must also be true (nshow that q must also be true (n22 is odd). is odd).

Page 64: Discrete Structures1 Let’s get started with... Logic !

Discrete Structures 64

Proving TheoremsProving Theorems

n is odd.n is odd.

Then n = 2k + 1, where k is an integer.Then n = 2k + 1, where k is an integer.

Consequently, nConsequently, n22 = (2k + 1) = (2k + 1)22.. = 4k= 4k22 + 4k + 1 + 4k + 1 = 2(2k= 2(2k22 + 2k) + 1 + 2k) + 1

Since nSince n22 can be written in this form, it is odd. can be written in this form, it is odd.

Page 65: Discrete Structures1 Let’s get started with... Logic !

Discrete Structures 65

Proving TheoremsProving Theorems

Indirect proof:Indirect proof:

An implication p An implication p q is equivalent to its q is equivalent to its contra-contra-positivepositive q q p. Therefore, we can prove p p. Therefore, we can prove p q by showing that whenever q is false, then p is q by showing that whenever q is false, then p is also false.also false.

Example:Example: Give an indirect proof of the theorem Give an indirect proof of the theorem

“If 3n + 2 is odd, then n is odd.”“If 3n + 2 is odd, then n is odd.”

Idea:Idea: Assume that the conclusion of this Assume that the conclusion of this implication is false (n is even). Then use rules of implication is false (n is even). Then use rules of inference and known theorems to show that p inference and known theorems to show that p must also be false (3n + 2 is even).must also be false (3n + 2 is even).

Page 66: Discrete Structures1 Let’s get started with... Logic !

Discrete Structures 66

Proving TheoremsProving Theoremsn is even.n is even.

Then n = 2k, where k is an integer.Then n = 2k, where k is an integer.

It follows that 3n + 2 = 3(2k) + 2 It follows that 3n + 2 = 3(2k) + 2 = 6k + 2= 6k + 2= 2(3k + 1)= 2(3k + 1)

Therefore, 3n + 2 is even.Therefore, 3n + 2 is even.

We have shown that the contrapositive of the We have shown that the contrapositive of the implication is true, so the implication itself is implication is true, so the implication itself is also true also true (If 3n + 2 is odd, then n is odd).(If 3n + 2 is odd, then n is odd).

Page 67: Discrete Structures1 Let’s get started with... Logic !

Discrete Structures 67

Proving TheoremsProving TheoremsIndirect Proof is related to Indirect Proof is related to proof by contradictionproof by contradiction

Simply put, in a proof by contradiction for p Simply put, in a proof by contradiction for p q, you prove q, you prove that its negation, pthat its negation, p qq (or any proposition deducible from (or any proposition deducible from it), is not true (is always false, or is a contradiction, or is it), is not true (is always false, or is a contradiction, or is the negation of a tautology). the negation of a tautology).

Suppose n is even (Suppose n is even (negation of the conclusionnegation of the conclusion).).

Then n = 2k, where k is an integer.Then n = 2k, where k is an integer.

It follows that 3n + 2 = 3(2k) + 2 It follows that 3n + 2 = 3(2k) + 2 = 6k + 2= 6k + 2= 2(3k + 1)= 2(3k + 1)

Therefore, 3n + 2 is even.Therefore, 3n + 2 is even.However, this is a However, this is a contradictioncontradiction since 3n + 2 is given to since 3n + 2 is given to be odd, so the conclusion (n is odd) holds.be odd, so the conclusion (n is odd) holds.

Page 68: Discrete Structures1 Let’s get started with... Logic !

Discrete Structures 68

Another ExampleAnother Example

Anyone who performs well is either intelligent Anyone who performs well is either intelligent or a good doctor.or a good doctor.If someone is intelligent, then he can count If someone is intelligent, then he can count from 1 to 10.from 1 to 10.Ahmed performs well.Ahmed performs well.Ahmed can only count from 1 to 3.Ahmed can only count from 1 to 3.Therefore, not everyone is both intelligent and Therefore, not everyone is both intelligent and a good doctora good doctor P(x): x performs wellP(x): x performs well I(x): x is intelligentI(x): x is intelligent D(x): x is a good doctorD(x): x is a good doctor C(x): x can count from 1 to 10C(x): x can count from 1 to 10

Page 69: Discrete Structures1 Let’s get started with... Logic !

Discrete Structures 69

Another ExampleAnother ExampleHypotheses:Hypotheses:1.1. Anyone performs well is either intelligent or a good Anyone performs well is either intelligent or a good

doctor.doctor. x (P(x) x (P(x) I(x) I(x) D(x)) D(x))2.2. If someone is intelligent, then he can count from 1 If someone is intelligent, then he can count from 1

to 10.to 10. x (I(x) x (I(x) C C(x) )(x) )3.3. Ahmed performs well.Ahmed performs well. P(A)P(A)4.4. Ahmed can only count from 1 to 3.Ahmed can only count from 1 to 3. C(A)C(A)

Conclusion: not everyone is both intelligent and a good Conclusion: not everyone is both intelligent and a good doctordoctor

x(I(x) x(I(x) D(x)) D(x))

Page 70: Discrete Structures1 Let’s get started with... Logic !

Discrete Structures 70

Another ExampleAnother ExampleDirect proof:Direct proof:

Step 1:Step 1: x (P(x) x (P(x) I(x) I(x) D(x)) D(x)) Hypothesis 1Hypothesis 1Step 2:Step 2: P(A) P(A) I(A) I(A) D(A) D(A) Univ. Inst. Step 1Univ. Inst. Step 1Step 3:Step 3: P(A) P(A) Hypothesis 3Hypothesis 3Step 4:Step 4: I(A) I(A) D(A) D(A) Modus ponens Steps 2 & 3Modus ponens Steps 2 & 3Step 5:Step 5: x (I(x) x (I(x) C(x)) C(x)) Hypothesis 2Hypothesis 2Step 6:Step 6: I(A) I(A) C(A) C(A) Univ. inst. Step5Univ. inst. Step5Step 7:Step 7: C(A) C(A) Hypothesis 4Hypothesis 4Step 8:Step 8: I(A) I(A) Modus tollens Steps 6 & 7Modus tollens Steps 6 & 7Step 9:Step 9: I(A) I(A) D(A) D(A) Addition Step 8Addition Step 8Step 10:Step 10: (I(A) (I(A) D(A)) D(A)) Equivalence Step 9Equivalence Step 9Step 11:Step 11: xx(I(x) (I(x) D(x)) D(x)) Exist. general. Step 10Exist. general. Step 10Step 12:Step 12: x (I(x) x (I(x) D(x)) D(x)) Equivalence Step 11Equivalence Step 11

Conclusion: Conclusion: x (I(x) x (I(x) D(x)) D(x)), not everyone is both , not everyone is both intelligent and a good doctor.intelligent and a good doctor.

Page 71: Discrete Structures1 Let’s get started with... Logic !

Discrete Structures 71

Summary, Section 1.5Summary, Section 1.5

• Terminology (axiom, theorem, conjecture, Terminology (axiom, theorem, conjecture, argument, etc.)argument, etc.)

• Rules of inference (Tables 1 and 2)Rules of inference (Tables 1 and 2)• Valid argument (hypotheses and conclusion)Valid argument (hypotheses and conclusion)• Construction of valid argument using rules Construction of valid argument using rules

of inferenceof inference– For each rule used, write down the statements For each rule used, write down the statements

involved in the proofinvolved in the proof

• Direct and indirect proofsDirect and indirect proofs– Other proof methods (e.g. induction, pigeon Other proof methods (e.g. induction, pigeon

hole) will be introduced in later chaptershole) will be introduced in later chapters