Discrete Mathematics and Its Application - Chapter 1

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 61

Ch.

1 (Part 1):
The Foundations: Logic and Proofs

• Introduction

• Propositional Logic (Section 1.1)

© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Sixth Edition, Mc Graw-Hill, 2011
Introduction: Areas in which discrete
mathematics concepts are present

• Formal Languages (computer languages)


• Compiler Design
• Data Structures
• Computability
• Automata Theory
• Algorithm Design
• Relational Database Theory
• Complexity Theory (counting)
Ch.1 (part© 1): 2
by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Example (counting):

• The Traveling Salesman Problem

Important in
• circuit design
• many other CS problems
______________________
Given:
• n cities c1, c2, . . . , cn
• distance between city i and j, dij

Find the shortest tour.


Ch.1 (part© 1): 3
by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Assume a very fast PC:
1 flop = 1 nanosecond
= 10-9 sec.
= 1,000,000,000 ops/sec
= 1 GHz.
A tour requires n-1 additions. How many different tours?
Choose the first city n ways,
the second city n-1 ways,
the third city n-2 ways,
etc.
# tours = n (n-1) (n-2) . . . .(2) (1) = n! (Combinations)
Ch.1 (part© 1): 4
by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Total number of additions = n(n-1)! (Rule of Product)

If n=8, T(n) = 8•7! = 40,320 flops < 1/3 second.

HOWEVER . . . . . . . . . . . . .

If n=50, T(n) = 50•49!


= 3.04 1064
= 3.04 1055 seconds
= 5.0 1053 minutes
= 8.0 1051 hours
= 3.0 1050 days
= 4.0 1049 weeks
= 7.0 1047 years.
...a long time. You’ll be an old person (dead) before it’s finished!

There are some problems for which we do not know if efficient algorithms
exist to solve them!
Ch.1 (part© 1): 5
by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Section 1.1: Propositional Logic

proposition : true = T (or 1) or false = F (or


0) (binary logic)

•‘the moon is made of green cheese’


•‘ go to town!’ X - imperative
•‘What time is it?’ X – interrogative

propositional variables: P, Q, R, S, . . .

New Propositions from old: calculus of


propositions -
©
Ch.1 (part
relate new 6 using TRUTH
by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
1): propositions to old
• Logical operators: unary, binary

• Unary:
– Negation

• Binary
– Conjunction
– Disjunction
– Exclusive OR
– Implication
– Biconditional
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Ch.1 (part 1): 7
• Unary
Truth Table
– Negation
P P
‘not’ F(0) T(1)
Symbol:  T(1) F(0)

Example: P: I am going to town


 P: I am not going to town;
It is not the case that I am going to town;
I ain’t goin’.

Ch.1 (part© 1): 8


by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Truth Table
P Q PQ
• Binary 0 0 0
– Conjunction: ‘and’ 0 1 0
1 0 0
Symbol: 
1 1 1

Example: P - ‘I am going to town’


Q - ‘It is going to rain’

P  Q: ‘I am going to town and it is going to


rain.’
Ch.1 (part© 1): 9
by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
• Binary
– Disjunction: inclusive ‘or’
Symbol: 
Truth Table:
Example: P - ‘I am going to town’
P Q PQ
Q - ‘It is going to rain’
0 0 0
P  Q: ‘I am going to town or 0 1 1
it is going to rain.’ 1 0 1
1 1 1

Note: Only one of P and Q must be true.


© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Hence, the1):
Ch.1 (part inclusive nature. 10
Truth Table
P Q PQ
• Binary
0 0 0
0 1 1
– Exclusive OR: Symbol 
1 0 1
1 1 0
Example:
P - ‘I am going to town’
Q - ‘It is going to rain’

P  Q: ‘Either I am going to town or it is going to


rain.’

Note: Only
© by Kenneth one of P and Q must be true.
Ch.1 (part 1): 11
H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
• Binary

– Implication: ‘If...then...’
Truth Table
Symbol: 
P Q PQ
Example: 0 0 1
P - ‘I am going to town’ 0 1 1
1 0 0
Q - ‘It is going to rain’
1 1 1

P  Q: ‘If I am going to town then it is going to


rain.’
Ch.1 (part© 1): 12
by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
– Implication (cont.)

Equivalent forms:
If P, then Q
P implies Q
If P, Q
P only if Q
P is a sufficient condition for Q
Q if P
Q whenever P
Q is a necessary condition for P

Note: The implication is false only when P is true


and1): Q isH. Rosen,
© by Kenneth
Ch.1 (part false! 13
Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
There is no causality implied here!
‘If the moon is made of green cheese then I have
more money than Bill Gates’ (T)
‘If the moon is made of green cheese then I’m on
welfare’ (T)

‘If 1+1=3 then your grandma wears combat boots’ (T)

‘If I’m wealthy then the moon is not made of green


cheese.’ (T)

‘If I’m not


Ch.1 wealthy then the moon is14not made of
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
(part 1):
Terminology:

P = premise, hypothesis, antecedent


Q = conclusion, consequence

More terminology:

Q  P is the CONVERSE of P  Q
 Q   P is the CONTRAPOSITIVE of P 
Q
Ch.1 (part© 1): 15
by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Example:

Find the converse and contrapositive of the


following statement:

R: ‘Raining tomorrow is a sufficient condition for


my not going to town.’

Ch.1 (part© 1): 16


by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Step 1: Assign propositional variables to component propositions
P: It will rain tomorrow
Q: I will not go to town

Step 2: Symbolize the assertion


R: PQ

Step 3: Symbolize the converse


QP

Step 4: Convert the symbols back into words


‘If I don’t go to town then it will rain tomorrow’
or
‘Raining tomorrow is a necessary condition for my not going
to town.’
or
Ch.1 (part© 1): 17
by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Truth Table
P Q PQ

• Binary 0 0 1
0 1 0
– Biconditional: ‘if and only if’, ‘iff’ 1 0 0
Symbol:  1 1 1
Example: P - ‘I am going to town’, Q - ‘It is going to rain’

P  Q: ‘I am going to town if and only if it is going to


rain.’

Note: Both P and Q must have the same truth value.

– Imprecision of the natural language:


‘If you finish your meal then you can have dessert’
Ch.1 (part© 1): 18
by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
– Breaking assertions into component
propositions - look for the logical operators!

Example:‘If I go to Harry’s or go to the country I will


not go shopping.’

P: I go to Harry’s
Q: I go to the country
R: I will go shopping

If......P......or.....Q.....then....not..…R

(P V Q)R
Ch.1 (part© 1): 19
by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Constructing a truth table:

- one column for each propositional variable


- one for the compound proposition
- count in binary
- n propositional variables = 2n rows

You may find it easier to include columns for


propositions which themselves are component
propositions.

Ch.1 (part© 1): 20


by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Truth Table
P Q R (P V Q)R

0 0 0 1
0 0 1 1
0 1 0 1
0 1 1 0
1 0 0 1
1 0 1 0
1 1 0 1
1 1 1 0
Ch.1 (part© 1): 21
by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Chapter 1: (Part 2):
The Foundations: Logic and Proofs

• Propositional
Equivalence
(Section 1.2)

• Predicates &
Quantifiers
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Sixth Edition, Mc Graw-Hill, 2011
© by Kenneth H. Rosen, Discrete Mathematics & its
Propositional Equivalences (1.2)

• A tautology is a proposition which is always


true .
Classic Example: P V P

• A contradiction is a proposition which is


always false .
Classic Example: P  P

• A contingency is a proposition which neither


a CS
tautology
© nor a contradiction.
23
by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
210, Ch.1
Propositional Equivalences (1.2) (cont.)

• Two propositions P and Q are logically


equivalent if
P  Q is a tautology. We write:

PQ

© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
CS 210, Ch.1 24
Propositional Equivalences (1.2) (cont.)

• Example:
(P  Q)  (Q  P)  (P  Q)

• Proof:
– The left side and the right side must have the
same truth values independent of the truth
value of the component propositions.

– To show a proposition is not a tautology: use


an abbreviated truth table
• try to find a counter example or to disprove the
assertion.
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
CS 210, Ch.1 25
Propositional Equivalences (1.2) (cont.)

– Case 1: Try left side false, right side true

Left side false: only one of PQ or Q P need be


false.

1a. Assume PQ = F.


Then P = T , Q = F. But then right side PQ = F.
Wrong guess.

1b. Try Q P = F. Then Q = T, P = F. Then


PQ = F. Another wrong guess.
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
CS 210, Ch.1 26
Propositional Equivalences (1.2)

– Case 2. Try left side true, right side false


If right side is false, P and Q cannot have the same truth
value.
2a. Assume P =T, Q = F.
Then PQ = F and the conjunction must be false so the left s
cannot be true in this case. Another wrong guess.
2b. Assume Q = T, P = F.
Again the left side cannot be true. We have exhausted all
possibilities and not found a counterexample. The two
propositions must be logically equivalent.

Note: Because of this equivalence, if and only if or iff is


also stated© as is aH. Rosen,
necessary and & itssufficient condition for.2011
by Kenneth
CS 210, Ch.1 Discrete Mathematics
27
Applications, Seventh Edition, Mc Graw-Hill,
Equivalence Name
PTP Identity Laws
PVFP
PVTT Domination Laws
PFF
PVPP Idempotent Laws
PPP
 ( P)  P Double Negation
Law

PVQQVP Commutative Law


PQQP

© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
CS 210, Ch.1 28
Equivalence Name
(P V Q) V R Associative Law
 P V (Q V R)
P V (Q  R) Distributive Law
 (P V Q)  (P V R)
(P  Q)  P V Q De Morgan’s Laws
(P V Q)  P  Q
P  Q  P V Q Implication
Equivalence
P  Q  Q  P Contrapositive Law

Note: equivalent expressions can always be substituted for each other in a more
complex expression - useful for simplification.
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
CS 210, Ch.1 29
Propositional Equivalences (1.2) (cont.)

• Normal or Canonical Forms

– Unique representations of a proposition

– Examples: Construct a simple proposition of


two variables which is true only when

• P is true and Q is false: P  Q


• P is true and Q is true: P  Q
• P is true and Q is false or P is true and Q is true:
(P  Q) V (P  Q)

© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
CS 210, Ch.1 30
Propositional Equivalences (1.2) (cont.)

• A disjunction of conjunctions where

– every variable or its negation is represented


once in each conjunction (a minterm)

– each minterms appears only once


Disjunctive Normal Form (DNF)

– Important in switching theory, simplification in the


design ©of circuits.
CS by Kenneth
210, Ch.1 31
H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Propositional Equivalences (1.2) (cont.)

• Method: To find the minterms of the DNF.

– Use the rows of the truth table where the


proposition is 1 or True

– If a zero appears under a variable, use the


negation of the propositional variable in the
minterm

– If a one appears, use the propositional variable.


© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
CS 210, Ch.1 32
Propositional Equivalences (1.2) (cont.)

• Example: Find the DNF of (P V Q) R


P Q R (P V Q) R
0 0 0 1
0 0 1 1
0 1 0 1
0 1 1 0
1 0 0 1
1 0 1 0
1 1 0 1
1 1 1 0
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
CS 210, Ch.1 33
Propositional Equivalences (1.2) (cont.)

– There are 5 cases where the proposition is


true, hence 5 minterms. Rows 1,2,3, 5 and 7
produce the following disjunction of
minterms:

(P V Q) R
 (P  Q  R) V (P  Q  R) V (P  Q 
R)
V (P  Q  R) V (P  Q  R)

– Note that you get a Conjunctive Normal Form


(CNF) if you
© by Kenneth negate a DNF and use
CS 210, Ch.1 34
H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Predicates & Quantifiers (1.3)

• A generalization of propositions -
propositional functions or predicates:
propositions which contain variables

• Predicates become propositions once


every variable is bound- by

– assigning it a value from the Universe of


Discourse U

or
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
CS 210, Ch.1 35
Predicates & Quantifiers (1.3) (cont.)

• Examples:

– Let U = Z, the integers = {. . . -2, -1, 0 , 1, 2,


3, . . .}

• P(x): x > 0 is the predicate. It has no truth value


until the variable x is bound.

– Examples of propositions where x is


assigned a value:
• P(-3) is false,
• P(0) is false,
• P(3) is true.
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
CS 210, Ch.1 36
Predicates & Quantifiers (1.3) (cont.)

• P(y) V P(0) is not a proposition. The


variable y has not been bound. However,
P(3) V P(0) is a proposition which is
true.

• Let R be the three-variable predicate R(x,


y z):
x+y=z

• Find the truth value of


© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
CS 210, Ch.1 37
Predicates & Quantifiers (1.3) (cont.)

• Quantifiers

– Universal

P(x) is true for every x in the universe of discourse.


Notation: universal quantifier
x P(x)

‘For all x, P(x)’, ‘For every x, P(x)’

The variable x is bound by the universal quantifier


producing a proposition.
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
CS 210, Ch.1 38
Predicates & Quantifiers (1.3) (cont.)

– Example: U = {1, 2, 3}

x P(x)  P(1)  P(2)  P(3)

© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
CS 210, Ch.1 39
Predicates & Quantifiers (1.3) (cont.)

• Quantifiers (cont.)
– Existential

• P(x) is true for some x in the universe of discourse.


Notation: existential quantifier
x P(x)

‘There is an x such that P(x),’ ‘For some x, P(x)’, ‘For


at least one x, P(x)’, ‘I can find an x such that P(x).’

Example: U={1,2,3}
x P(x)  P(1) V P(2) V P(3)
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
CS 210, Ch.1 40
Predicates & Quantifiers (1.3) (cont.)

• Quantifiers (cont.)

– Unique Existential

P(x) is true for one and only one x in the universe


of discourse.

Notation: unique existential quantifier


!x P(x)

‘There is a unique x such that P(x),’ ‘There is one


and only one x such that P(x),’ ‘One can find only
one x such that P(x).’
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
CS 210, Ch.1 41
Predicates & Quantifiers (1.3) (cont.)

– Example: U = {1, 2, 3, 4}
P(1) P(2) P(3) !xP(x)

0 0 0 0
0 0 1 1
0 1 0 1
0 1 1 0
1 0 0 1 How many
1 0 1 0 minterms are
1 1 0 0 in the DNF?
1 1 1 0
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
CS 210, Ch.1 42
Predicates & Quantifiers (1.3) (cont.)

REMEMBER!

A predicate is not a proposition until all variables


have been bound either by quantification or
assignment of a value!

© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
CS 210, Ch.1 43
Predicates & Quantifiers (1.3) (cont.)

• Equivalences involving the negation operator


(x P(x ))  x P(x)
(x P(x))  x P(x)

• Distributing a negation operator across a


quantifier changes a universal to an
existential and vice versa.

– (x P(x))  (P(x1)  P(x2)  …  P(xn))


 P(x1) V P(x2) V … V P(xn)
210,
CS x Ch.1
P(x)
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
44
Predicates & Quantifiers (1.3) (cont.)

• Multiple Quantifiers: read left to right . . .

– Example: Let U = R, the real numbers,


P(x,y): xy= 0
x y P(x, y)
x y P(x, y)
x y P(x, y)
x y P(x, y)

The only one that is false is the first one.


What’s about the case when P(x,y) is the
predicate x/y=1?
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
CS 210, Ch.1 45
Predicates & Quantifiers (1.3) (cont.)

• Multiple Quantifiers: read left to right . . .


– Example: Let U = {1,2,3}. Find an expression
equivalent to x y P(x, y) where the variables
are bound by substitution instead:

Expand from inside out or outside in.

Outside in:

y P(1, y)  y P(2, y)  y P(3, y)


[P(1,1) V P(1,2) V P(1,3)] 
[P(2,1) V P(2,2) V P(2,3)] 
[P(3,1)
© by Kenneth H. Rosen,
CS 210, Ch.1 V P(3,2) V46 P(3,3)]
Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Predicates & Quantifiers (1.3) (cont.)

• Converting from English (Can be very difficult!)

“Every student in this class has studied calculus”


transformed into:

“For every student in this class, that student has


studied
calculus”

C(x): “x has studied calculus”


x C(x)

This is one way of converting from English!

© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
CS 210, Ch.1 47
Predicates & Quantifiers (1.3) (cont.)

• Multiple Quantifiers: read left to right . . .


(cont.)

– Example:

F(x): x is a fleegle
S(x): x is a snurd
T(x): x is a thingamabob

U={fleegles, snurds, thingamabobs}


© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
(Note: the equivalent form using the48
CS 210, Ch.1 existential quantifier
Predicates & Quantifiers (1.3) (cont.)

– Everything is a fleegle
x F( x)
  (x F(x))

– Nothing is a snurd.
x  S(x)
  (x S( x))

– All fleegles are snurds.


x [F(x)S(x)]
 x [F(x) V S(x)]
CS xCh.1
210, by[F(x)
© Kenneth H. S(x)]
Rosen,
49
Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
Predicates & Quantifiers (1.3) (cont.)

– Some fleegles are thingamabobs.


x [F(x)  T(x)]
 (x [F(x) V T(x)])

– No snurd is a thingamabob.
x [S(x) T(x)]
 (x [S(x )  T(x)])

– If any fleegle is a snurd then it's also a


thingamabob
x [(F(x)  S(x))  T(x)]
©(x [F(x)  S(x)  T( x)])
50
by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
CS 210, Ch.1
Predicates & Quantifiers (1.3) (cont.)

• Extra Definitions:

– An assertion involving predicates is valid if it


is true for every universe of discourse.

– An assertion involving predicates is


satisfiable if there is a universe and an
interpretation for which the assertion is true.
Else it is unsatisfiable.

– The scope of a quantifier is the part of an


© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
CS 210, Ch.1
assertion in which variables 51are bound by the
Predicates & Quantifiers (1.3) (cont.)

– Examples:

Valid: x S(x)  [x S( x)]

Not valid but satisfiable: x [F(x)  T(x)]

Not satisfiable: x [F(x)  F(x)]

Scope: x [F(x) V S( x)] vs. x [F(x)] V x [S(x)]

© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
CS 210, Ch.1 52
Predicates & Quantifiers (1.3) (cont.)

• Dangerous situations:

– Commutativity of quantifiers
x y P(x, y) y x P( x, y)?
YES!
x y P(x, y)  y x P(x, y)?
NO!
DIFFERENT MEANING!

– Distributivity of quantifiers over operators


x [P(x)  Q(x)]  x P( x)  x Q( x)?
YES!
CS 210,xCh.1
©[P( x) H.Rosen,
by Kenneth Q(Discrete [x&P(x)
x)] Mathematics  x
53
its Applications, Q(
Seventh x)]?
Edition, Mc Graw-Hill, 2011
Sets (1.6)

• A set is a collection or group of objects or


elements or members. (Cantor 1895)

– A set is said to contain its elements.

– There must be an underlying universal set U,


either specifically stated or understood.

© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
CS 210, Ch.1 54
Sets (1.6) (cont.)

– Notation:

• list the elements between braces:


S = {a, b, c, d}={b, c, a, d, d}
(Note: listing an object more than once does not
change the set. Ordering means nothing.)

• specification by predicates:
S= {x| P(x)},
S contains all the elements from U which make
the predicate P true.

• brace notation with ellipses:


S =Mathematics
© by Kenneth H. Rosen, Discrete { . . .&,its-3, -2, -1},
CS 210, Ch.1 55 Seventh Edition, Mc Graw-Hill, 2011
Applications,
Sets (1.6) (cont.)

• Common Universal Sets


– R = reals
– N = natural numbers = {0,1, 2, 3, . . . }, the
counting numbers
– Z = all integers = {. . , -3, -2, -1, 0, 1, 2, 3, 4, . .}
– Z+ is the set of positive integers

• Notation:
x is a member of S or x is an element of S:
x  S.
xCS
is 210,
not Ch.1
an element
© by Kenneth of Mathematics
H. Rosen, Discrete S: & its Applications,
56 Seventh Edition, Mc Graw-Hill, 2011
Sets (1.6) (cont.)

• Subsets
– Definition: The set A is a subset of the set B,
denoted
A  B, iff
x [x  A  x  B]

– Definition: The void set, the null set, the empty


set, denoted , is the set with no members.

Note: the assertion x   is always false. Hence


x [x    x  B]
is always true(vacuously). Therefore,  is a subset of
every
© by Kenneth H. Rosen, Discrete Mathematics set.
CS 210, Ch.1 57
& its Applications, Seventh Edition, Mc Graw-Hill, 2011
Sets (1.6) (cont.)

– Definition: If A  B but A  B the we say A is a


proper subset of B, denoted A  B (in some
texts).

– Definition: The set of all subset of a set A,


denoted P(A), is called the power set of A.

– Example: If A = {a, b} then


P(A) = {, {a}, {b}, {a,b}}

© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
CS 210, Ch.1 58
Sets (1.6) (cont.)

– Definition: The number of (distinct) elements


in A, denoted |A|, is called the cardinality of
A.

If the cardinality is a natural number (in N), then the


set is called finite, else infinite.

– Example: A = {a, b},


|{a, b}| = 2,
|P({a, b})| = 4.
A is finite and so is P(A).
Useful Fact: |A|=n implies |P(A)| = 2n
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
CS 210, Ch.1 59
Sets (1.6) (cont.)

– N is infinite since |N| is not a natural number. It is called a


transfinite cardinal number.

– Note: Sets can be both members and subsets of other sets.

– Example:
A = {,{}}.
A has two elements and hence four subsets:
, {}, {{}}. {,{}}
Note that  is both a member of A and a subset of A!

– Russell's paradox: Let S be the set of all sets which are not
members of themselves. Is S a member of itself?

– Another paradox: Henry is a barber who shaves all people who


do not shave themselves. Does Henry shave himself?

© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
CS 210, Ch.1 60
Sets (1.6) (cont.)

• Definition: The Cartesian product of A with B, denoted


A x B, is the set of ordered pairs {<a, b> | a  A  b  B}
Notation:
n
 Ai   a1 , a 2 ,...,a n  a i  Ai 
i 1
Note: The Cartesian product of anything with  is . (why?)

– Example:
A = {a,b}, B = {1, 2, 3}
AxB = {<a, 1>, <a, 2>, <a, 3>, <b, 1>, <b, 2>, <b,
3>}
What is BxA? AxBxA?

CS–210, © by Kenneth H. Rosen, Discrete Mathematics & its Applications, Seventh Edition, Mc Graw-Hill, 2011
If |A|
Ch.1= m and |B| = n, what61 is |AxB|?

You might also like