Quiz 2

Relations and Functions

447 words
2 min read
Python Week 1: the first filter for runtime behavior
Visual companion
Python
Type and operator map

Python Week 1: the first filter for runtime behavior

View
Revision summary

What this note is really saying

Short form

# Relations and Functions ## 🎯 Learning Objectives - Define relations as sets of ordered pairs - Identify properties: reflexive, symmetric, transitive, antisymmetric - Distinguish equivalence relations from partial orders - Classify functions as injective/surjective/bijective - Compose functions and find inverses *...

Relations and Functions

🎯 Learning Objectives

  • Define relations as sets of ordered pairs
  • Identify properties: reflexive, symmetric, transitive, antisymmetric
  • Distinguish equivalence relations from partial orders
  • Classify functions as injective/surjective/bijective
  • Compose functions and find inverses

6.1 Relations

A relation RR from AA to BB is a subset of A×BA \times B. We write aRbaRb for (a,b)R(a,b) \in R.

Properties

PropertyDefinitionExample on Z\mathbb{Z}
Reflexivea:aRa\forall a: aRaaaa \leq a
SymmetricaRb    bRaaRb \implies bRaa=ba = b
TransitiveaRbbRc    aRcaRb \land bRc \implies aRca<b<ca < b < c
AntisymmetricaRbbRa    a=baRb \land bRa \implies a = baba \leq b

6.2 Equivalence Relations

A relation that is reflexive, symmetric, and transitive is an equivalence relation. Partitions: An equivalence relation partitions the set into equivalence classes. Example: ab(modn)a \equiv b \pmod{n} (congruence mod nn). Equivalence classes: {0},{1},,{n1}\{0\}, \{1\}, \dots, \{n-1\} modulo nn.

6.3 Partial Orders

A relation that is reflexive, antisymmetric, and transitive is a partial order.
  • Total order: Every pair is comparable (\leq on R\mathbb{R})
  • Partial order: Some pairs incomparable (\subseteq on sets)

Hasse Diagrams

A graphical representation of a partial order.

6.4 Functions

A function f:ABf: A \to B is a relation where each aAa \in A relates to exactly one bBb \in B.

Types

TypeDefinitionExample
Injective (one-to-one)f(a1)=f(a2)    a1=a2f(a_1) = f(a_2) \implies a_1 = a_2f(x)=3xf(x) = 3x
Surjective (onto)bB aA:f(a)=b\forall b \in B \ \exists a \in A: f(a) = bf(x)=x3f(x) = x^3
BijectiveBoth injective and surjectivef(x)=x+1f(x) = x+1

Composition

(gf)(x)=g(f(x))(g \circ f)(x) = g(f(x))

Inverse

f1(y)=xf^{-1}(y) = x iff f(x)=yf(x) = y. Exists only if ff is bijective.

✅ Practice Questions

Q1: Determine if R={(1,1),(1,2),(2,1),(2,2),(3,3)}R = \{(1,1), (1,2), (2,1), (2,2), (3,3)\} on {1,2,3}\{1,2,3\} is an equivalence relation.
Solution
Reflexive? Need (1,1),(2,2),(3,3)(1,1), (2,2), (3,3) — all present. ✓ Symmetric? Check every pair: (1,2)(1,2) has (2,1)(2,1) ✓, (2,1)(2,1) has (1,2)(1,2) ✓, all self-pairs are symmetric. ✓ Transitive? (1,2)(1,2) and (2,1)(1,1)(2,1) \to (1,1) ✓; (2,1)(2,1) and (1,2)(2,2)(1,2) \to (2,2) ✓. Yes, it's an equivalence relation. Classes: {1,2}\{1,2\} and {3}\{3\}. Q2: Is f(x)=x2f(x) = x^2 on R\mathbb{R} injective? Surjective? Solution
Not injective: f(2)=f(2)=4f(-2) = f(2) = 4 but 22-2 \neq 2. Not surjective: f(x)0f(x) \geq 0, so negative numbers have no preimage. If defined as f:R+R+f: \mathbb{R}^+ \to \mathbb{R}^+, it is bijective. Q3: Find the inverse of f(x)=3x+2f(x) = 3x + 2. Solution
y=3x+2    y2=3x    x=y23y = 3x + 2 \implies y - 2 = 3x \implies x = \frac{y-2}{3}. So f1(y)=y23f^{-1}(y) = \frac{y-2}{3}. Join Discord PreviousSet Operation ProofsNextNumber Theory
Document outline

Keep your place and jump directly to a heading.

Table of Contents
System Normal // Awaiting Context

Intelligence Hub

Navigate the knowledge graph to generate context. The Hub adapts dynamically to surface backlinks, related notes, and metadata insights.