Introduction Discrete Mathemetics: Topics Logic

Report 6 Downloads 102 Views
5/8/2016

Discrete Mathemetics: Introduction • Discrete vs. Continuous • Continuous math example: – Given a fixed surface area, what are the dimensions of a cylinder that maximizes volume?

Lecture 1

• Discrete math example: – Given a fixed set of characters, and a length, how many different passwords can you construct? – How many edges are there in a graph with n vertices?

Introduction to Discrete Mathematics and Propositional Logic

S. Ahmed

CSE173 Discrete Mathematics

1

S. Ahmed

CSE173 Discrete Mathematics

Discrete Mathemetics: Topics

2

Logic • Proposition

1. Logic 2. Method of proofs 3. Set theory 4. Functions and relations 5. Sums and recurrence relations 6. Counting 7. Probability 8. Graphs 9. Trees 10. Number theory

– A proposition is a declarative sentence (i.e. A sentence that declares a fact) which is either true or false, but not both. – Example: True 1. Washington, D.C., is the capital of the USA. 2. Toronto is the capital of Canada. 3. 1+1 = 2.

True

4. 2+2 = 3.

False

False

5. What time is it? 6. Read this carefully. 7. X+1 = 3. 8. X+Y = Z.

S. Ahmed

CSE173 Discrete Mathematics

3

S. Ahmed

CSE173 Discrete Mathematics

4

1

5/8/2016

Proposition

Proposition

Exercise: Which of these are propositions? What are the truth values of those that are propositions? Justify your answer. a) Do not pass go. b) What time is it? c) There are no black flies in Maine. d) 4 + x = 5. e) The moon is made of green cheese. f) 2𝑛 ≥ 100.

S. Ahmed

CSE173 Discrete Mathematics

5

• Letters are used to denote propositions, just as letters are used to denote variables. • Conventional letters: p, q, r, s, ... • True proposition T • False proposition F • The area of logic that deals with propositions is called propositional calculus or propositional logic.

S. Ahmed

CSE173 Discrete Mathematics

Compound propositions

Negation

• New propositions called compound propositions are formed from existing propositions using logical operators. • Logical operators: – – – – – –

• Let p be a proposition. The negation of p is the statement “It is not the case that p.”

• Denoted by ¬𝑝 and also 𝑝 • The truth value of ¬𝑝 is the opposite of the truth value of 𝑝.

Negation Conjunction Disjundtion Exclusive OR Implication Biconditional

S. Ahmed

CSE173 Discrete Mathematics

6

7

𝑝

¬𝑝

T

F

F

T

S. Ahmed

Table 1: The truth table for the negation of a proposition

CSE173 Discrete Mathematics

8

2

5/8/2016

Negation

Negation

Example 1: Find the negation of the proposition “Michael‘s PC runs Linux.” and express this in simple English. Solution: • “It is not the case that Michael’s PC runs Linux.” More simply • “Michael’s PC does not run Linux.”

S. Ahmed

Example 2: Find the negation of the proposition “Vandana’s smartphone has at least 32GB of memory.” and express this in simple English. Solution: • “It is not the case that Vandana’s smartphone has at least 32 GB of memory.” • “Vandana’s smartphone does not have at least 32GB of memory. • “Vandana’s smartphone has less than 32GB of memory.”

9

CSE173 Discrete Mathematics

S. Ahmed

Conjunction

q

pᴧq

T

T

T

T

F

F

F

T

F

F

F

F

S. Ahmed

10

Conjunction

• Connective • Let p and q be propositions. The conjunction of p and q is the proposition “p and q.” • Denoted by “p ᴧ q”. • The conjunction p ᴧ q is true when both p and q are true and is false otherwise. p

CSE173 Discrete Mathematics

Table 2: The truth table for the conjunction of two propositions

• Example: Find the conjunction of the propositions p and q where p is the proposition „Rebecca‘s PC has more than 16 GB free hard disk space“ and q is the proposition „The processor in Rebecca‘s PC runs faster than 1 GHz.“

• Solution: – “Rebecca‘s PC has more than 16 GB free hard disk space, and the processor in her PC runs faster than 1 GHz.” Or more simply, – “Rebecca‘s PC has more than 16 GB free hard disk space and its processor runs faster than 1 GHz” Note: In logic the word “but” sometimes is used instead of “and” in a conjunction.

CSE173 Discrete Mathematics

11

S. Ahmed

CSE173 Discrete Mathematics

12

3

5/8/2016

Disjunction

Disjunction

• Let p and q be propositions. The disjunction of p and q is the proposition “p or q.” • Denoted by “p ˅ q” • The disjunction p ˅ q is false when both p and q are false and is true otherwise. p

q

p˅q

T

T

T

T

F

T

F

T

T

F

F

F

Table 3: The truth table for the disjunction of two propositions S. Ahmed

• The “or” corresponds to inclusive or. • Inclusive or: A statement is true when at least one of the two propositions is true.

CSE173 Discrete Mathematics

13

• Example: Find the disjunction of the propositions p and q where p is the proposition „Rebecca‘s PC has more than 16 GB free hard disk space“ and q is the proposition „The processor in Rebecca‘s PC runs faster than 1 GHz.“

• Solution: – “Rebecca’s PC has at least 16 GB free hard disk space, or the processor in Rebecca’s PC runs faster than 1 GHz”.

S. Ahmed

Exclusive OR

p⊕q

q

T

T

F

T

F

T

F

T

F

F

S. Ahmed

Table 4: The truth table for the exclusive or of two propositions

• Let p and q be propositions. The conditional statement with p and q is “if p, then q.” • Denoted by “p → q” • The conditional statement p → q is false when p is true and q is false, and true otherwise. • In p → q, p is called the hypothesis (or premise) and q is called the conclusion (or consequence). p

q

p→q

T

T

T

T

T

F

F

F

F

T

T

F

F

T

CSE173 Discrete Mathematics

14

Conditional Statements

• Let p and q be propositions. The exclusive or of p and q is the statement “p or q (but not both)” • Denoted by “p ⊕ q” • It is true when exactly one of p and q is true and is false otherwise. p

CSE173 Discrete Mathematics

15

S. Ahmed

Table 5: The truth table for the conditional statement p → q.

CSE173 Discrete Mathematics

16

4

5/8/2016

Conditional Statements

Conditional Statements

• Variety of terminology is used to express p → q: “if p, then q”

“p implies q”

“if p, q”

“p only if q”

“p is sufficient for q”

“a sufficient condition for q is p”

“q if p”

“q whenever p”

“q when p”

“q is necessary for p”

“a necessary condition for p is q”

“q follows from p”

“q unless ¬p”

S. Ahmed

CSE173 Discrete Mathematics

17

Example: Let p be the statement “Maria learns discrete mathematics” and q the statement “Maria will find a good job.” Express the statement p → q as a statement in English. Solution: 1. “if p, then q” 2. “q when p” 3. “a sufficient condition for q is p” 4. “q unless ¬p” 5. Etc.

S. Ahmed

CSE173 Discrete Mathematics

18

Converse, Contrapositive, Inverse

Bi-conditional Statement

Let p → q be the conditional statement of two propositions. • Converse: q → p • Contrapositive: ¬q → ¬p • Inverse: ¬p → ¬q

• Let p and q be propositions. The bi-conditional statement is the proposition “p if and only if q” • Denoted by p ↔ q • The bi-conditional statement p ↔ q is true when p and q have the same truth values, and is false otherwise. • These statements are also called bi-implications.

Example: What are the contrapositive, the converse and the inverse of the conditional statement “The home team wins whenever it is raining.”?

S. Ahmed

CSE173 Discrete Mathematics

19

p

q

p↔q

T

T

T

T

F

F

F

T

F

F

F

T

S. Ahmed

Table 5: The truth table for the bi- conditional statement p ↔ q.

CSE173 Discrete Mathematics

20

5

5/8/2016

Bi-conditional Statement

Exercise Problem

Example: Let p and q be the propositions p: “You can take the flight” q: “You buy a ticket.” Express the statement p ↔ q as an English statement. Solution: “You can take the flight if and only if you buy a ticket.”

S. Ahmed

Exercise 8 Let p and q be the propositions p: “I bought a lottery ticket this week.” q: “I won the million dollar jackpot.” Express each of these propositions as an English sentence.

21

CSE173 Discrete Mathematics

Truth Table of compound proposition

a) ¬p

e) p ↔ q

b) p v q

f) ¬p → ¬q

c) p → q

g) ¬p ᴧ ¬q

d) p ᴧ q

h) ¬p v (p ᴧ q)

S. Ahmed

Precedence of Logical Operators

Example: Construct the truth table of the compound proposition (p v ¬q) → (p ᴧ q)

Operator

Precedence

¬

1



2

Solution: ¬q

p v ¬q

pᴧq

(p v ¬q) → (p ᴧ q)

T

F

T

T

T

F

T

T

F

F

F

T

F

F

F

T

F

F

T

T

F

F

p

q

T T

S. Ahmed

CSE173 Discrete Mathematics

22

CSE173 Discrete Mathematics

23

S. Ahmed

v

3



4



5

CSE173 Discrete Mathematics

highest

lowest

24

6

5/8/2016

Logic and Bit Operations

Bit String

• Bit: Binary Digit 0 => False 1 => True • Boolean Variable: A variable is called a Boolean variable if its value is either true or false. • Table for bit operators (OR, AND, and XOR):

• A bit string is a sequence of zero or more bits. • The length of this string is the number of bits in the string. Example: 01 1011 0110 11 0001 1101

x

y

xvy

xᴧy

x⊕y

0

0

0

0

0

11 1011 1111 : bitwise OR

0

1

1

0

1

1

0

1

0

1

1

1

1

1

0

01 0001 0100 : bitwise AND 10 1010 1011 : bitwise XOR

S. Ahmed

CSE173 Discrete Mathematics

25

S. Ahmed

CSE173 Discrete Mathematics

26

Exercise Problem Exercise 14 Let p, q, and r be the propositions p: “You get an A on the final exam.” q: “You do every exercise in this book.” r: “You get an A in this class.” Write these propositions using p, q, and r and logical connectives (including negations). a) You get an A in this class, but you do not do every exercise in this book. b) You get an A on the final, you do every exercise in this book, and you get an A in this class. c) To get an A in this class, it is necessary for you to get an A on the final. d) You get an A on the final, but you don’t do every exercise in this book; nevertheless, you get an A in this class. e) Getting an A on the final and doing every exercise in this book is sufficient for getting an A in this class. f) You will get an A in this class if and only if you either do every exercise in this book or you get an A on the final. S. Ahmed

CSE173 Discrete Mathematics

27

7

Recommend Documents