Download presentation
Presentation is loading. Please wait.
Published byEgbert Townsend Modified over 9 years ago
1
Sets
2
Definitions (I) Collection of elements such that: There are no duplicates There is no order Special sets Universe (U or E): all elements under consideration Empty set ({ } or ): set with no elements NZR Others: N, Z, R, etc. Notation { } Enumeration: {1, 2, 3}, {1, 2, …}, {1, 2, …, 100}, etc. N Set building: { x | P(x) } all elements in E that satisfy property P (e.g., { x in N | x>5 x<10 } = {6, 7, 8, 9}
3
Definitions (II) Element of: x A Cardinality: |A| = size or number of elements in A Set Equality A = B iff A and B have the same elements A = B x A x B Subset/Superset A B x A x B (subset or equal) A B A B x(x B x A) (proper subset)
4
Set Operations: Intersection A B {x | x A x B} Example: {1, 2, 3} {2, 3, 4} = {2, 3} Prove: A B A By definition, A B A x A B x A 1. x Anegate conclusion 2. x A Bpremise 3. x A x Bdef of 4. x A3, simplification 5. x A x A1&4, conjunction 6. F5, contradiction Proof by contradiction AB
5
Set Operations: Union A B {x | x A x B} Example: {1, 2, 3} {2, 3, 4} = {1, 2, 3, 4} No duplicates! Prove: A A B By definition, A A B x A x A x B 1. x A premise 2. x A x B1, law of addition AB
6
Set Operations: Difference A – B {x | x A x B} Example: {1, 2, 3} – {2, 3, 4} = {1} Remove elements of B from A Prove: A – B A By definition, A – B A x A–B x A 1. x A – B premise 2. x A x B definition 3. x A simplification AB
7
Set Operations: Complement ~ A E – A {x | x E x A} Example: ~{1, 2, 3} = {4} if E = {1, 2, 3, 4} Prove: A ~A = A ~A = A ~A A ~A set equality A ~A T is subset of every set A ~A identity x A x ~A x def of and x A x E x A x def of ~ F x comm., contradict., dominat. T A
8
Basic Set Laws Set AlgebraName A ~A = E A ~A = Complementation law Exclusion law A E = A A = A Identity laws A E = E A = Domination laws A A = A A A = A Idempotent laws Duals: and E
9
Basic Set Identities (continued…) Set AlgebraName ~(~A) = A Double Compl. A B = B A A B = B A Commutative laws (A B) C = A (B C) (A B) C = A (B C) Associative laws A (B C) = (A B) (A C) A (B C) = (A B) (A C) Distributive laws ~ (A B) = ~A ~B ~ (A B) = ~A ~B De Morgan’s laws
10
Example: Set Laws Absorption A (A B) = A A (A B) = A Venn Diagram “Proof” Direct Proof A (A B) = (A ) (A B)ident. = A ( B)distrib. = A dominat. = Aident. AB
11
Practice Exercises PE1 Prove that if R is a subset of S and S is a subset of T, then R is a subset of T. ------------------ PE2 Prove De Morgan's law for sets (do not use a Venn diagram): ~ (A B) = ~A ~B
12
Tuples Collection of elements, such that: All elements are ordered Notation: ( ) (x 1, x 2, …, x n ) Tuples of 2 elements are known as pairs Typically, elements are taken from known sets x females, y males (Mary, Jim) – might mean: Mary and Jim are a married couple x people, y cars (Mary, red sports car 17 ) – might mean: Mary owns red sports car 17 x, y, z integers (3, 4, 7) – might mean: 3 + 4 = 7
13
Cartesian/Cross Product A 1 … A n = {(x 1, …, x n ) | x A 1 … x n A n } Example: A = {1, 2}, B = {a, b, c} A B = {(1, a), (1, b), (1, c), (2, a), (2, b), (2, c)} A = {1, 2}, B = {a, b, c}, C = { , } A B C = {(1,a, ), (1,a, ), (1,b, ), (1,b, ), (1,c, ), (1,c, ), (2,a, ), (2,a, ), (2,b, ), (2,b, ), (2,c, ), (2,c, )} |A 1 … A n | = |A 1 | … |A n | Can get large: A = set of students at BYU(30,000) B = set of BYU student addresses(10,000) C = set of BYU student phone#’s(60,000) |A| |B| |C| = 1.8 10 13
14
Relations Relation Subset of the cross product Examples: A = {1, 2} & B = {a, b, c} R = {(1, a), (2, b), (2, c)} A = {1, 2} & B = {a, b, c} & C = { , } R = {(1, a, ), (2, c, )} Marriage: subset of the cross product of males and females If 2 sets, the relation is binary
15
Functions
16
A function is a special kind of binary relation A binary relation f A B is a function if for each a A there is a unique b B Function Definition 1 2 3 α β γ x y
17
NOT Functions 1 2 3 α β γ f = {(1, α), (2, β)} “For each” violated Some x’s do not have corresponding y’s x y
18
NOT Functions Uniqueness violated for some x’s x y 1 2 3 α β γ f = {(1, α), (2, β), (3, β), (3, γ)} uniqueness violated for 3 appears twice
19
Functions with N-Dimensional Domains An (n+1)-ary relation f A 1 A 2 … A n B is a function if for each A 1 A 2 … A n there is a unique b B. α β γ
20
We can use various notation for functions: for f = {(1, α),(2, β),(3, β)} Notation for Functions Notation (x, y) f f : x→yy = f(x) Example (2, β) f f : 2→ββ = f(2) In the notation, x is the argument or preimage and y is the image. For functions with n-ary domains, use in place of x.
21
Function Domain and Range f : A → B A is the domain space same as the domain (since all elements participate) dom f, dom(f), or domain(f) B is the range space may or may not be the same as the range, which is: {y | x(y=f(x))} All rhs values in pairs (all that get “hit”) B f ran f, ran(f), range(f) f : D 1 D 2 … D n → Z f : D n → Z (when all domains are the same)
22
Remove the requirement that each a A must participate. Retain the uniqueness requirement. Partial Functions Partial Function: α β γ f = {(, β),(, β),(, γ)} not unique α β γ NOT a Partial Function: α β γ Partial Function: (A Total Function is also a Partial Function.)
23
Identity Function I A : A → A I A = {(x, x) | x A} Constant Function C : A → B C = {(x, c) | x A c B } Often A and B are the same C : A → A C= {(x, c) | x A c A} Special Functions
24
Composition of Functions Composition is written “°” Range space of f = domain space of g a c 1 2 4 f g b α β 3 f(a) = 2g(2) = αg(f(a)) = α g ° f(a) = α f(b) = 2g(2) = αg(f(b)) = α g ° f(b) = α f(c) = 4g(4) = βg(f(c)) = β g ° f(c) = β
25
Injection: “one-to-one” or “1-1” x y(f(x) = f(y) x = y) For f : A → B, the elements in B are “ hit ” at most once Injection a b d 1 2 3 c Injective a b d 1 2 3 c NOT Injective x y x y
26
Surjection: “onto” y x(y = f(x)) For f : A → B, the elements in B are all “ hit ” at least once Surjection 1 2 4 a b c 3 SurjectiveNOT Surjective x y x y 1 2 4 a b c 3 { not “hit”
27
Bijection: “one-to-one and onto” or “1-1 correspondence” x y(f(x) = f(y) x = y) y x(y = f(x)) For f : A → B, every B element is “ hit ” once and only once Bijection 1 2 a b c 3 BijectiveNOT Bijective x y x y 1 2 4 a b c 3 NOT Surjective NOT injective
28
Notes on Bijection 1.|A| = |B| An “extra” B cannot be “hit” (not a surjection) An “extra” A requires that at least one B must be “hit” twice (not an injection) 2.If f is a bijection, swapping the elements of the ordered pairs is a function Called the inverse Denoted f -1 Is also a bijection f -1 (f(x)) is the identity function, i.e. f -1 (f(x)) = x.
29
Practice Exercises PE1 If A={a,b,c,d}, are the following functions from A to A injective, surjective or bijective? {(d, a), (d, c), (b, b), (b, d)} {(a, b), (b, b), (c, d), (d, d)} ------------------ PE2 If f(x)=2x+3 and g(x)=x-3, what is g°f? ------------------ PE3 Which is the larger set? E (even numbers)vs.O (odd numbers) N (natural numbers)vs.Z (integers) N (natural numbers)vs.[0,1] (real numbers between 0 and 1)
30
NZ Which is bigger? N or Z? f(x) = x odd: (x+1)/−2 x even: x/2 y negative: −2x−1 y positive: 2x g(y) = { { x y 0 0 1 −1 2 1 3 −2 4 2 NZNZ Since g = f −1, there is a bijection from N to Z and thus |N| = |Z|
31
N[0,1] Which is bigger? N or [0,1]? N[0,1] Assume |N| = |[0,1]|, then there exists a bijection, e.g., 1 0.34234… 2 0.34987…diagonalization 3 0.00040… [0,1] But now, there exists a number in [0,1] such that d 1 = not 3, d 2 = not 4, d 3 = not 0, etc. Hence, not surjective and thus not bijective
32
ALL THAT THE FATHER HATH A Functional “Proof”
33
Language
34
Power Set Set of all subsets of a set A A = {1,2} P(A) = 2 A = { {}, {1}, {2}, {1,2} } Each element of A is either present (1) or not present (0) Treat the elements of A as a sequence (e.g., A={a,b,c,d}) Use bit-string representation to say which elements are present (e.g., 0110 means {b,c}) Can represent all subsets of A, from = 0000 to A = 1111 Number of subsets in power set | 2 A | = 2 · 2 · … · 2(|A| times) = 2 |A| Motivates the notation 2 A for the power set
35
Bit-String Operations With bit string representations Set intersection: = pairwise Set union: = pairwise Set complement: ~ = bit complement Set minus: – = mask out using 1’s = complement 2 nd operand and do pairwise E.g. using {a,b,c,d} 1011 1101 = 1001i.e. {a,c,d} {a,b,d} = {a,d} 1011 1101 = 1111i.e. {a,c,d} {a,b,d} = {a,b,c,d} ~1011 = 0100i.e. ~{a,c,d} = {b} 1010 – 1100 = 0010i.e. {a,c} – {a,b} = {c}
36
Practice Exercises PE1 What is the power set of {a, 1, x, 2} ? ------------------ PE2 What is the power set of (i.e., the empty set)? ------------------ PE3 What is the power set of { } (i.e., the set containing the empty set) ? ------------------ PE4 What is the power set of { a, { } } ?
37
Language Let V be a set of symbols, known as an alphabet or a vocabulary A string is any finite sequence of symbols from V Strings have length V n denotes the set of all strings of length n V * denotes the set of all strings, or sentences, over V A language L is a subset of V *, i.e., L V * Programming language Set of all possible programs (valid, very long string)
38
Language Representation Finite –Enumerate all sentences Infinite language –Cannot be specified by enumeration –Use a generative device, i.e., a grammar Specifies the set of all legal sentences Defined recursively (or inductively)
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.