8
$\begingroup$

The problem 1 of the 2025 IMO is the following:

A line in the plane is called sunny if it is not parallel to any of the x-axis, the y-axis, and the line $x + y = 0$.
Let $n ⩾ 3$ be a given integer.
Determine all nonnegative integers $k$ such that there exist $n$ distinct lines in the plane satisfying both of the following:

  • for all positive integers $a$ and $b$ with $a + b ⩽ n + 1$, the point $(a, b)$ is on at least one of the lines; and
  • exactly $k$ of the $n$ lines are sunny.

Warning: this post will spoil the solution.

I am interested here in the possibility of solving this problem in a fully automated way using deterministic solvers of some sort.

For specific values of $n$, I was able to solve the problem using the Satisfiability Modulo Theories tool z3 and the following program:

from z3 import *

def solve_sunny_lines(n):
    s = Solver()
    
    lines = []

    is_vertical = [Bool(f"v_{i}") for i in range(n)]
    m = [Real(f"m_{i}") for i in range(n)]
    c = [Real(f"c_{i}") for i in range(n)]
    d = [Real(f"d_{i}") for i in range(n)]
    is_sunny = [Bool(f"sunny_{i}") for i in range(n)]

    for i in range(n):
        s.add(
            is_sunny[i] ==
            And(
                Not(is_vertical[i]),
                m[i] != 0,
                m[i] != -1
            )
        )

    points = [(a, b) for a in range(1, n+1) for b in range(1, n+1) if a + b <= n + 1]

    for (a, b) in points:
        on_some_line = []
        for i in range(n):
            vertical_case = And(is_vertical[i], a == d[i])
            non_vertical_case = And(Not(is_vertical[i]), b == m[i]*a + c[i])
            on_some_line.append(Or(vertical_case, non_vertical_case))
        s.add(Or(*on_some_line))

    possible_k = []
    for k in range(n+1):
        s_k = Solver()
        s_k.add(s.assertions())
        s_k.add(Sum([If(is_sunny[i], 1, 0) for i in range(n)]) == k)
        if s_k.check() == sat:
            possible_k.append(k)

    return possible_k

Which gives me:

>>> solve_sunny_lines(3)
[0, 1, 3]
>>> solve_sunny_lines(4)
[0, 1, 3]
>>> solve_sunny_lines(5)
[0, 1, 3]
>>> solve_sunny_lines(6)
[0, 1, 3]

This is a good hint for conjecturing the general solution $k \in \{0, 1, 3\}$. This conjecture can be proven by induction, e.g. using geometrical arguments (there are several solutions discussed at various places, see here for instance).

Question: is there a way to fully automate the resolution of the general case using a deterministic software tool (z3 or other)?

Naïvely, the best I could think of is:

  • Solving specific cases with some SMT tool like detailed above.
  • Formulating a conjecture in the form $\forall n \geq 3, (P(k, n) \iff k = 0 \lor k = 1 \lor k = 3)$ (*) where $P$ is a predicate (which I suppose might be) definable in Presburger arithmetic (since the problem involves natural numbers and no multiplication, but as mentioned in comment there are other difficulties...)
  • Since Presburger arithmetic is complete and decidable, we could (theoretically) algorithmically show (*) to be true.
$\endgroup$
2
  • 8
    $\begingroup$ I doubt you can formulate this in Presburger arithmetic — lines are a form of multiplications, and the question also contains a set of lines and counting some of the lines, both of which can't really be expressed in Presburger arithmetic $\endgroup$ Commented Aug 2 at 12:13
  • $\begingroup$ @DanielWeber right, the more I look into it the less I am confident about it... which means I have no idea how to automate the general case. $\endgroup$ Commented Aug 2 at 12:22

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.