Tutorials › Real Analysis › How to Debug a Proof

Mathematical Foundations · Tutorial 35 of 1000

How to Debug a Proof

A careful proof check finds the first unsupported step, identifies what it needs, and either repairs the argument or clarifies the claim.

Beginner 14 min read

What You'll Learn

  • How to locate the first step that does not follow
  • How to check hypotheses, domains, and quantifiers
  • How counterexamples distinguish a false claim from a flawed proof
  • How to repair an argument without assuming its conclusion
  • How to verify that a corrected proof reaches the original target

Debug the Argument, Not Just the Conclusion

A proof can be checked in much the same way as a calculation: trace its steps, locate the first place where the reasoning is not justified, and inspect what that step requires. This is more useful than deciding that an argument “looks wrong” or rewriting every line before understanding the gap. A proof may contain many correct statements and still fail because one transition uses an unstated assumption.

The previous tutorial, Common Invalid Proofs, examined several familiar failures, including reversing a conditional, dividing by zero, and circular reasoning. Here the emphasis is on a practical method for diagnosing an argument of any kind. We distinguish three questions: Is the claim true? Does the proposed proof establish it? If not, can the argument be repaired, or must the claim itself be changed?

Begin by writing the target in a precise form. For a conditional claim, mark the hypothesis and conclusion. For a universal claim, identify the domain and consider what an arbitrary input would be. Then read each line in order and ask what facts are available at that point. A line may be true on its own but still fail to follow from the preceding information.

The first gap matters most. Once a step is unsupported, later steps may be correct calculations from that point onward, but they do not establish the original claim. Find the earliest unjustified transition before deciding whether later lines need attention.

A Practical Proof-Debugging Procedure

A useful audit keeps the intended conclusion separate from what has actually been established. In particular, a proof plan may work backward from a target, but the completed argument must justify each step from the original hypotheses. The following procedure makes that distinction explicit.

1
State the claim and its scope.
Record the domain, hypotheses, quantifiers, and exact conclusion. Check whether the claim says “for every,” “there exists,” or “if.”
2
List the available information.
Separate the given assumptions and earlier established results from facts that the proof still needs to establish.
3
Trace each transition.
For every equality, inequality, implication, or change of variables, ask which rule permits it and what conditions that rule requires.
4
Test the first questionable step.
Look for a counterexample to the inference, a missing hypothesis, an omitted case, or a mismatch between the line and the stated domain.
5
Repair and check the endpoint.
Add a justified condition, handle the missing case, or revise a false claim. Then verify that the repaired argument proves the original target.

This procedure is not a substitute for mathematical reasoning; it organizes that reasoning. Some gaps are local, such as an illegal division. Others affect the entire statement, such as a quantifier that is stronger than the available argument can support. It is also possible for a proof to be incomplete while its claim remains true. Debugging should diagnose which situation applies.

What you find Diagnostic question Possible response
A step uses an algebraic operation. Are the operation's conditions satisfied? State and establish the missing condition, or split into cases.
The proof treats a general input as if it had a special value. Was the input arbitrary, or was that restriction given? Restore the full domain or state the needed restriction in the claim.
The conclusion is stronger than the calculations show. Which cases or alternatives have not been ruled out? Weaken the conclusion or prove the additional information required.
A step appears to assume the target. Has that step been established independently? Derive it from the hypotheses rather than using the desired result.

Worked Diagnoses and Repairs

Consider first a short argument that reaches an incorrect conclusion. The useful task is not merely to label it invalid, but to locate the precise inference and determine what the true conclusion should say.

Worked Example: Repairing a Conclusion About Squares

Claim under review. “For every real number \(x\), if \(x^2=16\), then \(x=4\).” The proposed proof says: “Taking the square root of both sides gives \(x=4\).”

Test the claim before trying to repair the proof. For \(x=-4\), we have \(x^2=(-4)^2=16\), but \(x\ne4\). Thus the universal conditional is false as stated. The gap is not a small missing algebraic detail: taking a square root of \(x^2\) gives \(|x|\), not necessarily \(x\). The original hypothesis does not say \(x\geq0\).

A correct replacement is that \(x^2=16\) if and only if \(x=4\) or \(x=-4\). To prove the forward direction, suppose \(x^2=16\). Then $$ x^2-16=0,\qquad (x-4)(x+4)=0. $$ A product of real numbers is zero only if at least one factor is zero. Therefore \(x-4=0\) or \(x+4=0\), so \(x=4\) or \(x=-4\). Conversely, if \(x=4\), then \(x^2=16\); if \(x=-4\), then \(x^2=(-4)^2=16\). Both directions hold.

There is another valid repair if the intended conclusion really is \(x=4\): add the hypothesis \(x\geq0\). Under \(x^2=16\), the factorization gives \(x=4\) or \(x=-4\); the second alternative contradicts \(x\geq0\). The repaired hypothesis excludes exactly the case that broke the original claim.

This diagnosis uses both a counterexample and a repair. The counterexample establishes that the original universal claim cannot be proved. The factorization then identifies the complete set of possibilities, allowing a corrected statement. A proof debugger should not quietly discard a failing case; the revised claim must make its scope explicit.

Worked Example: Checking a Sign Condition in an Inequality

Claim under review. “For every real number \(x\), \(x^2\geq x\).” A proposed argument factors the difference as \(x^2-x=x(x-1)\), then says that the product is nonnegative because both factors have the same sign.

The factorization is correct, but the sign assertion is not true for every real \(x\). For example, if \(x=\tfrac12\), then \(x>0\) and \(x-1<0\), so the factors have opposite signs. Indeed, $$ \left(\frac12\right)^2=\frac14<\frac12. $$ This is a counterexample to the claim, and the unsupported step is the assertion about the factors' signs.

The factorization also helps determine the exact correct statement. We prove that, for real \(x\), $$ x^2\geq x\quad\Longleftrightarrow\quad x\leq0\ \text{or}\ x\geq1. $$ The inequality is equivalent, by subtracting \(x\) from both sides, to $$ x(x-1)\geq0. $$ If \(x\leq0\), then \(x\leq0\) and \(x-1<0\), so their product is nonnegative. If \(x\geq1\), then \(x\geq0\) and \(x-1\geq0\), so their product is again nonnegative. Thus either stated condition implies \(x^2\geq x\).

For the reverse direction, suppose \(x^2\geq x\), so \(x(x-1)\geq0\). If \(0<x<1\), then \(x>0\) while \(x-1<0\), which would give \(x(x-1)<0\), a contradiction. Therefore \(x\) cannot lie strictly between \(0\) and \(1\). Every real number not in that interval satisfies \(x\leq0\) or \(x\geq1\). This proves the equivalence, including the boundary values \(x=0\) and \(x=1\).

The corrected conclusion is stronger than a list of examples: it classifies every real input for which the inequality holds. Checking the endpoints is essential. At \(x=0\) and \(x=1\), equality holds, so replacing the weak inequality by a strict one would require a further correction.

Check the Domain and the Quantifiers

Many proof gaps arise before any calculation: the argument quietly changes which objects are under consideration. A statement about every real number cannot be proved by choosing a convenient positive number unless positivity is one of its hypotheses. A statement about integers may permit an argument based on integer structure that does not apply to real numbers. In each case, the domain is part of the claim, not background decoration.

The quantifier matters just as much. To prove a universal claim, the input must be arbitrary and the reasoning must apply throughout the stated domain. A single example can disprove such a claim if that example satisfies the hypotheses and fails the conclusion. By contrast, one successful example does not establish that all inputs work. To prove an existence claim, one valid example may be enough, but it must satisfy every required condition.

Worked Example: Finding a Hidden Domain Restriction

Claim under review. “For every real number \(x\), if \(x^2=9\), then \(x>0\).” The proof says: “Since \(x^2\) is positive, \(x\) must be positive.”

The inference confuses the sign of a square with the sign of its input. Taking \(x=-3\) gives \(x^2=9\), which satisfies the hypothesis, while \(x>0\) is false. The claim is therefore false. The exact assumption the proof needs is a sign restriction, such as \(x\geq0\), but even that only yields \(x\geq0\); in this particular situation \(x^2=9\) rules out \(x=0\), so it would yield \(x>0\).

To verify that repair, suppose \(x^2=9\) and \(x\geq0\). Factoring gives $$ (x-3)(x+3)=0, $$ so \(x=3\) or \(x=-3\). The condition \(x\geq0\) excludes \(x=-3\), leaving \(x=3\), and hence \(x>0\). The additional hypothesis is not a decorative detail: it removes a real counterexample.

A domain or sign restriction can be introduced only when it is given or derived. A proof cannot resolve a counterexample by treating the offending input as inadmissible unless the statement itself excludes that input. This is why the first audit step records the complete claim before examining the calculations.

Follow Every Transformation in Both Directions

A line of algebra may be equivalent to the preceding line, or it may merely follow from it in one direction. This distinction is crucial when working backward from a conclusion. For example, squaring an equation can create additional solutions: if \(u=v\), then \(u^2=v^2\), but the reverse implication need not give \(u=v\). Debugging asks whether the proof needs implication or equivalence at that particular point.

When an argument transforms a target into a simpler condition, mark whether each transformation can be reversed under the stated assumptions. If a transformation is reversible only when a quantity is positive or nonzero, record that condition and show it holds. If the step is one-way, it may help discover a route, but it cannot automatically be retraced as a proof.

Worked Example: Auditing Squaring an Equation

Claim under review. “If real numbers \(u\) and \(v\) satisfy \(u^2=v^2\), then \(u=v\).” One proposed line is to take square roots and conclude \(u=v\).

Test the inference with \(u=5\) and \(v=-5\). Then \(u^2=25=v^2\), but \(u\ne v\). Thus squaring does not preserve enough information to recover equality of the original inputs. Factoring provides the exact result instead.

Proposition. For real numbers \(u\) and \(v\), $$ u^2=v^2\quad\Longleftrightarrow\quad u=v\ \text{or}\ u=-v. $$ Proof. Suppose first that \(u^2=v^2\). Subtracting gives $$ u^2-v^2=0. $$ Factoring the difference of squares yields $$ (u-v)(u+v)=0. $$ Since the real numbers have no zero divisors, \(u-v=0\) or \(u+v=0\). Thus \(u=v\) or \(u=-v\).

For the converse, suppose \(u=v\) or \(u=-v\). If \(u=v\), then \(u^2=v^2\) directly. If \(u=-v\), then $$ u^2=(-v)^2=v^2. $$ In either case \(u^2=v^2\). Both directions are proved, so the equivalence is established.

This example illustrates a general debugging question: did the proof preserve all possible cases? The equality of squares permits two alternatives, and the incorrect argument retained only one. Factoring made the missing alternative visible and allowed both directions of the corrected statement to be checked separately.

What a Good Repair Looks Like

Once a gap is found, the repair should address its cause. If an operation needs a nonzero quantity, establish that the quantity is nonzero or divide the proof into zero and nonzero cases. If an argument assumes a sign, prove the sign from the hypotheses or state it as an additional hypothesis. If a counterexample shows the claim is false, revise the claim rather than hiding the counterexample.

A useful repair preserves as much of the original argument as possible while making every inference valid. But “minimal change” is not more important than correctness. A revised theorem must match what the proof actually establishes, and the proof must still handle every input allowed by the revised statement. In particular, check endpoint cases after changing strict inequalities to weak ones or adding a restriction.

A repaired proof has two obligations. Every step must now follow from the available assumptions, and the final conclusion must be exactly the claim being asserted. Fixing one algebraic line does not help if the theorem still says more than the repaired reasoning proves.

When no repair is immediately apparent, write down the first questionable inference as a separate claim. Ask whether it is valid for arbitrary objects satisfying its stated premises. If it is not, search for a counterexample. If it is valid only with extra conditions, identify them precisely. This reduces a vague difficulty to a definite mathematical question that can be answered.

Check Your Understanding

For each question, describe how you would diagnose the argument and, where appropriate, repair it.

  1. A proof claims that \(x=6\) follows from \(x^2=36\). Give a counterexample, identify the missing possibility, and state a correct conclusion.
  2. In the argument for \(x^2\geq x\), why is it not enough to write \(x^2-x=x(x-1)\)? What additional sign analysis is needed?
  3. A proof of a statement about every real number begins, “Choose a positive real number \(x\).” What should you check before accepting that choice?
  4. What is the difference between finding one example that satisfies an existence claim and checking one example when the claim is universal?
  5. If a proof squares both sides of an equation, what question should you ask before treating the resulting equation as equivalent to the original one?
  6. After repairing an unsupported step, what two checks should you make before accepting the completed proof?