cse 311: foundations of computing

21
CSE 311: Foundations of Computing Fall 2013 Lecture 9: Set theory and functions

Upload: brynn-savage

Post on 01-Jan-2016

26 views

Category:

Documents


0 download

DESCRIPTION

CSE 311: Foundations of Computing. Fall 2013 Lecture 9: Set theory and functions. announcements. Reading assignment Set theory 2.1-2.3 (both editions). set theory. Formal treatment dates from late 19 th century Direct ties between set theory and logic Important foundational language. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: CSE 311: Foundations of Computing

CSE 311: Foundations of Computing

Fall 2013Lecture 9: Set theory and functions

Page 2: CSE 311: Foundations of Computing

announcements

Reading assignmentSet theory2.1-2.3 (both editions)

Page 3: CSE 311: Foundations of Computing

set theory

• Formal treatment dates from late 19th century

• Direct ties between set theory and logic• Important foundational language

Page 4: CSE 311: Foundations of Computing

definition: a set is an unordered collection of objects

: “x is an element of A” “x is a member of A” “x is in A” : ()

𝐴=\{1 ,2 ,7 , cat , dog ,𝜑 ,𝛼 }

cat∈𝐴fish∉𝐴

Page 5: CSE 311: Foundations of Computing

definitions

• A and B are equal if they have the same elements

• A is a subset of B if every element of A is also in B

A = B x (x A x B)

A B x (x A x B)

Page 6: CSE 311: Foundations of Computing

empty set and power set

• Empty set does not contain any elements

• Power set of a set A = set of all subsets of A 𝒫 (𝐴 )={𝐵 :𝐵⊆ 𝐴}

Page 7: CSE 311: Foundations of Computing

cartesian product

𝐴×𝐵={(𝑎 ,𝑏):𝑎∈𝐴 ,𝑏∈𝐵 }

Page 8: CSE 311: Foundations of Computing

set operations

𝐴∪𝐵={𝑥 : (𝑥∈𝐴 )∨ (𝑥  ∈𝐵 ) }

𝐴∩𝐵={𝑥 : (𝑥∈𝐴 )∧ (𝑥∈𝐵 )}

𝐴⊕𝐵={𝑥 : (𝑥∈𝐴 )⊕ (𝑥∈𝐵 ) }

𝐴−𝐵={𝑥 : (𝑥∈ 𝐴)∧ (𝑥∉𝐵 )}

(with respect to universe U)

union

intersection

set difference

symmetric difference

complement

Page 9: CSE 311: Foundations of Computing

it’s Boolean algebra again

• Definition for based on

• Definition for based on

• Complement works like

Page 10: CSE 311: Foundations of Computing

De Morgan’s Laws

Proof technique:To show C = D showx C x D andx D x C

𝐴∪𝐵=𝐴∩𝐵

𝐴∩𝐵=𝐴∪𝐵

Page 11: CSE 311: Foundations of Computing

distributive laws

C

A B

C

A B

Page 12: CSE 311: Foundations of Computing

representing sets using bits

• Suppose universe is • Can represent set as a vector of bits: where when

when – Called the characteristic vector of set B

• Given characteristic vectors for and – What is characteristic vector for ? ?

Page 13: CSE 311: Foundations of Computing

bitwise operations on vectors

01101101 Java: z=x|y 00110111   01111111

00101010         Java: z=x&y    00001111   00001010

01101101 Java: z=x^y

  00110111   01011010

Page 14: CSE 311: Foundations of Computing

a simple identity

• If x and y are bits: (x y) y = ?

• What if x and y are bit-vectors?

Page 15: CSE 311: Foundations of Computing

private key cryptography

• Alice wants to communicate message secretly to Bob so that eavesdropper Eve who hears their conversation cannot tell what Alice’s message is.

• Alice and Bob can get together and privately share a secret key K ahead of time.

Page 16: CSE 311: Foundations of Computing

one-time pad

• Alice and Bob privately share random n-bit vector K – Eve does not know K

• Later, Alice has n-bit message m to send to Bob– Alice computes C = m K– Alice sends C to Bob– Bob computes m = C K which is (m K) K

• Eve cannot figure out m from C unless she can guess K

Page 17: CSE 311: Foundations of Computing

unix/linux file permissions

• ls –l drwxr-xr-x ... Documents/ -rw-r--r-- ... file1

• Permissions maintained as bit vectors– Letter means bit is 1 – “--” means bit is 0.

Page 18: CSE 311: Foundations of Computing

russell’s paradox

𝑆={𝑥 :𝑥∉𝑥 }

Page 19: CSE 311: Foundations of Computing

functions review

• A function from to • an assignment of exactly one element of to each element of . • We write .• “Image of a” =

• Domain of :

• Range of = set of all images of elements of

Page 20: CSE 311: Foundations of Computing

image, preimage

a

b

c

d

e

1

2

3

4

Page 21: CSE 311: Foundations of Computing

is this a function? one-to-one? onto?

a

b

c

d

e

1

2

3

4

5

6