Basic Proof Techniques for Software Engineers
For those who want to get started with algorithm analysis, data structures, and mathematical reasoning.
Many software engineers encounter proofs when studying algorithms, complexity theory, discrete mathematics, machine learning, or theoretical computer science. Fortunately, a handful of proof techniques appear again and again.
In this post, we'll look at three fundamental methods:
- Proof by Induction
- Proof by Contradiction
- Proof by Counterexample
1. Proof by Induction
Mathematical induction is commonly used to prove statements that depend on a positive integer
The method has two steps:
Step 1: Prove the Base Case
Show that the statement is true for the smallest value (usually
Step 2: Prove the Inductive Step
Assume the statement is true for some integer
Then prove that the statement must also be true for
If both steps succeed, the statement is true for all positive integers.
Think of a row of dominoes:
- The base case knocks over the first domino.
- The inductive step shows that whenever one domino falls, the next one falls too.
- Therefore all dominoes eventually fall.
Example: Sum of Squares
Prove that for all integers
Base Case:
Therefore, the formula holds for
Inductive Hypothesis
Assume
Inductive Step
Since
and
the formula holds for
2. Proof by Contradiction
In a proof by contradiction, we assume that the statement we want to prove is false.
We then follow a sequence of logically valid steps until we reach a contradiction. Since the contradiction cannot be true, the original assumption must be false.
Example: There Are Infinitely Many Prime Numbers
Assume the statement is false.
Then there exists a largest prime number
Consider
Since
However, dividing
Therefore none of
But every integer greater than
This contradiction shows that our assumption was false.
Hence there are infinitely many prime numbers.
3. Proof by Counterexample
A universal statement claims that something is true for every element in a set.
To disprove such a statement, it is sufficient to find a single example for which the statement fails. Such an example is called a counterexample.
Example
Consider the claim:
for all ,
where
For
and
Therefore
This single counterexample proves that the statement
is false.
Final Thoughts
These three proof techniques appear throughout mathematics and computer science.
| Technique | Typical Use |
|---|---|
| Proof by Induction | Recursive structures, loops, recurrence relations |
| Proof by Contradiction | Existence proofs and impossibility results |
| Proof by Counterexample | Disproving universal statements |
Mastering these techniques provides a strong foundation for studying algorithms, data structures, discrete mathematics, machine learning, and theoretical computer science.
References
- Data Structures and Algorithm Analysis in C++ (Third Edition) by Mark Allen Weiss (Chapter 1)