Propositions and Proofs
A proof is a chain of logical steps that shows a statement is true, starting from facts everyone accepts. Programmers meet the same idea when they argue that a function always returns the right answer, not just on the inputs they tested. This lesson defines the basic vocabulary: propositions, predicates, axioms and proofs.
Propositions
A proposition is a statement that is either true or false, and not both.
| Statement | Proposition? |
|---|---|
| yes, true | |
| "Every even number greater than 2 is a sum of two primes" | yes (Goldbach's conjecture), truth value unknown |
| no: its truth depends on (it is a predicate) | |
| "Close the door." | no: a command is neither true nor false |
A predicate is a statement with variables that becomes a proposition once the variables get values. Write for " is prime". Then is true and is false. Many important propositions have the form "for every , ", written .
Why checking examples is not enough
A predicate can hold for a long run of values and still fail. Euler's polynomial is prime for . An even more striking case: the equation was conjectured by Euler to have no positive integer solutions, and the smallest counterexample has . Some false claims fail only for numbers far beyond what any computer can test. That is why mathematicians want proofs.
def first_failure(pred, limit):
for n in range(limit):
if not pred(n):
return n
return None
is_prime = lambda m: m > 1 and all(m % d for d in range(2, int(m ** 0.5) + 1))
print("n^2 + n + 41 first fails at n =", first_failure(lambda n: is_prime(n * n + n + 41), 100))
print("2^n > n^2 first fails at n =", first_failure(lambda n: 2 ** n > n * n, 100))
print("2^n > n^2 holds for 5..99:", all(2 ** n > n * n for n in range(5, 100)))n^2 + n + 41 first fails at n = 40
2^n > n^2 first fails at n = 2
2^n > n^2 holds for 5..99: True
The second predicate fails for small (at , is false; and fail too) but holds from on. Proving "for all " needs induction.
Axioms and the axiomatic method
A proof has to start somewhere. Axioms are propositions accepted without proof, such as the rules of integer arithmetic. From axioms we derive new true statements using inference rules. The most important rule is modus ponens: from and , conclude .
Results have different names depending on their role:
| Name | Meaning |
|---|---|
| theorem | an important proposition that has been proved |
| lemma | a preliminary result used to prove a theorem |
| corollary | a result that follows quickly from a theorem |
| conjecture | a statement believed true but not yet proved |
Anatomy of a good proof
Here is a short complete proof.
Theorem. The sum of two odd integers is even.
Proof. Let and be odd. By definition of odd, and for some integers . Then
which is 2 times an integer, so is even.
Notice the habits: state what you assume, use the definitions (an odd number is ), name new variables, and end by saying exactly what was shown. A good proof is clear enough that a reader can check each step.
In software
Formal verification tools (Coq, Lean, Isabelle, TLA+, Dafny) check proofs by computer. They are used for compilers (CompCert), operating system kernels (seL4) and cloud infrastructure, where tests alone cannot cover every input. Even without such tools, writing down why code is correct is the habit that finds bugs before users do. See Proving Programs Correct with Invariants.
Exercises
Exercise 1: Proposition or not?
Which are propositions? (a) , (b) , (c) "Every prime is odd", (d) "Is 9 prime?"
Answer
(a) and (c) are propositions ((a) true, (c) false); (b) is a predicate; (d) is a question.
Solution
(a) has a definite truth value: true. (c) is a definite claim, false because 2 is prime and even. (b) depends on , so it is a predicate ; it becomes a proposition once is fixed. (d) is a question, which is neither true nor false.
Exercise 2: Product of odd numbers
Prove that the product of two odd integers is odd.
Answer
, which is odd.
Solution
Let and with integers . Then
and is an integer, so has the form : it is odd.
Exercise 3: Find the counterexample
The claim " is prime whenever is a power of 2" holds for . Check .
Answer
, so the claim is false.
Solution
These are the Fermat numbers; Fermat himself conjectured they are all prime, and Euler found the factor 641.
from sympy import factorint
for k in range(6):
n = 2 ** k
print(n, 2 ** n + 1, factorint(2 ** n + 1))1 3 {3: 1}
2 5 {5: 1}
4 17 {17: 1}
8 257 {257: 1}
16 65537 {65537: 1}
32 4294967297 {641: 1, 6700417: 1}
Test yourself
Which of these is a predicate rather than a proposition?
- is prime
- There are infinitely many primes
From and we may conclude . What is this rule called?
- Contradiction
- Modus ponens
- Induction
- Contrapositive
A claim holds for the first natural numbers. Which is true?
- It is proved for all natural numbers
- It may still fail for a larger number
- It must be an axiom
- It is a corollary