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.
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|
| Expression | Meaning | Count cue |
|---|---|---|
| A ∪ B | In A or B (or both) | IE: add then subtract ∩ |
| A ∩ B | In both | Overlap |
| A − B | In A not B | |A| − |A∩B| |
| A × B | Ordered 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}).
| Property | Quick check | GATE tip |
|---|---|---|
| Reflexive | All diagonal pairs present | One missing (a,a) kills it |
| Symmetric | Matrix = transpose | Directed edges in pairs |
| Antisymmetric | No 2-cycle on a≠b | Needed for partial orders |
| Transitive | Close all 2-paths | Verify systematically on small n |
| Equivalence | R + S + T | Induces 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!
| Type | Condition | Count (|A|=m,|B|=n) |
|---|---|---|
| Any function | — | n^m |
| Injection | m≤n | P(n,m) |
| Surjection | m≥n | n! S(m,n) |
| Bijection | m=n | n! |
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.
10 GATE-style MCQs for Sets, Relations & Functions with full explanations. Attempt each question before revealing the answer.
The number of subsets of a set with n elements is:
Show answer & explanation
Answer: C
Each element may be in or out of a subset independently → 2^n = |P(A)|.
Number of binary relations on a set with 3 elements is:
Show answer & explanation
Answer: C
A×A has 3²=9 pairs; each in/out → 2^9 = 512.
Which property must hold for an equivalence relation?
Show answer & explanation
Answer: B
Equivalence = R+S+T. Option C is a partial order, not equivalence.
How many equivalence relations are there on a set with 3 elements?
Show answer & explanation
Answer: B
Bell number B_3=5: one 3-block; three partitions of type 2+1; three singletons.
Let |A|=m, |B|=n. Number of injective functions A→B (m≤n) is:
Show answer & explanation
Answer: C
Choose distinct images in order: n(n−1)…(n−m+1)=P(n,m).
In the poset of {1,2,3,6} under divisibility, which statement is TRUE?
Show answer & explanation
Answer: C
1 divides all (least); all divide 6 (greatest). 2∤3 and 3∤2 ⇒ not total/comparable.
If |A|=10, |B|=15, |A∩B|=4, then |A∪B| equals:
Show answer & explanation
Answer: A
|A∪B|=10+15−4=21.
Number of reflexive relations on a set with 4 elements is:
Show answer & explanation
Answer: B
Diagonal 4 pairs fixed present; remaining 16−4=12 pairs free → 2^12.
Number of surjective functions from a 4-element set onto a 2-element set is:
Show answer & explanation
Answer: B
2^4 − C(2,1)1^4 = 16−2=14.
Which of the following is NOT necessarily true for a lattice?
Show answer & explanation
Answer: C
Lattices need glb/lub for every pair but need not be total orders — comparability is extra.
Extra page-specific practice beyond the GATE samples. Attempt all 10, then reveal answers to check your reasoning.
If |A|=6, number of proper subsets of A is:
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).
Number of symmetric relations on a set with 3 elements is:
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.
|A∪B∪C| when |A|=|B|=|C|=12, each pairwise ∩ has 4, and |A∩B∩C|=2 equals:
Show answer & explanation
Answer: A) 26
3×12 − 3×4 + 2 = 36 − 12 + 2 = 26.
Which relation on Z is a partial order but not an equivalence?
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).
Number of functions from a 3-set to a 3-set that are NOT bijective is:
Show answer & explanation
Answer: B) 21
Total 3^3=27; bijections 3!=6; not bijective = 21.
In a Hasse diagram of a finite poset, an edge upward from a to b means:
Show answer & explanation
Answer: B) a < b and no c with a < c < b (cover)
Hasse edges are covering relations only.
Number of surjective functions from a 5-set onto a 3-set is:
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.
Let R be reflexive and transitive on A. Which is TRUE?
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.
If |A|=4, number of subsets with odd cardinality is:
Show answer & explanation
Answer: B) 8
C(4,1)+C(4,3)=4+4=8 (half of 2^4 for n≥1).
The inverse of a bijective f: A→B exists. (f⁻¹∘f)(a) equals:
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.
Hover a card to reveal the answer with a 3D flip. On touch devices, tap the card or use Show answer.