Sets, relations, functions, partial orders and lattices
Set operations and inclusion-exclusion, properties and counts of relations, equivalence relations, types and counts of functions, partial orders and Hasse diagrams, and lattices (bounded, complemented, distributive).
A set is an unordered collection of distinct elements. Key operations: union , intersection , difference , complement , symmetric difference , and Cartesian product with .
The power set is the set of all subsets; .
Inclusion-exclusion counts a union:
In general, add single sets, subtract pairs, add triples, and so on with alternating signs.
Countability. A set is countable if it is finite or in bijection with . , , , the set of all finite strings over a finite alphabet, and any countable union of countable sets are countable. , any interval of , and the set of all functions are uncountable (Cantor's diagonal argument). For any set, .
2. Relations and their properties
A relation on a set is a subset . With there are ordered pairs, so relations.
Property
Condition
Count on elements
Reflexive
for all
Irreflexive
for all
Symmetric
Antisymmetric
Asymmetric
Reflexive and symmetric
both
Transitive
no simple formula
How the counts arise: split the pairs into diagonal pairs and unordered off-diagonal pairs . For antisymmetry each off-diagonal pair has 3 choices: neither, only , or only . The diagonal is free (2 choices each).
Antisymmetric does not mean "not symmetric": the empty relation and the identity relation are both symmetric and antisymmetric.
The transitive closure of is the smallest transitive relation containing it, (Warshall's algorithm computes it).
3. Equivalence relations and partitions
An equivalence relation is reflexive, symmetric and transitive. Each element has an equivalence class . Two classes are either equal or disjoint, so the classes form a partition of . Conversely every partition gives an equivalence relation. So:
number of equivalence relations on elements = number of partitions = the Bell number : .
number with exactly classes = the Stirling number of the second kind , with and .
If the classes have sizes , the relation contains ordered pairs.
Standard example: congruence modulo on , when . It has classes .
Checks to remember:
the union of two equivalence relations need not be transitive, so need not be an equivalence;
the intersection of two equivalence relations is always an equivalence.
4. Functions
A function assigns each element of exactly one element of .
Injective (one-one): .
Surjective (onto): every is for some .
Bijective: both. Only a bijection has an inverse .
Counting with , :
Kind
Count
Condition
All functions
Injective
Surjective
Bijective
The surjection count also equals .
Composition ( first):
injective injective; same for surjective.
injective injective ( need not be).
surjective surjective ( need not be).
For a finite set mapped to itself, injective, surjective and bijective are the same thing. By the pigeonhole principle, if no function is injective.
5. Partial orders and Hasse diagrams
A partial order is reflexive, antisymmetric and transitive; is a poset. Examples: on a power set, divisibility on positive integers, on numbers. If every two elements are comparable, it is a total (linear) order.
A Hasse diagram draws below with an edge when covers ( with nothing in between). Reflexive loops and transitive edges are left out.
Term
Meaning
Minimal / maximal
nothing strictly below / above it
Least / greatest
below / above every element (unique if it exists)
Upper bound of
an element above every member of
LUB (join, )
the least upper bound
GLB (meet, )
the greatest lower bound
A finite poset always has at least one minimal and one maximal element, but may have no least or greatest element. A greatest element is the only maximal element, but a unique maximal element need not be greatest in an infinite poset.
Every finite poset has a topological sort: a total order that respects .
In the divisibility poset, and . In , join is and meet is .
6. Lattices
A lattice is a poset in which every pair has both a join and a meet. Every finite lattice is bounded: it has a least element 0 and a greatest element 1.
Complement of : an element with and . A lattice is complemented if every element has at least one complement.
Distributive: for all . In a distributive lattice each element has at most one complement.
A Boolean algebra is a complemented distributive lattice, for example .
Test for distributivity: a lattice is distributive if and only if it has no sublattice shaped like (the diamond) or (the pentagon). In , the element has two complements and , which already breaks distributivity.
Divisor lattice (divisors of under divisibility, join = lcm, meet = gcd):
always distributive;
complemented (so Boolean) exactly when is square-free, such as ;
in the element 2 has no complement, since a complement would need and .
Every total order is a distributive lattice. A total order with three or more elements is not complemented, since a middle element has no complement.
Hasse diagrams: D12 is distributive but not complemented; M3 and N5 are the two lattices that are not distributive.
Formulas to remember
Inclusion-exclusion (two sets)
Power set
All relations on n elements
Reflexive relations
Symmetric relations
Antisymmetric relations
Functions from an m-set to an n-set
Onto functionsFrom an -set onto an -set
Stirling numbers of the second kind
Common mistakes
Treating antisymmetric as the opposite of symmetric; a relation can be both (the identity) or neither.
Confusing maximal with greatest: a poset can have many maximal elements and no greatest one.
Using in the wrong direction: functions from an -set to an -set number , not .
Forgetting the inclusion-exclusion correction terms when counting onto functions.
Assuming the union of two equivalence relations is an equivalence relation; it may fail transitivity.
Calling every a Boolean algebra; it is complemented only when is square-free.
Worked examples
Try each step yourself, then reveal the working.
Example 1: Counting relations on a 3-element set
numerical
Let . Count the reflexive, symmetric, reflexive-and-symmetric, and antisymmetric relations on .
Step 1: Split the 9 ordered pairs into diagonal and off-diagonal.
Try it on paper first.
Example 2: Onto functions by inclusion-exclusion
numerical
How many functions from onto are there?
Step 1: Count all functions first.
Try it on paper first.
Example 3: Is D12 a complemented lattice?
conceptual
For the divisors of 12 under divisibility, find the join and meet of 4 and 6, and decide whether the lattice is complemented and whether it is distributive.
Step 1: Use lcm for join and gcd for meet.
Try it on paper first.
Example 4: Equivalence classes of a congruence
numerical
On define if . List the classes and find .
Step 1: Group the elements by remainder on division by 3.
Try it on paper first.
Previous year questions
15 official GATE CSE questions on this topic, newest first.
10 questions: up to 4 official PYQs and original practice questions, with GATE marking (MCQ wrong answers lose marks). Score 60% or more to pass. A new set is drawn each time.
Mark as mastered
Loading your progress…
My revision notes
Notes written by the GATEiit team against the official GATE CSE syllabus; being checked by a reviewer. Updated 2026-11-21. Spotted a mistake? Use Report an issue on any question, or contact us.