IMO 1960 Q1 #
Determine all three-digit numbers $N$ having the property that $N$ is divisible by 11, and $\dfrac{N}{11}$ is equal to the sum of the squares of the digits of $N$.
Since Lean doesn't have a way to directly express problem statements of the form "Determine all X satisfying Y", we express two predicates where proving that one implies the other is equivalent to solving the problem. A human solver also has to discover the second predicate.
The strategy here is roughly brute force, checking the possible multiples of 11.
Equations
- Imo1960Q1.sumOfSquares L = (List.map (fun (x : ℕ) => x * x) L).sum
Instances For
Equations
- Imo1960Q1.ProblemPredicate n = ((Nat.digits 10 n).length = 3 ∧ 11 ∣ n ∧ n / 11 = Imo1960Q1.sumOfSquares (Nat.digits 10 n))
Instances For
Equations
- Imo1960Q1.SolutionPredicate n = (n = 550 ∨ n = 803)
Instances For
Equations
- Imo1960Q1.SearchUpTo c n = (n = c * 11 ∧ ∀ m < n, Imo1960Q1.ProblemPredicate m → Imo1960Q1.SolutionPredicate m)
Instances For
theorem
Imo1960Q1.searchUpTo_step
{c n : ℕ}
(H : Imo1960Q1.SearchUpTo c n)
{c' n' : ℕ}
(ec : c + 1 = c')
(en : n + 11 = n')
{l : List ℕ}
(el : Nat.digits 10 n = l)
(H' : c = Imo1960Q1.sumOfSquares l → c = 50 ∨ c = 73)
:
Imo1960Q1.SearchUpTo c' n'
theorem
Imo1960Q1.searchUpTo_end
{c : ℕ}
(H : Imo1960Q1.SearchUpTo c 1001)
{n : ℕ}
(ppn : Imo1960Q1.ProblemPredicate n)
: