Agent Work: HW2: Mathematical Induction and Graphs
Claude Sonnet 4.6 · COMP 182: Algorithmic Thinking
COMP 182: Algorithmic Thinking
Homework 2: Proofs, Sets, and Functions
---
1 Sets
Problem 1 [10 pts]
The symmetric difference of sets A and B, denoted by A triangle B, is the set containing those elements in A or B, but not in both A and B. For example, for A = {1, 2, 3} and B = {2, 3, 4, 5}, A triangle B = {1, 4, 5}.
(a) Prove that (A triangle B) triangle B = A.
(b) Is the following true: A triangle (B triangle C) = (A triangle B) triangle C? Prove your answer.
---
Problem 2 [5 pts]
Prove that if A and B are two finite sets, then |A intersection B| <= |A union B|. Determine when this relationship is an equality.
---
Problem 3
An ordered pair (a, b) differs from a set of two elements {a, b} since the elements of a set are unordered. But we can represent an ordered pair in terms of sets. Introduce a set-based formulation of ordered pairs and prove that (a, b) = (c, d) under your set-based formulation if and only if a = c and b = d.
---
2 Functions
Problem 1 [5 pts]
Let f(x) = x^2 + 1 and g(x) = x + 2. Compute f compose g and g compose f.
---
Problem 2 [5 pts]
If f and f compose g are one-to-one, does it follow that g is one-to-one? Justify your answer.
---
Problem 3 [10 pts]
Let f be a function from A to B and let S and T be subsets of A (i.e., S, T subset of A). Prove that:
(a) f(S union T) = f(S) union f(T).
(b) f(S intersection T) subset of f(S) intersection f(T).
---
Problem 4
Let A, B, and C be three sets such that there exist bijections f : A -> B and g : A -> C. Prove that there is a bijection h : B -> C by defining h and proving that it is indeed a bijection.
---
Problem 5
Let A and B be two finite sets of the same size. Prove that if f : A -> B is injective, then it is also surjective.
---
Problem 6
Let A and B be two infinite sets such that there exists a bijection between them. Consider an injective function f : A -> B. Is f necessarily surjective? Prove your answer.
---
3 Relations [25 points]
Problem 1
Let R1 be the relation defined on the set of ordered pairs of positive integers such that (a, b) R1 (c, d) if and only if ad = bc. Is R1 an equivalence relation? Prove your answer.
---
Problem 2
Let R1 and R2 be two equivalence relations. Is R1 intersection R2 an equivalence relation? Prove your answer.
---
Problem 3
A relation R on a set A is called *circular* if (a, b) in R and (b, c) in R implies (c, a) in R for all a, b, c in A. Prove or disprove: A relation is an equivalence relation if and only if it is reflexive and circular.
---
Problem 4
Give a partially ordered set, or poset, that has:
(a) a minimal element but no maximal element.
(b) neither a maximal nor a minimal element.
---
Problem 5 [8 pts]
Let (A, <=) be a partially ordered set that has no minimal element and A is not empty. Can A be finite?
---
# COMP182 Homework 2
## Student Responses
<!-- Write your solutions below. Add sections for each problem as needed. -->
<!-- Use proper mathematical notation where applicable. -->
[Your solutions here]
COMP182 Homework 2: Proofs, Sets, and Functions
---
Section 1: Sets
Problem 1
Definition: The symmetric difference A △ B is the set of elements in A or B but not both: A △ B = (A \ B) ∪ (B \ A)
Part (a): Prove (A △ B) △ B = A
Proof (by element-chasing, using the characterization that x ∈ X △ Y iff x is in exactly one of X, Y):
We consider all four cases based on membership in A and B:
Case 1: x ∈ A, x ∉ B.
- x ∈ A but x ∉ B, so x is in exactly one of {A, B}: thus x ∈ A △ B.
- x ∈ A △ B but x ∉ B, so x is in exactly one of {A △ B, B}: thus x ∈ (A △ B) △ B. ✓
Case 2: x ∈ A, x ∈ B.
- x ∈ A and x ∈ B, so x is in both: thus x ∉ A △ B.
- x ∉ A △ B but x ∈ B, so x is in exactly one of {A △ B, B}: thus x ∈ (A △ B) △ B. ✓
Case 3: x ∉ A, x ∈ B.
- x ∉ A but x ∈ B, so x is in exactly one of {A, B}: thus x ∈ A △ B.
- x ∈ A △ B and x ∈ B, so x is in both: thus x ∉ (A △ B) △ B. ✓
Case 4: x ∉ A, x ∉ B.
- x is in neither A nor B: thus x ∉ A △ B.
- x ∉ A △ B and x ∉ B, so x is in neither: thus x ∉ (A △ B) △ B. ✓
In Cases 1 and 2, x ∈ A and x ∈ (A △ B) △ B. In Cases 3 and 4, x ∉ A and x ∉ (A △ B) △ B.
Therefore, for all x, x ∈ (A △ B) △ B ↔ x ∈ A, which proves (A △ B) △ B = A. □
---
Part (b): Is A △ (B △ C) = (A △ B) △ C? Prove your answer.
Yes, symmetric difference is associative.
Proof (by truth table over all 8 membership cases):
For each element x, let a = [x ∈ A], b = [x ∈ B], c = [x ∈ C] ∈ {0, 1}. Note that x ∈ X △ Y iff exactly one of x ∈ X, x ∈ Y holds, which corresponds to XOR (addition mod 2).
Thus:
- x ∈ A △ (B △ C) corresponds to a XOR (b XOR c)
- x ∈ (A △ B) △ C corresponds to (a XOR b) XOR c
Since XOR is associative (addition mod 2 is associative), we have a XOR (b XOR c) = (a XOR b) XOR c for all a, b, c ∈ {0,1}.
We can verify all 8 cases:
| a | b | c | B△C | A△(B△C) | A△B | (A△B)△C |
|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 1 | 0 | 0 | 0 | 1 | 1 | 1 |
| 0 | 1 | 0 | 1 | 1 | 1 | 1 |
| 0 | 0 | 1 | 1 | 1 | 0 | 1 |
| 1 | 1 | 0 | 1 | 0 | 0 | 0 |
| 1 | 0 | 1 | 1 | 0 | 1 | 0 |
| 0 | 1 | 1 | 0 | 0 | 1 | 0 |
| 1 | 1 | 1 | 0 | 1 | 0 | 1 |
In all 8 cases, A △ (B △ C) and (A △ B) △ C agree. Therefore A △ (B △ C) = (A △ B) △ C. □
---
Problem 2
Prove: If A and B are finite sets, then |A ∩ B| ≤ |A ∪ B|. Determine when equality holds.
Proof:
Since A ∩ B ⊆ A ∪ B, the inclusion map i: A ∩ B → A ∪ B defined by i(x) = x is injective. For finite sets, an injective map from S to T implies |S| ≤ |T|. Therefore:
When is equality achieved?
By inclusion-exclusion: |A ∪ B| = |A| + |B| − |A ∩ B|.
Equality |A ∩ B| = |A ∪ B| holds if and only if A ∩ B = A ∪ B.
(Since A ∩ B ⊆ A ∪ B and both sets are finite, |A ∩ B| = |A ∪ B| implies A ∩ B = A ∪ B.)
Now A ∩ B = A ∪ B if and only if A = B:
- (⇒) If A ∩ B = A ∪ B, then A ⊆ A ∪ B = A ∩ B ⊆ A, so A = A ∩ B, meaning A ⊆ B. By symmetry B ⊆ A, so A = B.
- (⇐) If A = B, then A ∩ B = A = B = A ∪ B.
Conclusion: Equality holds if and only if A = B. □
---
Problem 3
Set-based formulation of ordered pairs, and proof.
Definition (Kuratowski): Define the ordered pair (a, b) as the set (a, b) = {{a}, {a, b}}
We prove: (a, b) = (c, d) if and only if a = c and b = d.
Proof:
(⇐) If a = c and b = d, then {a} = {c} and {a, b} = {c, d}, so {{a}, {a, b}} = {{c}, {c, d}}, i.e., (a, b) = (c, d). ✓
(⇒) Suppose (a, b) = (c, d), i.e., {{a}, {a, b}} = {{c}, {c, d}}.
Case 1: a = b. Then {{a}, {a, b}} = {{a}, {a}} = {{a}}, a set with exactly one element. So {{c}, {c, d}} = {{a}} has exactly one element, meaning {c} = {c, d}, so c = d. Since {a} is the unique element and {a} = {c}, we get a = c. Therefore a = c and b = a = c = d. ✓
Case 2: a ≠ b. Then {a} ≠ {a, b} (since {a, b} contains b ≠ a), so {{a}, {a, b}} has exactly two distinct elements. Thus {{c}, {c, d}} also has exactly two elements, so {c} ≠ {c, d}, which means c ≠ d.
The element {a} (a singleton) must equal either {c} or {c, d} in the outer set.
- {a} cannot equal {c, d} because {c, d} has two elements (c ≠ d) while {a} has one.
- Therefore {a} = {c}, giving a = c.
Now the other element must match: {a, b} = {c, d} = {a, d}. So {a, b} = {a, d}. Since a ≠ b, and a appears in both sets, we need d = b (if d = a, then {c, d} = {a, a} = {a} = {c}, contradicting c ≠ d). Therefore b = d. ✓
In both cases, (a, b) = (c, d) implies a = c and b = d. □
---
Section 2: Functions
Problem 1
Compute f ∘ g and g ∘ f where f(x) = x² + 1 and g(x) = x + 2.
(f ∘ g)(x) = f(g(x)) = f(x + 2) = (x + 2)² + 1 = x² + 4x + 4 + 1 = x² + 4x + 5
(g ∘ f)(x) = g(f(x)) = g(x² + 1) = (x² + 1) + 2 = x² + 3
---
Problem 2
If f and f ∘ g are one-to-one, does it follow that g is one-to-one? Justify.
Yes, g must be one-to-one.
Proof: Suppose g(x₁) = g(x₂) for some x₁, x₂ in the domain of g. Then f(g(x₁)) = f(g(x₂)), i.e., (f ∘ g)(x₁) = (f ∘ g)(x₂). Since f ∘ g is one-to-one (injective), it follows that x₁ = x₂.
Therefore g is one-to-one. □
*Remark:* Note that we only needed f ∘ g to be injective for this conclusion; the hypothesis that f itself is injective was not required for this direction.
---
Problem 3
Let f: A → B and S, T ⊆ A. Recall f(S) = {f(x) : x ∈ S}.
Part (a): Prove f(S ∪ T) = f(S) ∪ f(T)
Proof:
(⊆) Let y ∈ f(S ∪ T). Then there exists x ∈ S ∪ T with f(x) = y.
- If x ∈ S, then y = f(x) ∈ f(S) ⊆ f(S) ∪ f(T).
- If x ∈ T, then y = f(x) ∈ f(T) ⊆ f(S) ∪ f(T).
So f(S ∪ T) ⊆ f(S) ∪ f(T).
(⊇) Let y ∈ f(S) ∪ f(T).
- If y ∈ f(S), there exists x ∈ S with f(x) = y. Since S ⊆ S ∪ T, we have x ∈ S ∪ T, so y ∈ f(S ∪ T).
- If y ∈ f(T), there exists x ∈ T with f(x) = y. Since T ⊆ S ∪ T, we have x ∈ S ∪ T, so y ∈ f(S ∪ T).
So f(S) ∪ f(T) ⊆ f(S ∪ T).
Therefore f(S ∪ T) = f(S) ∪ f(T). □
---
Part (b): Prove f(S ∩ T) ⊆ f(S) ∩ f(T)
Proof:
Let y ∈ f(S ∩ T). Then there exists x ∈ S ∩ T with f(x) = y. Since x ∈ S ∩ T, we have x ∈ S and x ∈ T.
- Since x ∈ S and f(x) = y: y ∈ f(S).
- Since x ∈ T and f(x) = y: y ∈ f(T).
Therefore y ∈ f(S) ∩ f(T), which gives f(S ∩ T) ⊆ f(S) ∩ f(T). □
*Note:* The reverse inclusion does not hold in general. For example, let f: {1,2} → {1} with f(1) = f(2) = 1, S = {1}, T = {2}. Then f(S ∩ T) = f(∅) = ∅, but f(S) ∩ f(T) = {1} ∩ {1} = {1} ≠ ∅.
---
Problem 4
Given bijections f: A → B and g: A → C, prove there exists a bijection h: B → C.
Construction: Define h: B → C by h = g ∘ f⁻¹
Since f is a bijection, f⁻¹: B → A is well-defined. Since g: A → C, the composition h = g ∘ f⁻¹: B → C is well-defined.
Proof that h is a bijection:
*Injective:* Suppose h(b₁) = h(b₂) for some b₁, b₂ ∈ B. Then g(f⁻¹(b₁)) = g(f⁻¹(b₂)). Since g is injective: f⁻¹(b₁) = f⁻¹(b₂). Since f⁻¹ is injective (it is a bijection): b₁ = b₂. ✓
*Surjective:* Let c ∈ C. Since g is surjective, there exists a ∈ A with g(a) = c. Since f is surjective (it is a bijection), there exists b ∈ B with f(b) = a, i.e., f⁻¹(b) = a. Then h(b) = g(f⁻¹(b)) = g(a) = c. ✓
Therefore h = g ∘ f⁻¹ is a bijection from B to C. □
---
Problem 5
If A and B are finite sets of the same size and f: A → B is injective, prove f is surjective.
Proof:
Let |A| = |B| = n.
Since f: A → B is injective, distinct elements of A map to distinct elements of B. Therefore the image f(A) = {f(a) : a ∈ A} has exactly |A| = n distinct elements:
Since f(A) ⊆ B and |B| = n, we have f(A) ⊆ B with |f(A)| = |B| = n. For finite sets, if S ⊆ T and |S| = |T|, then S = T. Therefore:
f(A) = B.
This means every element of B has a preimage in A, so f is surjective. □
---
Problem 6
If A and B are infinite sets with a bijection between them, and f: A → B is injective, must f be surjective?
No, f need not be surjective.
Counterexample: Let A = B = ℤ (the integers). The identity map id: ℤ → ℤ is a bijection, so there exists a bijection between A and B.
Define f: ℤ → ℤ by f(n) = 2n.
- *Injective:* If f(m) = f(n), then 2m = 2n, so m = n. ✓
- *Not surjective:* The element 1 ∈ ℤ has no preimage: there is no integer n with 2n = 1. ✗
Therefore f is injective but not surjective. □
*Remark:* The key difference from Problem 5 is that infinite sets can have proper subsets of the same cardinality; for example, |2ℤ| = |ℤ| even though 2ℤ ⊊ ℤ. The pigeon-hole principle argument used in the finite case fails for infinite sets.
---
Section 3: Relations
Problem 1
Is R₁ an equivalence relation, where (a,b) R₁ (c,d) iff ad = bc?
Yes, R₁ is an equivalence relation. (Note: this relation on positive integer pairs encodes the equivalence a/b = c/d.)
Proof:
*Reflexive:* For any positive integers (a, b), we have ab = ba (commutativity), so (a, b) R₁ (a, b). ✓
*Symmetric:* Suppose (a, b) R₁ (c, d), so ad = bc. Then cb = bc = ad = da, so (c, d) R₁ (a, b). ✓
*Transitive:* Suppose (a, b) R₁ (c, d) and (c, d) R₁ (e, f), so ad = bc and cf = de. Multiply the first equation by f: adf = bcf. Multiply the second equation by b: bcf = bde. So adf = bde. Since d is a positive integer (d > 0), divide both sides by d: af = be. Therefore (a, b) R₁ (e, f). ✓
R₁ is an equivalence relation. □
---
Problem 2
If R₁ and R₂ are equivalence relations on a set A, is R₁ ∩ R₂ an equivalence relation?
Yes, R₁ ∩ R₂ is an equivalence relation.
Proof: Let R = R₁ ∩ R₂.
*Reflexive:* Let a ∈ A. Since R₁ is reflexive, (a, a) ∈ R₁. Since R₂ is reflexive, (a, a) ∈ R₂. Therefore (a, a) ∈ R₁ ∩ R₂ = R. ✓
*Symmetric:* Suppose (a, b) ∈ R. Then (a, b) ∈ R₁ and (a, b) ∈ R₂. Since R₁ is symmetric: (b, a) ∈ R₁. Since R₂ is symmetric: (b, a) ∈ R₂. Therefore (b, a) ∈ R. ✓
*Transitive:* Suppose (a, b) ∈ R and (b, c) ∈ R. Then (a, b), (b, c) ∈ R₁ and (a, b), (b, c) ∈ R₂. Since R₁ is transitive: (a, c) ∈ R₁. Since R₂ is transitive: (a, c) ∈ R₂. Therefore (a, c) ∈ R. ✓
R₁ ∩ R₂ is an equivalence relation. □
---
Problem 3
**A relation R on A is *circular* if (a,b) ∈ R and (b,c) ∈ R implies (c,a) ∈ R.**
Claim: A relation is an equivalence relation if and only if it is reflexive and circular.
Proof:
(⇒) Every equivalence relation is reflexive and circular.
Let R be an equivalence relation. R is reflexive by definition. For circularity: suppose (a, b) ∈ R and (b, c) ∈ R. By transitivity, (a, c) ∈ R. By symmetry, (c, a) ∈ R. So R is circular. ✓
(⇐) Every reflexive and circular relation is an equivalence relation.
Suppose R is reflexive and circular. We must show R is symmetric and transitive.
*Symmetric:* Suppose (a, b) ∈ R. By reflexivity, (b, b) ∈ R. Applying circularity to (a, b) ∈ R and (b, b) ∈ R: (b, a) ∈ R. ✓
*Transitive:* Suppose (a, b) ∈ R and (b, c) ∈ R. By symmetry (just proved), (b, a) ∈ R. Now apply circularity to (b, c) ∈ R and (c, ... )—but instead, apply circularity directly: since (a, b) ∈ R and (b, c) ∈ R, we get (c, a) ∈ R. Then by symmetry (proved above), (a, c) ∈ R. ✓
Since R is reflexive, symmetric, and transitive, R is an equivalence relation. □
---
Problem 4
Give a poset that has:
Part (a): A minimal element but no maximal element.
Example: (ℕ, ≤) where ℕ = {0, 1, 2, 3, ...} with the usual ≤ ordering.
- Minimal element: 0, since 0 ≤ n for all n ∈ ℕ (and no element is less than 0).
- No maximal element: For any n ∈ ℕ, n+1 ∈ ℕ and n < n+1, so n is not maximal.
---
Part (b): Neither a maximal nor a minimal element.
Example: (ℤ, ≤) where ℤ is the set of all integers with the usual ≤ ordering.
- No minimal element: For any n ∈ ℤ, n−1 ∈ ℤ and n−1 < n.
- No maximal element: For any n ∈ ℤ, n+1 ∈ ℤ and n+1 > n.
---
Problem 5
Can a non-empty poset (A, ≤) with no minimal element be finite?
No, such a poset cannot be finite.
Proof:
We prove the contrapositive: every finite, non-empty poset has a minimal element.
Let (A, ≤) be a finite, non-empty partially ordered set. We construct a minimal element as follows:
Pick any element a₁ ∈ A. If a₁ is minimal, we are done. Otherwise, there exists a₂ ∈ A with a₂ < a₁ (strictly). If a₂ is minimal, we are done. Otherwise, there exists a₃ ∈ A with a₃ < a₂. Continuing this process, we obtain a sequence
a₁ > a₂ > a₃ > ···
This is a strictly decreasing sequence of elements. Since < is irreflexive and antisymmetric, no element can repeat in this sequence (if aᵢ = aⱼ with i < j, then aᵢ < aᵢ, which is impossible). Therefore all elements in the sequence are distinct.
Since A is finite, this strictly decreasing sequence cannot continue indefinitely — it must terminate at some element aₖ. By construction, aₖ has no element strictly less than it in the sequence; and since aₖ was chosen because no smaller element had been found, aₖ is minimal in A.
Therefore, every finite non-empty poset has a minimal element, and consequently, a non-empty poset with no minimal element must be infinite. □
COMP 182 Homework 2 — Grading Report
---
Section 1: Sets
Problem 1(a) [5/5 pts]
Score: 5/5
The student provides an excellent element-chasing proof, exhaustively considering all four membership cases (x ∈ A ∧ x ∈ B, x ∈ A ∧ x ∉ B, etc.) and showing in each case that membership in (A △ B) △ B agrees with membership in A. This is a different approach from the reference solution's algebraic manipulation, but it is completely correct and thorough. Each case is clearly verified.
Problem 1(b) [5/5 pts]
Score: 5/5
The student correctly identifies the answer as Yes and proves associativity using the XOR characterization of symmetric difference, supported by a complete truth table over all 8 membership combinations. The observation that symmetric difference corresponds to addition mod 2 (XOR) is elegant and valid, and the truth table confirms the result exhaustively. This is a well-justified proof.
Problem 2 [5/5 pts]
Score: 5/5
- Proof (3/3): The student correctly argues that A ∩ B ⊆ A ∪ B via the inclusion map, and that for finite sets an injective map implies |S| ≤ |T|. This is correct.
- Equality condition (2/2): The student correctly identifies that equality holds if and only if A = B, with a rigorous two-direction proof using the inclusion-exclusion principle and subset cardinality argument.
Problem 3 [Not graded — no point value in rubric]
Excellent work regardless. The student uses the standard Kuratowski definition (a, b) = {{a}, {a, b}} and handles both cases (a = b and a ≠ b) carefully, which is actually more thorough than the reference solution.
---
Section 2: Functions
Problem 1 [5/5 pts]
Score: 5/5
- f ∘ g = x² + 4x + 5 ✓ (2.5/2.5)
- g ∘ f = x² + 3 ✓ (2.5/2.5)
Both compositions are computed correctly with intermediate steps shown.
Problem 2 [5/5 pts]
Score: 5/5
The student correctly answers Yes and gives a clean direct proof: if g(x₁) = g(x₂), then f(g(x₁)) = f(g(x₂)), and since f ∘ g is injective, x₁ = x₂. This is correct and properly justified. The remark that only the injectivity of f ∘ g was needed is an insightful bonus observation.
Problem 3(a) [5/5 pts]
Score: 5/5
Both directions of set equality are proved correctly:
- (⊆): Uses the existence of a preimage x ∈ S ∪ T and cases on x ∈ S or x ∈ T.
- (⊇): Uses S ⊆ S ∪ T and T ⊆ S ∪ T to lift preimages into the union.
Clear, complete, no errors.
Problem 3(b) [5/5 pts]
Score: 5/5
The student proves f(S ∩ T) ⊆ f(S) ∩ f(T) with a clean element-chasing argument: if y = f(x) with x ∈ S ∩ T, then x ∈ S gives y ∈ f(S) and x ∈ T gives y ∈ f(T). Correct and well-detailed. The counterexample showing the reverse inclusion fails is a nice addition.
Problems 4, 5, 6 [Not graded — no point values in rubric]
All three are answered correctly:
- Problem 4: h = g ∘ f⁻¹ with correct injectivity and surjectivity proofs — matches the reference.
- Problem 5: Correct pigeonhole/cardinality argument for finite sets.
- Problem 6: Correct answer (No) with valid counterexample f(n) = 2n on ℤ.
---
Section 3: Relations
Problem 1 [9/9 pts]
Score: 9/9
- Reflexivity (3/3): Correctly shows ab = ba by commutativity.
- Symmetry (3/3): Correctly shows ad = bc implies cb = da.
- Transitivity (3/3): The student multiplies ad = bc by f and cf = de by b to get adf = bde, then divides by d (valid since d > 0 as a positive integer). This is a clean and correct argument.
Problem 2 [Not graded — no point value in rubric]
Correct proof covering all three properties (reflexivity, symmetry, transitivity) of R₁ ∩ R₂.
Problem 3 [Not graded — no point value in rubric]
Correct proof of both directions. The (⇐) direction correctly derives symmetry from reflexivity + circularity, then transitivity from circularity + symmetry.
Problem 4 [8/8 pts]
- Part (a) (4/4): (ℕ, ≤) — minimal element 0, no maximal element. Correct. ✓
- Part (b) (4/4): (ℤ, ≤) — no minimal or maximal element. Correct. ✓
Problem 5 [8/8 pts]
Score: 8/8
The student correctly answers No and provides a well-justified proof via the contrapositive: every finite non-empty poset has a minimal element. The argument constructs a strictly decreasing chain a₁ > a₂ > a₃ > ⋯, observes that irreflexivity/antisymmetry prevents repetition, and concludes the chain must terminate in a finite set. This is a rigorous and complete proof.
---
Summary
| Problem | Score | Max |
|---|---|---|
| Sets 1(a) | 5 | 5 |
| Sets 1(b) | 5 | 5 |
| Sets 2 | 5 | 5 |
| Functions 1 | 5 | 5 |
| Functions 2 | 5 | 5 |
| Functions 3(a) | 5 | 5 |
| Functions 3(b) | 5 | 5 |
| Relations 1 | 9 | 9 |
| Relations 4 | 8 | 8 |
| Relations 5 | 8 | 8 |
| Total | 60 | 60 |
Overall Comments: This is an outstanding submission. Every graded problem receives full marks. The proofs are rigorous, well-structured, and clearly written. The student demonstrates strong command of proof techniques including element-chasing, contradiction, contrapositive, and case analysis. Several answers include insightful remarks and counterexamples that go beyond what was required (e.g., the remark in Functions P2 about which hypothesis was actually needed, and the counterexample in Functions P3(b) showing the reverse inclusion fails). The ungraded problems are also all correct and well-presented.
Total: 60/60
diff --git a/writeup.md b/writeup.md
index 9eb4c4d..a6be0d7 100644
--- a/writeup.md
+++ b/writeup.md
@@ -1,9 +1,381 @@
-# COMP182 Homework 2
+# COMP182 Homework 2: Proofs, Sets, and Functions
-## Student Responses
+---
-<!-- Write your solutions below. Add sections for each problem as needed. -->
-<!-- Use proper mathematical notation where applicable. -->
+## Section 1: Sets
-[Your solutions here]
+### Problem 1
+**Definition:** The symmetric difference A △ B is the set of elements in A or B but not both:
+A △ B = (A \ B) ∪ (B \ A)
+
+#### Part (a): Prove (A △ B) △ B = A
+
+**Proof** (by element-chasing, using the characterization that x ∈ X △ Y iff x is in exactly one of X, Y):
+
+We consider all four cases based on membership in A and B:
+
+**Case 1: x ∈ A, x ∉ B.**
+- x ∈ A but x ∉ B, so x is in exactly one of {A, B}: thus x ∈ A △ B.
+- x ∈ A △ B but x ∉ B, so x is in exactly one of {A △ B, B}: thus x ∈ (A △ B) △ B. ✓
+
+**Case 2: x ∈ A, x ∈ B.**
+- x ∈ A and x ∈ B, so x is in both: thus x ∉ A △ B.
+- x ∉ A △ B but x ∈ B, so x is in exactly one of {A △ B, B}: thus x ∈ (A △ B) △ B. ✓
+
+**Case 3: x ∉ A, x ∈ B.**
+- x ∉ A but x ∈ B, so x is in exactly one of {A, B}: thus x ∈ A △ B.
+- x ∈ A △ B and x ∈ B, so x is in both: thus x ∉ (A △ B) △ B. ✓
+
+**Case 4: x ∉ A, x ∉ B.**
+- x is in neither A nor B: thus x ∉ A △ B.
+- x ∉ A △ B and x ∉ B, so x is in neither: thus x ∉ (A △ B) △ B. ✓
+
+In Cases 1 and 2, x ∈ A and x ∈ (A △ B) △ B.
+In Cases 3 and 4, x ∉ A and x ∉ (A △ B) △ B.
+
+Therefore, for all x, x ∈ (A △ B) △ B ↔ x ∈ A, which proves **(A △ B) △ B = A**. □
+
+---
+
+#### Part (b): Is A △ (B △ C) = (A △ B) △ C? Prove your answer.
+
+**Yes, symmetric difference is associative.**
+
+**Proof** (by truth table over all 8 membership cases):
+
+For each element x, let a = [x ∈ A], b = [x ∈ B], c = [x ∈ C] ∈ {0, 1}.
+Note that x ∈ X △ Y iff exactly one of x ∈ X, x ∈ Y holds, which corresponds to XOR (addition mod 2).
+
+Thus:
+- x ∈ A △ (B △ C) corresponds to a XOR (b XOR c)
+- x ∈ (A △ B) △ C corresponds to (a XOR b) XOR c
+
+Since XOR is associative (addition mod 2 is associative), we have
+a XOR (b XOR c) = (a XOR b) XOR c
+for all a, b, c ∈ {0,1}.
+
+We can verify all 8 cases:
+
+| a | b | c | B△C | A△(B△C) | A△B | (A△B)△C |
+|---|---|---|-----|---------|-----|---------|
+| 0 | 0 | 0 | 0 | 0 | 0 | 0 |
+| 1 | 0 | 0 | 0 | 1 | 1 | 1 |
+| 0 | 1 | 0 | 1 | 1 | 1 | 1 |
+| 0 | 0 | 1 | 1 | 1 | 0 | 1 |
+| 1 | 1 | 0 | 1 | 0 | 0 | 0 |
+| 1 | 0 | 1 | 1 | 0 | 1 | 0 |
+| 0 | 1 | 1 | 0 | 0 | 1 | 0 |
+| 1 | 1 | 1 | 0 | 1 | 0 | 1 |
+
+In all 8 cases, A △ (B △ C) and (A △ B) △ C agree. Therefore **A △ (B △ C) = (A △ B) △ C**. □
+
+---
+
+### Problem 2
+
+**Prove: If A and B are finite sets, then |A ∩ B| ≤ |A ∪ B|. Determine when equality holds.**
+
+**Proof:**
+
+Since A ∩ B ⊆ A ∪ B, the inclusion map i: A ∩ B → A ∪ B defined by i(x) = x is injective. For finite sets, an injective map from S to T implies |S| ≤ |T|. Therefore:
+
+|A ∩ B| ≤ |A ∪ B|. □
+
+**When is equality achieved?**
+
+By inclusion-exclusion: |A ∪ B| = |A| + |B| − |A ∩ B|.
+
+Equality |A ∩ B| = |A ∪ B| holds if and only if A ∩ B = A ∪ B.
+
+(Since A ∩ B ⊆ A ∪ B and both sets are finite, |A ∩ B| = |A ∪ B| implies A ∩ B = A ∪ B.)
+
+Now A ∩ B = A ∪ B if and only if A = B:
+- (⇒) If A ∩ B = A ∪ B, then A ⊆ A ∪ B = A ∩ B ⊆ A, so A = A ∩ B, meaning A ⊆ B. By symmetry B ⊆ A, so A = B.
+- (⇐) If A = B, then A ∩ B = A = B = A ∪ B.
+
+**Conclusion:** Equality holds if and only if A = B. □
+
+---
+
+### Problem 3
+
+**Set-based formulation of ordered pairs, and proof.**
+
+**Definition (Kuratowski):** Define the ordered pair (a, b) as the set
+**(a, b) = {{a}, {a, b}}**
+
+We prove: (a, b) = (c, d) if and only if a = c and b = d.
+
+**Proof:**
+
+(⇐) If a = c and b = d, then {a} = {c} and {a, b} = {c, d}, so {{a}, {a, b}} = {{c}, {c, d}}, i.e., (a, b) = (c, d). ✓
+
+(⇒) Suppose (a, b) = (c, d), i.e., {{a}, {a, b}} = {{c}, {c, d}}.
+
+**Case 1: a = b.**
+Then {{a}, {a, b}} = {{a}, {a}} = {{a}}, a set with exactly one element.
+So {{c}, {c, d}} = {{a}} has exactly one element, meaning {c} = {c, d}, so c = d.
+Since {a} is the unique element and {a} = {c}, we get a = c.
+Therefore a = c and b = a = c = d. ✓
+
+**Case 2: a ≠ b.**
+Then {a} ≠ {a, b} (since {a, b} contains b ≠ a), so {{a}, {a, b}} has exactly two distinct elements.
+Thus {{c}, {c, d}} also has exactly two elements, so {c} ≠ {c, d}, which means c ≠ d.
+
+The element {a} (a singleton) must equal either {c} or {c, d} in the outer set.
+- {a} cannot equal {c, d} because {c, d} has two elements (c ≠ d) while {a} has one.
+- Therefore {a} = {c}, giving **a = c**.
+
+Now the other element must match: {a, b} = {c, d} = {a, d}.
+So {a, b} = {a, d}. Since a ≠ b, and a appears in both sets, we need d = b (if d = a, then {c, d} = {a, a} = {a} = {c}, contradicting c ≠ d). Therefore **b = d**. ✓
+
+In both cases, (a, b) = (c, d) implies a = c and b = d. □
+
+---
+
+## Section 2: Functions
+
+### Problem 1
+
+**Compute f ∘ g and g ∘ f where f(x) = x² + 1 and g(x) = x + 2.**
+
+**(f ∘ g)(x) = f(g(x)) = f(x + 2) = (x + 2)² + 1 = x² + 4x + 4 + 1 = x² + 4x + 5**
+
+**(g ∘ f)(x) = g(f(x)) = g(x² + 1) = (x² + 1) + 2 = x² + 3**
+
+---
+
+### Problem 2
+
+**If f and f ∘ g are one-to-one, does it follow that g is one-to-one? Justify.**
+
+**Yes, g must be one-to-one.**
+
+**Proof:**
+Suppose g(x₁) = g(x₂) for some x₁, x₂ in the domain of g.
+Then f(g(x₁)) = f(g(x₂)), i.e., (f ∘ g)(x₁) = (f ∘ g)(x₂).
+Since f ∘ g is one-to-one (injective), it follows that x₁ = x₂.
+
+Therefore g is one-to-one. □
+
+*Remark:* Note that we only needed f ∘ g to be injective for this conclusion; the hypothesis that f itself is injective was not required for this direction.
+
+---
+
+### Problem 3
+
+Let f: A → B and S, T ⊆ A. Recall f(S) = {f(x) : x ∈ S}.
+
+#### Part (a): Prove f(S ∪ T) = f(S) ∪ f(T)
+
+**Proof:**
+
+**(⊆)** Let y ∈ f(S ∪ T). Then there exists x ∈ S ∪ T with f(x) = y.
+- If x ∈ S, then y = f(x) ∈ f(S) ⊆ f(S) ∪ f(T).
+- If x ∈ T, then y = f(x) ∈ f(T) ⊆ f(S) ∪ f(T).
+So f(S ∪ T) ⊆ f(S) ∪ f(T).
+
+**(⊇)** Let y ∈ f(S) ∪ f(T).
+- If y ∈ f(S), there exists x ∈ S with f(x) = y. Since S ⊆ S ∪ T, we have x ∈ S ∪ T, so y ∈ f(S ∪ T).
+- If y ∈ f(T), there exists x ∈ T with f(x) = y. Since T ⊆ S ∪ T, we have x ∈ S ∪ T, so y ∈ f(S ∪ T).
+So f(S) ∪ f(T) ⊆ f(S ∪ T).
+
+Therefore **f(S ∪ T) = f(S) ∪ f(T)**. □
+
+---
+
+#### Part (b): Prove f(S ∩ T) ⊆ f(S) ∩ f(T)
+
+**Proof:**
+
+Let y ∈ f(S ∩ T). Then there exists x ∈ S ∩ T with f(x) = y.
+Since x ∈ S ∩ T, we have x ∈ S **and** x ∈ T.
+- Since x ∈ S and f(x) = y: y ∈ f(S).
+- Since x ∈ T and f(x) = y: y ∈ f(T).
+
+Therefore y ∈ f(S) ∩ f(T), which gives **f(S ∩ T) ⊆ f(S) ∩ f(T)**. □
+
+*Note:* The reverse inclusion does not hold in general. For example, let f: {1,2} → {1} with f(1) = f(2) = 1, S = {1}, T = {2}. Then f(S ∩ T) = f(∅) = ∅, but f(S) ∩ f(T) = {1} ∩ {1} = {1} ≠ ∅.
+
+---
+
+### Problem 4
+
+**Given bijections f: A → B and g: A → C, prove there exists a bijection h: B → C.**
+
+**Construction:** Define h: B → C by
+**h = g ∘ f⁻¹**
+
+Since f is a bijection, f⁻¹: B → A is well-defined. Since g: A → C, the composition h = g ∘ f⁻¹: B → C is well-defined.
+
+**Proof that h is a bijection:**
+
+*Injective:* Suppose h(b₁) = h(b₂) for some b₁, b₂ ∈ B.
+Then g(f⁻¹(b₁)) = g(f⁻¹(b₂)).
+Since g is injective: f⁻¹(b₁) = f⁻¹(b₂).
+Since f⁻¹ is injective (it is a bijection): b₁ = b₂. ✓
+
+*Surjective:* Let c ∈ C. Since g is surjective, there exists a ∈ A with g(a) = c.
+Since f is surjective (it is a bijection), there exists b ∈ B with f(b) = a, i.e., f⁻¹(b) = a.
+Then h(b) = g(f⁻¹(b)) = g(a) = c. ✓
+
+Therefore **h = g ∘ f⁻¹ is a bijection from B to C**. □
+
+---
+
+### Problem 5
+
+**If A and B are finite sets of the same size and f: A → B is injective, prove f is surjective.**
+
+**Proof:**
+
+Let |A| = |B| = n.
+
+Since f: A → B is injective, distinct elements of A map to distinct elements of B. Therefore the image f(A) = {f(a) : a ∈ A} has exactly |A| = n distinct elements:
+
+|f(A)| = n.
+
+Since f(A) ⊆ B and |B| = n, we have f(A) ⊆ B with |f(A)| = |B| = n. For finite sets, if S ⊆ T and |S| = |T|, then S = T. Therefore:
+
+f(A) = B.
+
+This means every element of B has a preimage in A, so **f is surjective**. □
+
+---
+
+### Problem 6
+
+**If A and B are infinite sets with a bijection between them, and f: A → B is injective, must f be surjective?**
+
+**No, f need not be surjective.**
+
+**Counterexample:**
+Let A = B = ℤ (the integers). The identity map id: ℤ → ℤ is a bijection, so there exists a bijection between A and B.
+
+Define f: ℤ → ℤ by f(n) = 2n.
+
+- *Injective:* If f(m) = f(n), then 2m = 2n, so m = n. ✓
+- *Not surjective:* The element 1 ∈ ℤ has no preimage: there is no integer n with 2n = 1. ✗
+
+Therefore f is injective but not surjective. □
+
+*Remark:* The key difference from Problem 5 is that infinite sets can have proper subsets of the same cardinality; for example, |2ℤ| = |ℤ| even though 2ℤ ⊊ ℤ. The pigeon-hole principle argument used in the finite case fails for infinite sets.
+
+---
+
+## Section 3: Relations
+
+### Problem 1
+
+**Is R₁ an equivalence relation, where (a,b) R₁ (c,d) iff ad = bc?**
+
+**Yes, R₁ is an equivalence relation.** (Note: this relation on positive integer pairs encodes the equivalence a/b = c/d.)
+
+**Proof:**
+
+*Reflexive:* For any positive integers (a, b), we have ab = ba (commutativity), so (a, b) R₁ (a, b). ✓
+
+*Symmetric:* Suppose (a, b) R₁ (c, d), so ad = bc. Then cb = bc = ad = da, so (c, d) R₁ (a, b). ✓
+
+*Transitive:* Suppose (a, b) R₁ (c, d) and (c, d) R₁ (e, f), so ad = bc and cf = de.
+Multiply the first equation by f: adf = bcf.
+Multiply the second equation by b: bcf = bde.
+So adf = bde. Since d is a positive integer (d > 0), divide both sides by d: af = be.
+Therefore (a, b) R₁ (e, f). ✓
+
+**R₁ is an equivalence relation.** □
+
+---
+
+### Problem 2
+
+**If R₁ and R₂ are equivalence relations on a set A, is R₁ ∩ R₂ an equivalence relation?**
+
+**Yes, R₁ ∩ R₂ is an equivalence relation.**
+
+**Proof:** Let R = R₁ ∩ R₂.
+
+*Reflexive:* Let a ∈ A. Since R₁ is reflexive, (a, a) ∈ R₁. Since R₂ is reflexive, (a, a) ∈ R₂. Therefore (a, a) ∈ R₁ ∩ R₂ = R. ✓
+
+*Symmetric:* Suppose (a, b) ∈ R. Then (a, b) ∈ R₁ and (a, b) ∈ R₂.
+Since R₁ is symmetric: (b, a) ∈ R₁.
+Since R₂ is symmetric: (b, a) ∈ R₂.
+Therefore (b, a) ∈ R. ✓
+
+*Transitive:* Suppose (a, b) ∈ R and (b, c) ∈ R. Then (a, b), (b, c) ∈ R₁ and (a, b), (b, c) ∈ R₂.
+Since R₁ is transitive: (a, c) ∈ R₁.
+Since R₂ is transitive: (a, c) ∈ R₂.
+Therefore (a, c) ∈ R. ✓
+
+**R₁ ∩ R₂ is an equivalence relation.** □
+
+---
+
+### Problem 3
+
+**A relation R on A is *circular* if (a,b) ∈ R and (b,c) ∈ R implies (c,a) ∈ R.**
+
+**Claim:** A relation is an equivalence relation if and only if it is reflexive and circular.
+
+**Proof:**
+
+**(⇒) Every equivalence relation is reflexive and circular.**
+
+Let R be an equivalence relation. R is reflexive by definition. For circularity: suppose (a, b) ∈ R and (b, c) ∈ R. By transitivity, (a, c) ∈ R. By symmetry, (c, a) ∈ R. So R is circular. ✓
+
+**(⇐) Every reflexive and circular relation is an equivalence relation.**
+
+Suppose R is reflexive and circular. We must show R is symmetric and transitive.
+
+*Symmetric:* Suppose (a, b) ∈ R. By reflexivity, (b, b) ∈ R. Applying circularity to (a, b) ∈ R and (b, b) ∈ R: (b, a) ∈ R. ✓
+
+*Transitive:* Suppose (a, b) ∈ R and (b, c) ∈ R. By symmetry (just proved), (b, a) ∈ R. Now apply circularity to (b, c) ∈ R and (c, ... )—but instead, apply circularity directly: since (a, b) ∈ R and (b, c) ∈ R, we get (c, a) ∈ R. Then by symmetry (proved above), (a, c) ∈ R. ✓
+
+Since R is reflexive, symmetric, and transitive, **R is an equivalence relation**. □
+
+---
+
+### Problem 4
+
+**Give a poset that has:**
+
+#### Part (a): A minimal element but no maximal element.
+
+**Example:** (ℕ, ≤) where ℕ = {0, 1, 2, 3, ...} with the usual ≤ ordering.
+
+- **Minimal element:** 0, since 0 ≤ n for all n ∈ ℕ (and no element is less than 0).
+- **No maximal element:** For any n ∈ ℕ, n+1 ∈ ℕ and n < n+1, so n is not maximal.
+
+---
+
+#### Part (b): Neither a maximal nor a minimal element.
+
+**Example:** (ℤ, ≤) where ℤ is the set of all integers with the usual ≤ ordering.
+
+- **No minimal element:** For any n ∈ ℤ, n−1 ∈ ℤ and n−1 < n.
+- **No maximal element:** For any n ∈ ℤ, n+1 ∈ ℤ and n+1 > n.
+
+---
+
+### Problem 5
+
+**Can a non-empty poset (A, ≤) with no minimal element be finite?**
+
+**No, such a poset cannot be finite.**
+
+**Proof:**
+
+We prove the contrapositive: every finite, non-empty poset has a minimal element.
+
+Let (A, ≤) be a finite, non-empty partially ordered set. We construct a minimal element as follows:
+
+Pick any element a₁ ∈ A. If a₁ is minimal, we are done. Otherwise, there exists a₂ ∈ A with a₂ < a₁ (strictly). If a₂ is minimal, we are done. Otherwise, there exists a₃ ∈ A with a₃ < a₂. Continuing this process, we obtain a sequence
+
+a₁ > a₂ > a₃ > ···
+
+This is a strictly decreasing sequence of elements. Since < is irreflexive and antisymmetric, no element can repeat in this sequence (if aᵢ = aⱼ with i < j, then aᵢ < aᵢ, which is impossible). Therefore all elements in the sequence are distinct.
+
+Since A is finite, this strictly decreasing sequence cannot continue indefinitely — it must terminate at some element aₖ. By construction, aₖ has no element strictly less than it in the sequence; and since aₖ was chosen because no smaller element had been found, aₖ is minimal in A.
+
+Therefore, **every finite non-empty poset has a minimal element**, and consequently, a non-empty poset with no minimal element must be infinite. □
Sub-Model Usage
| Model | Input | Output | Cache Read | Cost |
|---|---|---|---|---|
| claude-sonnet-4-6 | 10 | 16.1K | 321.9K | $0.80 |
BSCS Bench