Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph...

63
Copyright © Zeph Grunschl ag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag

Transcript of Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph...

Page 1: Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag.

Copyright © Zeph Grunschlag, 2001-2002.

Lecture 4: Predicates and Quantifiers; Sets.

Zeph Grunschlag

Page 2: Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag.

L4 2

Announcements

HW1 due now

Page 3: Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag.

L4 3

AgendaPredicates and Quantifiers Existential Quantifier Universal Quantifier

Sets Curly brace notation “{ … }” Cardinality “| … |” Element containment Subset containment Empty set { } = Power set P(S ) = 2S

N-tuples “( … )” and Cartesian product

Page 4: Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag.

L4 4

Motivating exampleConsider the compound proposition:

If Zeph is an octopus then Zeph has 8 limbs.Q1: What are the atomic propositions and

how do they form this proposition.Q2: Is the proposition true or false?Q3: Why?

Page 5: Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag.

L4 5

Motivating exampleA1: Let p = “Zeph is an octopus” and q =

“Zeph has 8 limbs”. The compound proposition is represented by p q.

A2: True!A3: Conditional always true when p is

false!

Q: Why is this not satisfying?

Page 6: Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag.

L4 6

Motivating exampleA: We wanted this to be true because of the fact

that octopi have 8 limbs and not because of some (important) non-semantic technicality in the truth table of implication.

But recall that propositional calculus doesn’t take semantics into account so there is no way that p could impact on q or affect the truth of pq.

Logical Quantifiers help to fix this problem. In our case the fix would look like:

For all x, if x is an octopus then x has 8 limbs.

Page 7: Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag.

L4 7

Motivating exampleExpressions such as the previous are built up from

propositional functions –statements that have a variable or variables that represent various possible subjects. Then quantifiers are used to bind the variables and create a proposition with embedded semantics. For example:“For all x, if x is an octopus then x has 8 limbs.”there are two atomic propositional functions

P (x) = “x is an octopus” Q (x) = “x has 8 limbs”

whose conditional P (x) Q (x) is formed and is bound by “For all x ”.

Page 8: Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag.

L4 8

SemanticsIf logical propositions are to have meaning, they

need to describe something. Up to now, propositions such as “Johnny is tall”, “Debbie is 5 years old”, and “Andre is immature” had no intrinsic meaning. Either they are true or false, but no more.

In order to endow such propositions with meaning, we need to have a universe of discourse, i.e. a collection of subjects (or nouns) about which the propositions relate.

Q: What is the universe of discourse for the three propositions above?

Page 9: Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag.

L4 9

SemanticsA: There are many answers. Here are some:

Johnny, Debbie and Andre (this is also the smallest correct answer)

People in the world Animals

Java: The Java analog of a universe of discourse is a type. There are two categories of types in Java: reference types which consist of objects and arrays, and primitive types like int, boolean, char, etc. Examples of Java “universes” are:int, char, int[][], Object, String, java.util.LinkedList, Exception, etc.

Page 10: Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag.

L4 10

PredicatesA predicate is a property or description of

subjects in the universe of discourse. The following predicates are all italicized : Johnny is tall. The bridge is structurally sound. 17 is a prime number.

Java: predicates are boolean-valued method calls- someLinkedList.isEmpty() isPrime(17)

Page 11: Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag.

L4 11

Propositional FunctionsBy taking a variable subject denoted by symbols

such as x, y, z, and applying a predicate one obtains a propositional function (or formula). When an object from the universe is plugged in for x, y, etc. a truth value results: x is tall. …e.g. plug in x = Johnny y is structurally sound. …e.g. plug in y = GWB n is a prime number. …e.g. plug in n = 111

Java: propositional functions are boolean methods, rather than particular calls. boolean isEmpty(){…} //in LinkedList boolean isPrime(int n){…}

Page 12: Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag.

L4 12

Multivariable PredicatesMultivariable predicates generalize

predicates to allow descriptions of relationships between subjects. These subjects may or may not even be in the same universe of discourse. For example: Johnny is taller than Debbie. 17 is greater than one of 12, 45. Johnny is at least 5 inches taller than Debbie.

Q: What universes of discourse are involved?

Page 13: Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag.

L4 13

Multivariable PredicatesA: Again, many correct answers. The most

obvious answers are: For “Johnny is taller than Debbie” the universe

of discourse of both variables is all people in the universe

For “17 is greater than one of 12, 45” the universe of discourse of all three variables is Z (the set of integers)

For “Johnny is at least 5 inches taller than Debbie” the first and last variable have people as their universe of discourse, while the second variable has R (the set of real numbers).

Page 14: Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag.

L4 14

Multivariable Propositional Functions

The multivariable predicates, together with their variables create multivariable propositional functions. In the above examples, we have the following generalizations: x is taller than y a is greater than one of b, c x is at least n inches taller than y

In Java, a multivariable predicate is a boolean method with several arguments:

tallerByNumInches(Person x, double n, Person y)

{ … }

Page 15: Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag.

L4 15

Quantifiers

There are two quantifiersExistential Quantifier“” reads “there exists”Universal Quantifier“” reads “for all”

Each is placed in front of a propositional function and binds it to obtain a proposition with semantic value.

Page 16: Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag.

L4 16

Existential Quantifier

“x P (x)” is true when an instance can be found which when plugged in for x makes P (x) true

Like disjunctioning over entire

universe x P (x ) P (x1) P (x2) P (x3) …

Page 17: Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag.

L4 17

Existential Quantifier. Example

Consider a universe consisting of Leo: a lion Jan: an octopus with all 8 tentacles Bill: an octopus with only 7 tentacles

And recall the propositional functions P (x) = “x is an octopus” Q (x) = “x has 8 limbs”

x ( P (x) Q (x) )Q: Is the proposition true or false?

Page 18: Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag.

L4 18

Existential Quantifier. Example

A: True. Proposition is equivalent to (P (Leo)Q (Leo) )(P (Jan) Q (Jan) )(P(Bill)Q (Bill) )

P (Leo) is false because Leo is a Lion, not an octopus, therefore the conditional

P (Leo) Q (Leo) is true, and the disjunction is true.

Leo is called a positive example.

Page 19: Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag.

L4 19

The Universal Quantifier

“x P (x)” true when every instance of x makes P (x) true when plugged in

Like conjunctioning over entire

universe x P (x ) P (x1) P (x2) P (x3) …

Page 20: Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag.

L4 20

Universal Quantifier. Example

Consider the same universe and propositional functions as before.

x ( P (x) Q (x ) ) Q: Is the proposition true or false?

Page 21: Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag.

L4 21

Universal Quantifier. Example

A: False. The proposition is equivalent to (P (Leo)Q (Leo))(P (Jan)Q (Jan))(P (Bill)Q

(Bill))Bill is the counter-example, i.e. a value

making an instance –and therefore the whole universal quantification– false.

P (Bill) is true because Bill is an octopus, while Q (Bill) is false because Bill only has 7 tentacles, not 8. Thus the conditional P (Bill)Q (Bill) is false since TF gives F, and the conjunction is false.

Page 22: Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag.

L4 22

Illegal QuantificationsOnce a variable has been bound, we

cannot bind it again. For example the expression

x ( x P (x) )is nonsensical. The interior expression (x P (x)) bounded x already and therefore made it unobservable to the outside. Going back to our example, the English equivalent would be:

Everybody is an everybody is an octopus.

Page 23: Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag.

L4 23

Multivariate Quantification

Quantification involving only one variable is fairly straightforward. Just a bunch of OR’s or a bunch of AND’s.

When two or more variables are involved each of which is bound by a quantifier, the order of the binding is important and the meaning often requires some thought.

Page 24: Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag.

L4 26

Parsing ExampleA: True.For any “exists” we need to find a positive

instance.Since x is the first variable in the

expression and is “existential”, we need a number that works for all other y, z. Set x = 0 (want to ensure that y -x is not too small).

Now for each y we need to find a positive instance z such that y - x ≥ z holds. Plugging in x = 0 we need to satisfy y ≥ z so set z := y.

Q: Did we have to set z := y ?

Page 25: Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag.

L4 27

Parsing Example

A: No. Could also have used the constant z := 0. Many other valid solutions.

Q: Isn’t it simpler to satisfy x y z (y - x ≥ z )

by setting x := y and z := 0 ?

Page 26: Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag.

L4 28

Parsing Example

A: No, this is illegal ! The existence of x comes before we know about y. I.e., the scope of x is higher than the scope of y so as far as y can tell, x is a constant and cannot affect x.

A Java example helps explain this point. To evaluate x y Q (x,y ) might do the following.

Page 27: Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag.

L4 29

Parsing Example —Java boolean exists_x_forAll_y(){for(int x=firstInt; x<=lastInt; x++){

if (forAll_y(x)) return true;}

return false;}

boolean forAll_y(int x){for(int y=firstInt; y<=lastInt; y++){

if ( !Q(x,y) ) return false;}return true;

}

Page 28: Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag.

L4 30

Order matters

Set the universe of discourse to be all natural numbers {0, 1, 2, 3, … }.

Let R (x,y ) = “x < y”.Q1: What does x y R (x,y ) mean?Q2: What does y x R (x,y ) mean?

Page 29: Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag.

L4 31

Order mattersR (x,y ) = “x < y”A1: x y R (x,y ): “All numbers x admit a bigger number

y ”A2: y x R (x,y ): “Some number y is bigger than all x”Q: What’s the true value of each

expression?

Page 30: Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag.

L4 32

Order matters

A: 1 is true and 2 is false.x y R (x,y ): “All numbers x admit a

bigger number y ” --just set y = x + 1y x R (x,y ): “Some number y is bigger

than all numbers x” --y is never bigger than itself, so setting x = y is a counterexample

Q: What if we have two quantifiers of the same kind? Does order still matter?

Page 31: Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag.

L4 33

Order matters –but not always

A: No! If we have two quantifiers of the same kind order is irrelevent.

x y is the same as y x because these are both interpreted as “for every combination of x and y…”

x y is the same as y x because these are both interpreted as “there is a pair x , y…”

Page 32: Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag.

L4 34

Logical Equivalence with Formulas

DEF: Two logical expressions possibly involving propositional formulas and quantifiers are said to be logically equivalent if no-matter what universe and what particular propositional formulas are plugged in, the expressions always have the same truth value.

EG: x y Q (x,y ) and y x Q (y,x ) are equivalent –names of variables don’t matter.

EG: x y Q (x,y ) and y x Q (x,y ) are not!

Page 33: Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag.

L4 35

DeMorgan RevisitedRecall DeMorgan’s identities:

Conjunctional negation:(p1p2…pn) (p1p2…pn)

Disjunctional negation:(p1p2…pn) (p1p2…pn)

Since the quantifiers are the same as taking a bunch of AND’s () or OR’s () we have:Universal negation:

x P(x ) x P(x )

Existential negation: x P(x ) x P(x )

Page 34: Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag.

L4 36

Negation Example

Compute: x y x2 yIn English, we are trying to find the opposite

of “every x admits a y greater or equal to x’s square”. The opposite is that “some x does not admit a y greater or equal to x’s square”

Algebraically, one just flips all quantifiers from to and vice versa, and negates the interior propositional function. In our case we get:

x y ( x 2 y ) x y x 2 > y

Page 35: Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag.

L4 37

Blackboard ExercisesSection 1.3

1.3.41) Show that the following are logically equivalent:(x A(x ))(x B(x ))

x,y A(x )B(y )

Page 36: Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag.

L4 38

Blackboard ExercisesSection 1.3

Need to show that (x A(x ))(x B(x ))x,y A(x )B(y )is a tautology, so LHS and RHS must

always have same truth values.

Page 37: Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag.

L4 39

Blackboard Exercises Section 1.3

(x A(x ))(x B(x ))x,y A(x )B(y )

CASE I) Assuming LHS true show RHS true.Either x A(x ) true OR x B(x ) trueCase I.A) For all x, A(x ) true.

As (T anything) = T, we can set anything = B(y) and obtain

For all x and y, A(x )B(y ) –the RHS!Case I.B) For all x, B(x ) true… similar to case (I.A)

Page 38: Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag.

L4 40

Blackboard Exercises Section 1.3

(x A(x ))(x B(x ))x,y A(x )B(y )

CASE II) Assume LHS false, show RHS false.Both x A(x ) false AND x B(x ) false.Thusx A(x ) true AND x B(x ) true.Thus there is an example x1 for which A(x1) is

false and an example x2 for which B(x2) is false.

As F F = F, we have A(x1)B(x2) false.

Setting x = x1 and y = x2 gives a counterexample to x,y A(x )B(y ) showing the RHS false.

//QED

Page 39: Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag.

L4 41

Section 1.4: Sets

DEF: A set is a collection of elements.This is another example where mathematics

must start at the level of intuition. Sets are the basic data structure out of which most mathematical theories are built. For many years mathematicians hoped that sets could be defined directly from logic, thus giving a full-proof foundation to Mathematics, when compared to other sciences. Effort failed!

Page 40: Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag.

L4 42

SetsCurly braces “{“ and “}” are used to denote

sets.Java note: In Java curly braces denote arrays,

a data-structure with inherent ordering. Mathematical sets are unordered so different from Java arrays. Java arrays require that all elements be of the same type. Mathematical sets don’t require this, however. EG: { 11, 12, 13 } { , , } { , , , 11, Leo }

Page 41: Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag.

L4 43

Sets

A set is defined only by the elements which it contains. Thus repeating an element, or changing the ordering of elements in the description of the set, does not change the set itself: { 11, 11, 11, 12, 13 } = { 11, 12, 13 } { , , } = { , , }

Page 42: Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag.

L4 44

Standard Numerical SetsThe natural numbers:N = { 0, 1, 2, 3, 4, … }

The integers:Z = { … -3, -2, -1, 0, 1, 2, 3, … }

The positive integers:Z+ = {1, 2, 3, 4, 5, … }

The real numbers: R --contains any decimal number of arbitrary precision The rational numbers: Q --these are decimal numbers whose decimal expansion repeats

Q: Give examples of numbers in R but not Q.

Page 43: Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag.

L4 45

Standard Numerical SetsA: number irrationalany or , π,,2 e

Page 44: Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag.

L4 46

-NotationThe Greek letter “” (epsilon) is used to denote that

an object is an element of a set. When crossed out “” denotes that the object is not an element.”

EG: 3 S reads:“3 is an element of the set S ”.

Q: Which of the following are true:1. 3 R2. -3 N3. -3 R4. 0 Z+

5. x xR x2=-5

Page 45: Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag.

L4 47

-Notation

A: 1, 3 and 41. 3 R. True: 3 is a real number.2. -3 N. False: natural numbers don’t

contain negatives.3. -3 R. True: -3 is a real number. 4. 0 Z+. True: 0 isn’t positive.

5. x xR x2=-5 . False: square of a real number is non-neg., so can’t be -5.

Page 46: Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag.

L4 48

-NotationDEF: A set S is said to be a subset of the set T iff

every element of S is also an element of T. This situation is denoted by

S TA synonym of “subset” is “contained by”.Definitions are often just a means of establishing

a logical equivalence which aids in notation. The definition above says that:

S T x (xS ) (xT )We already had all the necessary concepts, but

the “” notation saves work.

Page 47: Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag.

L4 49

-NotationWhen “” is used instead of “”, proper

containment is meant. A subset S of T is said to be a proper subset if S is not equal to T. Notationally:

S T S T x (x S xT )

Q: What algebraic symbol is reminiscent of?

Page 48: Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag.

L4 50

-NotationA: is to , as < is to .

Page 49: Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag.

L4 51

The Empty Set

The empty set is the set containing no elements. This set is also called the null set and is denoted by: {}

Page 50: Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag.

L4 52

Subset Examples

Q: Which of the following are true:1. N R2. Z N 3. -3 R4. {1,2} Z+

5. 6.

Page 51: Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag.

L4 53

Subset Examples

A: 1, 4 and 51. N R. All natural numbers are real.2. Z N. Negative numbers aren’t natural.3. -3 R. Nonsensical. -3 is not a subset but an

element! (This could have made sense if we viewed -3 as a set –which in principle is the case– in this case the proposition is false).

4. {1,2} Z+. This actually makes sense. The set {1,2} is an object in its own right, so could be an element of some set; however, {1,2} is not a number, therefore is not an element of Z.

5. . Any set contains itself.6. . No set can contain itself properly.

Page 52: Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag.

L4 54

Cardinality

The cardinality of a set is the number of distinct elements in the set. |S | denotes the cardinality of S.

Q: Compute each cardinality.1. |{1, -13, 4, -13, 1}|2. |{3, {1,2,3,4}, }|3. |{}|4. |{ {}, {{}}, {{{}}} }|

Page 53: Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag.

L4 55

Cardinality

Hint: After eliminating the redundancies just look at the number of top level commas and add 1 (except for the empty set).

A:1. |{1, -13, 4, -13, 1}| = |{1, -13, 4}| = 32. |{3, {1,2,3,4}, }| = 3. To see this, set S =

{1,2,3,4}. Compute the cardinality of {3,S, }

3. |{}| = || = 04. |{ {}, {{}}, {{{}}} }|

= |{ , {}, {{}}| = 3

Page 54: Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag.

L4 56

Cardinality

DEF: The set S is said to be finite if its cardinality is a nonnegative integer. Otherwise, S is said to be infinite.

EG: N, Z, Z+, R, Q are each infinite.

Note: We’ll see later that not all infinities are the same. In fact, R will end up having a bigger infinity-type than N, but surprisingly, N has same infinity-type as Z, Z+, and Q.

Page 55: Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag.

L4 57

Power Set

DEF: The power set of S is the set of all subsets of S.

Denote the power set by P (S ) or by 2s .

The latter weird notation comes from the following.

Lemma: | 2s | = 2|s|

Page 56: Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag.

L4 58

Power Set –ExampleTo understand the previous fact consider

S = {1,2,3}Enumerate all the subsets of S :0-element sets: {} 1 1-element sets: {1}, {2}, {3} +32-element sets: {1,2}, {1,3}, {2,3} +33-element sets: {1,2,3} +1Therefore: | 2s | = 8 = 23 = 2|s|

Page 57: Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag.

L4 59

Ordered n-tuplesNotationally, n-tuples look like sets except

that curly braces are replaced by parentheses:

( 11, 12 ) –a 2-tuple aka ordered pair ( , , ) –a 3-tuple ( , , , 11, Leo ) –a 5-tuple

Java: n -tuples are similar to Java arrays “{…}”, except that type-mixing isn’t allowed in Java.

Page 58: Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag.

L4 60

Ordered n-tuples

As opposed to sets, repetition and ordering do matter with n-tuples. (11, 11, 11, 12, 13) ( 11, 12, 13 ) ( , , ) ( , , )

Page 59: Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag.

L4 61

Cartesian ProductThe most famous example of 2-tuples are points

in the Cartesian plane R2. Here ordered pairs (x,y) of elements of R describe the coordinates of each point. We can think of the first coordinate as the value on the x-axis and the second coordinate as the value on the y-axis.

DEF: The Cartesian product of two sets A and B –denoted by A B– is the set of all ordered pairs (a, b) where aA and bB .

Q: Describe R2 as the Cartesian product of two sets.

Page 60: Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag.

L4 62

Cartesian ProductA: R2 = RR. I.e., the Cartesian plane is

formed by taking the Cartesian product of the x-axis with the y-axis.

One can generalize the Cartesian product to several sets simultaneously.

Q: If A = {1,2}, B = {3,4}, C = {5,6,7}what is A B C ?

Page 61: Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag.

L4 63

Cartesian ProductA: A = {1,2}, B = {3,4}, C = {5,6,7}A B C ={ (1,3,5), (1,3,6), (1,3,7),

(1,4,5), (1,4,6), (1,4,7), (2,3,5), (2,3,6), (2,3,7), (2,4,5), (2,4,6), (2,4,7) }

Lemma: The cardinality of the Cartesian product is the product of the cardinalities:

| A1 A2 … An | = |A1||A2| … |An| Q: What does S equal?

Page 62: Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag.

L4 64

Cartesian ProductA: From the lemma:

|S | = |||S | = 0|S | = 0There is only one set with no elements

–the empty set– therefore, S must be the empty set .

One can also check this directly from the definition of the Cartesian product.

Page 63: Copyright © Zeph Grunschlag, 2001-2002. Lecture 4: Predicates and Quantifiers; Sets. Zeph Grunschlag.

L4 65

Blackboard ExerciseSection 1.4

Prove the following:If A B and B C then A C .