Skip to main content

Engineering Mathematics

Sets, Relations & Functions

Master set identities, relation properties, and function counts so Discrete Maths MCQs and NATs become pattern recognition — then lock marks with GATE-style samples and flashcards.

~8 hrs High in Discrete Maths 10 samples · 10 practice · 10 cards

GATE CSE sets, relations, and functions — power sets, Cartesian products, equivalence relations, posets, lattices, injections/surjections, sample GATE questions, flashcards, and practice drills.

Learning outcomes

  • Apply set identities, power-set counts, and inclusion–exclusion under exam time
  • Classify relations as reflexive, symmetric, antisymmetric, transitive, equivalence, or poset
  • Count relations of each type on small sets and read relation matrices
  • Identify injective, surjective, and bijective functions and count them
  • Read Hasse diagrams and distinguish minimal/maximal vs least/greatest elements
  • Solve GATE-style sets/relations/functions MCQs with a clear explanation trail

Sets — core language

  • A set is a well-defined collection of distinct objects. GATE cares about cardinality, subsets, identities, and Venn counting — not axiomatic essays.
  • Subset A ⊆ B means every element of A is in B. Proper subset A ⊂ B means A ⊆ B and A ≠ B.
  • Power set P(A) = set of all subsets of A; |P(A)| = 2^n when |A| = n. Subsets of size k: C(n,k).
  • Universe U and complement A′ = U \ A. De Morgan: (A ∪ B)′ = A′ ∩ B′ and (A ∩ B)′ = A′ ∪ B′.
  • Distributive laws: A ∩ (B ∪ C) = (A ∩ B) ∪ (A ∩ C) and the dual with ∪/∩ swapped.

Formulas to remember

  • |P(A)| = 2^n if |A| = n
  • Number of k-subsets = C(n,k)
  • (A ∪ B)′ = A′ ∩ B′ ; (A ∩ B)′ = A′ ∪ B′

Worked example

Problem. If |A| = 5, how many subsets of A contain at least one element?

Solution. Total subsets = 2^5 = 32. Exclude ∅ → 31.

Cartesian products & counting with sets

  • A × B = {(a,b) | a ∈ A, b ∈ B}; |A × B| = |A|·|B|. A × A has n² ordered pairs when |A|=n.
  • Inclusion–exclusion (2 sets): |A ∪ B| = |A| + |B| − |A ∩ B|.
  • Three sets: add singles, subtract pairwise intersections, add the triple intersection.
  • “Only A” region in a Venn diagram: |A| − |A∩B| − |A∩C| + |A∩B∩C| (adjust to the stem).
  • Multiset / bag ideas are rare; assume distinct elements unless the stem says otherwise.

Formulas to remember

  • |A ∪ B| = |A| + |B| − |A ∩ B|
  • |A ∪ B ∪ C| = |A|+|B|+|C| − |A∩B| − |B∩C| − |C∩A| + |A∩B∩C|
  • |A × B| = |A|·|B|
ExpressionMeaningCount cue
A ∪ BIn A or B (or both)IE: add then subtract ∩
A ∩ BIn bothOverlap
A − BIn A not B|A| − |A∩B|
A × BOrdered pairs|A|·|B|

Worked example

Problem. |A|=20, |B|=25, |A∩B|=10. Find |A∪B| and |A−B|.

Solution. |A∪B|=20+25−10=35. |A−B|=|A|−|A∩B|=10.

Relations — definitions & counts

  • A binary relation R on A is any subset of A × A. Number of relations on an n-set: 2^(n²).
  • Relation from A to B: subset of A × B; there are 2^(mn) such relations if |A|=m, |B|=n.
  • Represent R by a 0-1 matrix (rows/cols indexed by A) or a directed graph (edge a→b iff (a,b)∈R).
  • Empty relation and universal relation A×A are the extremes; identity / diagonal Δ = {(a,a)}.
  • Composition S∘R: (a,c) ∈ S∘R iff ∃b with (a,b)∈R and (b,c)∈S. Matrix product (Boolean) mirrors this.

Formulas to remember

  • # relations on n-set = 2^(n²)
  • # relations A→B = 2^(mn)
  • # reflexive relations = 2^(n²−n) (diagonal forced)

Relation properties

  • Reflexive: (a,a)∈R for every a — matrix diagonal all 1s; digraph has a loop at every vertex.
  • Symmetric: (a,b)∈R ⇒ (b,a)∈R — matrix equals its transpose; edges come in pairs (or loops).
  • Antisymmetric: (a,b)∈R and (b,a)∈R ⇒ a=b — no two-cycle between distinct elements.
  • Transitive: (a,b),(b,c)∈R ⇒ (a,c)∈R — often the hardest; check all length-2 paths close.
  • Asymmetric: (a,b)∈R ⇒ (b,a)∉R (implies irreflexive). Different from antisymmetric.
  • Neither symmetric nor antisymmetric is possible (e.g. {(1,2),(2,1),(1,3)} on {1,2,3}).
PropertyQuick checkGATE tip
ReflexiveAll diagonal pairs presentOne missing (a,a) kills it
SymmetricMatrix = transposeDirected edges in pairs
AntisymmetricNo 2-cycle on a≠bNeeded for partial orders
TransitiveClose all 2-pathsVerify systematically on small n
EquivalenceR + S + TInduces a partition

Worked example

Problem. On {1,2,3}, is R={(1,1),(2,2),(3,3),(1,2),(2,1)} an equivalence relation?

Solution. Reflexive and symmetric yes. Transitive: (1,2),(2,1) already give (1,1); no other 2-path fails. Yes — classes {1,2} and {3}.

Equivalence relations & partitions

  • Equivalence relation = reflexive + symmetric + transitive.
  • Equivalence classes [a] = {x | xRa} partition A: pairwise disjoint, union = A.
  • Conversely, every partition defines an equivalence (same block ⇔ related).
  • Number of equivalences on an n-set = Bell number B_n (partitions of an n-set). B_3=5, B_4=15.
  • Classic examples: mod m on integers; “same age”; kernel of a function (a∼b iff f(a)=f(b)).

Formulas to remember

  • B_1=1, B_2=2, B_3=5, B_4=15, B_5=52
  • B_n = Σ S(n,k) (Stirling 2nd kind; k=1…n)

Worked example

Problem. How many equivalence relations are there on a 3-element set?

Solution. Partitions: 1×3-block; 3 ways for one 2-block + singleton; 1× three singletons → 1+3+1=5 = B_3.

Partial orders, Hasse diagrams & lattices

  • Partial order ≤ : reflexive + antisymmetric + transitive. (A,≤) is a poset.
  • Total (linear) order: every pair comparable (a≤b or b≤a). Divisibility on {1,2,3,6} is not total.
  • Hasse diagram: draw covering relations only — omit loops and edges implied by transitivity; usually “upward”.
  • Minimal: nothing strictly below. Maximal: nothing strictly above. Least: below everything. Greatest: above everything. A poset can have many maximals and no greatest.
  • Lattice: every pair has a meet (glb) and join (lub). Bounded lattice has 0 and 1. Boolean algebra is a complemented distributive lattice.
  • Divisibility poset on positive divisors of n is always a lattice (meet=gcd, join=lcm).

Worked example

Problem. On {1,2,3,6} ordered by divisibility, is every pair comparable? Is it a lattice?

Solution. 2 and 3 are incomparable ⇒ not a total order. Every pair has gcd/lcm ⇒ it is a lattice. Hasse: 1 at bottom, 2 and 3 above 1, 6 above both.

Functions — types & counting

  • f: A → B assigns each a ∈ A exactly one f(a) ∈ B. Total functions: n^m when |A|=m, |B|=n.
  • Injective (1–1): f(a1)=f(a2) ⇒ a1=a2. Needs m≤n; count = P(n,m)=n!/(n−m)!.
  • Surjective (onto): every b has ≥1 preimage. Count = n! S(m,n) = Σ (−1)^k C(n,k)(n−k)^m.
  • Bijective: injective + surjective ⇔ inverse exists. Needs m=n; count = n!.
  • Composition g∘f means apply f then g. Associative; identity id_A is the unit. (g∘f)⁻¹ = f⁻¹∘g⁻¹ when invertible.
  • Image f(A) ⊆ B; for finite sets, |A|=|B| and injective ⇒ bijective (and similarly surjective ⇒ bijective).

Formulas to remember

  • Total functions: n^m
  • Injections (m≤n): P(n,m)
  • Surjections: Σ_{k=0}^{n} (−1)^k C(n,k)(n−k)^m
  • Bijections (m=n): n!
TypeConditionCount (|A|=m,|B|=n)
Any function—n^m
Injectionm≤nP(n,m)
Surjectionm≥nn! S(m,n)
Bijectionm=nn!

Worked example

Problem. Number of injections from a 3-set to a 5-set? Number of surjections from a 4-set to a 2-set?

Solution. Injections: P(5,3)=5×4×3=60. Surjections 4→2: 2^4 − C(2,1)1^4 = 16−2=14 (or 2! S(4,2)=2×7=14).

Closures of relations (GATE depth)

  • Reflexive closure: add all missing (a,a). Symmetric closure: add all missing reverses.
  • Transitive closure R⁺: add all pairs linked by a path (Warshall / matrix OR-powers idea).
  • Equivalence closure: make reflexive, symmetric, and transitive (reachability in undirected sense after symmetrizing).
  • GATE usually asks which pairs must be added — work on n≤4 by hand.

Exam tips

  • Relation matrix: diagonal → reflexive; transpose → symmetric; scan 2-paths → transitive.
  • Partition / “same class” stems almost always mean an equivalence relation.
  • For function counts, write |domain|=m and |codomain|=n first — swapped m/n is the #1 error.
  • Hasse: do not draw transitive edges; “above” means greater in the order.
  • Minimal ≠ least: many maximals possible; least/greatest are unique when they exist.
  • Power set questions: 2^n total, subtract ∅ or use C(n,k) for fixed size.
Exam pattern · 10 questions

GATE sample questions & answers

10 GATE-style MCQs for Sets, Relations & Functions with full explanations. Attempt each question before revealing the answer.

Q1 Power set cardinality

The number of subsets of a set with n elements is:

  • A) n!
  • B) n²
  • C) 2^n
  • D) n^2 − 1
Show answer & explanation

Answer: C

Each element may be in or out of a subset independently → 2^n = |P(A)|.

Q2 Relations count 2^(n²)

Number of binary relations on a set with 3 elements is:

  • A) 9
  • B) 27
  • C) 512
  • D) 256
Show answer & explanation

Answer: C

A×A has 3²=9 pairs; each in/out → 2^9 = 512.

Q3 Equivalence definition

Which property must hold for an equivalence relation?

  • A) Reflexive and asymmetric
  • B) Reflexive, symmetric, transitive
  • C) Reflexive, antisymmetric, transitive
  • D) Symmetric and antisymmetric only
Show answer & explanation

Answer: B

Equivalence = R+S+T. Option C is a partial order, not equivalence.

Q4 Bell number B_3

How many equivalence relations are there on a set with 3 elements?

  • A) 3
  • B) 5
  • C) 6
  • D) 9
Show answer & explanation

Answer: B

Bell number B_3=5: one 3-block; three partitions of type 2+1; three singletons.

Q5 Injection count

Let |A|=m, |B|=n. Number of injective functions A→B (m≤n) is:

  • A) n^m
  • B) m^n
  • C) P(n,m)
  • D) C(n,m)
Show answer & explanation

Answer: C

Choose distinct images in order: n(n−1)…(n−m+1)=P(n,m).

Q6 Divisibility poset

In the poset of {1,2,3,6} under divisibility, which statement is TRUE?

  • A) 2 and 3 are comparable
  • B) 1 is the greatest element
  • C) 6 is the greatest element and 1 is the least
  • D) The poset is a total order
Show answer & explanation

Answer: C

1 divides all (least); all divide 6 (greatest). 2∤3 and 3∤2 ⇒ not total/comparable.

Q7 Two-set inclusion–exclusion

If |A|=10, |B|=15, |A∩B|=4, then |A∪B| equals:

  • A) 21
  • B) 25
  • C) 29
  • D) 19
Show answer & explanation

Answer: A

|A∪B|=10+15−4=21.

Q8 Reflexive relation count

Number of reflexive relations on a set with 4 elements is:

  • A) 2^16
  • B) 2^12
  • C) 2^4
  • D) 4^4
Show answer & explanation

Answer: B

Diagonal 4 pairs fixed present; remaining 16−4=12 pairs free → 2^12.

Q9 Surjection via IE

Number of surjective functions from a 4-element set onto a 2-element set is:

  • A) 8
  • B) 14
  • C) 16
  • D) 24
Show answer & explanation

Answer: B

2^4 − C(2,1)1^4 = 16−2=14.

Q10 Lattice vs total order

Which of the following is NOT necessarily true for a lattice?

  • A) Every pair of elements has a least upper bound
  • B) Every pair of elements has a greatest lower bound
  • C) Every pair of elements is comparable
  • D) The order is a partial order
Show answer & explanation

Answer: C

Lattices need glb/lub for every pair but need not be total orders — comparability is extra.

Topic drill · 10 questions

10 practice questions — Sets, Relations & Functions

Extra page-specific practice beyond the GATE samples. Attempt all 10, then reveal answers to check your reasoning.

P1

If |A|=6, number of proper subsets of A is:

  • A) 64
  • B) 63
  • C) 62
  • D) 32
Show answer & explanation

Answer: B) 63

Total subsets 2^6=64; proper usually means exclude A itself → 63 (some texts also exclude ∅; GATE typically means ≠A → 63).

P2

Number of symmetric relations on a set with 3 elements is:

  • A) 2^6
  • B) 2^9
  • C) 2^3
  • D) 3^3
Show answer & explanation

Answer: A) 2^6

Diagonal 3 free; off-diagonal pairs {i,j} choose together (3 unordered pairs) → 3+3=6 free bits → 2^6=64.

P3

|A∪B∪C| when |A|=|B|=|C|=12, each pairwise ∩ has 4, and |A∩B∩C|=2 equals:

  • A) 26
  • B) 28
  • C) 30
  • D) 36
Show answer & explanation

Answer: A) 26

3×12 − 3×4 + 2 = 36 − 12 + 2 = 26.

P4

Which relation on Z is a partial order but not an equivalence?

  • A) aRb iff a−b even
  • B) aRb iff a ≤ b (usual order)
  • C) aRb iff a=b
  • D) aRb iff |a|=|b|
Show answer & explanation

Answer: B) aRb iff a ≤ b (usual order)

≤ is reflexive, antisymmetric, transitive (poset) but not symmetric. A and D are equivalences; C is both equivalence and partial order (discrete order).

P5

Number of functions from a 3-set to a 3-set that are NOT bijective is:

  • A) 6
  • B) 21
  • C) 27
  • D) 24
Show answer & explanation

Answer: B) 21

Total 3^3=27; bijections 3!=6; not bijective = 21.

P6

In a Hasse diagram of a finite poset, an edge upward from a to b means:

  • A) a and b are incomparable
  • B) a < b and no c with a < c < b (cover)
  • C) a is maximal
  • D) b ≤ a always
Show answer & explanation

Answer: B) a < b and no c with a < c < b (cover)

Hasse edges are covering relations only.

P7

Number of surjective functions from a 5-set onto a 3-set is:

  • A) 150
  • B) 243
  • C) 60
  • D) 125
Show answer & explanation

Answer: A) 150

Σ (−1)^k C(3,k)(3−k)^5 = 3^5 − C(3,1)2^5 + C(3,2)1^5 = 243 − 96 + 3 = 150.

P8

Let R be reflexive and transitive on A. Which is TRUE?

  • A) R must be an equivalence
  • B) R must be a partial order
  • C) R is a preorder (quasi-order); need antisymmetry for a poset
  • D) R must be symmetric
Show answer & explanation

Answer: C) R is a preorder (quasi-order); need antisymmetry for a poset

Reflexive+transitive = preorder. Equivalence needs symmetry; poset needs antisymmetry.

P9

If |A|=4, number of subsets with odd cardinality is:

  • A) 4
  • B) 8
  • C) 7
  • D) 16
Show answer & explanation

Answer: B) 8

C(4,1)+C(4,3)=4+4=8 (half of 2^4 for n≥1).

P10

The inverse of a bijective f: A→B exists. (f⁻¹∘f)(a) equals:

  • A) f(a)
  • B) a
  • C) f⁻¹(a)
  • D) undefined
Show answer & explanation

Answer: B) a

f⁻¹∘f = id_A, so (f⁻¹∘f)(a)=a.

Topic FAQs

How many relations are there on a set with n elements?

2^(n²): A×A has n² ordered pairs and each may or may not belong to the relation.

Is every partial order a total order?

No. Total orders require every pair comparable. Divisibility on {1,2,3,6} is a standard non-total poset (still a lattice).

How do equivalence relations relate to partitions?

Every equivalence relation’s classes form a partition, and every partition defines an equivalence (related iff same block). Counts match Bell numbers.

When does a function have an inverse?

Iff it is bijective. Then f⁻¹∘f = id_A and f∘f⁻¹ = id_B.

Quick revision · 10 cards

10 flashcards — Sets, Relations & Functions

Hover a card to reveal the answer with a 3D flip. On touch devices, tap the card or use Show answer.

Q1 How many elements does the power set of an n-element set have?
Q2 How many binary relations are there on an n-element set?
Q3 State the definition of an equivalence relation.
Q4 State the definition of a partial order.
Q5 What is the difference between a minimal element and a least element in a poset?
Q6 How many reflexive relations are there on an n-set?
Q7 Give counts of total, injective, and bijective functions from an m-set to an n-set.
Q8 Write the two-set inclusion–exclusion formula.
Q9 What do Bell numbers count?
Q10 What does a Hasse diagram omit?