3.2 Function Inversion, Composition & Counting of Special Mappings
π‘ Core Intuition: The 3-Second Mental Modelβ
π³ The Everyday Analogy: Assembly Line Processing & Reversible Operationsβ
Think of function composition and inversion like an automated manufacturing pipeline:
- Composition (): Stage 1 () wraps an item in protective bubble wrap; Stage 2 () places the wrapped item into a cardboard shipping box. The combined workflow () takes the raw item and delivers the boxed package. Notice the order: you apply first, then !
- Inversion (): The reverse disassembly procedure. If you packed a box, the inverse opens it and extracts the original item. You can only invert a procedure if it is bijective:
- If two different items were packed into identical boxes (not injective), unpacking cannot tell which item was original!
- If some boxes came from thin air without an item (not surjective), unpacking those boxes fails!
- The Reversal Law: If you put on socks () and then put on shoes (), to undo the process you must take off your shoes first (), and then take off your socks (). Hence: .
π» Bridging to Computer Science: Unix Pipes, Functional Programming & Compilersβ
In software systems:
- Unix Pipelines:
cat log.txt | grep ERROR | wc -lis the pure composition of three functions: . - Functional Programming: High-order functions like
map,filter, andcomposedirectly execute mathematical composition. - Cryptography & Decryption: Symmetric and asymmetric decryption keys compute .
- Database Query Plans: A multi-table join plan is composed of relational operators whose inversion allows transactional rollback.
π Function Composition: Chaining Transformationsβ
Let and be functions. The composition of and , denoted by:
is a function from to defined for all by:
Domain & Codomain Requirement: For to be defined, the Range of must be a subset of the Domain of :
The Two-Stage Function Composition Pipeline
Sequential evaluation from input element x to final transformed output g(f(x))
Element x
Domain input value fed into initial mapping f.
Image f(x)
Codomain of f serving as input domain for downstream mapping g.
Final Output g(f(x))
Resulting element in Codomain C representing (g β f)(x).
Concrete Evaluation Trace of Compositionβ
Consider sets , , and . Let functions and be defined by:
We trace each input element through the intermediate image to the final output :
| Input | First Stage | Second Stage | Composite Pair in |
|---|---|---|---|
Fundamental Properties of Function Compositionβ
- Associativity: Function composition is strictly associative. If , , and , then:
- Non-Commutativity: In general, function composition is NOT commutative: (Often, if is defined, may not even be defined because domain and codomain boundaries do not align).
- Identity Element: For any function : where and are the identity mappings on sets and .
β‘ Composition Preservation & The Backward Deduction Ruleβ
How do injectivity and surjectivity propagate across chained mappings? The following theorems establish the exact forward and backward dependencies:
| Direction & Hypothesis | Guaranteed Conclusion | Non-Guaranteed Counter-Trap | Core Intuition |
|---|---|---|---|
| Forward: and are Injective | is Injective | β | Collision-free pipeline: if neither stage collides, the composite cannot collide. |
| Forward: and are Surjective | is Surjective | β | Complete coverage: every target in has a pre-image in , which has a pre-image in . |
| Backward: is Injective | MUST be Injective | does NOT need to be injective | If collides at step 1, can never un-collide them. But collisions in outside are irrelevant! |
| Backward: is Surjective | MUST be Surjective | does NOT need to be surjective | The final stage must cover all of . Unreached elements in intermediate set don't harm coverage of . |
| Backward: is Bijective | is Injective AND is Surjective | Neither nor is individually forced to be bijective | The first stage guarantees no collisions; the final stage guarantees full coverage. |
Always remember: Injectivity tests the input end (), while Surjectivity tests the output end ()!
β©οΈ Inverse Functions & The Reversal Lawβ
Let be a function. An inverse function exists if and only if is a bijection (both injective and surjective).
When is bijective, is uniquely defined by:
Satisfying the identity compositions:
If and are both bijective functions, then is bijective, and its inverse is given by the socks-and-shoes reversal law:
Proof Derivation: Multiply by on the right:
Similarly, on the left:
Because the inverse is unique, .
π’ Exhaustive Counting Formulas for Finite Setsβ
Let domain set have elements and codomain set have elements:
Master Function Counting Reference Tableβ
| Function Category | Cardinality Constraint | Counting Formula | Derivation Principle |
|---|---|---|---|
| Total Functions | Any | Each of the domain elements independently chooses any of the codomain targets (). | |
| Injective Functions (1-to-1) | () | Targets chosen without replacement: . When , collisions forced by Pigeonhole Principle. | |
| Surjective Functions (Onto) | () | Principle of Inclusion-Exclusion (PIE): total functions minus functions missing target, plus functions missing targets, etc. | |
| Bijective Functions | () | Perfect permutation of elements into slots (). | |
| Strictly Increasing () | () | Choosing any targets from has exactly unique sorting in strictly increasing order. |
The number of surjective functions from set () to set () where is given by:
Expanded explicitly:
Connection to Stirling Numbers of the Second Kind: counts the number of ways to partition distinct items into unlabeled non-empty groups:
π Step-by-Step Worked Examplesβ
Example 1: Verifying the Backward Deduction Ruleβ
Problem Statement: Let and . Prove that if is injective, then must be injective. Provide a concrete counter-example showing that does not need to be injective.
Step-by-Step Solution:
-
Step 1: Direct Proof that must be injective
- We must show: .
- Suppose for .
- Apply function to both sides:
- By definition of composition, this is:
- Since is given to be injective, implies:
- Hence, must be injective!
-
Step 2: Concrete Counter-Example showing need not be injective
- Let , , and .
- Define by (injective).
- Define by and . Notice that is NOT injective because while .
- Now compute :
- Since has only 1 element, is trivially injective!
- Thus, is injective even though is not.
Key Takeaway: Injectivity of guarantees injectivity of the first function (), while surjectivity of guarantees surjectivity of the second function ().
Example 2: Counting All Surjective Functionsβ
Problem Statement: Let and . Find:
- The total number of functions from to .
- The total number of injective functions from to .
- The total number of surjective functions from to .
Step-by-Step Solution:
-
Step 1: Total Functions
- Here and .
- Total functions = .
-
Step 2: Injective Functions
- Since , by the Pigeonhole Principle at least two domain elements must map to the same target.
- Therefore, number of injective functions = .
-
Step 3: Surjective Functions (PIE Formula)
- Using the formula :
- Calculate each term:
- Term 1:
- Term 2:
- Term 3:
- Term 4:
- Summing the terms:
- Verification via Stirling numbers:
Key Takeaway: Always check the cardinalities: if , onto functions are ; if , one-to-one functions are .
π― Exam & Interview Pitfall Checkβ
Question 1: If and satisfy for all , is necessarily bijective? Key Focus Points: No! means , which proves that is injective and is surjective. However, does NOT have to be surjective, and does NOT have to be injective! For to be bijective, both and must hold simultaneously.
Question 2: How many functions from set () to itself are strictly increasing if ? Key Focus Points: Exactly ! For any subset of elements chosen from the codomain, there is only one way to arrange them in strictly increasing order. Since , all elements must be selected, giving unique function (the identity function ).
Trap 1: Evaluating in the wrong order Why it fails: In , students often mistakenly evaluate first. In mathematical notation, : the rightmost function () acts on first! Always read compositions from right to left.
Trap 2: Forgetting the Reversal Law for Inverses Why it fails: When inverting a pipeline , writing is invalid. The outer layer must be unpacked first, yielding .