Agent Work: HW1: Algorithmic Thinking and Logic
Claude Sonnet 4.6 · COMP 182: Algorithmic Thinking
COMP 182: Algorithmic Thinking
Homework 1: Algorithmic Thinking and Logic
---
1. Algorithmic Thinking [20 pts]
In 1977, Anthropologist Wayne Zachary published a seminal paper (now cited more than 4,000 times) titled "An information flow model for conflict and fission in small groups". This paper is an excellent example of the use of the 5-step Algorithmic Thinking process that I defined in class.
The goal of this problem is for you to read the paper and describe each of the five steps as they relate to this paper. In particular:
- Understanding the problem: What is the question that Zachary wanted to answer? What was the motivation for the question? What data did he collect? How did he think about solving the problem?
- Formulating the problem: What was the mathematical formulation of the problem that Zachary arrived at after understanding the problem?
- Algorithm design: What algorithmic technique did Zachary use to solve the problem? You do not need to describe the algorithm itself, but rather the algorithmic technique he employed (1-2 sentences).
- Algorithm implementation: Comment on the algorithm implementation (1-2 sentences).
- Solving the original problem: What were Zachary's findings in terms of the original problem he set out to solve?
---
2. Propositional Logic [30 pts]
Problem 2.1
Write each of the following sentences using propositional logic. Clearly introduce propositions (using p, q, r, etc.) and give the compound proposition that corresponds to the English sentence.
(a) Neither the wind nor the rain affected the house.
(b) If the pandemic is not controlled, more people will die.
(c) Pedestrians should neither jaywalk nor cross a red light, or they will get a ticket.
(d) A plant is not poisonous unless it is tropical.
(e) Growing in the tropic is necessary but not sufficient for a plant to be poisonous.
Problem 2.2
Recall that XOR denotes "exclusive or." For each of the following compound propositions, determine if it is satisfiable or not. If it is satisfiable, determine also if it is a tautology. Prove your answer.
(a) p XOR p
(b) p XOR (NOT p)
(c) (p XOR q) OR (p XOR (NOT q))
Problem 2.3
Two compound propositions p and q are logically equivalent if p <-> q is a tautology (see Section 1.3 in your textbook). Which of the following pairs of compound propositions are logically equivalent? Prove your answer.
(a) (p AND q) -> r and (p -> r) AND (q -> r)
(b) (p OR q) -> r and (p -> r) OR (q -> r)
(c) p -> (q <-> r) and (p -> q) <-> (p -> r)
---
3. Predicate Logic [30 pts]
Problem 3.1
Determine the truth value of each of these statements if the domain is R (the real numbers). Explain your answer.
(a) There exists x such that x^3 = -1
(b) For all x, (-x)^2 = x^2
(c) For all x, 2x > x
(d) For all x, there exists y such that x * y = y * x
(e) For all x, for all y, there exists z such that z = (x + y)/2
(f) There exists x such that for all y, x <= y^2
(g) There exists x such that for all y, x <= y
Problem 3.2
Which of the following pairs of expressions are logically equivalent? Prove your answer.
(a) For all x (P(x) OR Q(x)) and (For all x P(x)) OR (For all x Q(x))
(b) For all x (P(x) AND Q(x)) and (For all x P(x)) AND (For all x Q(x))
(c) (For all x P(x)) OR (For all x Q(x)) and For all x, For all y (P(x) OR Q(y))
(Here all quantifiers have the same nonempty domain.)
---
4. Proofs [20 pts]
(a) [5 pts] Prove that given a nonnegative integer n, there is a unique nonnegative integer m such that m^2 <= n < (m + 1)^2.
(b) [5 pts] Prove that for any positive integer n, sqrt(n) is either an integer or irrational.
(c) [5 pts] Let a, b, and c be three odd integers. Prove that ax^2 + bx + c = 0 does not have a rational solution.
(d) [5 pts] Prove that between every rational number and every irrational number there is an irrational number.
# COMP182 Homework 1
## Student Responses
<!-- Write your solutions below. Add sections for each problem as needed. -->
<!-- Use proper mathematical notation where applicable. -->
[Your solutions here]
COMP182 Homework 1
Student Responses
---
Problem 1: Algorithmic Thinking [20 pts]
Wayne Zachary's 1977 paper "An information flow model for conflict and fission in small groups" studies how and why small social groups fracture. Below are the five steps of Algorithmic Thinking as applied to his work.
Understanding the Problem
Question: Zachary wanted to answer: can the ultimate loyalties of members of a social group—specifically, which sub-group each member will join after a split—be predicted *before* the split occurs, using only observable interaction data?
Motivation: Social scientists had long debated whether group fission was driven by external forces or by internal social structure. Zachary believed the internal communication/information-flow network contained enough signal to make precise predictions.
Data collected: Zachary observed a university karate club of 34 members over roughly two years (1970–72). He recorded 8 types of social interactions between all pairs of members (e.g., attending the same classes, socializing outside the club, etc.), producing a weighted graph of pairwise interaction strengths.
Initial approach: He hypothesized that information flows through the social network much like flow through a physical network, and that the "weakest links" in the network would reveal the natural fault lines along which the group would divide.
Formulating the Problem
Zachary modeled the social group as a *weighted undirected graph* where:
- Nodes represent the 34 club members.
- Edge weights represent the total strength of interaction between each pair of members (aggregated across 8 interaction contexts).
The conflict was between two key nodes: the club president (John A.) and the instructor (Mr. Hi). The mathematical problem became: find the minimum-capacity cut in this network that separates the two leaders, thereby partitioning all members into two groups. The min-cut corresponds to the "weakest" set of social ties whose removal divides the network between the two authority figures.
Algorithm Design
Zachary employed network flow (specifically the max-flow/min-cut theorem). By computing the maximum flow from one leader's node to the other's, the min-cut is obtained as a byproduct; this cut identifies which members fall on which side of the fundamental social division.
Algorithm Implementation
Zachary implemented the Ford-Fulkerson max-flow algorithm on the 34-node weighted graph, computing the minimum cut that separates the two leader nodes. The algorithm was run on the interaction-weight matrix he had assembled from his field observations.
Solving the Original Problem
Zachary's findings were striking: the minimum cut of the network correctly predicted the faction alignment of 33 out of 34 members after the club did in fact split (the one mis-predicted member was near the boundary and could have gone either way). This validated the hypothesis that the internal information-flow structure of a social network encodes enough information to forecast group fission, demonstrating that network-theoretic tools can model and predict real social phenomena.
---
Problem 2: Propositional Logic [30 pts]
Problem 2.1
(a) "Neither the wind nor the rain affected the house."
Let:
- p = "The wind affected the house"
- q = "The rain affected the house"
Compound proposition: ¬p ∧ ¬q (equivalently, ¬(p ∨ q))
---
(b) "If the pandemic is not controlled, more people will die."
Let:
- p = "The pandemic is controlled"
- q = "More people will die"
Compound proposition: ¬p → q
---
(c) "Pedestrians should neither jaywalk nor cross a red light, or they will get a ticket."
Let:
- p = "Pedestrians jaywalk"
- q = "Pedestrians cross a red light"
- r = "Pedestrians get a ticket"
The sentence means: either pedestrians refrain from both actions, or they get a ticket.
Compound proposition: (¬p ∧ ¬q) ∨ r
(Equivalently: (p ∨ q) → r, since (¬p ∧ ¬q) ∨ r ≡ ¬(p ∨ q) ∨ r ≡ (p ∨ q) → r.)
---
(d) "A plant is not poisonous unless it is tropical."
Let:
- p = "A plant is poisonous"
- q = "A plant is tropical"
"A is not B unless C" means: if not C, then not A, i.e., ¬q → ¬p.
Compound proposition: ¬q → ¬p (equivalently, p → q)
---
(e) "Growing in the tropics is necessary but not sufficient for a plant to be poisonous."
Let:
- p = "A plant grows in the tropics"
- q = "A plant is poisonous"
- *Necessary*: p is necessary for q means q → p (you cannot be poisonous without growing in the tropics).
- *Not sufficient*: p alone does not guarantee q, i.e., ¬(p → q).
Compound proposition: (q → p) ∧ ¬(p → q)
---
Problem 2.2
(a) p XOR p
Truth table:
| p | p XOR p |
|---|---|
| T | T XOR T = F |
| F | F XOR F = F |
The proposition is always false — it is a contradiction and therefore not satisfiable.
---
(b) p XOR (¬p)
Truth table:
| p | ¬p | p XOR ¬p |
|---|---|---|
| T | F | T XOR F = T |
| F | T | F XOR T = T |
The proposition is always true — it is a tautology and therefore satisfiable. ✓
---
(c) (p XOR q) OR (p XOR (¬q))
We evaluate all four cases:
| p | q | p XOR q | p XOR ¬q | (p XOR q) OR (p XOR ¬q) |
|---|---|---|---|---|
| T | T | F | T | T |
| T | F | T | F | T |
| F | T | T | F | T |
| F | F | F | T | T |
The proposition is always true — it is a tautology and therefore satisfiable. ✓
Algebraic proof:
- p XOR q ≡ (p ∧ ¬q) ∨ (¬p ∧ q)
- p XOR ¬q ≡ (p ∧ q) ∨ (¬p ∧ ¬q)
Their disjunction:
(p ∧ ¬q) ∨ (¬p ∧ q) ∨ (p ∧ q) ∨ (¬p ∧ ¬q) = p ∧ (¬q ∨ q) ∨ ¬p ∧ (q ∨ ¬q) = p ∧ T ∨ ¬p ∧ T = p ∨ ¬p = T ✓
---
Problem 2.3
(a) (p ∧ q) → r vs. (p → r) ∧ (q → r)
Not logically equivalent.
Counterexample: Let p = T, q = F, r = F.
- Left: (T ∧ F) → F = F → F = T
- Right: (T → F) ∧ (F → F) = F ∧ T = F
Since the two sides differ, they are not logically equivalent.
Intuition: The left side requires r only when *both* p and q hold simultaneously. The right side requires r whenever *either* p or q holds alone—a strictly stronger condition.
---
(b) (p ∨ q) → r vs. (p → r) ∨ (q → r)
Not logically equivalent.
Counterexample: Let p = T, q = F, r = F.
- Left: (T ∨ F) → F = T → F = F
- Right: (T → F) ∨ (F → F) = F ∨ T = T
Since the two sides differ, they are not logically equivalent.
Intuition: The left says r must hold whenever at least one of p, q holds—this fails if p=T and r=F even when q=F. The right says at least one of the conditionals holds; when q=F, (q → r) is vacuously true, so the whole disjunction is true regardless of r.
---
(c) p → (q ↔ r) vs. (p → q) ↔ (p → r)
Logically equivalent.
Proof:
We consider two cases based on the truth value of p.
*Case 1: p = F.*
- Left: F → (q ↔ r) = T (vacuously true)
- Right: (F → q) ↔ (F → r) = T ↔ T = T
Both sides are true.
*Case 2: p = T.*
- Left: T → (q ↔ r) = q ↔ r
- Right: (T → q) ↔ (T → r) = q ↔ r
Both sides reduce to q ↔ r.
In both cases the two expressions have identical truth values, so they are logically equivalent. ✓
---
Problem 3: Predicate Logic [30 pts]
Problem 3.1
Domain: ℝ (real numbers)
(a) ∃x: x³ = −1
TRUE. Take x = −1. Then (−1)³ = −1. ✓
---
(b) ∀x: (−x)² = x²
TRUE. For any real x: (−x)² = (−1)² · x² = 1 · x² = x². ✓
---
(c) ∀x: 2x > x
FALSE. Counterexample: x = 0. Then 2(0) = 0 = 0, so 2x > x is 0 > 0, which is false. (Also x = −1 gives 2(−1) = −2 < −1.) ✗
---
(d) ∀x: ∃y: x·y = y·x
TRUE. Multiplication of real numbers is commutative; for any x, choose y = 0 (or any real number), and x·y = y·x holds trivially. ✓
---
(e) ∀x: ∀y: ∃z: z = (x + y)/2
TRUE. For any real numbers x and y, the expression (x + y)/2 is a well-defined real number (ℝ is closed under addition and division by nonzero constants). Setting z = (x + y)/2 satisfies the condition. ✓
---
(f) ∃x: ∀y: x ≤ y²
TRUE. Take x = 0. For any real y, y² ≥ 0 = x. ✓
---
(g) ∃x: ∀y: x ≤ y
FALSE. For any candidate x, the real number y = x − 1 satisfies y < x, so x ≤ y is false. The real numbers have no minimum element. ✗
---
Problem 3.2
Assume all quantifiers range over the same nonempty domain D.
(a) ∀x(P(x) ∨ Q(x)) vs. (∀x P(x)) ∨ (∀x Q(x))
Not logically equivalent.
Counterexample: Let D = {1, 2}, P(1) = T, P(2) = F, Q(1) = F, Q(2) = T.
- Left: P(1) ∨ Q(1) = T ∨ F = T, and P(2) ∨ Q(2) = F ∨ T = T. So ∀x(P(x) ∨ Q(x)) = T.
- Right: ∀x P(x) = F (since P(2) = F); ∀x Q(x) = F (since Q(1) = F). So F ∨ F = F.
The right-to-left direction holds: if every element satisfies P or every element satisfies Q, then certainly every element satisfies P ∨ Q. But the left-to-right fails; elements can "alternate" which disjunct they satisfy. ✗
---
(b) ∀x(P(x) ∧ Q(x)) vs. (∀x P(x)) ∧ (∀x Q(x))
Logically equivalent.
Forward (⇒): Assume ∀x(P(x) ∧ Q(x)). For any x in D, P(x) ∧ Q(x) holds, so P(x) holds and Q(x) holds. Since this is true for every x, we get ∀x P(x) and ∀x Q(x), hence (∀x P(x)) ∧ (∀x Q(x)). ✓
Backward (⇐): Assume (∀x P(x)) ∧ (∀x Q(x)). For any x in D, P(x) holds (from ∀x P(x)) and Q(x) holds (from ∀x Q(x)), so P(x) ∧ Q(x) holds. Hence ∀x(P(x) ∧ Q(x)). ✓
---
(c) (∀x P(x)) ∨ (∀x Q(x)) vs. ∀x ∀y(P(x) ∨ Q(y))
Logically equivalent.
Forward (⇒): Assume (∀x P(x)) ∨ (∀x Q(x)).
- *Case 1:* ∀x P(x). For any x, y in D, P(x) is true, so P(x) ∨ Q(y) = T.
- *Case 2:* ∀x Q(x). For any x, y in D, Q(y) is true (y is also in D), so P(x) ∨ Q(y) = T.
In both cases, ∀x ∀y(P(x) ∨ Q(y)) holds. ✓
Backward (⇐): Assume ∀x ∀y(P(x) ∨ Q(y)), but for contradiction suppose ¬(∀x P(x)) ∧ ¬(∀x Q(x)).
- From ¬(∀x P(x)): ∃a ∈ D with ¬P(a).
- From ¬(∀x Q(x)): ∃b ∈ D with ¬Q(b).
By hypothesis (with x = a, y = b): P(a) ∨ Q(b) must be true. But P(a) = F and Q(b) = F, so P(a) ∨ Q(b) = F. Contradiction. Therefore (∀x P(x)) ∨ (∀x Q(x)) holds. ✓
---
Problem 4: Proofs [20 pts]
(a) Uniqueness and existence of the integer square root [5 pts]
Claim: For every nonnegative integer n, there exists a unique nonnegative integer m such that m² ≤ n < (m+1)².
Proof:
*Existence:* Let S = {k ∈ ℤ≥0 : k² ≤ n}. The set S is nonempty since 0 ∈ S (0² = 0 ≤ n). S is bounded above: if k ≥ n + 1, then k² ≥ (n+1)² = n² + 2n + 1 > n, so k ∉ S. Hence S is a finite nonempty set of nonnegative integers and has a maximum; let m = max(S).
By definition, m ∈ S so m² ≤ n. We claim n < (m+1)²: if (m+1)² ≤ n, then m+1 ∈ S, contradicting m = max(S). Therefore m² ≤ n < (m+1)². ✓
*Uniqueness:* Suppose m₁, m₂ are nonnegative integers satisfying the condition, and assume without loss of generality m₁ < m₂. Then m₁ + 1 ≤ m₂ (since they are integers), so
(m₁ + 1)² ≤ m₂² ≤ n.
But this contradicts n < (m₁ + 1)². Hence m₁ = m₂, establishing uniqueness. ✓
---
(b) √n is an integer or irrational [5 pts]
Claim: For any positive integer n, √n is either an integer or irrational.
Proof by contradiction: Suppose √n is rational but not an integer. Then we can write √n = p/q where p, q are positive integers with gcd(p, q) = 1 and q > 1 (the denominator is greater than 1 because √n is not an integer).
Squaring both sides: n = p²/q², so nq² = p².
Since q > 1, there exists a prime r that divides q. Then r | q², so r | p² (from nq² = p²). Since r is prime, r | p. So r divides both p and q, contradicting gcd(p, q) = 1.
Therefore no such rational non-integer expression exists, and √n must be either an integer or irrational. ✓
---
(c) ax² + bx + c = 0 has no rational solution when a, b, c are odd [5 pts]
Claim: Let a, b, c be odd integers. Then ax² + bx + c = 0 has no rational solution.
Proof by contradiction: Suppose x = p/q is a rational solution, where p, q are integers with gcd(p, q) = 1 and q > 0. Since gcd(p, q) = 1, p and q cannot both be even.
Substituting: a(p/q)² + b(p/q) + c = 0. Multiplying through by q²:
ap² + bpq + cq² = 0.
We consider all cases modulo 2, using the fact that a ≡ b ≡ c ≡ 1 (mod 2):
Case 1: p odd, q odd.
ap² ≡ 1·1 = 1, bpq ≡ 1·1·1 = 1, cq² ≡ 1·1 = 1 (mod 2).
Sum: 1 + 1 + 1 = 3 ≡ 1 (mod 2) ≠ 0. Contradiction.
Case 2: p even, q odd.
ap² ≡ 1·0 = 0, bpq ≡ 1·0·1 = 0, cq² ≡ 1·1 = 1 (mod 2).
Sum: 0 + 0 + 1 = 1 ≡ 1 (mod 2) ≠ 0. Contradiction.
Case 3: p odd, q even.
ap² ≡ 1·1 = 1, bpq ≡ 1·1·0 = 0, cq² ≡ 1·0 = 0 (mod 2).
Sum: 1 + 0 + 0 = 1 ≡ 1 (mod 2) ≠ 0. Contradiction.
(The case p even, q even is impossible since gcd(p, q) = 1.)
In every admissible case we reach a contradiction. Therefore ax² + bx + c = 0 has no rational solution. ✓
---
(d) Between every rational and every irrational there is an irrational [5 pts]
Claim: Let r be rational and t be irrational with r ≠ t. Then there exists an irrational number s strictly between r and t.
Proof: Without loss of generality, assume r < t (if t < r, the argument is symmetric with the roles swapped).
Define:
s = (r + t) / 2.
*s lies strictly between r and t:* Since t > r, we have t − r > 0, so (t − r)/2 > 0. Then:
s = r + (t − r)/2 > r and s = t − (t − r)/2 < t.
So r < s < t.
*s is irrational:* Suppose for contradiction that s is rational. Then 2s is rational (product of rationals), and r is rational, so
t = 2s − r
would be a difference of rationals, hence rational. This contradicts the assumption that t is irrational.
Therefore s = (r + t)/2 is an irrational number satisfying r < s < t. ✓
COMP 182 — Homework 1 Grading
---
Problem 1: Algorithmic Thinking — 20/20
All five steps are thoroughly and accurately addressed.
| Step | Pts | Notes |
|---|---|---|
| Understanding the problem | 4/4 | Correctly identifies the karate club fission, the prediction question, observed interactions (8 types), and the hypothesis about network structure. Minor note: says "two years (1970–72)" vs. rubric's "three years," but the substance is correct. |
| Formulating the problem | 4/4 | Accurately describes the weighted undirected graph model and identifies the min-cut formulation between the two leaders. More specific than the rubric's answer — excellent. |
| Algorithm design | 4/4 | Correctly identifies network flow / max-flow min-cut theorem. |
| Algorithm implementation | 4/4 | Identifies Ford-Fulkerson. Doesn't mention the specific NETFLOW/APL program, but the rubric says to be generous here. |
| Solving the original problem | 4/4 | Correctly reports 33/34 prediction accuracy and the broader conclusion about network-theoretic modeling of social phenomena. |
---
Problem 2: Propositional Logic — 33/30
*(Rubric explicitly states: "Yes, a student can get a maximum of 33 points for this problem, and that's fine.")*
Problem 2.1 (15/15)
| Part | Pts | Assessment |
|---|---|---|
| (a) | 3/3 | ¬p ∧ ¬q — correct, also notes equivalence to ¬(p ∨ q). Matches rubric. |
| (b) | 3/3 | ¬p → q — correct. Matches rubric. |
| (c) | 3/3 | (¬p ∧ ¬q) ∨ r — correct, equivalent to rubric's ¬(p ∨ q) ∨ r by De Morgan's. Also notes equivalence to (p ∨ q) → r. |
| (d) | 3/3 | ¬q → ¬p (equiv. p → q) — correct. Matches rubric. |
| (e) | 3/3 | (q → p) ∧ ¬(p → q) — this is arguably more correct than the rubric's answer of just p → q, as the student captures both the "necessary" condition (q → p) and the "not sufficient" condition ¬(p → q), faithfully representing the full English sentence. Full credit. |
Problem 2.2 (9/9)
| Part | Pts | Assessment |
|---|---|---|
| (a) | 3/3 | Correctly identifies as contradiction (always False), not satisfiable. Truth table provided. |
| (b) | 3/3 | Correctly identifies as tautology and satisfiable. Truth table provided. |
| (c) | 3/3 | Correctly identifies as tautology. Provides both a truth table and an elegant algebraic proof. Exceeds expectations. |
Problem 2.3 (9/9)
| Part | Pts | Assessment |
|---|---|---|
| (a) | 3/3 | Not equivalent. Counterexample (T, F, F) matches rubric exactly. Good added intuition about the asymmetry. |
| (b) | 3/3 | Not equivalent. Same counterexample, correctly verified. Clear intuition about vacuous truth. |
| (c) | 3/3 | Equivalent. Proof by case split on p is clean and correct — when p=F both sides are T; when p=T both reduce to q ↔ r. |
---
Problem 3: Predicate Logic — 30/30
Problem 3.1 (14/14)
| Part | Pts | Assessment |
|---|---|---|
| (a) | 2/2 | True, x = −1. Matches rubric. |
| (b) | 2/2 | True, uses (−x)² = (−1)²x² = x². Correct algebraic justification. |
| (c) | 2/2 | False. Uses x = 0 as counterexample (valid alternative to rubric's x = −1). |
| (d) | 2/2 | True, commutativity of real multiplication. |
| (e) | 2/2 | True, (x+y)/2 is well-defined in ℝ. Matches rubric reasoning. |
| (f) | 2/2 | True, x = 0. Matches rubric. |
| (g) | 2/2 | False, reals have no minimum. Student gives constructive argument (y = x−1). |
Problem 3.2 (16/16)
| Part | Pts | Assessment |
|---|---|---|
| (a) | 4/4 | Not equivalent. Clean counterexample with D = {1,2} and alternating predicates. Correctly notes the right-to-left direction does hold. |
| (b) | 6/6 | Equivalent. Both directions proved correctly using universal instantiation, simplification, and universal generalization. Matches rubric structure. |
| (c) | 6/6 | Equivalent. Forward direction proved by cases; backward direction proved by contradiction (assuming both ∀x P(x) and ∀x Q(x) fail, finding witnesses a, b where P(a)∨Q(b) = F). Rigorous and complete. |
---
Problem 4: Proofs — 20/20
(a) Integer square root — 5/5
Existence proof using S = {k ≥ 0 : k² ≤ n} is rigorous: shows S is nonempty (0 ∈ S) and bounded above, takes m = max(S), and argues (m+1)² > n by maximality. Uniqueness by contradiction: if m₁ < m₂ then (m₁+1)² ≤ m₂² ≤ n, contradicting n < (m₁+1)². Clean and correct.
(b) √n is integer or irrational — 5/5
Proof by contradiction assuming √n = p/q with gcd(p,q) = 1 and q > 1. Uses prime divisor of q to show it must divide both p and q, contradicting coprimality. This is a correct alternative to the rubric's approach and arguably cleaner.
(c) No rational solution with odd coefficients — 5/5
Proof by contradiction, multiplying through by q² to get ap² + bpq + cq² = 0, then exhaustive case analysis mod 2. All three admissible parity cases (odd-odd, even-odd, odd-even) yield odd sums, contradicting = 0. Both even excluded by gcd = 1. Matches rubric approach perfectly.
(d) Irrational between rational and irrational — 5/5
Takes s = (r+t)/2, proves s is strictly between r and t, then proves irrationality by contradiction (if s rational, then t = 2s − r is rational, contradiction). Matches rubric exactly.
---
Summary
| Problem | Score | Max |
|---|---|---|
| 1. Algorithmic Thinking | 20 | 20 |
| 2. Propositional Logic | 33 | 30* |
| 3. Predicate Logic | 30 | 30 |
| 4. Proofs | 20 | 20 |
*\*Rubric permits up to 33 points on Problem 2.*
Overall Comments: This is an exceptional submission. Every problem is answered correctly with clear reasoning, well-chosen examples, and rigorous proofs. Several answers go beyond what the rubric requires — notably the algebraic proof in 2.2(c), the more complete formalization in 2.1(e), and the constructive counterexample in 3.1(g). The proofs in Problem 4 are all clean, well-structured, and mathematically sound.
Total: 103/100
diff --git a/writeup.md b/writeup.md
index 22c0a80..975ba3a 100644
--- a/writeup.md
+++ b/writeup.md
@@ -2,8 +2,401 @@
## Student Responses
-<!-- Write your solutions below. Add sections for each problem as needed. -->
-<!-- Use proper mathematical notation where applicable. -->
+---
-[Your solutions here]
+## Problem 1: Algorithmic Thinking [20 pts]
+Wayne Zachary's 1977 paper "An information flow model for conflict and fission in small groups" studies how and why small social groups fracture. Below are the five steps of Algorithmic Thinking as applied to his work.
+
+### Understanding the Problem
+
+**Question:** Zachary wanted to answer: can the ultimate loyalties of members of a social group—specifically, which sub-group each member will join after a split—be predicted *before* the split occurs, using only observable interaction data?
+
+**Motivation:** Social scientists had long debated whether group fission was driven by external forces or by internal social structure. Zachary believed the internal communication/information-flow network contained enough signal to make precise predictions.
+
+**Data collected:** Zachary observed a university karate club of 34 members over roughly two years (1970–72). He recorded 8 types of social interactions between all pairs of members (e.g., attending the same classes, socializing outside the club, etc.), producing a weighted graph of pairwise interaction strengths.
+
+**Initial approach:** He hypothesized that information flows through the social network much like flow through a physical network, and that the "weakest links" in the network would reveal the natural fault lines along which the group would divide.
+
+### Formulating the Problem
+
+Zachary modeled the social group as a *weighted undirected graph* where:
+- Nodes represent the 34 club members.
+- Edge weights represent the total strength of interaction between each pair of members (aggregated across 8 interaction contexts).
+
+The conflict was between two key nodes: the club president (John A.) and the instructor (Mr. Hi). The mathematical problem became: **find the minimum-capacity cut** in this network that separates the two leaders, thereby partitioning all members into two groups. The min-cut corresponds to the "weakest" set of social ties whose removal divides the network between the two authority figures.
+
+### Algorithm Design
+
+Zachary employed **network flow** (specifically the max-flow/min-cut theorem). By computing the maximum flow from one leader's node to the other's, the min-cut is obtained as a byproduct; this cut identifies which members fall on which side of the fundamental social division.
+
+### Algorithm Implementation
+
+Zachary implemented the Ford-Fulkerson max-flow algorithm on the 34-node weighted graph, computing the minimum cut that separates the two leader nodes. The algorithm was run on the interaction-weight matrix he had assembled from his field observations.
+
+### Solving the Original Problem
+
+Zachary's findings were striking: the minimum cut of the network correctly predicted the faction alignment of **33 out of 34 members** after the club did in fact split (the one mis-predicted member was near the boundary and could have gone either way). This validated the hypothesis that the internal information-flow structure of a social network encodes enough information to forecast group fission, demonstrating that network-theoretic tools can model and predict real social phenomena.
+
+---
+
+## Problem 2: Propositional Logic [30 pts]
+
+### Problem 2.1
+
+**(a) "Neither the wind nor the rain affected the house."**
+
+Let:
+- p = "The wind affected the house"
+- q = "The rain affected the house"
+
+Compound proposition: **¬p ∧ ¬q** (equivalently, ¬(p ∨ q))
+
+---
+
+**(b) "If the pandemic is not controlled, more people will die."**
+
+Let:
+- p = "The pandemic is controlled"
+- q = "More people will die"
+
+Compound proposition: **¬p → q**
+
+---
+
+**(c) "Pedestrians should neither jaywalk nor cross a red light, or they will get a ticket."**
+
+Let:
+- p = "Pedestrians jaywalk"
+- q = "Pedestrians cross a red light"
+- r = "Pedestrians get a ticket"
+
+The sentence means: either pedestrians refrain from both actions, or they get a ticket.
+
+Compound proposition: **(¬p ∧ ¬q) ∨ r**
+
+(Equivalently: (p ∨ q) → r, since (¬p ∧ ¬q) ∨ r ≡ ¬(p ∨ q) ∨ r ≡ (p ∨ q) → r.)
+
+---
+
+**(d) "A plant is not poisonous unless it is tropical."**
+
+Let:
+- p = "A plant is poisonous"
+- q = "A plant is tropical"
+
+"A is not B unless C" means: if not C, then not A, i.e., ¬q → ¬p.
+
+Compound proposition: **¬q → ¬p** (equivalently, p → q)
+
+---
+
+**(e) "Growing in the tropics is necessary but not sufficient for a plant to be poisonous."**
+
+Let:
+- p = "A plant grows in the tropics"
+- q = "A plant is poisonous"
+
+- *Necessary*: p is necessary for q means q → p (you cannot be poisonous without growing in the tropics).
+- *Not sufficient*: p alone does not guarantee q, i.e., ¬(p → q).
+
+Compound proposition: **(q → p) ∧ ¬(p → q)**
+
+---
+
+### Problem 2.2
+
+**(a) p XOR p**
+
+Truth table:
+
+| p | p XOR p |
+|---|---------|
+| T | T XOR T = **F** |
+| F | F XOR F = **F** |
+
+The proposition is always **false** — it is a **contradiction** and therefore **not satisfiable**.
+
+---
+
+**(b) p XOR (¬p)**
+
+Truth table:
+
+| p | ¬p | p XOR ¬p |
+|---|-----|---------|
+| T | F | T XOR F = **T** |
+| F | T | F XOR T = **T** |
+
+The proposition is always **true** — it is a **tautology** and therefore **satisfiable**. ✓
+
+---
+
+**(c) (p XOR q) OR (p XOR (¬q))**
+
+We evaluate all four cases:
+
+| p | q | p XOR q | p XOR ¬q | (p XOR q) OR (p XOR ¬q) |
+|---|---|---------|----------|--------------------------|
+| T | T | F | T | **T** |
+| T | F | T | F | **T** |
+| F | T | T | F | **T** |
+| F | F | F | T | **T** |
+
+The proposition is always **true** — it is a **tautology** and therefore **satisfiable**. ✓
+
+**Algebraic proof:**
+
+- p XOR q ≡ (p ∧ ¬q) ∨ (¬p ∧ q)
+- p XOR ¬q ≡ (p ∧ q) ∨ (¬p ∧ ¬q)
+
+Their disjunction:
+
+(p ∧ ¬q) ∨ (¬p ∧ q) ∨ (p ∧ q) ∨ (¬p ∧ ¬q)
+= p ∧ (¬q ∨ q) ∨ ¬p ∧ (q ∨ ¬q)
+= p ∧ T ∨ ¬p ∧ T
+= p ∨ ¬p
+= **T** ✓
+
+---
+
+### Problem 2.3
+
+**(a) (p ∧ q) → r vs. (p → r) ∧ (q → r)**
+
+**Not logically equivalent.**
+
+**Counterexample:** Let p = T, q = F, r = F.
+- Left: (T ∧ F) → F = F → F = **T**
+- Right: (T → F) ∧ (F → F) = F ∧ T = **F**
+
+Since the two sides differ, they are not logically equivalent.
+
+**Intuition:** The left side requires r only when *both* p and q hold simultaneously. The right side requires r whenever *either* p or q holds alone—a strictly stronger condition.
+
+---
+
+**(b) (p ∨ q) → r vs. (p → r) ∨ (q → r)**
+
+**Not logically equivalent.**
+
+**Counterexample:** Let p = T, q = F, r = F.
+- Left: (T ∨ F) → F = T → F = **F**
+- Right: (T → F) ∨ (F → F) = F ∨ T = **T**
+
+Since the two sides differ, they are not logically equivalent.
+
+**Intuition:** The left says r must hold whenever at least one of p, q holds—this fails if p=T and r=F even when q=F. The right says at least one of the conditionals holds; when q=F, (q → r) is vacuously true, so the whole disjunction is true regardless of r.
+
+---
+
+**(c) p → (q ↔ r) vs. (p → q) ↔ (p → r)**
+
+**Logically equivalent.**
+
+**Proof:**
+
+We consider two cases based on the truth value of p.
+
+*Case 1: p = F.*
+- Left: F → (q ↔ r) = **T** (vacuously true)
+- Right: (F → q) ↔ (F → r) = T ↔ T = **T**
+Both sides are true.
+
+*Case 2: p = T.*
+- Left: T → (q ↔ r) = **q ↔ r**
+- Right: (T → q) ↔ (T → r) = q ↔ r
+
+Both sides reduce to **q ↔ r**.
+
+In both cases the two expressions have identical truth values, so they are logically equivalent. ✓
+
+---
+
+## Problem 3: Predicate Logic [30 pts]
+
+### Problem 3.1
+
+Domain: **ℝ** (real numbers)
+
+**(a) ∃x: x³ = −1**
+
+**TRUE.** Take x = −1. Then (−1)³ = −1. ✓
+
+---
+
+**(b) ∀x: (−x)² = x²**
+
+**TRUE.** For any real x: (−x)² = (−1)² · x² = 1 · x² = x². ✓
+
+---
+
+**(c) ∀x: 2x > x**
+
+**FALSE.** Counterexample: x = 0. Then 2(0) = 0 = 0, so 2x > x is 0 > 0, which is false. (Also x = −1 gives 2(−1) = −2 < −1.) ✗
+
+---
+
+**(d) ∀x: ∃y: x·y = y·x**
+
+**TRUE.** Multiplication of real numbers is commutative; for any x, choose y = 0 (or any real number), and x·y = y·x holds trivially. ✓
+
+---
+
+**(e) ∀x: ∀y: ∃z: z = (x + y)/2**
+
+**TRUE.** For any real numbers x and y, the expression (x + y)/2 is a well-defined real number (ℝ is closed under addition and division by nonzero constants). Setting z = (x + y)/2 satisfies the condition. ✓
+
+---
+
+**(f) ∃x: ∀y: x ≤ y²**
+
+**TRUE.** Take x = 0. For any real y, y² ≥ 0 = x. ✓
+
+---
+
+**(g) ∃x: ∀y: x ≤ y**
+
+**FALSE.** For any candidate x, the real number y = x − 1 satisfies y < x, so x ≤ y is false. The real numbers have no minimum element. ✗
+
+---
+
+### Problem 3.2
+
+Assume all quantifiers range over the same nonempty domain D.
+
+**(a) ∀x(P(x) ∨ Q(x)) vs. (∀x P(x)) ∨ (∀x Q(x))**
+
+**Not logically equivalent.**
+
+**Counterexample:** Let D = {1, 2}, P(1) = T, P(2) = F, Q(1) = F, Q(2) = T.
+
+- Left: P(1) ∨ Q(1) = T ∨ F = T, and P(2) ∨ Q(2) = F ∨ T = T. So ∀x(P(x) ∨ Q(x)) = **T**.
+- Right: ∀x P(x) = F (since P(2) = F); ∀x Q(x) = F (since Q(1) = F). So F ∨ F = **F**.
+
+The right-to-left direction holds: if every element satisfies P or every element satisfies Q, then certainly every element satisfies P ∨ Q. But the left-to-right fails; elements can "alternate" which disjunct they satisfy. ✗
+
+---
+
+**(b) ∀x(P(x) ∧ Q(x)) vs. (∀x P(x)) ∧ (∀x Q(x))**
+
+**Logically equivalent.**
+
+**Forward (⇒):** Assume ∀x(P(x) ∧ Q(x)). For any x in D, P(x) ∧ Q(x) holds, so P(x) holds and Q(x) holds. Since this is true for every x, we get ∀x P(x) and ∀x Q(x), hence (∀x P(x)) ∧ (∀x Q(x)). ✓
+
+**Backward (⇐):** Assume (∀x P(x)) ∧ (∀x Q(x)). For any x in D, P(x) holds (from ∀x P(x)) and Q(x) holds (from ∀x Q(x)), so P(x) ∧ Q(x) holds. Hence ∀x(P(x) ∧ Q(x)). ✓
+
+---
+
+**(c) (∀x P(x)) ∨ (∀x Q(x)) vs. ∀x ∀y(P(x) ∨ Q(y))**
+
+**Logically equivalent.**
+
+**Forward (⇒):** Assume (∀x P(x)) ∨ (∀x Q(x)).
+- *Case 1:* ∀x P(x). For any x, y in D, P(x) is true, so P(x) ∨ Q(y) = T.
+- *Case 2:* ∀x Q(x). For any x, y in D, Q(y) is true (y is also in D), so P(x) ∨ Q(y) = T.
+
+In both cases, ∀x ∀y(P(x) ∨ Q(y)) holds. ✓
+
+**Backward (⇐):** Assume ∀x ∀y(P(x) ∨ Q(y)), but for contradiction suppose ¬(∀x P(x)) ∧ ¬(∀x Q(x)).
+
+- From ¬(∀x P(x)): ∃a ∈ D with ¬P(a).
+- From ¬(∀x Q(x)): ∃b ∈ D with ¬Q(b).
+
+By hypothesis (with x = a, y = b): P(a) ∨ Q(b) must be true. But P(a) = F and Q(b) = F, so P(a) ∨ Q(b) = F. Contradiction. Therefore (∀x P(x)) ∨ (∀x Q(x)) holds. ✓
+
+---
+
+## Problem 4: Proofs [20 pts]
+
+### (a) Uniqueness and existence of the integer square root [5 pts]
+
+**Claim:** For every nonnegative integer n, there exists a unique nonnegative integer m such that m² ≤ n < (m+1)².
+
+**Proof:**
+
+*Existence:* Let S = {k ∈ ℤ≥0 : k² ≤ n}. The set S is nonempty since 0 ∈ S (0² = 0 ≤ n). S is bounded above: if k ≥ n + 1, then k² ≥ (n+1)² = n² + 2n + 1 > n, so k ∉ S. Hence S is a finite nonempty set of nonnegative integers and has a maximum; let m = max(S).
+
+By definition, m ∈ S so m² ≤ n. We claim n < (m+1)²: if (m+1)² ≤ n, then m+1 ∈ S, contradicting m = max(S). Therefore m² ≤ n < (m+1)². ✓
+
+*Uniqueness:* Suppose m₁, m₂ are nonnegative integers satisfying the condition, and assume without loss of generality m₁ < m₂. Then m₁ + 1 ≤ m₂ (since they are integers), so
+
+(m₁ + 1)² ≤ m₂² ≤ n.
+
+But this contradicts n < (m₁ + 1)². Hence m₁ = m₂, establishing uniqueness. ✓
+
+---
+
+### (b) √n is an integer or irrational [5 pts]
+
+**Claim:** For any positive integer n, √n is either an integer or irrational.
+
+**Proof by contradiction:** Suppose √n is rational but not an integer. Then we can write √n = p/q where p, q are positive integers with gcd(p, q) = 1 and q > 1 (the denominator is greater than 1 because √n is not an integer).
+
+Squaring both sides: n = p²/q², so nq² = p².
+
+Since q > 1, there exists a prime r that divides q. Then r | q², so r | p² (from nq² = p²). Since r is prime, r | p. So r divides both p and q, contradicting gcd(p, q) = 1.
+
+Therefore no such rational non-integer expression exists, and √n must be either an integer or irrational. ✓
+
+---
+
+### (c) ax² + bx + c = 0 has no rational solution when a, b, c are odd [5 pts]
+
+**Claim:** Let a, b, c be odd integers. Then ax² + bx + c = 0 has no rational solution.
+
+**Proof by contradiction:** Suppose x = p/q is a rational solution, where p, q are integers with gcd(p, q) = 1 and q > 0. Since gcd(p, q) = 1, p and q cannot both be even.
+
+Substituting: a(p/q)² + b(p/q) + c = 0. Multiplying through by q²:
+
+ap² + bpq + cq² = 0.
+
+We consider all cases modulo 2, using the fact that a ≡ b ≡ c ≡ 1 (mod 2):
+
+**Case 1: p odd, q odd.**
+
+ap² ≡ 1·1 = 1, bpq ≡ 1·1·1 = 1, cq² ≡ 1·1 = 1 (mod 2).
+
+Sum: 1 + 1 + 1 = 3 ≡ 1 (mod 2) ≠ 0. Contradiction.
+
+**Case 2: p even, q odd.**
+
+ap² ≡ 1·0 = 0, bpq ≡ 1·0·1 = 0, cq² ≡ 1·1 = 1 (mod 2).
+
+Sum: 0 + 0 + 1 = 1 ≡ 1 (mod 2) ≠ 0. Contradiction.
+
+**Case 3: p odd, q even.**
+
+ap² ≡ 1·1 = 1, bpq ≡ 1·1·0 = 0, cq² ≡ 1·0 = 0 (mod 2).
+
+Sum: 1 + 0 + 0 = 1 ≡ 1 (mod 2) ≠ 0. Contradiction.
+
+(The case p even, q even is impossible since gcd(p, q) = 1.)
+
+In every admissible case we reach a contradiction. Therefore ax² + bx + c = 0 has no rational solution. ✓
+
+---
+
+### (d) Between every rational and every irrational there is an irrational [5 pts]
+
+**Claim:** Let r be rational and t be irrational with r ≠ t. Then there exists an irrational number s strictly between r and t.
+
+**Proof:** Without loss of generality, assume r < t (if t < r, the argument is symmetric with the roles swapped).
+
+Define:
+
+s = (r + t) / 2.
+
+*s lies strictly between r and t:* Since t > r, we have t − r > 0, so (t − r)/2 > 0. Then:
+
+s = r + (t − r)/2 > r and s = t − (t − r)/2 < t.
+
+So r < s < t.
+
+*s is irrational:* Suppose for contradiction that s is rational. Then 2s is rational (product of rationals), and r is rational, so
+
+t = 2s − r
+
+would be a difference of rationals, hence rational. This contradicts the assumption that t is irrational.
+
+Therefore s = (r + t)/2 is an irrational number satisfying r < s < t. ✓
Sub-Model Usage
| Model | Input | Output | Cache Read | Cost |
|---|---|---|---|---|
| claude-sonnet-4-6 | 6 | 16.9K | 165.5K | $0.74 |
BSCS Bench