print(all((n**3 - n) % 6 == 0 for n in range(1, 11)))True
ISE Block 1.2 Maths · Week 1
math.sqrt(2) * math.sqrt(2) == 2 True or False?| Statement | Its negation | Careful |
|---|---|---|
| \(x > 0\) | \(x \leq 0\) | not \(x < 0\): at \(x = 0\), both \(x > 0\) and \(x < 0\) are false |
| \(n \geq 5\) | \(n < 5\) | the boundary 5 changes side |
| there is no largest \(n\) | some \(n\) is largest | |
| integer \(n\) is even | \(n\) is odd | uses the fact below |
Start from an implication \(P \IMPLIES Q\), “if \(P\), then \(Q\)”.
| Name | Statement | Read aloud |
|---|---|---|
| converse | \(Q \IMPLIES P\) | if \(Q\), then \(P\) |
| contrapositive | \(\NOT(Q) \IMPLIES \NOT(P)\) | if not \(Q\), then not \(P\) |
\(P\): it rains. \(Q\): I bring an umbrella.
| umbrella | no umbrella | |
|---|---|---|
| rain | nothing broken | \(P \IMPLIES Q\) and \(\NOT(Q) \IMPLIES \NOT(P)\) broken |
| no rain | \(Q \IMPLIES P\) broken | nothing broken |
TRY: “if \(n\) is a multiple of 4, then \(n\) is even”. Write the converse and the contrapositive. Which must be true?
Theorem: for every real \(r \geq 0\), if \(r\) is irrational, then \(\sqrt{r}\) is irrational.
Proof (we prove the contrapositive: if \(\sqrt{r}\) is rational, then \(r\) is rational). Let \(r \geq 0\) be real.
\[ P \IFF Q \]
TRY: for a real number \(x\), which is true?
Proof. Let \(n\) be an integer. We prove each direction.
Claim: for every integer \(n\), \(n^2 + n\) is even.
Proof (by cases). Let \(n\) be an integer. It is even or odd (the fact), so two cases cover it.
Claim: for every integer \(n\), \(n^2 \geq n\).
“Proof” (by cases).
| \(n\) | \(\ldots\) | \(-2\) | \(-1\) | \(0\) | \(1\) | \(2\) | \(\ldots\) |
|---|---|---|---|---|---|---|---|
| case | \(n < 0\) | \(n < 0\) | \(n < 0\) | none | \(n > 0\) | \(n > 0\) | \(n > 0\) |
True alone shows neitherTheorem: \(\sqrt{2}\) is irrational.
Proof. We argue by contradiction. Suppose \(\sqrt{2}\) is rational.
| Maths | In Python | The difference |
|---|---|---|
| Integers \(\Int\) | int |
Python integers can grow as memory allows; many languages use fixed-width integers that can overflow |
| Real numbers \(\Real\) | float |
A finite-precision float stores only certain values, not an arbitrary real number |
inf and nan is \(m \cdot 2^e\) for integers \(m\) and \(e\) (IEEE Standard for Floating-Point Arithmetic, n.d.), so it is rational
Fraction(x) is that exact valuex * x rounds the mathematical product to a float. That result may be 2.0==: compares stored numeric values without a tolerancex * x == 2 and Fraction(x) ** 2 == 2 give the same answer?True
False
11.0; for 2 it misses 2.0
False for every floatFalse too, but that rests on a known fact not proved here: \(\sqrt{11}\) is irrational
== on floats: compares stored values; it does not reverse rounding2.0.== compares stored results exactly; it does not undo earlier roundingThree “proofs” of true claims. For each: which check fails?
| Flaw | Check that fails | |
|---|---|---|
| 1 | circular reasoning: “odd plus odd is even” is the claim, used as a step | every step justified |
| 2 | converse assumed: it proves “\(n\) even implies \(n^2\) even” | right claim (clue: “\(n^2\) even” is never used) |
| 3 | a missing case: \(n\) odd is never treated | cases cover everything |
Prove: there is no largest natural number.
Proof. We argue by contradiction. Suppose there is a largest natural number \(m\). Then \(m + 1\) is a natural number, since adding 1 to a natural number gives a natural number, and \(m + 1 > m\), which contradicts \(m\) being the largest. So there is no largest natural number. \(\qedmark\)
| Method | Start by | Tends to fit |
|---|---|---|
| direct | assuming \(P\) | unpacking \(P\) leads towards \(Q\) |
| contrapositive | assuming \(\NOT(Q)\) | \(\NOT(Q)\) gives more to unpack than \(P\) |
| both directions | proving each implication | an “if and only if” |
| cases | splitting the possibilities | the objects split naturally: even or odd, sign |
| contradiction | supposing the claim false | “there is no …”, “never” |
For an integer \(n\), which method would you try first, and why?
“For every integer \(n\): if \(n^2\) is odd, then \(n\) is odd.”
You should now be able to: