SlideShare a Scribd company logo
1 of 13
Download to read offline
Sets & Relations
Basics of Sets
Relational Database
Queries to the DB are set/logical operations
SELECT x
FROM Likes
WHERE y=‘Alice’ OR y=‘Flamingo’
{ x | (x,Alice) ∈ Likes } ∪ { x | (x,Flamingo) ∈ Likes }
x y Likes(x,y)
Alice
Alice TRUE
Jabberwock FALSE
Flamingo TRUE
Jabberwock
Alice FALSE
Jabberwock TRUE
Flamingo FALSE
Flamingo
Alice FALSE
Jabberwock FALSE
Flamingo TRUE
Likes
x y
Alice Alice
Alice Flamingo
Jabberwock Jabberwock
Flamingo Flamingo
Relational DB Table
Sets & Relations
in action
Sets: Basics
Unordered collection of “elements”
e.g.: Z, R (infinite sets), Ø (empty set), {1, 2, 5}, ...
Will always be given an implicit or explicit universe (universal set)
from which the elements come
(Aside: In developing the foundations of mathematics, often one
starts from “scratch”, using only set theory to create the
elements themselves)
Set membership: e.g. 0.5 ∈ R, 0.5 ∉ Z, Ø ∉ Z
Set inclusion: e.g. Z, ⊆ R, Ø ⊆ Z
Set operations: complement, union, intersection, difference
Set Operations
S̅
S ∩ T
S - T
S ∪ T
S
T
Sets as Predicates
Given a predicate can define the set of elements for which it holds
WingedSet = { x | Winged(x) } = {J’wock, Flamingo}
FliesSet = { x | Flies(x) } = {J’wock, Flamingo}
PinkSet = { x | Pink(x) } = {Flamingo}
Conversely, given a set, can define a membership predicate for it
e.g. given set Club = {Alice, Flamingo}. Then, define predicate
inClub(x) s.t. inClub(x) = True iff x ∈ Club
x Winged(x) Flies(x) Pink(x)
Alice FALSE FALSE FALSE
Jabberwock TRUE TRUE FALSE
Flamingo TRUE TRUE TRUE
inClub(x)
TRUE
FALSE
TRUE
Binary operators
Set Operations
S complement
Symbol:
in (x) ≡ ¬inS(x)
S
S
S union T
Symbol: S∪T
inS∪T(x)
≡ inS(x) ∨ inT(x)
S intersection T
Symbol: S ∩ T
inS∩T(x)
≡ inS(x) ∧ inT(x)
S difference T
Symbol: S - T
(Alternately: ST)
Unary operator
Binary operator.
Creates a new proposition
out of two
Binary operators
inS-T(x)
≡ inS(x) ∧ ¬inT(x)
≡ inS(x) ↛ inT(x))
Binary operators
Note: Notation inS(x) used only to explicate the connection
with predicate logic. Will always write x∈S later.
S symmetric diff. T
Symbol: S Δ T
inSΔT(x)
≡ inS(x) ⊕ inT(x)
Binary operators
Associative
S-T = S∩T
S ∪ T = S ∩ T
S ∩ T = S ∪ T
x∈ ≡ ¬(x∈S∪T)
≡ ¬(x∈S ∨ x∈T) ≡ ¬(x∈S) ∧ ¬(x∈T)
≡ x∈ ∧ x∈ ≡ x ∈
S∪T
S T S∩T
De Morgan’s Laws
S ∪ T
T
S
x∈ ≡ ¬(x∈S∩T)
≡ ¬(x∈S ∧ x∈T) ≡ ¬(x∈S) ∨ ¬(x∈T)
≡ x∈ ⋁ x∈ ≡ x ∈
S∩T
S T S∪T
S ∩ T
∪
S T
∩
S T
S T
Distributivity
R ∩ (S ∪ T) = (R ∩ S) ∪ (R ∩ T)
R ∪ (S ∩ T) = (R ∪ S) ∩ (R ∪ T)
x ∈ R∩(S∪T) ≡
≡ x∈R ∧ (x∈S ∨ x∈T) ≡ (x∈R ∧ x∈S) ∨ (x∈R ∧ x∈T)
≡ x∈ (R∩S) ∪ (R∩T)
x ∈ R∪(S∩T) ≡
≡ x∈R ∨ (x∈S ∧ x∈T) ≡ (x∈R ∨ x∈S) ∧ (x∈R ∨ x∈T)
≡ x∈ (R∪S) ∩ (R∪T)
Set Inclusion
PinkSet ⊆ FliesSet = WingedSet
S ⊆ T same as the proposition ∀x x∈S → x∈T
S ⊇ T same as the proposition ∀x x∈S ← x∈T
S = T same as the proposition ∀x x∈S ↔ x∈T
x Winged(x) Flies(x) Pink(x)
Alice FALSE FALSE FALSE
Jabberwock TRUE TRUE FALSE
Flamingo TRUE TRUE TRUE
Set Inclusion
S ⊆ T same as the proposition ∀x x∈S → x∈T
If S = Ø, and T any arbitrary set, S ⊆ T
∀x, vacuously we have x∈S → x∈T
If S⊆T and T⊆R, then S⊆R
Consider arbitrary x∈S. Since S⊆T, x∈T. Then since T⊆R, x∈R.
S ⊆ T ⟷ ⊆
∀x x∈S → x∈T ≡ ∀x x∉T → x∉S (contrapositive)
≡ ∀x x∈ → x∈
T S
T S
If no such x, already done
Proving Set Equality
To prove S = T, show S ⊆ T and T ⊆ S
e.g., L(a,b) = { x : ∃u,v ∈ Z x=au+bv }
M(a,b) = { x : ( gcd(a,b) | x ) }
[Recall] Theorem: L(a,b) = M(a,b)
Proof in two parts:
L(a,b) ⊆ M(a,b) : i.e., ∀x∈Z x∈ L(a,b) → x∈ M(a,b)
M(a,b) ⊆ L(a,b) : i.e., ∀x∈Z x∈ M(a,b) → x∈ L(a,b)
Let x=au+bv.
g|a, g|b g|x
First show that
g∈L(a,b)
(as the smallest +ve
element in L(a,b))
Let x=ng. But
g=au+bv x=au’+bv’
Inclusion-Exclusion
|S| + |T| counts every element that is in S or in T
But it double counts the number of elements that are in both:
i.e., elements in S∩T
So, |S|+|T| = |S∪T| + |S∩T|
Or, |S∪T| = |S| + |T| - |S∩T|
|R∪S∪T| = |R|+|S|+|T| - |R∩S| - |S∩T| - |T∩R| + |R∩S∩T|
|R∪S∪T| = |R| + |S∪T| - |R∩(S∪T)|
= |R| + |S∪T| - |(R∩S)∪(R∩T)|
= |R| + |S| + |T| - |S∩T|
-( |R∩S| + |R∩T| - |R∩S∩T| )
◆ ◆
◆
◆
◆
◆
◆
S T
◆ ◆
◆
◆
◆
◆
◆
S T
R
◆
Cartesian Product
S × T = { (s,t) | s∈S and t∈T }
(S= Ø ∨ T= Ø) ↔ S × T = Ø
|S × T| = |S|⋅|T|
R × S × T = { (r,s,t) | r∈R, s∈S, t∈T }
Not the same as (R × S) × T (but “essentially” the same)
(A∪B) × C = (A×C) ∪ (B×C). Also, (A∩B) × C = (A×C) ∩ (B×C)
(A∪B) × (C∪D) = (A×(C∪D)) ∪ (B×(C∪D))
= (A×C) ∪ (A×D) ∪ (B×C) ∪ (B×D)
Complement: = ?
( × ) ∪ ( ×T) ∪ (S× )
S × T
S T S T
{ ((r,s),t) | r∈R, s∈S, t∈T }
S
T
S×T
A
C
S
S
T T
B
D

More Related Content

Similar to 04-Sets-Relations-A.pdf

Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and ScalaFolding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and ScalaPhilip Schwarz
 
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - with ...
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - with ...Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - with ...
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - with ...Philip Schwarz
 
Interval valued intuitionistic fuzzy homomorphism of bf algebras
Interval valued intuitionistic fuzzy homomorphism of bf algebrasInterval valued intuitionistic fuzzy homomorphism of bf algebras
Interval valued intuitionistic fuzzy homomorphism of bf algebrasAlexander Decker
 
Truth, deduction, computation lecture h
Truth, deduction, computation   lecture hTruth, deduction, computation   lecture h
Truth, deduction, computation lecture hVlad Patryshev
 
Binary Operations.pptx
Binary Operations.pptxBinary Operations.pptx
Binary Operations.pptxSoyaMathew1
 
17 integrals of rational functions x
17 integrals of rational functions x17 integrals of rational functions x
17 integrals of rational functions xmath266
 
Relations & functions
Relations & functionsRelations & functions
Relations & functionsindu thakur
 
FINAL PROJECT, MATH 251, FALL 2015[The project is Due Mond.docx
FINAL PROJECT, MATH 251, FALL 2015[The project is Due Mond.docxFINAL PROJECT, MATH 251, FALL 2015[The project is Due Mond.docx
FINAL PROJECT, MATH 251, FALL 2015[The project is Due Mond.docxvoversbyobersby
 

Similar to 04-Sets-Relations-A.pdf (20)

Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and ScalaFolding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala
 
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - with ...
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - with ...Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - with ...
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - with ...
 
Sets.pdf
Sets.pdfSets.pdf
Sets.pdf
 
Aed.pptx
Aed.pptxAed.pptx
Aed.pptx
 
2 homework
2 homework2 homework
2 homework
 
Random Variable
Random Variable Random Variable
Random Variable
 
set theory --.pptx
set theory --.pptxset theory --.pptx
set theory --.pptx
 
Interval valued intuitionistic fuzzy homomorphism of bf algebras
Interval valued intuitionistic fuzzy homomorphism of bf algebrasInterval valued intuitionistic fuzzy homomorphism of bf algebras
Interval valued intuitionistic fuzzy homomorphism of bf algebras
 
3 mal1
3 mal13 mal1
3 mal1
 
discrete maths notes.ppt
discrete maths notes.pptdiscrete maths notes.ppt
discrete maths notes.ppt
 
Truth, deduction, computation lecture h
Truth, deduction, computation   lecture hTruth, deduction, computation   lecture h
Truth, deduction, computation lecture h
 
Set theory
Set theorySet theory
Set theory
 
05 - Relations
05 - Relations05 - Relations
05 - Relations
 
WEEK-1.pdf
WEEK-1.pdfWEEK-1.pdf
WEEK-1.pdf
 
Binary Operations.pptx
Binary Operations.pptxBinary Operations.pptx
Binary Operations.pptx
 
Lec2 slides
Lec2 slidesLec2 slides
Lec2 slides
 
17 integrals of rational functions x
17 integrals of rational functions x17 integrals of rational functions x
17 integrals of rational functions x
 
Relations & functions
Relations & functionsRelations & functions
Relations & functions
 
FINAL PROJECT, MATH 251, FALL 2015[The project is Due Mond.docx
FINAL PROJECT, MATH 251, FALL 2015[The project is Due Mond.docxFINAL PROJECT, MATH 251, FALL 2015[The project is Due Mond.docx
FINAL PROJECT, MATH 251, FALL 2015[The project is Due Mond.docx
 
Per6 basis2_NUMBER SYSTEMS
Per6 basis2_NUMBER SYSTEMSPer6 basis2_NUMBER SYSTEMS
Per6 basis2_NUMBER SYSTEMS
 

Recently uploaded

(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 

Recently uploaded (20)

(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 

04-Sets-Relations-A.pdf

  • 2. Relational Database Queries to the DB are set/logical operations SELECT x FROM Likes WHERE y=‘Alice’ OR y=‘Flamingo’ { x | (x,Alice) ∈ Likes } ∪ { x | (x,Flamingo) ∈ Likes } x y Likes(x,y) Alice Alice TRUE Jabberwock FALSE Flamingo TRUE Jabberwock Alice FALSE Jabberwock TRUE Flamingo FALSE Flamingo Alice FALSE Jabberwock FALSE Flamingo TRUE Likes x y Alice Alice Alice Flamingo Jabberwock Jabberwock Flamingo Flamingo Relational DB Table Sets & Relations in action
  • 3. Sets: Basics Unordered collection of “elements” e.g.: Z, R (infinite sets), Ø (empty set), {1, 2, 5}, ... Will always be given an implicit or explicit universe (universal set) from which the elements come (Aside: In developing the foundations of mathematics, often one starts from “scratch”, using only set theory to create the elements themselves) Set membership: e.g. 0.5 ∈ R, 0.5 ∉ Z, Ø ∉ Z Set inclusion: e.g. Z, ⊆ R, Ø ⊆ Z Set operations: complement, union, intersection, difference
  • 4. Set Operations S̅ S ∩ T S - T S ∪ T S T
  • 5. Sets as Predicates Given a predicate can define the set of elements for which it holds WingedSet = { x | Winged(x) } = {J’wock, Flamingo} FliesSet = { x | Flies(x) } = {J’wock, Flamingo} PinkSet = { x | Pink(x) } = {Flamingo} Conversely, given a set, can define a membership predicate for it e.g. given set Club = {Alice, Flamingo}. Then, define predicate inClub(x) s.t. inClub(x) = True iff x ∈ Club x Winged(x) Flies(x) Pink(x) Alice FALSE FALSE FALSE Jabberwock TRUE TRUE FALSE Flamingo TRUE TRUE TRUE inClub(x) TRUE FALSE TRUE
  • 6. Binary operators Set Operations S complement Symbol: in (x) ≡ ¬inS(x) S S S union T Symbol: S∪T inS∪T(x) ≡ inS(x) ∨ inT(x) S intersection T Symbol: S ∩ T inS∩T(x) ≡ inS(x) ∧ inT(x) S difference T Symbol: S - T (Alternately: ST) Unary operator Binary operator. Creates a new proposition out of two Binary operators inS-T(x) ≡ inS(x) ∧ ¬inT(x) ≡ inS(x) ↛ inT(x)) Binary operators Note: Notation inS(x) used only to explicate the connection with predicate logic. Will always write x∈S later. S symmetric diff. T Symbol: S Δ T inSΔT(x) ≡ inS(x) ⊕ inT(x) Binary operators Associative S-T = S∩T
  • 7. S ∪ T = S ∩ T S ∩ T = S ∪ T x∈ ≡ ¬(x∈S∪T) ≡ ¬(x∈S ∨ x∈T) ≡ ¬(x∈S) ∧ ¬(x∈T) ≡ x∈ ∧ x∈ ≡ x ∈ S∪T S T S∩T De Morgan’s Laws S ∪ T T S x∈ ≡ ¬(x∈S∩T) ≡ ¬(x∈S ∧ x∈T) ≡ ¬(x∈S) ∨ ¬(x∈T) ≡ x∈ ⋁ x∈ ≡ x ∈ S∩T S T S∪T S ∩ T ∪ S T ∩ S T S T
  • 8. Distributivity R ∩ (S ∪ T) = (R ∩ S) ∪ (R ∩ T) R ∪ (S ∩ T) = (R ∪ S) ∩ (R ∪ T) x ∈ R∩(S∪T) ≡ ≡ x∈R ∧ (x∈S ∨ x∈T) ≡ (x∈R ∧ x∈S) ∨ (x∈R ∧ x∈T) ≡ x∈ (R∩S) ∪ (R∩T) x ∈ R∪(S∩T) ≡ ≡ x∈R ∨ (x∈S ∧ x∈T) ≡ (x∈R ∨ x∈S) ∧ (x∈R ∨ x∈T) ≡ x∈ (R∪S) ∩ (R∪T)
  • 9. Set Inclusion PinkSet ⊆ FliesSet = WingedSet S ⊆ T same as the proposition ∀x x∈S → x∈T S ⊇ T same as the proposition ∀x x∈S ← x∈T S = T same as the proposition ∀x x∈S ↔ x∈T x Winged(x) Flies(x) Pink(x) Alice FALSE FALSE FALSE Jabberwock TRUE TRUE FALSE Flamingo TRUE TRUE TRUE
  • 10. Set Inclusion S ⊆ T same as the proposition ∀x x∈S → x∈T If S = Ø, and T any arbitrary set, S ⊆ T ∀x, vacuously we have x∈S → x∈T If S⊆T and T⊆R, then S⊆R Consider arbitrary x∈S. Since S⊆T, x∈T. Then since T⊆R, x∈R. S ⊆ T ⟷ ⊆ ∀x x∈S → x∈T ≡ ∀x x∉T → x∉S (contrapositive) ≡ ∀x x∈ → x∈ T S T S If no such x, already done
  • 11. Proving Set Equality To prove S = T, show S ⊆ T and T ⊆ S e.g., L(a,b) = { x : ∃u,v ∈ Z x=au+bv } M(a,b) = { x : ( gcd(a,b) | x ) } [Recall] Theorem: L(a,b) = M(a,b) Proof in two parts: L(a,b) ⊆ M(a,b) : i.e., ∀x∈Z x∈ L(a,b) → x∈ M(a,b) M(a,b) ⊆ L(a,b) : i.e., ∀x∈Z x∈ M(a,b) → x∈ L(a,b) Let x=au+bv. g|a, g|b g|x First show that g∈L(a,b) (as the smallest +ve element in L(a,b)) Let x=ng. But g=au+bv x=au’+bv’
  • 12. Inclusion-Exclusion |S| + |T| counts every element that is in S or in T But it double counts the number of elements that are in both: i.e., elements in S∩T So, |S|+|T| = |S∪T| + |S∩T| Or, |S∪T| = |S| + |T| - |S∩T| |R∪S∪T| = |R|+|S|+|T| - |R∩S| - |S∩T| - |T∩R| + |R∩S∩T| |R∪S∪T| = |R| + |S∪T| - |R∩(S∪T)| = |R| + |S∪T| - |(R∩S)∪(R∩T)| = |R| + |S| + |T| - |S∩T| -( |R∩S| + |R∩T| - |R∩S∩T| ) ◆ ◆ ◆ ◆ ◆ ◆ ◆ S T ◆ ◆ ◆ ◆ ◆ ◆ ◆ S T R ◆
  • 13. Cartesian Product S × T = { (s,t) | s∈S and t∈T } (S= Ø ∨ T= Ø) ↔ S × T = Ø |S × T| = |S|⋅|T| R × S × T = { (r,s,t) | r∈R, s∈S, t∈T } Not the same as (R × S) × T (but “essentially” the same) (A∪B) × C = (A×C) ∪ (B×C). Also, (A∩B) × C = (A×C) ∩ (B×C) (A∪B) × (C∪D) = (A×(C∪D)) ∪ (B×(C∪D)) = (A×C) ∪ (A×D) ∪ (B×C) ∪ (B×D) Complement: = ? ( × ) ∪ ( ×T) ∪ (S× ) S × T S T S T { ((r,s),t) | r∈R, s∈S, t∈T } S T S×T A C S S T T B D