def p(n: int) -> int:
return n**2 + n + 41
print(all(is_prime(p(n)) for n in range(40)))
print(all(is_prime(p(n)) for n in range(41)))ISE Block 1.2 Maths · Week 1
\[ n^2 + n + 41 \]
For each: a proposition or not? If it is: true, false, or not known?
| Statement | Proposition? | Truth value | |
|---|---|---|---|
| 1 | 91 is prime | yes | false: \(91 = 7 \cdot 13\) |
| 2 | Is 91 prime? | no: a question | |
| 3 | \(x + 1 = 5\) | it depends on \(x\) | |
| 4 | Goldbach’s conjecture | yes | not known |
\[ p(n) \defeq n^2 + n + 41 \]
x = 5 binds a name, like a definition; it is not a propositionx == 5 asks a question: it gives True or Falserange(40) is \(0, 1, \ldots, 39\)\[ \text{for every } n \in \Nat,\ p(n) \text{ is prime} \]
all(...) is True exactly when every item is True
range(40), \(p(n)\) is prime”True
False
\[ \begin{aligned} p(40) &= 40^2 + 40 + 41 \\ &= 40 \cdot 41 + 41 \\ &= 41 \cdot 41 \end{aligned} \]
| \(x\) | the proposition | its truth value |
|---|---|---|
| 3 | \(3 + 1 = 5\) | false |
| 4 | \(4 + 1 = 5\) | true |
| 5 | \(5 + 1 = 5\) | false |
\[ \mathrm{Prime}(m) \defeq m \text{ is prime} \]
intboolis_prime(m) tests divisibility by integers \(d\) from 2 while \(d^2 \le m\)is_prime returns boolTrue True True False
any(...) is True exactly when at least one item is True: it is “for some”, as all(...) is “for every”Claim: for all integers \(m\) and \(n\), if \(m\) and \(n\) are even, then \(m + n\) is even.
Theorem: for all integers \(m\) and \(n\), if \(m\) and \(n\) are even, then \(m + n\) is even.
Proof (direct).
Theorem: for all integers \(m\) and \(n\), if \(m\) and \(n\) are odd, then \(m + n\) is even.
Theorem: for all integers \(m\) and \(n\), if \(m\) and \(n\) are odd, then \(m + n\) is even.
Hints, one at a time:
Theorem: for all integers \(m\) and \(n\), if \(m\) and \(n\) are odd, then \(m + n\) is even.
Proof (direct).
“The product of two odd integers is odd.”
You should now be able to:
[eoin@eoin.ai](mailto:eoin@eoin.ai) · [eoin.p.o.brien@ul.ie](mailto:eoin.p.o.brien@ul.ie)