Discrete StructureUnit 311 min read
Functions, Induction: Definitions, Proofs, and Real-World Models
Unit 3 of Discrete Structure covers functions (types, properties, and inverses) and mathematical induction (principles, proofs, and applications), with visuals for injectivity, surjectivity, and recursive structures, plus real-world ties to eSewa transactions, Daraz order queues, and Ncell billing.
TAKEAWAYS:
- Functions are mappings between sets with rules for injectivity (one-to-one), surjectivity (onto), and bijectivity (both), visualized via arrows and Venn diagrams.
- Mathematical induction proves statements for all natural numbers by verifying a base case and an inductive step, critical for algorithms and recursive definitions.
- Real-world functions model eSewa’s transaction hashing (injective), Daraz’s order queue (surjective), and Ncell’s billing cycles (recursive).
- Proof techniques include strong induction (for nested dependencies) and structural induction (for recursive data like trees).
- Common pitfalls: assuming induction works without a base case, misapplying surjectivity in finite sets, and conflating recursive definitions with iterative ones.
1. Functions: Definitions and Classifications
A function assigns each element of set (domain) to exactly one element of set (codomain). Functions are the backbone of algorithms, data mappings, and real-world systems like user authentication (hashing) or inventory tracking.
Key Properties
| Property | Definition | Visual Check | Example (Nepal Context) |
|---|---|---|---|
| Injective | (one-to-one) | No two arrows from point to the same element. | eSewa transaction IDs: unique per payment. |
| Surjective | Every has a pre-image in (onto) | Every element in is covered by at least one arrow. | Daraz order queue: every order ID maps to a delivery status. |
| Bijective | Both injective and surjective (one-to-one correspondence) | Perfect pairing: every maps to a unique , and vice versa. | Ncell’s SIM-to-user mapping (theoretical ideal). |
Worked Example: eSewa Transaction Hashing
eSewa uses a hash function that is injective (no two transactions produce the same hash). If Alice and Bob both pay ₹1000 to a merchant, their hashes must differ:
- Domain : All possible transactions (user, amount, timestamp).
- Codomain : 256-bit hash strings.
- Proof of injectivity: If , the system flags a collision (rare but possible in practice).
Trace:
- User inputs:
{"user": "Alice", "amount": 1000, "time": "10:00"}. - Hash function computes:
h(t) = "a1b2c3...". - Check: No other transaction in the database has this hash → injective.
2. Function Composition and Inverses
- Composition : Combining functions (e.g., applying a discount then tax).
- Inverse : Reverses if is bijective. Used in encryption (e.g., RSA) and decryption.
Mermaid Diagram: Function Composition
flowchart LR
A["Domain (X)"] -->|"g"| B["Intermediate (Y)"]
B -->|"f"| C["Codomain (Z)"]
A -->|"f∘g"| CReal-World Tie: Ncell Billing Cycle Ncell’s billing function is not injective (same minutes → same bill), but the inverse (predicting usage from bill) is not well-defined because multiple usage patterns can yield the same bill.
3. Mathematical Induction: Principle and Proofs
Induction proves statements for all natural numbers . It’s used in algorithm analysis (e.g., proving a sorting algorithm works for items) and recursive definitions (e.g., Fibonacci sequence).
Weak vs. Strong Induction
| Type | Base Case | Inductive Step | Use Case |
|---|---|---|---|
| Weak Induction | Prove | Assume true, prove . | Sum of first integers. |
| Strong Induction | Prove | Assume true, prove . | Recursive algorithms (e.g., Tower of Hanoi). |
Worked Example: Sum of First Natural Numbers
Statement: .
Proof by Weak Induction:
- Base Case (): . ✅
- Inductive Step: Assume holds. Prove : Thus, holds. By induction, is true for all .
Real-World Tie: Daraz Order Queue Daraz’s order processing can be modeled recursively:
- Base Case: 1 order is delivered in 1 day.
- Inductive Step: If orders take days, then orders take days (assuming linear processing).
- Limitation: Real queues have parallel processing (strong induction needed for multi-worker systems).
4. Structural Induction
Used for recursive data structures like trees or linked lists. Prove a property holds for:
- The base case (smallest structure, e.g., empty tree).
- Any structure built from smaller ones (inductive step).
Example: Sum of Nodes in a Binary Tree Statement: The sum of all nodes in a binary tree is .
Proof:
- Base Case: Empty tree . Sum is . ✅
- Inductive Step: Assume all trees with nodes satisfy the property. For a tree with nodes: By the inductive hypothesis, the sums of left and right subtrees hold. Thus, holds.
Mermaid Diagram: Binary Tree Sum
5. Common Pitfalls and Exam Traps
Forgetting the Base Case:
- ❌ "Assume holds" without proving .
- ✅ Always start with or the smallest valid input.
Misapplying Surjectivity:
- In finite sets, a function with cannot be surjective.
- Example: A Daraz warehouse with 100 items () cannot map surjectively to 200 customers () if each customer can only receive one item.
Confusing Weak and Strong Induction:
- Weak induction suffices for linear recursion (e.g., Fibonacci).
- Strong induction is needed for nested dependencies (e.g., proving a sorting network works for all input sizes).
Assuming Inverses Exist:
- Only bijective functions have inverses. Non-injective functions (e.g., ) fail here.
## In the Real World
eSewa Transactions (Injective Functions)
- Idea: Hash functions map transactions to unique codes.
- How: The system uses SHA-256, an injective (almost) function to prevent duplicate payments. If two transactions hash to the same code, the system detects a collision and rejects one.
- Why it matters: Ensures no double-spending or fraud in digital payments.
Daraz Order Queue (Surjective Functions)
- Idea: Order status updates must cover all possible states.
- How: The function (e.g., "Processing," "Shipped," "Delivered") is surjective if every order eventually reaches "Delivered." In practice, failed deliveries create "Returned" as an additional codomain element.
- Why it matters: Helps customers track orders and Daraz manage logistics.
Ncell Billing Cycles (Recursive Definitions)
- Idea: Billing is calculated recursively over usage periods.
- How: Monthly bill depends on usage in the -th month and the previous month’s bill: This resembles a recurrence relation where each month’s bill builds on prior data.
- Why it matters: Enables dynamic pricing and usage-based billing.
## Exam Tip
For Functions:
- Always draw arrows to show injectivity/surjectivity. Examiners love visual proofs.
- Memorize the definitions: Write them out in your own words (e.g., "Injective means no two inputs share the same output").
- Common question: Given a function , determine if it’s injective/surjective. Solution: Check if (injective) or if every is mapped to (surjective).
For Induction:
- Structure your proof clearly:
1. Base Case: Show P(1) holds. 2. Inductive Hypothesis: Assume P(k) holds. 3. Inductive Step: Prove P(k+1) using P(k). 4. Conclusion: By induction, P(n) holds for all n. - Practice with recurrence relations: Questions often ask to prove a closed-form solution (e.g., Fibonacci) using induction.
- Watch for strong induction: If the problem involves nested cases (e.g., "proving a sorting algorithm works for any input size"), use strong induction.
- Structure your proof clearly:
Avoid These Mistakes:
- ❌ Skipping the base case or assuming it’s trivial.
- ❌ Using weak induction for problems requiring strong induction (e.g., recursive algorithms).
- ❌ Forgetting to define the domain and codomain explicitly in function questions.
Real-World Applications:
- eSewa/Khalti: Expect questions on injective functions (e.g., "Why can’t two transactions have the same hash?").
- Daraz/Nepse: Surjective functions (e.g., "Can all orders be delivered? What if the warehouse is full?").
- Banks/Ncell: Recurrence relations (e.g., "Model the monthly interest on a loan using a recurrence relation").
Final Note: Discrete functions and induction are the "glue" between theory and real-world systems. Master these, and you’ll ace problems on algorithms, cryptography, and system design—key topics in IT235 and beyond.
Based on the TU BIM syllabus for Discrete Structure (IT235), unit 3.
Discussion
Loading…