12/6/2015 1 A sample class of Discrete Structures Gongjun Yan Computer Science Department, Old...

14
06/23/22 1 A sample class of A sample class of Discrete Discrete Structures Structures Gongjun Yan Gongjun Yan Computer Science Department, Computer Science Department, Old Dominion University, Old Dominion University, Norfolk, VA Norfolk, VA (Logical conjunction (Logical conjunction and logical and logical implication) implication)

Transcript of 12/6/2015 1 A sample class of Discrete Structures Gongjun Yan Computer Science Department, Old...

Page 1: 12/6/2015 1 A sample class of Discrete Structures Gongjun Yan Computer Science Department, Old Dominion University, Norfolk, VA (Logical conjunction and.

04/21/23 1

A sample class of A sample class of Discrete Discrete

StructuresStructures

Gongjun YanGongjun Yan

Computer Science Department,Computer Science Department,

Old Dominion University, Old Dominion University, Norfolk, VANorfolk, VA

(Logical conjunction (Logical conjunction and logical and logical implication)implication)

Page 2: 12/6/2015 1 A sample class of Discrete Structures Gongjun Yan Computer Science Department, Old Dominion University, Norfolk, VA (Logical conjunction and.

04/21/23 2

ReviewReview

PropositionProposition DeclarativeDeclarative Either true or false but not bothEither true or false but not both

ExamplesExamples Which of the following are propositions?Which of the following are propositions?

Today is Friday. Today is Friday. 1 + 1 = 31 + 1 = 3 What time is it? What time is it? Close the window. Close the window.

Value = TrueValue = TrueValue = False

Page 3: 12/6/2015 1 A sample class of Discrete Structures Gongjun Yan Computer Science Department, Old Dominion University, Norfolk, VA (Logical conjunction and.

04/21/23 3

More QuestionsMore Questions What are the values of propositions below?What are the values of propositions below?

If Tiger Woods is studying discrete structures, then he If Tiger Woods is studying discrete structures, then he will not play golf.will not play golf.

If a fly has no wings, it can be called a walk.If a fly has no wings, it can be called a walk. If olive oil comes from olives, then baby oil comes from If olive oil comes from olives, then baby oil comes from

babies.babies.

How the How the ifif statement works in the below code? statement works in the below code? dScore = 93;dScore = 93; if ( if ( (dScore <= 100) && (dScore > 90)(dScore <= 100) && (dScore > 90) ) ) {{ print "You got an A."print "You got an A." }}

Page 4: 12/6/2015 1 A sample class of Discrete Structures Gongjun Yan Computer Science Department, Old Dominion University, Norfolk, VA (Logical conjunction and.

04/21/23 4

Today’s ContentToday’s Content

Logical Conjunction (AND), logical Logical Conjunction (AND), logical implication (IF-Then)implication (IF-Then)

The truth table of AND and IF-THENThe truth table of AND and IF-THEN

Page 5: 12/6/2015 1 A sample class of Discrete Structures Gongjun Yan Computer Science Department, Old Dominion University, Norfolk, VA (Logical conjunction and.

04/21/23 5

Logical conjunction: ANDLogical conjunction: AND

Is an operation on two propositionsIs an operation on two propositions Produces a value of Produces a value of truetrue if and only if if and only if

both of its propositions are trueboth of its propositions are true Is written as Is written as p AND qp AND q, , p ∧ qp ∧ q, , p & qp & q, or , or

pp..qq We often use We often use p qp q

Page 6: 12/6/2015 1 A sample class of Discrete Structures Gongjun Yan Computer Science Department, Old Dominion University, Norfolk, VA (Logical conjunction and.

04/21/23 6

Truth TableTruth Table

Indicate the value of the logical Indicate the value of the logical expressions.expressions.

The # of rows = 2 to the power of The # of rows = 2 to the power of (# of (# of operators)operators)

The Truth table of The Truth table of p ∧ qp ∧ qif both p and q are true, then p ∧ q is true

Page 7: 12/6/2015 1 A sample class of Discrete Structures Gongjun Yan Computer Science Department, Old Dominion University, Norfolk, VA (Logical conjunction and.

04/21/23 7

ExampleExample Translate the underlined expression Translate the underlined expression

into the conjunction p ∧ qinto the conjunction p ∧ q dScore = 93;dScore = 93;

if ( if ( (dScore <= 100) && (dScore > 90) (dScore <= 100) && (dScore > 90) )){{

print(“you got an A.”);print(“you got an A.”);}}

Answer:Answer: Let p = (dScore <= 100), Let p = (dScore <= 100), q = (dScore > 90) .q = (dScore > 90) . We write p qWe write p q

Page 8: 12/6/2015 1 A sample class of Discrete Structures Gongjun Yan Computer Science Department, Old Dominion University, Norfolk, VA (Logical conjunction and.

04/21/23 8

Example 2Example 2 dScore = 93;dScore = 93;

what is the value of the expressionwhat is the value of the expression(dScore <= 100) && (dScore > 90) ?(dScore <= 100) && (dScore > 90) ?

Answer:Answer: Let p = (dScore <= 100);Let p = (dScore <= 100); q = (dScore > 90).q = (dScore > 90). The expression can be translated to p The expression can be translated to p

qq p=true;p=true; q=true.q=true. By By truth tabletruth table, , the answer is the answer is truetrue..

Page 9: 12/6/2015 1 A sample class of Discrete Structures Gongjun Yan Computer Science Department, Old Dominion University, Norfolk, VA (Logical conjunction and.

04/21/23 9

Logical implication: Logical implication: IMPLIESIMPLIES

Is a proposition “if p, then q”.Is a proposition “if p, then q”. Produces Produces all trueall true values values except when except when

p is true and q is falsep is true and q is false. . Is written as Is written as p IMPLIES qp IMPLIES q , , p → qp → q, ,

p ⇒ qp ⇒ q We often use p qWe often use p q The Truth table of The Truth table of p → qp → q All true

except when p is true and q is false.

Page 10: 12/6/2015 1 A sample class of Discrete Structures Gongjun Yan Computer Science Department, Old Dominion University, Norfolk, VA (Logical conjunction and.

04/21/23 10

Example 3Example 3 3.1 Translate English into logical implication 3.1 Translate English into logical implication

p→q:p→q:

If olive oil comes from olives, then baby oil If olive oil comes from olives, then baby oil comes from babies.comes from babies.

AnswerAnswer: : Let p = “Olive oil comes from olives.”Let p = “Olive oil comes from olives.” q = “Baby oil comes from babies.”q = “Baby oil comes from babies.” We write: p q.We write: p q.

Page 11: 12/6/2015 1 A sample class of Discrete Structures Gongjun Yan Computer Science Department, Old Dominion University, Norfolk, VA (Logical conjunction and.

04/21/23 11

Example 3Example 3 3.2 What is the value of the statement:3.2 What is the value of the statement:

If olive oil comes from olives, then baby oil If olive oil comes from olives, then baby oil comes from babies.comes from babies.

Answer:Answer: Let p = “Olive oil comes from olives.”Let p = “Olive oil comes from olives.”

q = “Baby oil comes from babies.” q = “Baby oil comes from babies.” We write: p→q;We write: p→q; p=true;p=true; q=false.q=false. By truth table, By truth table, the answer is false.the answer is false.

Page 12: 12/6/2015 1 A sample class of Discrete Structures Gongjun Yan Computer Science Department, Old Dominion University, Norfolk, VA (Logical conjunction and.

04/21/23 12

QuizQuiz What are the values of propositions?What are the values of propositions?

1. Tom Cruise is an actor and he is handsome.1. Tom Cruise is an actor and he is handsome.pp = “ = “Tom Cruise is an actor.”Tom Cruise is an actor.”

q= “Tom Cruise is handsome.”q= “Tom Cruise is handsome.” AnswerAnswer: : We write We write p q. ∧p q. ∧ In my wife’s opinion, p=true, q=true. In my wife’s opinion, p=true, q=true. By truth table, the answer is By truth table, the answer is truetrue..

2. If Tiger Woods is studying discrete structures, 2. If Tiger Woods is studying discrete structures, then he will not play golf.then he will not play golf.p=“Tiger Woods is studying discrete structures.”p=“Tiger Woods is studying discrete structures.”q=“Tiger will not play golf.”q=“Tiger will not play golf.”

AnswerAnswer: : We write We write p → q. p → q. In my mind, p=false, q=false. In my mind, p=false, q=false. By truth table, the answer is By truth table, the answer is truetrue..

Page 13: 12/6/2015 1 A sample class of Discrete Structures Gongjun Yan Computer Science Department, Old Dominion University, Norfolk, VA (Logical conjunction and.

04/21/23 13

SummarySummary

Two definitionsTwo definitions:: logical conjunction p ∧ qlogical conjunction p ∧ q Logical implication p → qLogical implication p → q

Truth table of p ∧ q, p → qTruth table of p ∧ q, p → q

Any questions?Any questions?

Page 14: 12/6/2015 1 A sample class of Discrete Structures Gongjun Yan Computer Science Department, Old Dominion University, Norfolk, VA (Logical conjunction and.

04/21/23 14

InformationInformation

Course home page linkCourse home page link http://www.cs.odu.edu/~ygongjun/courses/http://www.cs.odu.edu/~ygongjun/courses/

cs381fall09/instructions/ cs381fall09/instructions/ HomeworkHomework: finish the online exercises:: finish the online exercises:

Translation between p ∧ q, p→q and EnglishTranslation between p ∧ q, p→q and EnglishLink: Link: course-home-page/if_then.htmlcourse-home-page/if_then.html

Turth TablesTurth TablesLink: Link: course-home-page/if_then.htmlcourse-home-page/if_then.html

Office hours: Monday 10:00-12:00amOffice hours: Monday 10:00-12:00am Wednesday 10:00- Wednesday 10:00-12:00am12:00am