Agent Work: HW1: Algorithmic Thinking and Logic
Claude Opus 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
---
1. Algorithmic Thinking [20 pts]
Understanding the Problem
Wayne Zachary wanted to answer the question: Can we predict how a social group will split when an internal conflict causes the group to fission? His motivation came from observing that small social groups often undergo fission (splitting into subgroups) due to internal conflicts, and sociologists lacked a rigorous, quantitative method for predicting the outcome of such fissions.
To study this, Zachary collected data on a university karate club over a period of approximately three years (1970–1972). He observed and recorded social interactions among the 34 members of the club outside the context of club activities, constructing a social network of friendships and associations. During this period, a conflict arose between the club's administrator (officer) and the head instructor over club policies and pricing, which ultimately caused the club to split into two factions.
Zachary's approach to solving the problem was to model the social relationships as a network and use information flow within that network to predict which faction each member would join.
Formulating the Problem
Zachary formulated the problem mathematically as a network flow problem on a graph. He represented the karate club as a weighted undirected graph where:
- Each node represents a club member.
- Each edge represents a social tie between two members, weighted by the strength of their interaction (number of contexts in which they interacted outside the club).
The question of predicting the fission was then formulated as finding a minimum cut in this network. Specifically, using the max-flow min-cut theorem from network flow theory, Zachary sought to find the partition of the network into two groups that minimizes the total weight of edges cut, corresponding to the split requiring the least disruption of social ties.
Algorithm Design
Zachary employed the Ford-Fulkerson maximum flow / minimum cut algorithm (a classic network flow technique). By computing the maximum flow between pairs of key nodes (specifically the administrator and the instructor, who were the leaders of the two factions), the minimum cut of the network could be determined, which predicts the most likely partition of members.
Algorithm Implementation
Zachary implemented the Ford-Fulkerson algorithm on the weighted social network graph he had constructed from his observational data. He computed maximum network flows between the two faction leaders and used the resulting minimum cut to assign each of the 34 members to one of the two predicted groups. The computation was performed on the full 34-node network with edge weights derived from his interaction data.
Solving the Original Problem
Zachary's model correctly predicted the faction membership of 33 out of 34 club members (all but one member). This was a remarkable result: using only the social network structure and an algorithmic approach based on network flow theory, Zachary was able to predict with near-perfect accuracy how the club would split. The one misclassified member was a weak supporter of one faction who had stronger social ties to the other, highlighting the power and limitations of the network flow approach. This demonstrated that information flow models could be effective tools for predicting group fission in social networks.
---
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: not p and not q, i.e., ~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 will get a ticket"
The sentence says: either pedestrians neither jaywalk nor cross a red light, or they get a ticket. In other words, if they jaywalk or cross a red light, they will get a ticket.
Compound proposition: (~p /\ ~q) \/ r
This is logically equivalent to: (p \/ q) -> r
(d) A plant is not poisonous unless it is tropical.
Let:
- p = "The plant is poisonous"
- q = "The plant is tropical"
"Unless" means "if not." So: the plant is not poisonous if it is not tropical.
Compound proposition: ~q -> ~p
This is logically equivalent to: p -> q
(e) Growing in the tropic is necessary but not sufficient for a plant to be poisonous.
Let:
- p = "The plant is poisonous"
- q = "The plant grows in the tropic"
"Necessary" means: p -> q (if poisonous, then tropical). "Not sufficient" means: ~(q -> p), i.e., it is not the case that being tropical guarantees being poisonous.
Compound proposition: (p -> q) /\ ~(q -> p)
Problem 2.2
(a) p XOR p
Truth table:
| p | p XOR p |
|---|---|
| T | T XOR T = F |
| F | F XOR F = F |
The result is always F. This proposition is not satisfiable (it is a contradiction); there is no assignment of truth values that makes it true.
(b) p XOR (~p)
Truth table:
| p | ~p | p XOR ~p |
|---|---|---|
| T | F | T XOR F = T |
| F | T | F XOR T = T |
The result is always T. This proposition is satisfiable and, moreover, it is a tautology (true for all truth value assignments).
(c) (p XOR q) \/ (p XOR ~q)
Truth table:
| p | q | ~q | p XOR q | p XOR ~q | (p XOR q) \/ (p XOR ~q) |
|---|---|---|---|---|---|
| T | T | F | F | T | T |
| T | F | T | T | F | T |
| F | T | F | T | F | T |
| F | F | T | F | T | T |
The result is always T. This proposition is satisfiable and, moreover, it is a tautology.
Problem 2.3
(a) (p /\ q) -> r and (p -> r) /\ (q -> r)
These are NOT logically equivalent.
Proof by counterexample: Consider p = T, q = F, r = F.
- LHS: (p /\ q) -> r = (T /\ F) -> F = F -> F = T
- RHS: (p -> r) /\ (q -> r) = (T -> F) /\ (F -> F) = F /\ T = F
Since LHS = T and RHS = F, the biconditional is not a tautology. Therefore the two propositions are not logically equivalent.
Full truth table for verification:
| p | q | r | (p /\ q) -> r | (p -> r) /\ (q -> r) |
|---|---|---|---|---|
| T | T | T | T | T |
| T | T | F | F | F |
| T | F | T | T | T |
| T | F | F | T | F |
| F | T | T | T | T |
| F | T | F | T | F |
| F | F | T | T | T |
| F | F | F | T | T |
The two columns differ in rows 4 and 5, confirming they are not logically equivalent.
(b) (p \/ q) -> r and (p -> r) \/ (q -> r)
These are NOT logically equivalent.
Proof by counterexample: Consider p = T, q = F, r = F.
- LHS: (p \/ q) -> r = (T \/ F) -> F = T -> F = F
- RHS: (p -> r) \/ (q -> r) = (T -> F) \/ (F -> F) = F \/ T = T
Since LHS = F and RHS = T, the biconditional is not a tautology, so the two propositions are not logically equivalent.
(c) p -> (q <-> r) and (p -> q) <-> (p -> r)
These are logically equivalent.
Proof by truth table:
| p | q | r | q <-> r | p -> (q <-> r) | p -> q | p -> r | (p -> q) <-> (p -> r) |
|---|---|---|---|---|---|---|---|
| T | T | T | T | T | T | T | T |
| T | T | F | F | F | T | F | F |
| T | F | T | F | F | F | T | F |
| T | F | F | T | T | F | F | T |
| F | T | T | T | T | T | T | T |
| F | T | F | F | T | T | T | T |
| F | F | T | F | T | T | T | T |
| F | F | F | T | T | T | T | T |
The columns for p -> (q <-> r) and (p -> q) <-> (p -> r) are identical in all 8 rows. Therefore their biconditional is a tautology, and the two propositions are logically equivalent.
---
3. Predicate Logic [30 pts]
Problem 3.1
(a) There exists x such that x^3 = -1
True. Let x = -1. Then (-1)^3 = -1. Since -1 is a real number and satisfies the equation, the existential statement is true.
(b) For all x, (-x)^2 = x^2
True. For any real number x, (-x)^2 = (-1 * x)^2 = (-1)^2 * x^2 = 1 * x^2 = x^2. This holds for all real x.
(c) For all x, 2x > x
False. Counterexample: let x = -1. Then 2(-1) = -2, and -2 > -1 is false. Another counterexample: x = 0, then 2(0) = 0, and 0 > 0 is false. The statement 2x > x simplifies to x > 0, which is not true for all real numbers.
**(d) For all x, there exists y such that x * y = y * x**
True. Multiplication of real numbers is commutative: for all real numbers x and y, x * y = y * x. So for any x, we can choose any y (e.g., y = 0 or y = x or any real number), and x * y = y * x will hold.
(e) For all x, for all y, there exists z such that z = (x + y)/2
True. For any real numbers x and y, the value (x + y)/2 is a well-defined real number (since the reals are closed under addition and division by a nonzero number). So we can simply let z = (x + y)/2, and z exists in R.
(f) There exists x such that for all y, x <= y^2
True. Let x = 0. For any real number y, y^2 >= 0, so 0 <= y^2 holds for all y in R. (In fact, any x <= 0 would work, since y^2 >= 0 for all real y.)
(g) There exists x such that for all y, x <= y
False. The real numbers have no minimum element. For any candidate x, we can choose y = x - 1, and then x <= x - 1 is equivalent to 0 <= -1, which is false. So no such x exists.
Problem 3.2
(a) For all x (P(x) \/ Q(x)) and (For all x P(x)) \/ (For all x Q(x))
These are NOT logically equivalent.
Proof by counterexample: Let the domain be {1, 2}. Define:
- P(1) = T, P(2) = F
- Q(1) = F, Q(2) = T
LHS: For all x (P(x) \/ Q(x)):
- P(1) \/ Q(1) = T \/ F = T
- P(2) \/ Q(2) = F \/ T = T
- Both are true, so the universal statement is T.
RHS: (For all x P(x)) \/ (For all x Q(x)):
- For all x P(x) = P(1) /\ P(2) = T /\ F = F
- For all x Q(x) = Q(1) /\ Q(2) = F /\ T = F
- F \/ F = F
Since LHS = T and RHS = F, they are not logically equivalent.
Note: The direction RHS -> LHS does hold (if everything is P or everything is Q, then everything is P or Q), but the converse fails as shown above.
(b) For all x (P(x) /\ Q(x)) and (For all x P(x)) /\ (For all x Q(x))
These are logically equivalent.
Proof:
(=>) Assume For all x (P(x) /\ Q(x)). Let a be an arbitrary element in the domain. Then P(a) /\ Q(a) is true, so P(a) is true and Q(a) is true. Since a was arbitrary, For all x P(x) is true and For all x Q(x) is true. Hence (For all x P(x)) /\ (For all x Q(x)).
(<=) Assume (For all x P(x)) /\ (For all x Q(x)). Let a be an arbitrary element. From For all x P(x), we have P(a). From For all x Q(x), we have Q(a). So P(a) /\ Q(a) is true. Since a was arbitrary, For all x (P(x) /\ Q(x)).
Since both directions hold, the two expressions are logically equivalent.
(c) (For all x P(x)) \/ (For all x Q(x)) and For all x, For all y (P(x) \/ Q(y))
These are logically equivalent.
Proof:
(=>) Assume (For all x P(x)) \/ (For all x Q(x)). Case 1: For all x P(x). Then for any x and any y, P(x) is true, so P(x) \/ Q(y) is true. Hence For all x, For all y (P(x) \/ Q(y)). Case 2: For all x Q(x). Then for any x and any y, Q(y) is true, so P(x) \/ Q(y) is true. Hence For all x, For all y (P(x) \/ Q(y)). In either case, the RHS holds.
(<=) Assume For all x, For all y (P(x) \/ Q(y)). We prove (For all x P(x)) \/ (For all x Q(x)) by showing that if For all x P(x) fails, then For all x Q(x) must hold.
Suppose ~(For all x P(x)), i.e., there exists some x_0 in the domain such that ~P(x_0). Now let y be any element in the domain. By our assumption, P(x_0) \/ Q(y) is true (instantiating x = x_0 and y = y). Since ~P(x_0), it must be the case that Q(y) is true. Since y was arbitrary, For all y Q(y) holds, which is the same as For all x Q(x) (just renaming the bound variable).
Therefore (For all x P(x)) \/ (For all x Q(x)) holds. Since both directions are proven, the two expressions are logically equivalent.
---
4. Proofs [20 pts]
(a) Prove that given a nonnegative integer n, there is a unique nonnegative integer m such that m^2 <= n < (m + 1)^2. [5 pts]
Proof.
Existence: Consider the set S = {k in Z, k >= 0 : k^2 <= n}. This set is nonempty because 0 is in S (since 0^2 = 0 <= n for any nonneg integer n). The set S is bounded above because for any k > n, we have k^2 > n (since if k >= 1 and k > n, then k^2 >= k > n; and if n = 0, then S = {0} which is bounded). Since S is a nonempty set of nonneg integers that is bounded above, it has a maximum element. Let m = max(S).
Since m is in S, we have m^2 <= n. Since m is the maximum element of S, m + 1 is not in S, which means (m + 1)^2 > n. Therefore m^2 <= n < (m + 1)^2.
Uniqueness: Suppose m_1 and m_2 are both nonneg integers satisfying:
- m_1^2 <= n < (m_1 + 1)^2
- m_2^2 <= n < (m_2 + 1)^2
Without loss of generality, assume m_1 <= m_2. If m_1 < m_2, then m_1 + 1 <= m_2 (since they are integers), which gives (m_1 + 1)^2 <= m_2^2. But then n < (m_1 + 1)^2 <= m_2^2 <= n, which gives n < n, a contradiction. Therefore m_1 = m_2, establishing uniqueness. QED
(b) Prove that for any positive integer n, sqrt(n) is either an integer or irrational. [5 pts]
Proof. Let n be a positive integer. We consider two cases: either sqrt(n) is an integer, or it is not. If sqrt(n) is an integer, we are done. So assume sqrt(n) is not an integer; we must show it is irrational.
Assume for contradiction that sqrt(n) is rational but not an integer. Then we can write sqrt(n) = p/q where p and q are positive integers with gcd(p, q) = 1 and q >= 2 (since sqrt(n) is not an integer).
Then n = p^2 / q^2, so n * q^2 = p^2, which means q^2 divides p^2.
Since gcd(p, q) = 1, by the Fundamental Theorem of Arithmetic, p and q share no common prime factors. Therefore p^2 and q^2 share no common prime factors, which means gcd(p^2, q^2) = 1.
But q^2 divides p^2 and gcd(p^2, q^2) = 1 together imply q^2 = 1, so q = 1. This contradicts q >= 2.
Therefore our assumption was wrong, and sqrt(n) is irrational. Combined with the first case, sqrt(n) is either an integer or irrational. QED
(c) Let a, b, and c be three odd integers. Prove that ax^2 + bx + c = 0 does not have a rational solution. [5 pts]
Proof. Assume for contradiction that x = p/q is a rational solution in lowest terms, i.e., p, q are integers with q > 0 and gcd(p, q) = 1.
Substituting into the equation: a(p/q)^2 + b(p/q) + c = 0.
Multiplying both sides by q^2: ap^2 + bpq + cq^2 = 0.
Since a, b, c are all odd, we analyze the parity of ap^2 + bpq + cq^2. Since gcd(p, q) = 1, p and q cannot both be even. We consider three exhaustive cases:
Case 1: p is odd and q is odd.
- ap^2: odd * odd = odd
- bpq: odd * odd * odd = odd
- cq^2: odd * odd = odd
- Sum: odd + odd + odd = odd ≠ 0. Contradiction.
Case 2: p is even and q is odd. (They can't both be even since gcd(p,q)=1.)
- ap^2: odd * even = even
- bpq: odd * even * odd = even
- cq^2: odd * odd = odd
- Sum: even + even + odd = odd ≠ 0. Contradiction.
Case 3: p is odd and q is even.
- ap^2: odd * odd = odd
- bpq: odd * odd * even = even
- cq^2: odd * even = even
- Sum: odd + even + even = odd ≠ 0. Contradiction.
In all cases, ap^2 + bpq + cq^2 is odd and thus cannot equal 0. This contradicts our assumption that p/q is a solution. Therefore ax^2 + bx + c = 0 has no rational solution. QED
(d) Prove that between every rational number and every irrational number there is an irrational number. [5 pts]
Proof. Let r be a rational number and s be an irrational number with r ≠ s. We need to find an irrational number strictly between r and s.
Consider the number t = (r + s) / 2, which is the midpoint of r and s.
Claim: t is irrational. Suppose for contradiction that t is rational. Then r + s = 2t would be rational (since the product of two rationals is rational). But r + s = (rational) + (irrational) = irrational, since the sum of a rational number and an irrational number is always irrational. This is a contradiction, so t must be irrational.
Claim: t is strictly between r and s. There are two cases:
- If r < s, then r < (r + s)/2 < s, so r < t < s.
- If s < r, then s < (r + s)/2 < r, so s < t < r.
In both cases, t = (r + s)/2 is an irrational number that lies strictly between the rational number r and the irrational number s. QED
COMP 182 Homework 1 — Grading Report
---
1. Algorithmic Thinking [20/20 pts]
| Step | Score | Max |
|---|---|---|
| Understanding the problem | 4 | 4 |
| Formulating the problem | 4 | 4 |
| Algorithm design | 4 | 4 |
| Algorithm implementation | 4 | 4 |
| Solving the original problem | 4 | 4 |
Feedback: Excellent responses across all five steps. The student clearly read and understood the Zachary paper. Key details are all present: the karate club dispute, the three-year observation period, the weighted graph formulation with nodes as members and edges as relationships, the Ford-Fulkerson max-flow/min-cut technique, and the 33/34 correct prediction result. The implementation step doesn't mention the specific program (NETFLOW in APL), but per the rubric's instruction to be generous, the description is sufficient.
---
2. Propositional Logic [33/30 pts]
*(Per rubric: "a student can get a maximum of 33 points for this problem, and that's fine.")*
Problem 2.1 [15/15]
| Part | Score | Notes |
|---|---|---|
| (a) | 3/3 | Correct: ¬p ∧ ¬q, noted equivalence to ¬(p ∨ q) |
| (b) | 3/3 | Correct: ¬p → q |
| (c) | 3/3 | Correct: (¬p ∧ ¬q) ∨ r, noted equivalence to (p ∨ q) → r |
| (d) | 3/3 | Correct: ¬q → ¬p, noted equivalence to p → q |
| (e) | 3/3 | Correct: (p → q) ∧ ¬(q → p). This actually captures the English more completely than the reference (which gives just p → q), since the student formalizes both "necessary" and "not sufficient" |
Problem 2.2 [9/9]
| Part | Score | Notes |
|---|---|---|
| (a) | 3/3 | Correctly identified as a contradiction (not satisfiable) with truth table proof |
| (b) | 3/3 | Correctly identified as satisfiable and a tautology with truth table proof |
| (c) | 3/3 | Correctly identified as satisfiable and a tautology with full 4-row truth table |
Problem 2.3 [9/9]
| Part | Score | Notes |
|---|---|---|
| (a) | 3/3 | Correctly not equivalent; counterexample p=T, q=F, r=F matches reference. Full truth table also provided |
| (b) | 3/3 | Correctly not equivalent; same counterexample p=T, q=F, r=F as reference |
| (c) | 3/3 | Correctly equivalent; complete 8-row truth table verifying all rows match |
---
3. Predicate Logic [30/30 pts]
Problem 3.1 [14/14]
| Part | Score | Notes |
|---|---|---|
| (a) | 2/2 | True, x = −1. Correct with explanation |
| (b) | 2/2 | True, algebraic proof via (−1)²·x² = x². Correct |
| (c) | 2/2 | False, counterexample x = −1 (also notes x = 0). Correct |
| (d) | 2/2 | True, commutativity of real multiplication. Correct |
| (e) | 2/2 | True, (x+y)/2 is well-defined in ℝ. Correct |
| (f) | 2/2 | True, x = 0 works since y² ≥ 0. Correct |
| (g) | 2/2 | False, reals have no minimum element. Correct |
Problem 3.2 [16/16]
| Part | Score | Notes |
|---|---|---|
| (a) | 4/4 | Correctly not equivalent. Clean counterexample using domain {1,2} with P(1)=T, P(2)=F, Q(1)=F, Q(2)=T |
| (b) | 6/6 | Correctly equivalent. Both directions proven rigorously using arbitrary element and universal generalization |
| (c) | 6/6 | Correctly equivalent. Forward direction uses clean case analysis; backward direction elegantly assumes ¬(∀x P(x)), finds witness x₀ with ¬P(x₀), then derives ∀y Q(y). Both directions are correct and well-structured |
---
4. Proofs [20/20 pts]
(a) Unique integer m with m² ≤ n < (m+1)² [5/5]
Feedback: Excellent proof. Existence is shown via the well-ordering principle on S = {k ≥ 0 : k² ≤ n}, taking m = max(S). Uniqueness is proven cleanly: assuming m₁ < m₂ yields (m₁+1)² ≤ m₂², leading to the contradiction n < n. Fully correct.
(b) √n is integer or irrational [5/5]
Feedback: Correct proof by contradiction. Assumes √n = p/q with gcd(p,q) = 1 and q ≥ 2, derives q² | p², uses the Fundamental Theorem of Arithmetic to conclude gcd(p²,q²) = 1, forcing q² = 1, contradicting q ≥ 2. Clean and rigorous.
(c) ax² + bx + c = 0 has no rational solution (a,b,c odd) [5/5]
Feedback: Correct. Substitutes x = p/q, clears denominators to get ap² + bpq + cq² = 0, then exhaustively checks all three parity cases (odd-odd, even-odd, odd-even). In every case the sum is odd, which cannot equal 0. Matches the reference approach exactly.
(d) Irrational between rational and irrational [5/5]
Feedback: Correct. Takes t = (r+s)/2, proves irrationality by contradiction (if t rational, then r + s = 2t is rational, but rational + irrational = irrational). Carefully handles both ordering cases (r < s and s < r). Clean and complete.
---
Summary
| Problem | Score | Max |
|---|---|---|
| 1. Algorithmic Thinking | 20 | 20 |
| 2. Propositional Logic | 33 | 30* |
| 3. Predicate Logic | 30 | 30 |
| 4. Proofs | 20 | 20 |
*\*Per rubric: "a student can get a maximum of 33 points for this problem, and that's fine."*
Overall Comments: This is an outstanding submission. Every problem is answered correctly with clear reasoning and rigorous proofs. The propositional logic section earns 3 bonus points by getting all 11 sub-parts correct. The predicate logic proofs (especially 3.2c) are particularly elegant. The proof section demonstrates strong mathematical maturity with well-structured arguments. No deductions anywhere.
Total: 103/100
diff --git a/writeup.md b/writeup.md
index 22c0a80..b7f8df5 100644
--- a/writeup.md
+++ b/writeup.md
@@ -2,8 +2,352 @@
## Student Responses
-<!-- Write your solutions below. Add sections for each problem as needed. -->
-<!-- Use proper mathematical notation where applicable. -->
+---
-[Your solutions here]
+## 1. Algorithmic Thinking [20 pts]
+### Understanding the Problem
+
+Wayne Zachary wanted to answer the question: **Can we predict how a social group will split when an internal conflict causes the group to fission?** His motivation came from observing that small social groups often undergo fission (splitting into subgroups) due to internal conflicts, and sociologists lacked a rigorous, quantitative method for predicting the outcome of such fissions.
+
+To study this, Zachary collected data on a university karate club over a period of approximately three years (1970–1972). He observed and recorded social interactions among the 34 members of the club outside the context of club activities, constructing a social network of friendships and associations. During this period, a conflict arose between the club's administrator (officer) and the head instructor over club policies and pricing, which ultimately caused the club to split into two factions.
+
+Zachary's approach to solving the problem was to model the social relationships as a network and use information flow within that network to predict which faction each member would join.
+
+### Formulating the Problem
+
+Zachary formulated the problem mathematically as a **network flow problem on a graph**. He represented the karate club as a weighted undirected graph where:
+- Each **node** represents a club member.
+- Each **edge** represents a social tie between two members, weighted by the strength of their interaction (number of contexts in which they interacted outside the club).
+
+The question of predicting the fission was then formulated as finding a **minimum cut** in this network. Specifically, using the max-flow min-cut theorem from network flow theory, Zachary sought to find the partition of the network into two groups that minimizes the total weight of edges cut, corresponding to the split requiring the least disruption of social ties.
+
+### Algorithm Design
+
+Zachary employed the **Ford-Fulkerson maximum flow / minimum cut algorithm** (a classic network flow technique). By computing the maximum flow between pairs of key nodes (specifically the administrator and the instructor, who were the leaders of the two factions), the minimum cut of the network could be determined, which predicts the most likely partition of members.
+
+### Algorithm Implementation
+
+Zachary implemented the Ford-Fulkerson algorithm on the weighted social network graph he had constructed from his observational data. He computed maximum network flows between the two faction leaders and used the resulting minimum cut to assign each of the 34 members to one of the two predicted groups. The computation was performed on the full 34-node network with edge weights derived from his interaction data.
+
+### Solving the Original Problem
+
+Zachary's model **correctly predicted the faction membership of 33 out of 34 club members** (all but one member). This was a remarkable result: using only the social network structure and an algorithmic approach based on network flow theory, Zachary was able to predict with near-perfect accuracy how the club would split. The one misclassified member was a weak supporter of one faction who had stronger social ties to the other, highlighting the power and limitations of the network flow approach. This demonstrated that information flow models could be effective tools for predicting group fission in social networks.
+
+---
+
+## 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: **not p and not q**, i.e., **~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 will get a ticket"
+
+The sentence says: either pedestrians neither jaywalk nor cross a red light, or they get a ticket. In other words, if they jaywalk or cross a red light, they will get a ticket.
+
+Compound proposition: **(~p /\ ~q) \/ r**
+
+This is logically equivalent to: (p \/ q) -> r
+
+**(d) A plant is not poisonous unless it is tropical.**
+
+Let:
+- p = "The plant is poisonous"
+- q = "The plant is tropical"
+
+"Unless" means "if not." So: the plant is not poisonous if it is not tropical.
+
+Compound proposition: **~q -> ~p**
+
+This is logically equivalent to: p -> q
+
+**(e) Growing in the tropic is necessary but not sufficient for a plant to be poisonous.**
+
+Let:
+- p = "The plant is poisonous"
+- q = "The plant grows in the tropic"
+
+"Necessary" means: p -> q (if poisonous, then tropical).
+"Not sufficient" means: ~(q -> p), i.e., it is not the case that being tropical guarantees being poisonous.
+
+Compound proposition: **(p -> q) /\ ~(q -> p)**
+
+### Problem 2.2
+
+**(a) p XOR p**
+
+Truth table:
+
+| p | p XOR p |
+|---|---------|
+| T | T XOR T = F |
+| F | F XOR F = F |
+
+The result is always **F**. This proposition is **not satisfiable** (it is a contradiction); there is no assignment of truth values that makes it true.
+
+**(b) p XOR (~p)**
+
+Truth table:
+
+| p | ~p | p XOR ~p |
+|---|-----|----------|
+| T | F | T XOR F = T |
+| F | T | F XOR T = T |
+
+The result is always **T**. This proposition is **satisfiable** and, moreover, it is a **tautology** (true for all truth value assignments).
+
+**(c) (p XOR q) \/ (p XOR ~q)**
+
+Truth table:
+
+| p | q | ~q | p XOR q | p XOR ~q | (p XOR q) \/ (p XOR ~q) |
+|---|---|-----|---------|----------|--------------------------|
+| T | T | F | F | T | T |
+| T | F | T | T | F | T |
+| F | T | F | T | F | T |
+| F | F | T | F | T | T |
+
+The result is always **T**. This proposition is **satisfiable** and, moreover, it is a **tautology**.
+
+### Problem 2.3
+
+**(a) (p /\ q) -> r and (p -> r) /\ (q -> r)**
+
+These are **NOT logically equivalent**.
+
+**Proof by counterexample:** Consider p = T, q = F, r = F.
+
+- LHS: (p /\ q) -> r = (T /\ F) -> F = F -> F = **T**
+- RHS: (p -> r) /\ (q -> r) = (T -> F) /\ (F -> F) = F /\ T = **F**
+
+Since LHS = T and RHS = F, the biconditional is not a tautology. Therefore the two propositions are not logically equivalent.
+
+Full truth table for verification:
+
+| p | q | r | (p /\ q) -> r | (p -> r) /\ (q -> r) |
+|---|---|---|---------------|----------------------|
+| T | T | T | T | T |
+| T | T | F | F | F |
+| T | F | T | T | T |
+| T | F | F | **T** | **F** |
+| F | T | T | T | T |
+| F | T | F | **T** | **F** |
+| F | F | T | T | T |
+| F | F | F | T | T |
+
+The two columns differ in rows 4 and 5, confirming they are not logically equivalent.
+
+**(b) (p \/ q) -> r and (p -> r) \/ (q -> r)**
+
+These are **NOT logically equivalent**.
+
+**Proof by counterexample:** Consider p = T, q = F, r = F.
+
+- LHS: (p \/ q) -> r = (T \/ F) -> F = T -> F = **F**
+- RHS: (p -> r) \/ (q -> r) = (T -> F) \/ (F -> F) = F \/ T = **T**
+
+Since LHS = F and RHS = T, the biconditional is not a tautology, so the two propositions are not logically equivalent.
+
+**(c) p -> (q <-> r) and (p -> q) <-> (p -> r)**
+
+These are **logically equivalent**.
+
+**Proof by truth table:**
+
+| p | q | r | q <-> r | p -> (q <-> r) | p -> q | p -> r | (p -> q) <-> (p -> r) |
+|---|---|---|---------|----------------|--------|--------|-----------------------|
+| T | T | T | T | T | T | T | T |
+| T | T | F | F | F | T | F | F |
+| T | F | T | F | F | F | T | F |
+| T | F | F | T | T | F | F | T |
+| F | T | T | T | T | T | T | T |
+| F | T | F | F | T | T | T | T |
+| F | F | T | F | T | T | T | T |
+| F | F | F | T | T | T | T | T |
+
+The columns for p -> (q <-> r) and (p -> q) <-> (p -> r) are identical in all 8 rows. Therefore their biconditional is a tautology, and the two propositions are **logically equivalent**.
+
+---
+
+## 3. Predicate Logic [30 pts]
+
+### Problem 3.1
+
+**(a) There exists x such that x^3 = -1**
+
+**True.** Let x = -1. Then (-1)^3 = -1. Since -1 is a real number and satisfies the equation, the existential statement is true.
+
+**(b) For all x, (-x)^2 = x^2**
+
+**True.** For any real number x, (-x)^2 = (-1 * x)^2 = (-1)^2 * x^2 = 1 * x^2 = x^2. This holds for all real x.
+
+**(c) For all x, 2x > x**
+
+**False.** Counterexample: let x = -1. Then 2(-1) = -2, and -2 > -1 is false. Another counterexample: x = 0, then 2(0) = 0, and 0 > 0 is false. The statement 2x > x simplifies to x > 0, which is not true for all real numbers.
+
+**(d) For all x, there exists y such that x * y = y * x**
+
+**True.** Multiplication of real numbers is commutative: for all real numbers x and y, x * y = y * x. So for any x, we can choose any y (e.g., y = 0 or y = x or any real number), and x * y = y * x will hold.
+
+**(e) For all x, for all y, there exists z such that z = (x + y)/2**
+
+**True.** For any real numbers x and y, the value (x + y)/2 is a well-defined real number (since the reals are closed under addition and division by a nonzero number). So we can simply let z = (x + y)/2, and z exists in R.
+
+**(f) There exists x such that for all y, x <= y^2**
+
+**True.** Let x = 0. For any real number y, y^2 >= 0, so 0 <= y^2 holds for all y in R. (In fact, any x <= 0 would work, since y^2 >= 0 for all real y.)
+
+**(g) There exists x such that for all y, x <= y**
+
+**False.** The real numbers have no minimum element. For any candidate x, we can choose y = x - 1, and then x <= x - 1 is equivalent to 0 <= -1, which is false. So no such x exists.
+
+### Problem 3.2
+
+**(a) For all x (P(x) \/ Q(x)) and (For all x P(x)) \/ (For all x Q(x))**
+
+These are **NOT logically equivalent**.
+
+**Proof by counterexample:** Let the domain be {1, 2}. Define:
+- P(1) = T, P(2) = F
+- Q(1) = F, Q(2) = T
+
+LHS: For all x (P(x) \/ Q(x)):
+- P(1) \/ Q(1) = T \/ F = T
+- P(2) \/ Q(2) = F \/ T = T
+- Both are true, so the universal statement is **T**.
+
+RHS: (For all x P(x)) \/ (For all x Q(x)):
+- For all x P(x) = P(1) /\ P(2) = T /\ F = F
+- For all x Q(x) = Q(1) /\ Q(2) = F /\ T = F
+- F \/ F = **F**
+
+Since LHS = T and RHS = F, they are not logically equivalent.
+
+Note: The direction RHS -> LHS does hold (if everything is P or everything is Q, then everything is P or Q), but the converse fails as shown above.
+
+**(b) For all x (P(x) /\ Q(x)) and (For all x P(x)) /\ (For all x Q(x))**
+
+These are **logically equivalent**.
+
+**Proof:**
+
+(=>) Assume For all x (P(x) /\ Q(x)). Let a be an arbitrary element in the domain. Then P(a) /\ Q(a) is true, so P(a) is true and Q(a) is true. Since a was arbitrary, For all x P(x) is true and For all x Q(x) is true. Hence (For all x P(x)) /\ (For all x Q(x)).
+
+(<=) Assume (For all x P(x)) /\ (For all x Q(x)). Let a be an arbitrary element. From For all x P(x), we have P(a). From For all x Q(x), we have Q(a). So P(a) /\ Q(a) is true. Since a was arbitrary, For all x (P(x) /\ Q(x)).
+
+Since both directions hold, the two expressions are logically equivalent.
+
+**(c) (For all x P(x)) \/ (For all x Q(x)) and For all x, For all y (P(x) \/ Q(y))**
+
+These are **logically equivalent**.
+
+**Proof:**
+
+(=>) Assume (For all x P(x)) \/ (For all x Q(x)).
+Case 1: For all x P(x). Then for any x and any y, P(x) is true, so P(x) \/ Q(y) is true. Hence For all x, For all y (P(x) \/ Q(y)).
+Case 2: For all x Q(x). Then for any x and any y, Q(y) is true, so P(x) \/ Q(y) is true. Hence For all x, For all y (P(x) \/ Q(y)).
+In either case, the RHS holds.
+
+(<=) Assume For all x, For all y (P(x) \/ Q(y)). We prove (For all x P(x)) \/ (For all x Q(x)) by showing that if For all x P(x) fails, then For all x Q(x) must hold.
+
+Suppose ~(For all x P(x)), i.e., there exists some x_0 in the domain such that ~P(x_0). Now let y be any element in the domain. By our assumption, P(x_0) \/ Q(y) is true (instantiating x = x_0 and y = y). Since ~P(x_0), it must be the case that Q(y) is true. Since y was arbitrary, For all y Q(y) holds, which is the same as For all x Q(x) (just renaming the bound variable).
+
+Therefore (For all x P(x)) \/ (For all x Q(x)) holds. Since both directions are proven, the two expressions are logically equivalent.
+
+---
+
+## 4. Proofs [20 pts]
+
+### (a) Prove that given a nonnegative integer n, there is a unique nonnegative integer m such that m^2 <= n < (m + 1)^2. [5 pts]
+
+**Proof.**
+
+**Existence:** Consider the set S = {k in Z, k >= 0 : k^2 <= n}. This set is nonempty because 0 is in S (since 0^2 = 0 <= n for any nonneg integer n). The set S is bounded above because for any k > n, we have k^2 > n (since if k >= 1 and k > n, then k^2 >= k > n; and if n = 0, then S = {0} which is bounded). Since S is a nonempty set of nonneg integers that is bounded above, it has a maximum element. Let m = max(S).
+
+Since m is in S, we have m^2 <= n. Since m is the maximum element of S, m + 1 is not in S, which means (m + 1)^2 > n. Therefore m^2 <= n < (m + 1)^2.
+
+**Uniqueness:** Suppose m_1 and m_2 are both nonneg integers satisfying:
+- m_1^2 <= n < (m_1 + 1)^2
+- m_2^2 <= n < (m_2 + 1)^2
+
+Without loss of generality, assume m_1 <= m_2. If m_1 < m_2, then m_1 + 1 <= m_2 (since they are integers), which gives (m_1 + 1)^2 <= m_2^2. But then n < (m_1 + 1)^2 <= m_2^2 <= n, which gives n < n, a contradiction. Therefore m_1 = m_2, establishing uniqueness. **QED**
+
+### (b) Prove that for any positive integer n, sqrt(n) is either an integer or irrational. [5 pts]
+
+**Proof.** Let n be a positive integer. We consider two cases: either sqrt(n) is an integer, or it is not. If sqrt(n) is an integer, we are done. So assume sqrt(n) is not an integer; we must show it is irrational.
+
+Assume for contradiction that sqrt(n) is rational but not an integer. Then we can write sqrt(n) = p/q where p and q are positive integers with gcd(p, q) = 1 and q >= 2 (since sqrt(n) is not an integer).
+
+Then n = p^2 / q^2, so n * q^2 = p^2, which means q^2 divides p^2.
+
+Since gcd(p, q) = 1, by the Fundamental Theorem of Arithmetic, p and q share no common prime factors. Therefore p^2 and q^2 share no common prime factors, which means gcd(p^2, q^2) = 1.
+
+But q^2 divides p^2 and gcd(p^2, q^2) = 1 together imply q^2 = 1, so q = 1. This contradicts q >= 2.
+
+Therefore our assumption was wrong, and sqrt(n) is irrational. Combined with the first case, sqrt(n) is either an integer or irrational. **QED**
+
+### (c) Let a, b, and c be three odd integers. Prove that ax^2 + bx + c = 0 does not have a rational solution. [5 pts]
+
+**Proof.** Assume for contradiction that x = p/q is a rational solution in lowest terms, i.e., p, q are integers with q > 0 and gcd(p, q) = 1.
+
+Substituting into the equation: a(p/q)^2 + b(p/q) + c = 0.
+
+Multiplying both sides by q^2: **ap^2 + bpq + cq^2 = 0**.
+
+Since a, b, c are all odd, we analyze the parity of ap^2 + bpq + cq^2. Since gcd(p, q) = 1, p and q cannot both be even. We consider three exhaustive cases:
+
+**Case 1: p is odd and q is odd.**
+- ap^2: odd * odd = odd
+- bpq: odd * odd * odd = odd
+- cq^2: odd * odd = odd
+- Sum: odd + odd + odd = odd ≠ 0. Contradiction.
+
+**Case 2: p is even and q is odd.** (They can't both be even since gcd(p,q)=1.)
+- ap^2: odd * even = even
+- bpq: odd * even * odd = even
+- cq^2: odd * odd = odd
+- Sum: even + even + odd = odd ≠ 0. Contradiction.
+
+**Case 3: p is odd and q is even.**
+- ap^2: odd * odd = odd
+- bpq: odd * odd * even = even
+- cq^2: odd * even = even
+- Sum: odd + even + even = odd ≠ 0. Contradiction.
+
+In all cases, ap^2 + bpq + cq^2 is odd and thus cannot equal 0. This contradicts our assumption that p/q is a solution. Therefore ax^2 + bx + c = 0 has no rational solution. **QED**
+
+### (d) Prove that between every rational number and every irrational number there is an irrational number. [5 pts]
+
+**Proof.** Let r be a rational number and s be an irrational number with r ≠ s. We need to find an irrational number strictly between r and s.
+
+Consider the number t = (r + s) / 2, which is the midpoint of r and s.
+
+**Claim: t is irrational.** Suppose for contradiction that t is rational. Then r + s = 2t would be rational (since the product of two rationals is rational). But r + s = (rational) + (irrational) = irrational, since the sum of a rational number and an irrational number is always irrational. This is a contradiction, so t must be irrational.
+
+**Claim: t is strictly between r and s.** There are two cases:
+- If r < s, then r < (r + s)/2 < s, so r < t < s.
+- If s < r, then s < (r + s)/2 < r, so s < t < r.
+
+In both cases, t = (r + s)/2 is an irrational number that lies strictly between the rational number r and the irrational number s. **QED**
Sub-Model Usage
| Model | Input | Output | Cache Read | Cost |
|---|---|---|---|---|
| claude-opus-4-6 | 7 | 12.1K | 191.7K | $0.56 |
BSCS Bench