When investigating geometric optimization problems with the help of artificial intelligence, one of the questions that interests me is how to verify the validity of the solutions we find.
Consider two unit squares placed side by side. In certain configurations, it can be difficult to tell by looking at them whether they share an edge or occupy part of the same region of the plane. Although the difference may seem small, it can determine whether a solution is valid.
In this first article in the series on artificial intelligence and mathematics, I propose examining this question through an example with just two squares.
The difference between contact and overlap
Consider two squares of side length 1 inside a square region of side length 3. Both have edges parallel to the coordinate axes.
The first square, which we will call A, occupies the interval from 0 to 1 on both the horizontal and vertical axes.
In the first configuration, square B occupies the interval from 1 to 2 on the horizontal axis and from 0 to 1 on the vertical axis. The two squares share an edge, but the area of their intersection is zero.
In the second configuration, we move B horizontally by 0.02 units toward A. The squares now share a region with positive area.
The demonstration below lets you explore what happens when we change the position of B.
Explore the intersection
The squares remain aligned with the axes. The vertical interval is unchanged.
Calculating the intersection
Since the edges of the squares are parallel to the axes, we can calculate the intersection area from the intervals they occupy in each dimension.
For two intervals, the length of the intersection is the difference between the smaller right endpoint and the larger left endpoint, with a lower bound of zero.
Applying this reasoning to both axes, we obtain:
w = max(0, min(xAmax, xBmax) - max(xAmin, xBmin))
h = max(0, min(yAmax, yBmax) - max(yAmin, yBmin))
The intersection area is the product of these two lengths:
Area = w × h
In the overlapping case, the relevant horizontal coordinates are 0.98 and 1. Therefore:
w = 1 - 0.98 = 0.02
Since the squares occupy the same interval on the vertical axis, we have:
h = 1
Consequently:
Area = 0.02 × 1 = 0.02
The calculation shows that the squares share a region whose area is 2% of the area of each square.
Area as a function of displacement
The squares remain aligned with the axes. The vertical interval is unchanged.
In a packing problem that permits contact between edges but prohibits overlap, the first configuration is valid and the second is not. Both satisfy the boundaries of the region containing them, but only the first satisfies the condition of no overlap.
To verify this example computationally, we can use rational arithmetic. By representing 0.98 as the fraction 49/50, we obtain the exact intersection area without relying on floating-point approximations.
From geometry to optimization
Square packing has been studied in mathematics for decades. One formulation consists of determining the smallest square that can contain a given number of unit squares, allowing rotations but prohibiting overlap.
As the number of squares increases, so does the number of geometric relationships that must be checked. When we allow rotations, the calculation based directly on intervals along the axes is no longer sufficient to determine the intersection area between the squares.
This is where artificial intelligence can contribute to the investigation. AI models can help formulate hypotheses and develop search algorithms, while mathematical methods allow us to evaluate the configurations we find.
The example in this article is not a mathematical discovery. I chose a simple configuration to demonstrate a principle I consider fundamental to the engineering of AI systems for mathematics: the search for a solution must be accompanied by a method for verifying its validity.
In the next articles, I intend to explore how rotations, geometric constraints and optimization algorithms make this problem progressively more interesting.
Reference
Friedman, E. Packing Unit Squares in Squares: A Survey and New Results. The Electronic Journal of Combinatorics, Dynamic Survey DS7. 1998, revised in 2009.
