discrete structures lecture 2

48
(CS 335) Mohsin Raza University Institute of Information Technology PMAS Arid Agriculture University Rawalpindi Discrete Structures Lecture 2

Upload: ali-usman

Post on 06-May-2015

705 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Discrete Structures lecture 2

(CS 335)

Mohsin Raza University Institute of Information

Technology PMAS Arid Agriculture University

Rawalpindi

Discrete Structures Lecture 2

Page 2: Discrete Structures lecture 2

Compound Propositions

Producing new propositions from existing propositions.

Logical Operators or Connectives

1. Not

2. And ˄

3. Or ˅

4. Exclusive or

5. Implication

6. Biconditional

Discrete Structures(CS 335) 2

Page 3: Discrete Structures lecture 2

Compound Propositions

Negation of a proposition

Let p be a proposition. The negation of p, denoted by

p (also denoted by ~p), is the statement

“It is not the case that p”.

The proposition p is read as “not p”. The truth

values of the negation of p, p, is the opposite of the

truth value of p.

Discrete Structures(CS 335) 3

Page 4: Discrete Structures lecture 2

Examples

1. Find the negation of the following proposition

p : Today is Friday.

The negation is

p : It is not the case that today is Friday.

This negation can be more simply expressed by

p : Today is not Friday.

Discrete Structures(CS 335) 4

Page 5: Discrete Structures lecture 2

Examples

2. Write the negation of

“6 is negative”.

The negation is

“It is not the case that 6 is negative”.

or “6 is nonnegative”.

Discrete Structures(CS 335) 5

Page 6: Discrete Structures lecture 2

Truth Table (NOT)

• Unary Operator, Symbol:

p p

true false

false true

Discrete Structures(CS 335) 6

Page 7: Discrete Structures lecture 2

Conjunction (AND)

Definition

Let p and q be propositions. The conjunction

of p and q, denoted by p˄q, is the proposition

“p and q”.

The conjunction p˄q is true when p and q are

both true and is false otherwise.

Discrete Structures(CS 335) 7

Page 8: Discrete Structures lecture 2

Examples

1. Find the conjunction of the propositions p and q, where

p : Today is Friday.

q : It is raining today.

The conjunction is

p˄q : Today is Friday and it is raining today.

Discrete Structures(CS 335) 8

Page 9: Discrete Structures lecture 2

Truth Table (AND)

• Binary Operator, Symbol:

p q pq

true true true

true false false

false true false

false false false

Discrete Structures(CS 335) 9

Page 10: Discrete Structures lecture 2

Disjunction (OR)

Definition

Let p and q be propositions. The disjunction

of p and q, denoted by p˅q, is the proposition

“p or q”.

The disjunction p˅q is false when both p and

q are false and is true otherwise.

Discrete Structures(CS 335) 10

Page 11: Discrete Structures lecture 2

Examples

1. Find the disjunction of the propositions p and q,

where

p : Today is Friday.

q : It is raining today.

The disjunction is

p˅q : Today is Friday or it is raining today.

Discrete Structures(CS 335) 11

Page 12: Discrete Structures lecture 2

Truth Table (OR)

• Binary Operator, Symbol:

p q p q

true true true

true false true

false true true

false false false

Discrete Structures(CS 335) 12

Page 13: Discrete Structures lecture 2

Exclusive OR (XOR)

Definition

Let p and q be propositions. The exclusive or

of p and q, denoted by pq, is the proposition

“pq”.

The exclusive or, p q, is true when exactly

one of p and q is true and is false otherwise.

Discrete Structures(CS 335) 13

Page 14: Discrete Structures lecture 2

Examples

1. Find the exclusive or of the propositions p and q,

where

p : Atif will pass the course CSC102.

q : Atif will fail the course CSC102.

The exclusive or is

pq : Atif will pass or fail the course CSC102.

Discrete Structures(CS 335) 14

Page 15: Discrete Structures lecture 2

Truth Table (XOR)

• Binary Operator, Symbol:

p q pq

true true false

true false true

false true true

false false false

Discrete Structures(CS 335) 15

Page 16: Discrete Structures lecture 2

Examples (OR vs XOR)

The following proposition uses the (English) connective

“or”. Determine from the context whether “or” is intended

to be used in the inclusive or exclusive sense.

1. “Nabeel has one or two brothers”.

A person cannot have both one and two brothers.

Therefore, “or” is used in the exclusive sense.

Discrete Structures(CS 335) 16

Page 17: Discrete Structures lecture 2

Examples (OR vs XOR)

2. To register for BSC you must have passed

the qualifying exam or be listed as an Math

major.

Presumably, if you have passed the qualifying exam and

are also listed as an Math major, you can still register for

BCS. Therefore, “or” is inclusive.

Discrete Structures(CS 335) 17

Page 18: Discrete Structures lecture 2

Composite Statements

Statements and operators can be combined in any

way to form new statements.

p q p q (p)(q)

true true false false false

true false false true true

false true true false true

false false true true true

Discrete Structures(CS 335) 18

Page 19: Discrete Structures lecture 2

Translating English to Logic

I did not buy a lottery ticket this week or I bought a

lottery ticket and won the million dollar on Friday.

Let p and q be two propositions

p: I bought a lottery ticket this week.

q: I won the million dollar on Friday.

In logic form

p(pq)

Discrete Structures(CS 335) 19

Page 20: Discrete Structures lecture 2

Discrete Structures(CS 335) 20

Page 21: Discrete Structures lecture 2

Conditional Statements

Definition: Let p and q be propositions. The conditional

statement p q, is the proposition “If p, then

q”.

The conditional statement p q is false when

p is true and q is false and is true otherwise.

where p is called hypothesis, antecedent or premise.

q is called conclusion or consequence

Implication

Discrete Structures(CS 335) 21

Page 22: Discrete Structures lecture 2

Implication (if - then)

• Binary Operator, Symbol:

P Q P Q

true true true

true false false

false true true

false false true

Discrete Structures(CS 335) 22

Page 23: Discrete Structures lecture 2

Conditional Statements

Definition: Let p and q be propositions. The

biconditional statement pq, is the

proposition “p if and only if q”.

The biconditional (bi-implication) statement p

q is true when p and q have same truth

values and is false otherwise.

Biconditional Statements

Discrete Structures(CS 335) 23

Page 24: Discrete Structures lecture 2

Biconditional (if and only if)

• Binary Operator, Symbol:

P Q P Q

true true true

true false false

false true false

false false true

Discrete Structures(CS 335) 24

Page 25: Discrete Structures lecture 2

Composite Statements

• Statements and operators can be combined in any way to

form new statements.

P Q P Q (P)(Q)

true true false false false

true false false true true

false true true false true

false false true true true

Discrete Structures(CS 335) 25

Page 26: Discrete Structures lecture 2

Equivalent Statements

P Q (PQ) (P)(Q) (PQ)(P)(Q)

true true false false true

true false true true true

false true true true true

false false true true true

• Two statements are called logically equivalent if and only if (iff) they

have identical truth tables

• The statements (PQ) and (P)(Q) are logically equivalent,

because (PQ)(P)(Q) is always true.

Discrete Structures(CS 335) 26

Page 27: Discrete Structures lecture 2

Tautologies and Contradictions

• Tautology is a statement that is always true regardless of the truth

values of the individual logical variables

• Examples:

• R(R)

• (PQ) (P)(Q)

• If S T is a tautology, we write S T.

• If S T is a tautology, we write S T.

Discrete Structures(CS 335) 27

Page 28: Discrete Structures lecture 2

Tautologies and Contradictions

• A Contradiction is a statement that is always false regardless of

the truth values of the individual logical variables

Examples

• R(R)

• ((PQ)(P)(Q))

• The negation of any tautology is a contradiction, and

the negation of any contradiction is a tautology.

Discrete Structures(CS 335) 28

Page 29: Discrete Structures lecture 2

Exercises

•We already know the following tautology:

•(PQ) (P)(Q)

•Nice home exercise:

•Show that (PQ) (P)(Q).

•These two tautologies are known as De Morgan’s laws.

Discrete Structures(CS 335) 29

Page 30: Discrete Structures lecture 2

Logical Equivalence

Definition

Two proposition form are called logically equivalent if

and only if they have identical truth values for each

possible substitution of propositions for their

proposition variable.

The logical equivalence of proposition forms P

and Q is written

P ≡ Q

Discrete Structures(CS 335) 30

Page 31: Discrete Structures lecture 2

1. Construct the truth table for P.

2. Construct the truth table for Q using the

same proposition variables for identical

component propositions.

3. Check each combination of truth values of

the proposition variables to see whether the

truth value of P is the same as the truth

value of Q.

Equivalence of Two Compound

Propositions P and Q

Discrete Structures(CS 335) 31

Page 32: Discrete Structures lecture 2

a. If in each row the truth value of P is the

same as the truth value of Q, then P and Q

are logically equivalent.

b. If in some row P has a different truth value

from Q, then P and Q are not logically

equivalent.

Equivalence Check

Discrete Structures(CS 335) 32

Page 33: Discrete Structures lecture 2

Example

• Prove that ¬ (¬p)≡ p

Solution

As you can see the corresponding truth values of p

and ¬ (¬p) are same, hence equivalence is justified.

p ¬p ¬ (¬p)

T F T

F T F

Discrete Structures(CS 335) 33

Page 34: Discrete Structures lecture 2

Example

Show that the proposition forms ¬(pq) and ¬p ¬q

are NOT logically equivalent.

Here the corresponding truth values

differ and hence equivalence does

not hold

p q ¬p ¬q (pq) ¬(pq) ¬p¬q

T T F F T F F

T F F T F T F

F T T F F T F

F F T T F T T

Discrete Structures(CS 335) 34

Page 35: Discrete Structures lecture 2

De Morgan’s laws

De Morgan’s laws state that:

The negation of an and proposition is

logically equivalent to the or proposition in

which each component is negated.

The negation of an or proposition is logically

equivalent to the and proposition in which

each component is negated.

Discrete Structures(CS 335) 35

Page 36: Discrete Structures lecture 2

Symbolically (De Morgan’s Laws)

1. ¬(pq) ≡ ¬p¬q

2. ¬(pq) ≡ ¬p¬q

Discrete Structures(CS 335) 36

Page 37: Discrete Structures lecture 2

Applying De-Morgan’s Law

Question: Negate the following compound Propositions

1. John is six feet tall and he weights at least 200

pounds.

2. The bus was late or Tom’s watch was slow.

Discrete Structures(CS 335) 37

Page 38: Discrete Structures lecture 2

Solution

a) John is not six feet tall or he weighs less

than 200 pounds.

b) The bus was not late and Tom’s watch was

not slow.

Discrete Structures(CS 335) 38

Page 39: Discrete Structures lecture 2

Inequalities and De Morgan’s Laws

Question Use De Morgan’s laws to write the negation of

-1< x 4

Solution: The given proposition is equivalent to

-1 < x and x 4,

By De Morgan’s laws, the negation is

-1 ≥ x or x > 4.

Discrete Structures(CS 335) 39

Page 40: Discrete Structures lecture 2

Tautology and Contradiction

Definition A tautology is a proposition form that is

always true regardless of the truth values of the

individual propositions substituted for its proposition

variables. A proposition whose form is a tautology is

called a tautological proposition.

Definition A contradiction is a proposition form that is

always false regardless of the truth values of the

individual propositions substituted for its proposition

variables. A proposition whose form is a contradiction is

called a contradictory proposition.

Discrete Structures(CS 335) 40

Page 41: Discrete Structures lecture 2

Example

Show that the proposition form p¬p is a

tautology and the proposition form p¬p is a

contradiction.

Exercise: If t is a tautology and c is

contradiction, show that pt≡p and pc≡c?

p ¬p p ¬p p ¬p

T F T F

F T T F

Discrete Structures(CS 335) 41

Page 42: Discrete Structures lecture 2

1. Commutative laws

pq ≡ qp ; pq ≡ qp

2. Associative laws

p (q r) ≡ (p q) r ; p(q r) ≡ (pq)r

3. Distributive laws

p (q r ) ≡ (p q) (p r)

p (q r) ≡ (p q) (p r)

Laws of Logic

Discrete Structures(CS 335) 42

Page 43: Discrete Structures lecture 2

Laws of Logic

4. Identity laws

p t ≡ p ; pc ≡ p

5. Negation laws

p¬p ≡ t ; p ¬p ≡ c

6. Double negation law

¬(¬p) ≡ p

7. Idempotent laws

p p ≡ p ; pp ≡ p

Discrete Structures(CS 335) 43

Page 44: Discrete Structures lecture 2

Laws of Logic

8. Universal bound laws

p t ≡ t ; p c ≡ c

9. Absorption laws

p (pq) ≡ p ; p (p q) ≡ p

10. Negation of t and c

¬t ≡ c ; ¬c ≡ t

Discrete Structures(CS 335) 44

Page 45: Discrete Structures lecture 2

Exercise

Using laws of logic, show that

⌐(⌐p q) (p q) ≡ p.

Solution

Take ⌐(⌐p q) (p q)

≡ (⌐(⌐p) ⌐q) (p q), (by De Morgan’s laws)

≡ (p ⌐q) (p q), (by double negative law)

≡ p (⌐q q), (by distributive law)

Discrete Structures(CS 335) 45

Page 46: Discrete Structures lecture 2

contd…

≡ p (q ⌐q), (by the commutative law)

≡ p c, (by the negation law)

≡ p, (by the identity law)

Skill in simplifying proposition forms is useful in

constructing logically efficient computer programs

and in designing digital circuits.

Discrete Structures(CS 335) 46

Page 47: Discrete Structures lecture 2

Prove that ¬[r ∨ (q ∧ (¬r →¬p))] ≡ ¬r ∧ (p∨ ¬q)

Another Example

¬[r ∨ (q ∧ (¬r → ¬p))]

≡ ¬r ∧ ¬(q ∧ (¬r → ¬p)), De Morgan’s law

≡ ¬r ∧ ¬(q ∧ (¬¬r ∨ ¬p)), Conditional rewritten as disjunction

≡ ¬r ∧ ¬(q ∧ (r ∨¬p)), Double negation law

≡ ¬r ∧ (¬q ∨ ¬(r ∨ ¬p)), De Morgan’s law

≡ ¬r ∧ (¬q ∨ (¬r ∧ p)), De Morgan’s law, double negation

≡ (¬r ∧¬q) ∨ (¬r ∧ (¬r ∧ p)), Distributive law

≡ (¬r ∧¬q) ∨ ((¬r ∧ ¬r) ∧ p), Associative law

≡ (¬r ∧¬q) ∨ (¬r ∧ p), Idempotent law

≡ ¬r ∧ (¬q ∨ p), Distributive law

≡ ¬r ∧ (p ∨¬q), Commutative law

Discrete Structures(CS 335) 47

Page 48: Discrete Structures lecture 2

Lecture Summery

• Logical Connectives

• Truth Tables

• Compound propositions

• Translating English to logic and logic to English.

• Logical Equivalence

• Equivalence Check

• Tautologies and Contradictions

• Laws of Logic

• Simplification of Compound Propositions

Discrete Structures(CS 335) 48