BS Artificial Intelligence · Semester 1 · Week 06

Discrete Mathematics for BSAI

Relations: Grouping and Ordering

Dr. Hira Benish
Associate Professor & HoD, Mathematics
PMAI Lab, Mathematics Behind AI

Week 6 · Dr. Hira BenishBegin reading  

01 · Opening Scenario: Two Kinds of Relationship

A learning-support system records a current support category for each learner and prerequisite links between learning modules. It asks two questions: “Which learners are in the same category?” and “Which modules must come before Relations?” Both questions connect objects, yet they behave differently.

Predict: If Amina and Chen have the same category, the statement works in either direction. If Logic must come before Relations, that does not mean Relations must come before Logic. We need to know which kind of relationship the system is using before drawing conclusions.

Central question

Given pairs that satisfy a rule, what structure do they reveal: groups of equivalent objects, an order of dependencies, or neither?

02 · Learning Objectives and Three-Hour Guide

By the end of Week 6, you should be able to read a relation as ordered pairs; test reflexivity, symmetry, transitivity and antisymmetry on a small set; form equivalence classes and a partition; recognize a partial order; and draw a simple Hasse diagram from prerequisite information.

Class timeEssential work
55 minRelation cards and four property tests
50 minEquivalence classes and grouping activity
40 minPrerequisite order and manual Hasse diagram
35 minMajor case study and short check

Classroom essentials Sections 01–10 and Problems 1–5. Optional self-study Colab and extended practice. Relation Detective and the group activities provide ungraded feedback; a short assessment may be collected separately.

03 · A Relation Records Which Pairs Are Connected

Week 5 gave us A×B, the set of all possible ordered pairs with first entry in A and second in B. A relation from A to B selects some of those pairs. We write R⊆A×B; aRb is shorthand for (a,b)∈R.

Worked example

Let A={1,2,3}. Define “is smaller than” on A. Its pair set is R={(1,2),(1,3),(2,3)}. Thus 1R3 is true, but 3R1 is false. The order inside a pair matters.

For properties such as symmetry and transitivity, we usually examine a relation on one set: R⊆A×A. Unlike a function, a relation may link one object to several others or to none. A prerequisite list, for example, need not assign each module exactly one successor.

04 · Four Questions to Ask of a Relation

Each property is a rule about all relevant elements of the stated set. One missing required pair disproves it. Test the pair set, rather than judging by a familiar name.

PropertyPlain-language testSymbolic version
ReflexiveEvery object is related to itself.For every x, xRx.
SymmetricEvery forward pair has a reverse pair.If xRy, then yRx.
TransitiveA two-step chain has its shortcut.If xRy and yRz, then xRz.
AntisymmetricTwo different objects cannot point both ways.If xRy and yRx, then x=y.

Test a small relation

On A={a,b,c}, let Q={(a,a),(b,b),(c,c),(a,b),(b,c)}. It is reflexive because all three self-pairs appear. It is not symmetric because (a,b) appears but (b,a) does not. It is not transitive because (a,b) and (b,c) appear but (a,c) is missing. It is antisymmetric because no two distinct objects have pairs in both directions.

Two cautions: Antisymmetric does not mean “never symmetric”: the relation containing only self-pairs has both properties. Transitivity asks for the shortcut whenever a two-step chain actually occurs.

05 · Same Category Makes an Equivalence Relation

Imagine each learner has exactly one current support category. Write x∼y when the two learners have the same category. This relation is reflexive (each learner matches themself), symmetric (if x matches y, y matches x), and transitive (if x matches y and y matches z, x matches z). A relation with these three properties is an equivalence relation.

Represent the pairs

For A={a,b,c}, suppose a and b share a category and c has a different one. The complete relation is E={(a,a),(a,b),(b,a),(b,b),(c,c)}. It includes both directions for a and b, and all self-pairs. It is not antisymmetric because a≠b while both aEb and bEa.

Do not confuse “same category” with “equally skilled” or “identical.” The relation says only that the specified label matches. If the category data changes, the groups may change too.

06 · Equivalence Classes Form a Partition

The equivalence class of a learner contains everyone related to that learner. In the previous example [a]={a,b}, [b]={a,b}, and [c]={c}. Classes that share a member are the same class; distinct classes do not overlap.

A={a,b,c}={a,b}∪{c}, with disjoint blocks {a,b} and {c}.

A partition is a collection of nonempty blocks that do not overlap and together cover the whole set. Equivalence classes produce such blocks. Conversely, if a partition is given, “belong to the same block” defines an equivalence relation.

Quick check: Can {a,b} and {b,c} be two different blocks of a partition of A? No: b appears in both.

07 · Prerequisites Make a Partial Order

For modules, define x≼y to mean “x is y, or x must come before y through one or more prerequisite steps.” This is reflexive because x≼x; transitive because a chain from x to y and y to z gives a chain from x to z; and antisymmetric if prerequisites have no cycle among distinct modules. Such a relation is a partial order.

“Partial” allows two modules to be incomparable. If a learner may take Logic and Sets in either order after Foundations, neither Logic≼Sets nor Sets≼Logic. This is not a defect: the rule does not specify an order between them.

Misconception warning: A partial order need not compare every distinct pair. Also, “must come before” by itself is not reflexive; we explicitly include x=x in ≼.

08 · Draw Only the Immediate Steps

A Hasse diagram displays a finite partial order compactly. Put earlier elements lower and later elements higher. Connect only a direct dependency with no intermediate element; omit self-links, arrowheads, and links already implied by a path.

Let M={F,L,S,R} stand for Foundations, Logic, Sets and Relations. The immediate prerequisite links are F→L, F→S, L→R, and S→R.

Hasse diagram: Foundations at bottom; Logic and Sets in middle; Relations at top FLSR FoundationsLogicSetsRelations
Figure 1. Read upward. F≼R follows through either middle module, so the F-to-R edge is omitted. L and S are incomparable.

The full relation ≼ includes the four self-pairs and the implied pair (F,R) as well as the four drawn links. The diagram is a compressed picture of the order, not a list of every pair.

09 · Relation Detective

Classroom activity · 15 minutes Each card gives a relation on one stated set. Select every property that holds, then read the evidence. A relation can satisfy several properties at once; the final card has a useful surprise.

Card 1 of 4

Which properties hold?

Choose the properties, then check.

10 · Major Case Study: Organizing an Intelligent Learning System

35-minute case · Scenario → Understand → Represent → Reason → Test → Interpret

Scenario and proposed decision

A small system records a current support category for five learners and a prerequisite plan for four modules. It proposes to place Amina with Chen in one support group. Amina has completed Foundations and Logic; the system also proposes to recommend Relations next. Can it justify both actions from its records?

Understand the two domains

Learners are L={Amina,Bilal,Chen,Diya,Eman}. The category records are Amina/Chen → Guided; Bilal/Diya → Practice; Eman → Independent. Modules are M={F,Lg,S,R} for Foundations, Logic, Sets and Relations. The four immediate links are F→Lg, F→S, Lg→R, and S→R. Notice that the symbol L names the learner set, while Lg abbreviates Logic.

Represent

Define x∼y for learners with the same recorded category. Its three classes are {Amina,Chen}, {Bilal,Diya}, and {Eman}. The pair set contains every pair within each block, including the five self-pairs. For example, (Amina,Chen) and (Chen,Amina) are both present, while (Amina,Bilal) is absent.

On modules, let x≼y mean x=y or x is before y by a prerequisite chain. The four drawn links and the implied F≼R belong to this relation, as do all four self-pairs. Logic and Sets remain incomparable.

Left: three support groups. Right: module prerequisite Hasse diagram. Bottom: Amina may take Sets but not yet Relations. Same category → groups Prerequisite → order Guided: Amina, ChenPractice: Bilal, DiyaIndependent: Eman FLgSR Amina completed F and Lg → S is available; R still needs S.
Figure 2. Grouping and ordering answer different questions about the same learning system.

Reason and test

Grouping: Amina and Chen share the category Guided. The relation is reflexive, symmetric and transitive, so the category blocks are a partition. The proposed group is justified.

Ordering: By the system’s stated policy, a learner may start a module after completing all its required predecessors. Amina has F and Lg. She can start S because F is complete; she cannot start R yet because S is still required. The proposed recommendation of R does not follow. The Hasse diagram shows the missing branch.

Interpret the limits

The category records are current system labels, not proof of equal ability. The prerequisite order is a declared plan, not a claim that a machine discovered the best curriculum. If records or rules change, the decision must be reconsidered.

Case record to complete: Identify the relation, cite the relevant pair or path, state the justified conclusion, and name one information limit for each of the system’s two actions.

11 · Optional Colab: Inspect Listed Pairs

Self-study · mathematics first Predict the two printed truth values. A tuple ("F","Lg") is an ordered pair; braces hold the set of four immediate links. The test in asks whether a pair is explicitly in that set.

immediate = {("F", "Lg"), ("F", "S"),
             ("Lg", "R"), ("S", "R")}
print(("F", "Lg") in immediate)
print(("F", "R") in immediate)

The outputs are True and False. Nevertheless F≼R in the full prerequisite order because a path through Lg or S reaches R. Membership in the four-link set and membership in the full order are different questions. Draw the Hasse diagram and reason about paths by hand.

12 · Practice

For property questions, name the underlying set and show a witness when a property fails. Selected solutions follow at the end.

  1. On A={1,2,3}, let R={(1,2),(2,3)}. Test reflexivity, symmetry, transitivity and antisymmetry. Which single pair makes this relation transitive without changing its existing pairs?
  2. On A={11,21,12}, define x∼y when x and y have the same last digit. List the equivalence classes and all ordered pairs in the relation.
  3. For the module order in Figure 1, list all pairs in the full ≼ relation. Explain why (F,R) is present although it has no drawn edge.
  4. On {a,b,c}, consider equality: D={(a,a),(b,b),(c,c)}. Is it an equivalence relation, a partial order, both, or neither? Explain.
  5. In the major case, Amina completed F and Lg. Which module among S and R may be started under the stated policy? What single missing completion prevents the other?
  6. Let Q={(a,a),(b,b),(c,c),(a,b),(b,a)} on {a,b,c}. Is it symmetric? Is it antisymmetric? Give the decisive pair evidence.
  7. Let T={(a,a),(b,b),(a,b)} on {a,b}. Test the four properties. Is it a partial order?
Exit check: In one sentence, explain why “same category” groups learners but “prerequisite” orders modules.

13 · Common Mistakes

Tempting moveBetter test
Assume a relation must be a function.A relation can have several or no links from one object.
Check a few self-pairs and call it reflexive.Check the self-pair for every element of the stated set.
Call antisymmetric the opposite of symmetric.Test whether two distinct elements are linked both ways.
Draw every pair in a Hasse diagram.Omit self-links and links implied by a path.
Treat incomparable modules as equal.They can be distinct while neither precedes the other.
Infer skill from a support-category label.Use the recorded label only for the stated grouping rule.

14 · Summary

  • A relation is a selected set of ordered pairs. For a relation on one set, four useful tests are reflexive, symmetric, transitive and antisymmetric.
  • Reflexive + symmetric + transitive gives an equivalence relation and a partition into nonoverlapping classes.
  • Reflexive + antisymmetric + transitive gives a partial order; some elements may remain incomparable.
  • A Hasse diagram draws immediate order links and leaves out self-links and shortcuts.
  • Grouping and prerequisite ordering answer different system questions; conclusions depend on the supplied records and rules.

15 · Visual Concept Map

Relation as ordered pairs branches into equivalence grouping and partial ordering RELATIONselected ordered pairs EQUIVALENCEreflexive · symmetric · transitiveclasses → partition PARTIAL ORDERreflexive · antisymmetric · transitiveimmediate links → Hasse diagram
The same starting idea, ordered pairs, supports grouping and ordering when different property combinations hold.

16 · Key Terms

Relation
A selected set of ordered pairs from a Cartesian product.
Reflexive
Every element relates to itself.
Symmetric
Every pair has its reverse.
Transitive
Every two-step chain has its shortcut.
Antisymmetric
Distinct elements cannot be related in both directions.
Equivalence relation; partition
A reflexive, symmetric, transitive relation; its nonoverlapping classes covering the set.
Partial order; Hasse diagram
A reflexive, antisymmetric, transitive relation; a diagram of its immediate links.

17 · Looking Ahead

Week 7 introduces divisibility, greatest common divisors and remainders, then reviews the mathematical ideas from Weeks 1–7 before the midterm. The habit of stating the set and checking a rule precisely carries forward.

Selected Solutions

Relation Detective cards

Card 1: Reflexive, symmetric and transitive; not antisymmetric because a and b point both ways. It is an equivalence relation. Card 2: Reflexive, transitive and antisymmetric; not symmetric because (1,2) has no reverse. It is a partial order. Card 3: Reflexive and antisymmetric; not symmetric, and not transitive because (a,b),(b,c) occur without (a,c). Neither type. Card 4: All four properties. Equality is both an equivalence relation and a partial order.

1 · Four tests

No self-pairs, so not reflexive. Missing reverse (2,1), so not symmetric. The chain (1,2),(2,3) lacks (1,3), so not transitive. No distinct pair appears both ways, so antisymmetric. Add (1,3) to make it transitive.

2 · Same last digit

Classes {11,21} and {12}. Pairs {(11,11),(11,21),(21,11),(21,21),(12,12)}.

3 · Full module order

On {F,L,S,R}, the relation contains (F,F),(L,L),(S,S),(R,R),(F,L),(F,S),(L,R),(S,R),(F,R). The path F→L→R (also F→S→R) implies (F,R).

4 · Equality

Both. Self-pairs give reflexivity; every pair reverses to itself, so symmetry; chaining equalities preserves equality, so transitivity; and no distinct elements point both ways, so antisymmetry.

5 · Case decision

Amina may start S since F is complete. She may not start R under the stated policy until S is complete; L is already complete.

6 · Symmetry versus antisymmetry

Symmetric: both (a,b) and (b,a) occur. Not antisymmetric: a≠b but both directions occur.

7 · A small order

Reflexive (both self-pairs), not symmetric (missing (b,a)), transitive (the only nontrivial link is a→b and self-links preserve its shortcut), antisymmetric (no distinct pair both ways). Thus it is a partial order.