Direct Proof and Proof by Contrapositive
A direct proof starts from what you're given and walks forward, one justified step at a time, until it reaches what you want. When the starting point gives you nothing to grab onto, prove the contrapositive instead: it's the same statement, just approached from the other end.
What the symbols mean
- An integer
The number the statement is about.
- A witness
Another integer that shows n has the right form.
Explanation
A direct proof is simply an argument that starts from what you're told and walks forward, one step at a time, to what you want to show, where every step is something nobody could argue with. It's called "direct" because it goes straight from the hypothesis to the conclusion, with no detours or tricks. This is how you convince someone (or yourself) that a statement is true for every case, not just the ones you tried. The definitions above look formal, but they just say (an even number is two times some whole number ) and (an odd number is one more than that). That little trick of naming the is most of the work in this lesson.
In the logic unit you saw that a theorem usually has the shape "if , then ." Now you get to prove them. To prove "if , then " directly:
- Assume is true.
- Unpack the definitions in into equations you can work with.
- Reason, one justified step at a time, until you reach .
For example, to prove that the sum of two odd numbers is even, write them as and . Notice the two different letters: the numbers needn't be the same, so they each get their own. Their sum is , which is times an integer: even.
Sometimes the hypothesis gives you nothing to work with. "If is even, then is even" is hard to attack directly, because knowing doesn't easily tell you about . So what can we do? Remember that the contrapositive always means the same thing as the original. Here it's "if is odd, then is odd," and that one is easy, since you can write and square it. Proving the contrapositive proves the original.
A good proof states what is assumed, names every variable, and justifies each step.
A common mistake. It's tempting to think that checking a bunch of examples proves a statement, because if it worked for 1, 3, 5, 7 and 99, surely it always works. It doesn't prove anything: a statement about all integers needs an argument that works for every one of them at once, and there are famous patterns that hold for millions of cases before they break.
See it
Worked examples
Prove: if is odd, then is odd.
- 1
Assume is odd, so by definition for some integer .
Prove: if is even, then is even.
- 1
Knowing doesn't lead anywhere directly, so prove the contrapositive: if is not even (odd), then is not even (odd).
Practice
Type your answer and check it. Solve them all to complete the lesson.
If , then with . What is when ?
To prove "if is odd, then is odd" by contrapositive, what do you assume?
Prove that the sum of two even integers is even.
A hashing routine relies on a fact: the square of any odd number leaves remainder 1 when divided by 8. Check it for 2025: what is the remainder when is divided by 8?
What is the converse of "if is even, then is even," and is it true?
The hardest one here. Get it, and you've got this lesson.
Find the largest integer that divides for every integer .
Where it's used
Correctness arguments for algorithms and the machine-checked proofs used to verify chips and operating systems are built from exactly these step-by-step deductions.