54

Warning: I am only an amateur in the foundations of mathematics.

My understanding of this Wikipedia page about Tarski's axiomatization of plane geometry (and especially the discussion about decidability) is that "plane geometry is decidable".

The 2019 International Maths Olympiad happened recently, and there were two plane geometry questions in it (problems 2 and 6). Their solutions look really intimidating! However even as a student I felt that one should be able to solve these questions, in theory, by just "writing down coordinates of everything and doing the algebra". Tarski's work, which I will freely confess that I do not understand fully, might even vindicate my view.

The question: Is there an algorithm for solving these kinds of questions, or have I misunderstood? If so, is this algorithm actually feasible to run in practice nowadays (on a computer say) for IMO-level problems? In other words -- are there computer programs which will take as input a planar geometry question of "olympiad level" (for example problems 2 and 6 in this year's IMO) and actually output a solution?

Currently I am not too bothered about whether the solution is human-readable -- it could just be a formal proof in some kind of type theory or something, but the output would be some object that some expert could coherently argue was a solution of some sort.

The reason I'm asking is that I was talking to some computer scientists about various goals in the long-term project of getting computers to do mathematics "better than humans", and having a computer program which could solve IMO problems by itself was a suggested milestone.

Kevin Buzzard
  • 40,559
  • 12
    Essentially all the usual Euclidean geometry questions could be reformulated as first-order sentences in the language of Tarski's geometry. And thus be solved by a decision algorithm for this theory. The exceptions are problems that talk about polygons with arbitrary amount of vertices rather than configurations that could be described by fixed amount of points. The decision problem is known to be NExpTime-hard. However, it doesn't mean that it is impossible to make algorithm that in practice solves some reasonable class of problems, although I am not aware of any practical algorithms here. – Fedor Pakhomov Aug 03 '19 at 17:45
  • 7
    My question is whether there is currently a feasible algorithm (and also whether I had misunderstood Tarski's work). I am more than happy to be told my question is not on topic, and would not be offended if it gets bumped to MSE or closed. I am looking for answers, I am not looking to cause trouble. I completely take your point about a 1 rep user. I built my rep up here talking about number theory but I am now interested in other things which are definitely of more marginal interest to the community here. – Kevin Buzzard Aug 03 '19 at 18:13
  • 2
    @yol I remember when I was younger trying to convince myself that the coordinate approach could be turned into an algorithm, but I had problems with choosing signs of square roots. I am wondering whether Tarski solved these issue and my impression from the comments is that this is indeed what he did. – Kevin Buzzard Aug 03 '19 at 18:16
  • 2
    In particular although it might be true that a statement about "the point where these lines intersect" is a statement about polynomials, a statement about "the point where these circles intersect and which has a property distinguishing it from the other point" is a statement about a certain square root, and squaring up to make it a statement about polynomials is where I get confused about whether this really is as simple as Groebner bases. – Kevin Buzzard Aug 03 '19 at 18:19
  • 5
    Tarski's method gives a way of translating a problem in Elementary Plane Geometry (in the technical sense made precise by his axioms for geometry) into a problem about real-closed fields, and the first-order theory of real-closed field is decidable, using the Tarski-Seidenberg theorem which allows for quantifier elimination. (Presumably the statements you have in mind about properties picking out one of the two points of circle intersections are statements expressible in terms of field ordering.) But algorithms for eliminating quantifiers have complexity unbounded by stacks of exponentials. – Todd Trimble Aug 04 '19 at 00:13
  • 14
    @KevinBuzzard Just de-lurking to say that I, for one, would be more than happy to see you ask questions like these and get answers. I can't see the comments you're responding to but I hope that their deletion indicates that the authors thought twice – Yemon Choi Aug 04 '19 at 00:15
  • 3
    I recall a chapter on "Automatic Geometric Theorem Proving" from the book Ideals, Varieties, and Algorithms by Cox, Little, and O'Shea. My assumption had always been that this precisely addressed the question you are now asking (quite frankly I have never bothered to actually read it, so I can't be positive). But since you are probably aware of this reference yourself, maybe I am mistaken. – R.P. Aug 04 '19 at 01:01
  • 2
    Gröbner bases do not suffice for real-closed fields, and this is already apparent from trying to eliminate the quantifier from $\exists y. x^2 + y^2 = 1$. – Robert Furber Aug 04 '19 at 02:08
  • 12
    While the time complexity of Tarski's algorithm was not bounded by any stack of exponentials, the modern way of eliminating quantifiers for real-closed fields is cylindrical algebraic decomposition, which is only double exponential. Mathematica has an implementation of this. Apparently, there is also an algorithm for eliminating existential quantifiers (projecting a semialgebraic set) that only takes exponential time, but this is not available in Mathematica or any other major CAS, and the only implementation I could find of it hit a bug on every nontrivial example I tried. – Robert Furber Aug 04 '19 at 02:12
  • 3
    Reference: Algorithms in Real Algebraic Geometry by Basu, Pollack and Roy. – Robert Furber Aug 04 '19 at 02:25
  • 5
    I am a little out of date - there is now something called QEPCAD that you can use in Sage, but I haven't tried it yet. – Robert Furber Aug 04 '19 at 02:30
  • 1
    @KevinBuzzard: you can use inequalities as well as equalities, I think that should clear up some confusion. And both Olympiad problems are expressible in the language of a real-closed field so they're solvable by the standard algorithms, in principle. Mathemtica should certainly be able to deal with the second problem. I did not think about the sixth problem, – Andrej Bauer Aug 06 '19 at 09:55
  • 2
    @AndrejBauer I have no experience with getting mathematica to do stuff like this. How would one do Q2 in mathematica? – Kevin Buzzard Aug 06 '19 at 17:47
  • 3
    Albeit not exactly solving geometry problems, it may interest you. Version 12 of Mathematica introduced a new function named FindGeometricConjectures for reasoning about problems in plane geometry. It was used to rediscover some classic theorems of plane geometry: https://community.wolfram.com/groups/-/m/t/1664846 – Tadashi Aug 06 '19 at 18:08
  • What if the algebraic reduction requires to solve a polynomial equation which is not solvable by radicals (for example if the problem involves the fifth of an angle)? – Sebastien Palcoux Aug 06 '19 at 21:33
  • 3
    Just because we can't write down explicit solutions to a polynomial equation using +-*/ and n'th roots doesn't mean that we can't prove things about the solutions. – Kevin Buzzard Aug 06 '19 at 22:19
  • 1
    @SebastienPalcoux The fact that something can't be expressed using one very restricted method (rational functions of radicals) doesn't mean that it is uncomputable. For instance, given a polynomial with rational coefficients, there is an algorithm that will give you a finite set of disjoint rational intervals containing one root each and whose union contains all the roots (see algorithm 10.4 of the book I mentioned earlier). – Robert Furber Aug 07 '19 at 09:18
  • 1
    I was thinking about this recently (in general, not just geometry). E.g., how distant is the goal of have a theorem prover that could get a medal in the IMO? I undertook an exercise to formalise a proof of an old problem to get some sense of what might be involved. It was a lot more work than I expected and left me thinking we have a long way to go. https://github.com/ocfnash/imo-coq – Oliver Nash Aug 07 '19 at 09:55
  • 2
    https://twitter.com/XenaProject/status/1156999302969008136 for a conversation talking about doing some of the other questions of this year's IMO in a theorem prover (Lean and Isabelle/HOL) – Kevin Buzzard Aug 07 '19 at 10:05
  • @KevinBuzzard Cool! Thank you for the link. Maybe I'll try to find someone with a Twitter account to chime in on my behalf. – Oliver Nash Aug 07 '19 at 11:14

2 Answers2

45

Arguably, the so-called "area method" of Chou, Gao and Zhang represents the state of the art in the field of machine proofs of Olympiad-style geometry problems. Their book Machine Proofs in Geometry features over 400 theorems proved by their computer program. Many of the proofs are human-readable, or nearly so.

The area method is less powerful than Tarski–Seidenberg quantifier elimination in the sense that not every statement provable by the latter is provable by the area method, but the area method has the advantage of staying closer to the "synthetic" nature of (the vast majority of) Olympiad problems.


EDIT (February 2022): OpenAI has announced some success with solving (some) formal math olympiad problems. They did not restrict themselves to geometry problems.


EDIT (January 2024): DeepMind has published Solving olympiad geometry without human demonstrations in Nature. On geometry problems, they claim performance close to that of an Olympiad gold medalist, though I would add some caveats. Their "AlphaGeometry" program does not have natural language processing capability, and is not parsing the Olympiad problem in the natural-language form that a human contestant would be presented with. On 30 selected problems, AlphaGeometry with pre-training and fine-tuning solves 25. They compare this with Wu's method, which they say solves 10 problems. There is no direct comparison with the area method of Chou, Gao, and Zhang, although the line "DD+AR+human-designed heuristics" in Table 1 seems to make some use of the area method, and reportedly solves 18 problems.

Timothy Chow
  • 78,129
  • Ah this is great! From 1993 though? Does a link to the prover exist? The suggestion at http://mathforum.org/kb/message.jspa?messageID=1095436 is also dead. http://www.cs.wichita.edu/~ye/ looks promising but I don't know about whether the prover can be run on your own problems. PS interesting last para in the foreward (p4 of the pdf). – Kevin Buzzard Aug 06 '19 at 17:43
  • 1
    Patrick Massot pointed me to https://dpt-info.u-strasbg.fr/~narboux/area_method.html ! – Kevin Buzzard Aug 06 '19 at 19:30
  • @KevinBuzzard : Not sure if you tried clicking on the "area method" hyperlink that Matt F. added? – Timothy Chow Aug 06 '19 at 20:21
  • 1
    There are some doubts about the axiom system behind DeepMind on the issue tracker. I am also worried, based on the description (I haven't dug into the code) about how Gaussian elimination should work with full angles (= oriented angles modulo 180°), seeing that they live in a $\mathbb{Z}$-module with torsion (i.e., $2\alpha = 2\beta$ does not entail $\alpha = \beta$). But the idea of combining AI guesswork with a symbolic proof checker is a good one and I would love to see this become a finished product. – darij grinberg Jan 21 '24 at 01:09
8

There is a pretty general method (although not always sufficient) to apply your intuition that one could translate everything into algebra and then solve it there.

Essentially, you introduce coordinates for your points, encode all your hypothesis as polynomial equalities between coordinates, do the same for the thesis, and then try to prove that the thesis is in the ideal generated by the hypotheses (or even its radical) using Gröbner bases. Of course, the issue here is that the classical Nullstellensatz does not hold for $\mathbb{R}$, so the thesis may hold even if it does not lie in the radical of the ideal generated by the hypotheses. Using the real Nullstellensatz, it may be possible to adapt the technique, but I did not give it much thought.

To make a concrete example, say you want to prove Heron's formula. Let $T$ be a triangle with side length $a, b, c$ and area $s$. You choose coordinates for the vertices of $T$ so that they are $(0, 0), (a, 0), (x, y)$ (this particular nice choice of coordinates is not necessary on a computer but simplifies the discussion for humans). Then the hypotheses are:

  • $b^2 = x^2 + y^2$
  • $c^2 = (a - x)^2 + y^2$
  • $2s = a y$.

The thesis is Heron's formula $16 s^2 = (a + b - c)(c + a - b)(b + c - a)(a + b + c)$.

What you do is consider the ideal $I \subset \mathbb{R}[a, b, c, x, y, s]$ generated by $b^2 - x^2 - y^2$, $c^2 - (a - x)^2 - y^2$ and $2s - ay$, and use Gröbner bases to check that $16 s^2 - (a + b - c)(c + a - b)(b + c - a)(a + b + c) \in \sqrt{I}$.

In fact, since the thesis does not involve $x, y$, one can compute $I \cap \mathbb{R}[a, b, c, s]$ - again using Gröbner bases - and discover that it is generated by the equation expressing Heron's formula.

EDIT

The above can actually be implemented very efficiently. I used rings, an efficient Scala library to perform polynomial computations, and the following

implicit val ring = MultivariateRing(Q, Array("a", "b", "c", "x", "y", "s"))
val h1 = ring("b^2 - x^2 - y^2")
val h2 = ring("c^2 - (a - x)^2 - y^2")
val h3 = ring("2 * s - a * y")
val t = ring("16 * s^2 - (a + b - c) * (c + a - b) * (b + c - a) * (a + b + c)")
val I = Ideal(ring, Seq(h1, h2, h3))
I.contains(t)

gave the answer true is about a second on my laptop.

Andrea Ferretti
  • 14,454
  • 13
  • 78
  • 111
  • Looks like there should be lot more identities. – Turbo Aug 07 '19 at 10:59
  • Did you do these calculations? Using which system? How long did they take? – Kevin Buzzard Aug 07 '19 at 11:30
  • 1
    I have a gut feeling that some olympiad problems will not be solvable in this way because they might involve assertions about only some roots. (a+b-c)(c+a-b)(b+c-a)(a+b+c) is a polynomial function of a^2, b^2 and c^2, so issues of sign do not show up. What about an analogous question where it's essential that b is chosen to be the positive square root, and where the claimed equation does not hold if the negative one is chosen? I think that's why Groebner bases are not sufficient here but I do not know a good toy example. – Kevin Buzzard Aug 07 '19 at 11:34
  • It is a classic example, so I did not perform the computation myself, but I may try later using https://github.com/PoslavskySV/rings . I will let you know how long it takes – Andrea Ferretti Aug 07 '19 at 12:06
  • @KevinBuzzard done, see my edit - in fact it was quicker and easier than I thought – Andrea Ferretti Aug 07 '19 at 12:26
  • I regularly ask the students to prove Héron's formula with Sage and it works well, resultants are sufficient. – François Brunault Aug 07 '19 at 12:26
  • 2
    For what it’s worth, this can also be done easily enough by hand. We have $2ax=a^2+b^2-c^2$, so $(2ab)^2=(2ax)^2+(2ay)^2=(a^2+b^2-c^2)^2+16s^2$, and the result follows by rearranging and factoring the differences of squares. –  Aug 07 '19 at 12:51
  • 1
    We need a better toy example. – Kevin Buzzard Aug 07 '19 at 18:03
  • 1
    Another easy one is Apollonius theorem: let ABC be a triangle right in A. The midpoints of the three sides and the foot of the altitude drawn from A to BC all lie on one circle. But again, it may be too easy... – Andrea Ferretti Aug 08 '19 at 12:15
  • @KevinBuzzard , Possibly if one is continuing in the same direction, maybe going with Brahmagupta's formula's next would make sense. – JoshuaZ Jan 21 '24 at 00:26