Relations
Learning objectives
- Define a relation as a subset of a Cartesian product
- Use the notation and identify the domain and range
- Recognise familiar relations: less-than, equality, divides, sibling-of
- Compute the inverse of a relation
Why do we need a new word for "this is related to that"? Because that single idea covers an enormous range of structures: numerical orderings (, ), arithmetic links (, ), social connections (friend-of, sibling-of), database keys (foreign-key links), and graph edges. The mathematical concept that captures all of them, with no extra restrictions, is the relation. It is the most general "connection" structure you can build, and once you have it, you can ask precise questions: Is the connection symmetric? Reflexive? Transitive? Does it chain? Does it partition? Sections 4.3-4.5 climb that ladder. This section sets the bottom rung.
The definition
A relation from a set to a set is any subset . When , we write and read it " is -related to ." If we call a relation on . There are no rules, can be tiny (empty), enormous (all of ), or anything in between.
Domain, range, inverse
The domain of is the set of first components: . The range is the set of second components: . The inverse swaps every pair: . Always: and .
Familiar relations
The most important examples to keep in mind:
- Less-than on : . Strict, no element relates to itself.
- Equality on : , the diagonal. Every element relates only to itself.
- Divides on : means for some positive integer .
- Congruence mod on : iff .
- Social and knowledge graphs: Facebookβs "is friends with," LinkedInβs "is connected to," Wikidataβs entire 1.3-billion-statement knowledge graph, all are relations on huge sets of entities. Each statement is one ordered pair.
- Database foreign keys: The
customer_idin anorderstable picks out a relation from orders to customers: iff that customer placed that order. Joins traverse this relation. - RDF and the semantic web: Every triple in an RDF store is a member of the relation named by predicate . Querying with SPARQL is querying relations.
- Recommendation systems: The "user liked item " relation between users and items is the raw material of collaborative filtering, Netflix, Spotify, Amazon all start here.
Pause and think: Why is the empty set a perfectly legitimate relation from to , no matter what and are? (Hint: a relation is just a subset of a Cartesian product, and for every set .)
Try it
- List the relation . Predict the size before listing.
- For , name , , and .
- Sketch the "less-than-or-equal" relation on as an arrow diagram in the widget. How many arrows?
- True or false: every function is a relation. Every relation is a function. Justify each.
- Find a relation on such that but has more than 3 pairs.
A trap to watch for
Relations are more general than functions. A relation from to can pair a single with many different βs, or with none at all. Students who have only seen functions sometimes assume "each input has exactly one output" is part of the definition of relation. It is not. That extra rule is what makes a relation into a function, we will see this in Section 5.1.
What you now know
You can write any relation as a set of ordered pairs, identify its domain and range, take its inverse, and recognise the relation behind everyday connection-style data, social graphs, database joins, divisibility, congruence. Section 4.3 asks the next obvious question: which properties can a relation have, and what changes when it does?
Mark section complete β
References
- Velleman, D. J. (2019). How to Prove It (3rd ed.). Cambridge University Press, Section 4.2.
- Halmos, P. R. (1960). Naive Set Theory. Springer, Section 7.
- Hammack, R. (2018). Book of Proof, ch. 11.
- Date, C. J. (2003). An Introduction to Database Systems (8th ed.). Addison-Wesley, ch. 3.
- Bloch, E. D. (2011). Proofs and Fundamentals (2nd ed.). Springer, ch. 5.