Fun with Learning Technology
LearnCoursesQuestionsTracksToolsNewsExplorePractice
Fun with Learning Technology

A new problem, explained clearly, every day.

Subscribe
Learn
  • Lessons
  • Topics
  • News
  • Tools
  • Courses
  • Career tracks
  • Everything
Site
  • About
  • Contact
  • Support
  • Privacy
  • Terms
Get the daily one

One email per new problem. No spam.

Request a tutorial

Requests shape what gets made next.

© 2026 Fun with Learning TechnologyRSS
Home›Courses›Reasoning›Formal Proof Techniques

Advanced Logical Systems

Formal Proof Techniques

Formal proof techniques are structured methods for verifying the truth of logical statements by breaking them into smaller, provable components. They matter because they eliminate ambiguity and provide rigorous, reproducible evidence for complex claims, which is essential in fields like mathematics, computer science, and philosophy. You reach for these techniques when intuitive reasoning fails, or when you need to ensure absolute correctness in high-stakes scenarios like algorithm design or system verification.

Direct Proof: The Foundation of Logical Deduction

Direct proof is the simplest and most intuitive formal proof technique, where you start with given premises and use logical deductions to arrive at the desired conclusion. The core idea is to follow a chain of implications, where each step is justified by a known axiom, definition, or previously proven theorem. For example, if you want to prove that 'if n is even, then n² is even,' you start by assuming n is even (the premise), express it as n = 2k for some integer k, and then show that n² = (2k)² = 4k² = 2(2k²), which is clearly even. The power of direct proof lies in its transparency—each step is explicit, leaving no room for hidden assumptions. This technique works because it mirrors how we naturally reason about cause and effect, making it accessible even for beginners. However, its simplicity can also be a limitation; not all statements can be proven directly, especially those involving negations or universal quantifiers. Understanding direct proof is crucial because it trains you to think in terms of logical dependencies, a skill that underpins all other proof techniques.

# Direct proof example: Prove that the sum of two even numbers is even.
# Premise: Let a and b be even numbers.
def is_even_sum(a, b):
    # By definition, even numbers can be written as 2k and 2m for integers k, m.
    k = a // 2
    m = b // 2
    # Sum of a and b: a + b = 2k + 2m = 2(k + m).
    sum_ab = a + b
    # Since (k + m) is an integer, 2(k + m) is even.
    return sum_ab % 2 == 0

# Test the proof with specific values.
assert is_even_sum(4, 6) == True  # 4 + 6 = 10, which is even.
assert is_even_sum(0, 2) == True  # 0 + 2 = 2, which is even.
print("Direct proof verified for even sums.")

Proof by Contrapositive: Flipping the Implication

Proof by contrapositive is a technique that leverages the logical equivalence between a statement 'P implies Q' and its contrapositive 'not Q implies not P.' Instead of proving the original statement directly, you prove the contrapositive, which is often simpler. For example, to prove 'if n² is odd, then n is odd,' you instead prove 'if n is not odd (i.e., even), then n² is not odd (i.e., even).' This works because the contrapositive is logically identical to the original statement, so proving one automatically proves the other. The advantage of this technique is that it can transform a difficult implication into a more manageable one, especially when dealing with negations. It’s particularly useful when the conclusion (Q) is easier to negate and manipulate than the premise (P). However, it requires careful handling of negations to avoid logical errors. Mastering the contrapositive helps you recognize when a problem is easier to tackle 'backwards,' a skill that becomes invaluable in more complex proofs.

# Proof by contrapositive: Prove 'if n² is odd, then n is odd.'
# We prove the contrapositive: 'if n is even, then n² is even.'
def is_odd_contrapositive(n):
    # Assume n is even (not odd).
    if n % 2 == 0:
        # n = 2k for some integer k.
        k = n // 2
        # n² = (2k)² = 4k² = 2(2k²), which is even.
        return (n * n) % 2 == 0
    # If n is odd, the contrapositive doesn't apply, but the original statement holds.
    return True

# Test the contrapositive.
assert is_odd_contrapositive(2) == True  # 2 is even, 2² = 4 is even.
assert is_odd_contrapositive(3) == True  # 3 is odd, but the function returns True (contrapositive holds).
print("Contrapositive proof verified.")

Proof by Contradiction: Assuming the Opposite

Proof by contradiction is a powerful technique where you assume the opposite of what you want to prove and show that this assumption leads to a contradiction. If the assumption leads to an impossible situation (e.g., a statement that is both true and false), then the original statement must be true. For example, to prove that √2 is irrational, you assume it is rational (i.e., √2 = a/b for integers a and b with no common factors) and show that this leads to a contradiction (a and b must both be even, violating the 'no common factors' condition). This technique works because it exploits the law of non-contradiction: a statement cannot be both true and false. It’s particularly useful for proving statements about non-existence or impossibility, where direct proof would be cumbersome. However, it can be tricky to identify the right contradiction, and the proof may feel less constructive than direct methods. Understanding contradiction helps you see how assumptions can unravel, a skill that sharpens your ability to spot flaws in arguments.

# Proof by contradiction: Prove that √2 is irrational.
# Assume √2 is rational, i.e., √2 = a/b where a and b are coprime integers.
import math

def is_irrational_sqrt2():
    # Assume √2 is rational: √2 = a/b, reduced to lowest terms.
    # Then 2 = a²/b² => a² = 2b².
    # This implies a² is even, so a must be even (let a = 2k).
    # Substituting: (2k)² = 2b² => 4k² = 2b² => b² = 2k².
    # Thus, b² is even, so b must be even.
    # But if both a and b are even, they share a common factor of 2, contradicting the assumption.
    # Therefore, √2 cannot be rational.
    return not (math.isqrt(2) * math.isqrt(2) == 2)  # Verifies √2 is not a perfect square.

assert is_irrational_sqrt2() == True
print("Contradiction proof verified: √2 is irrational.")

Proof by Induction: Building from the Base Case

Proof by induction is a technique for proving statements about all natural numbers by showing that if the statement holds for one case, it must hold for the next. It consists of two steps: the base case (proving the statement for the smallest number, usually 0 or 1) and the inductive step (assuming the statement holds for an arbitrary case n and proving it for n+1). For example, to prove that the sum of the first n natural numbers is n(n+1)/2, you first show it holds for n=1 (base case), then assume it holds for n=k and prove it for n=k+1. Induction works because it establishes a domino effect: if the base case is true and each case implies the next, then all cases must be true. This technique is indispensable for proving properties of recursive structures, like algorithms or sequences. However, it requires careful handling of the inductive hypothesis to avoid circular reasoning. Mastering induction trains you to think recursively, a skill that extends beyond proofs to problem-solving in general.

# Proof by induction: Prove the sum of the first n natural numbers is n(n+1)/2.
# Base case: n=1. Sum is 1, and 1(1+1)/2 = 1.
# Inductive step: Assume true for n=k, prove for n=k+1.
def sum_natural_numbers(n):
    # Base case.
    if n == 1:
        return 1 == 1 * (1 + 1) // 2
    # Inductive step: Assume sum of first k numbers is k(k+1)/2.
    # Sum of first (k+1) numbers = sum of first k numbers + (k+1).
    # By hypothesis: k(k+1)/2 + (k+1) = (k+1)(k/2 + 1) = (k+1)(k+2)/2.
    # Thus, the formula holds for n=k+1.
    return sum(range(1, n + 1)) == n * (n + 1) // 2

# Test the proof for n=1, 5, and 10.
assert sum_natural_numbers(1) == True
assert sum_natural_numbers(5) == True  # 1+2+3+4+5 = 15, 5*6/2 = 15.
assert sum_natural_numbers(10) == True
print("Induction proof verified for sum of natural numbers.")

Proof by Cases: Divide and Conquer

Proof by cases is a technique where you break a problem into distinct scenarios and prove the statement separately for each case. This is useful when the statement behaves differently under different conditions, such as when dealing with absolute values, piecewise functions, or modular arithmetic. For example, to prove that |x + y| ≤ |x| + |y| for all real numbers x and y, you consider four cases based on the signs of x and y: both positive, both negative, x positive and y negative, and vice versa. Each case is proven individually, and since the cases cover all possibilities, the statement holds universally. This technique works because it reduces a complex problem into simpler, more manageable parts, each of which can be tackled with direct proof or other methods. However, it requires careful enumeration of all possible cases to avoid gaps. Mastering proof by cases helps you recognize when a problem can be decomposed, a skill that is essential for tackling real-world problems with multiple variables or conditions.

# Proof by cases: Prove the triangle inequality |x + y| ≤ |x| + |y|.
# Cases: (1) x ≥ 0, y ≥ 0; (2) x ≥ 0, y < 0; (3) x < 0, y ≥ 0; (4) x < 0, y < 0.
def triangle_inequality(x, y):
    # Case 1: x ≥ 0, y ≥ 0. |x + y| = x + y = |x| + |y|.
    if x >= 0 and y >= 0:
        return abs(x + y) == abs(x) + abs(y)
    # Case 2: x ≥ 0, y < 0. |x + y| ≤ |x| + |y| because |x + y| ≤ max(|x|, |y|).
    elif x >= 0 and y < 0:
        return abs(x + y) <= abs(x) + abs(y)
    # Case 3: x < 0, y ≥ 0. Symmetric to Case 2.
    elif x < 0 and y >= 0:
        return abs(x + y) <= abs(x) + abs(y)
    # Case 4: x < 0, y < 0. |x + y| = |x| + |y| (both negative).
    else:
        return abs(x + y) == abs(x) + abs(y)

# Test all cases.
assert triangle_inequality(3, 4) == True    # Case 1.
assert triangle_inequality(3, -4) == True   # Case 2.
assert triangle_inequality(-3, 4) == True   # Case 3.
assert triangle_inequality(-3, -4) == True  # Case 4.
print("Proof by cases verified for triangle inequality.")

Key points

  • Direct proof is the most straightforward technique, where you derive the conclusion from the premises using logical steps, making it ideal for simple implications.
  • Proof by contrapositive is useful when the original statement is difficult to prove directly, as it allows you to work with the logically equivalent contrapositive instead.
  • Proof by contradiction assumes the opposite of what you want to prove and derives a contradiction, which confirms the original statement must be true.
  • Proof by induction is essential for proving statements about all natural numbers, relying on a base case and an inductive step to establish a chain of truth.
  • Proof by cases breaks a problem into distinct scenarios, each of which is proven separately, ensuring the statement holds under all possible conditions.
  • Each proof technique has strengths and limitations, and choosing the right one depends on the structure of the statement you are trying to prove.
  • Formal proofs eliminate ambiguity by making every logical step explicit, which is critical for verifying complex or high-stakes claims.
  • Mastering these techniques trains you to think rigorously and systematically, skills that are invaluable in both theoretical and applied reasoning.

Common mistakes

  • Mistake: Assuming the conclusion is true at the start of a proof by contradiction. Why it's wrong: This violates the principle of proof by contradiction, which requires assuming the *negation* of the conclusion to derive a contradiction. Fix: Always assume the negation of what you want to prove, not the conclusion itself.
  • Mistake: Confusing necessary and sufficient conditions in implications. Why it's wrong: Writing 'P implies Q' when you mean 'Q implies P' leads to incorrect proofs, as the direction of implication matters. Fix: Clearly state which condition is necessary and which is sufficient before writing the implication.
  • Mistake: Skipping steps in a proof and assuming the reader will 'see' the logic. Why it's wrong: Formal proofs require explicit justification for each step; omissions can hide errors or invalid reasoning. Fix: Write every logical step, no matter how trivial it seems, and justify it with definitions or rules.
  • Mistake: Using circular reasoning (e.g., proving P by assuming P). Why it's wrong: This makes the proof invalid because it doesn’t establish the truth of P independently. Fix: Ensure no step in the proof relies on the statement you’re trying to prove.
  • Mistake: Misapplying universal or existential quantifiers. Why it's wrong: Swapping ∀ (for all) and ∃ (there exists) changes the meaning of a statement and can invalidate a proof. Fix: Double-check quantifiers when translating statements into formal logic and when applying rules like universal instantiation.

Interview questions

What is a formal proof, and why is it important in reasoning?

A formal proof is a structured, step-by-step demonstration that a statement logically follows from a set of axioms or previously established theorems using precise rules of inference. It’s important in reasoning because it eliminates ambiguity and ensures absolute certainty—unlike informal arguments, which may rely on intuition or unstated assumptions. For example, in propositional logic, we might prove that 'P → Q' follows from '¬P ∨ Q' using the rule of material implication. Formal proofs provide a rigorous foundation for verifying the correctness of algorithms, mathematical theorems, and even hardware designs, where errors can have critical consequences.

Explain the difference between direct proof and proof by contradiction. When would you use each?

A direct proof starts with given premises and uses logical deductions to arrive at the conclusion directly. For example, to prove 'If n is even, then n² is even,' we assume n is even, express it as n = 2k, and show n² = 4k² = 2(2k²), which is even. Direct proofs are intuitive and straightforward when the path from premises to conclusion is clear. Proof by contradiction, on the other hand, assumes the negation of the statement we want to prove and derives a contradiction. For instance, to prove '√2 is irrational,' we assume it’s rational (√2 = a/b in lowest terms), square both sides, and show a and b must both be even, contradicting the assumption. Use contradiction when the direct path is obscure or when the negation of the statement leads to a clear contradiction, like proving uniqueness or impossibility.

How does mathematical induction work, and why is it a valid proof technique?

Mathematical induction is a proof technique for statements about all natural numbers. It has two steps: the base case, where we verify the statement for the smallest number (usually 0 or 1), and the inductive step, where we assume the statement holds for an arbitrary number k (inductive hypothesis) and prove it holds for k+1. For example, to prove '1 + 2 + ... + n = n(n+1)/2,' the base case (n=1) is 1 = 1(2)/2. For the inductive step, assume it holds for k, then show for k+1: 1 + ... + k + (k+1) = k(k+1)/2 + (k+1) = (k+1)(k+2)/2. Induction is valid because it mirrors the well-ordering principle: if the base case holds and the inductive step is valid, the statement must hold for all numbers, as you can 'climb' from the base case to any number via repeated application of the inductive step.

Compare proof by cases with proof by exhaustion. What are their strengths and limitations?

Proof by cases involves dividing a proof into distinct scenarios, each covering a possible situation, and proving the statement holds in every case. For example, to prove '|x| ≥ x for all real x,' we split into cases: if x ≥ 0, |x| = x; if x < 0, |x| > x. Proof by exhaustion, on the other hand, enumerates and verifies every possible instance, often used for finite domains. For example, proving 'all numbers from 1 to 100 are either prime or composite' requires checking each number individually. Cases are useful when the problem naturally splits into broad categories, while exhaustion is practical only for small, finite sets. Cases are more scalable but require careful identification of all scenarios, whereas exhaustion is exhaustive (hence the name) but computationally infeasible for large domains.

What is a constructive proof, and how does it differ from a non-constructive proof? Provide an example of each.

A constructive proof demonstrates the existence of an object by explicitly providing a method to construct it, while a non-constructive proof shows that an object must exist without necessarily providing an example. For instance, to constructively prove 'there exists an even number greater than 10,' we can simply state 12. In contrast, a non-constructive proof might use the pigeonhole principle to argue that among 11 integers, at least two must have the same parity, without identifying which two. Constructive proofs are preferred in algorithmic reasoning because they provide actionable results, such as an algorithm to find a solution. Non-constructive proofs, like those using the law of excluded middle (e.g., 'either P or ¬P'), are often shorter but less informative, as they don’t tell us how to find the object in question.

Explain how the resolution rule works in propositional logic and why it’s fundamental to automated theorem proving.

The resolution rule is a single inference rule used in propositional logic to derive a new clause from two existing clauses containing complementary literals. Given clauses C₁ = (A ∨ P) and C₂ = (B ∨ ¬P), resolution produces the resolvent (A ∨ B) by eliminating P and ¬P. For example, from '¬P ∨ Q' and 'P ∨ R,' we derive 'Q ∨ R.' Resolution is fundamental to automated theorem proving because it’s complete for refutation: to prove a statement, we negate it, convert the premises and negation into conjunctive normal form (CNF), and repeatedly apply resolution until we derive the empty clause (a contradiction). This process, called resolution refutation, is the backbone of many theorem provers and SAT solvers, as it’s mechanically simple and can be implemented efficiently. Its power lies in reducing proof search to a systematic elimination of literals.

All Reasoning interview questions →

Check yourself

1. In a proof by contradiction, what should you assume at the beginning?

  • A.The conclusion you want to prove is true
  • B.The negation of the conclusion you want to prove
  • C.A known true statement unrelated to the conclusion
  • D.The premises of the argument are false
Show answer

B. The negation of the conclusion you want to prove
The correct answer is assuming the negation of the conclusion. Proof by contradiction works by assuming the opposite of what you want to prove and showing this leads to a contradiction. The other options are incorrect: assuming the conclusion itself is circular, assuming an unrelated true statement doesn’t help, and assuming the premises are false undermines the proof.

2. Which of the following correctly represents 'All humans are mortal' in formal logic?

  • A.∀x (Human(x) ∧ Mortal(x))
  • B.∃x (Human(x) → Mortal(x))
  • C.∀x (Human(x) → Mortal(x))
  • D.∀x (Mortal(x) → Human(x))
Show answer

C. ∀x (Human(x) → Mortal(x))
The correct answer is ∀x (Human(x) → Mortal(x)). This reads as 'For all x, if x is a human, then x is mortal.' The other options are wrong: the first says 'Everything is both human and mortal,' the second uses an existential quantifier and is nonsensical, and the fourth reverses the implication to say 'All mortals are human.'

3. You are proving 'If n is even, then n² is even.' Which of the following is a valid first step in a direct proof?

  • A.Assume n is odd and show n² is odd
  • B.Assume n² is even and show n is even
  • C.Assume n is even and write n = 2k for some integer k
  • D.Assume n is even and n² is odd, then derive a contradiction
Show answer

C. Assume n is even and write n = 2k for some integer k
The correct answer is assuming n is even and writing n = 2k. This is the standard approach for a direct proof: start with the premise and express it in a usable form. The other options are incorrect: the first is a proof for the converse, the second is the converse itself, and the fourth describes a proof by contradiction, not a direct proof.

4. In a proof, you write: 'Let x be an arbitrary element of the set S. Since S is non-empty, x exists.' What is wrong with this reasoning?

  • A.It assumes S is non-empty without justification
  • B.It confuses existential and universal quantifiers
  • C.It incorrectly assumes an arbitrary element exists
  • D.It is circular because it assumes what it’s trying to prove
Show answer

B. It confuses existential and universal quantifiers
The correct answer is it confuses existential and universal quantifiers. The statement 'Let x be an arbitrary element' is about universal quantification (∀x), while 'x exists' is about existential quantification (∃x). The other options are incorrect: the reasoning doesn’t assume S is non-empty without justification (it’s given), it doesn’t assume an arbitrary element exists (it’s defining x), and it’s not circular.

5. You are proving 'There exists an x such that P(x)' by constructing a specific example. Which of the following is a valid approach?

  • A.Assume P(x) is false for all x and derive a contradiction
  • B.Assume P(x) is true for all x and show it holds for a specific x
  • C.Construct a specific x and show P(x) holds for that x
  • D.Assume no such x exists and show this leads to a contradiction
Show answer

C. Construct a specific x and show P(x) holds for that x
The correct answer is constructing a specific x and showing P(x) holds for that x. This is a constructive proof for an existential statement. The other options are incorrect: the first describes a proof by contradiction for a universal statement, the second is nonsensical (you can’t assume P(x) is true for all x), and the fourth is a proof by contradiction for the existential statement, not a constructive one.

Take the full Reasoning quiz →

← PreviousModal Logic: Possibility and NecessityNext →Mathematical Reasoning and Proofs

Reasoning

36 lessons, free to read.

All lessons →

Track your progress

Sign in to mark lessons done, score quizzes and keep notes.

Open in the app