The software can generate difficult geometry problems suitable for mathematical contests. The following is an automatically generated, drawn, and stated problem:
This repository contains the code developed for the master's thesis Automated Generation of Planar Geometry Olympiad Problems. For more information check out the following assets:
- Poster (prepared for the competition ACMSpy)
- Slides (used during the thesis defense)
- Thesis (for more examples like this one check out the appendix)
The system requires to have .NET 5.0 installed.
The application can be built via dotnet build run in the Source folder.
Automated tests can be run via dotnet test run in the Source folder.
All major logic is written from scratch, with heavy use of LINQ to objects.
The following helper libraries have also been used:
For tests, we used:
- NUnit - unit testing framework
- FluentAssertions - a cute way to write unit tests
This is the main module that runs the main algorithm. The application tries to read the settings from the file settings.json. The example settings are available here. As a start, you may copy this file to the folder with the executable. These settings are configured so that:
-
The input files are loaded from the input folder.
-
The output is written to the following subdirectories of the output folder:
- ReadableWithoutProofs - All found theorems that haven't been excluded.
- ReadableWithProofs - All found theorems, with reasons why some have been excluded.
- ReadableBestTheorems - The best theorems for each type, ordered by their ranking.
- JsonOutput - All found theorems that haven't been excluded in the JSON format.
- JsonBestTheorems - Same as ReadableBestTheorems, but in the JSON format.
The following constructions are supported in input files (and object introduction rules / inference rules / drawing rules...):
CircleWithCenterThroughPoint- takes two pointsA,Band outputs the circle with the centerAand a radiusABCircleWithDiameter- takes two pointsA,Band outputs the circle with a diameterAB.Circumcenter- takes three pointsA,B,Cand outputs the circumcenter of triangleABC.Circumcircle- takes three pointsA,B,Cand outputs the circumcircle of triangleABC.Excenter- takes three pointsA,B,Cand outputs theA-excenter of triangleABC.Excircle- takes three pointsA,B,Cand outputs theA-excircle of triangleABC.ExternalAngleBisector- takes three pointsA,B,Cand outputs the external angle bisector of angleBAC.Incenter- takes three pointsA,B,Cand outputs the incenter of triangleABC.Incircle- takes three pointsA,B,Cand outputs the incircle of triangleABC.InternalAngleBisector- takes three pointsA,B,Cand outputs the internal angle bisector of angleBAC.IntersectionOfLineAndLineFromPoints- takes four pointsA,B,C,Dand outputs the intersection point of linesABandCD.IntersectionOfLines- takes two lines and outputs their intersection points.IntersectionOfLinesFromPoints- takes a lineland two pointsA,Band outputs the intersection point of lineslandAB.IsoscelesTrapezoidPoint- takes three pointsA,B,Cand outputs such a pointDthatABCDis an isosceles trapezoid.LineFromPoints- takes two points and outputs the line passing through both of them.LineThroughCircumcenter- takes three pointsA,B,Cand outputs the line throughAand the circumcenter ofABC.Median- takes three pointsA,B,Cand outputs theA-median of triangleABC.Midline- takes three pointsA,B,Cand outputs theA-midline of triangleABC.Midpoint- takes two pointsA,Band output the midpoint of segmentAB.MidpointOfArc- takes three pointsA,B,Cand outputs the midpoint of arcBAC.MidpointOfOppositeArc- takes three pointsA,B,Cand outputs the midpoint of arcBACnot containingA.NinePointCircle- takes three pointsA,B,Cand outputs the Nine-Point circle of triangleABC.OppositePointOnCircumcircle- takes three pointsA,B,Cand outputs such a pointDthatADis a diameter of the circumcircle ofABC.Orthocenter- takes three pointsA,B,Cand outputs the orthocenter of triangleABC.ParallelLine- takes a pointAand a lineland outputs the line throughAparallel tol.ParallelLineToLineFromPoints- takes three pointsA,B,Cand outputs the line throughAparallel toBC.ParallelogramPoint- takes three pointsA,B,Cand outputs such a pointDthatABDCis a parallelogram.PerpendicularBisector- takes two pointsA,Band outputs the perpendicular bisector of segmentAB.PerpendicularLine- takes a pointPand a lineland outputs the line throughPperpendicular tol.PerpendicularLineAtPointOfLine- takes two pointsA,Band outputs the line throughAperpendicular toAB.PerpendicularLineToLineFromPoints- takes three pointsA,B,Cand outputs the perpendicular line throughAtoBC.PerpendicularProjection- takes a pointPand a lineland outputs the projection ofPontol.PerpendicularProjectionOnLineFromPoints- takes three pointsA,B,Cand outputs the projection ofAontoBC.PointReflection- takes two pointsA,Band outputs the reflection ofAinB.ReflectionInLine- takes a lineland a pointPand outputs the reflection ofAinl.ReflectionInLineFromPoints- takes three pointsA,B,Cand outputs the reflection ofAin lineBC.SecondIntersectionOfCircleAndLineFromPoints- takes four pointsA,C,C,Dand outputs the second intersection point of lineABand the circumcircle ofACD.SecondIntersectionOfTwoCircumcircles- takes five pointsA,B,C,D,Eand outputs the second intersection point of the circumcirclesABCandADE.TangentLine- takes three pointsA,B,Cand outputs the tangent line to the circumcircle ofABCatA.
The used inference rules can be found here. They use constructions described here.
The used object introduction rules can be found here. They use constructions described here.
Provides visualization of the results produced by Main Launcher via generating EPS figures using MetaPost.
- MikTeX (other distributions haven't been tested, but they will probably work too)
- OPmac, used for quick font selection while printing problem texts
To preview generated results, I personally use
- SumatraPDF
- Ghostscript (this is required by Sumatra and does the actual rendering)
The application tries to read the settings from the file settings.json. The example settings are available here.
After running, you are requested to provide a path to a JSON theorem file. These files are produced by the Main Launcher. In our examples, the files from the folders JsonOutput and JsonBestTheorems. After selecting the theorems to be drawn, the program will generate eps files in the folder with the executable.
Note the following folder, which contains all written MetaPost macros and custom drawing rules.
-
In the settings, set
PostcompilationCommandtofile.bat -
In the folder with the executable create a file
file.batwith the following content:@ECHO OFF SET /A starting_index = %1 SET /A number_of_files = %2 SET /A maximal_index = %starting_index% + %number_of_files% - 1 FOR /L %%i IN (%starting_index% 1 %maximal_index%) DO "{SumatraPath}" "figures.%%i" EXIT 0
{SumatraPath} should be replaced with the path to the SumatraPDF executable. The usual location on Windows is C:\Program Files\SumatraPDF\SumatraPDF.exe. This will ensure that drawn figures are automatically opened for previewing.
If you want to review the capabilities of the theorem prover, then run this test. The main method requires two arguments:
- The path to the folder with inference rules.
- The path to the folder with object introduction rules.
The default values that should work after cloning can be found in launchSettings.json.
The following modules were used to prepare the large-scale experiments described in the thesis.
- Configuration Generation Launcher - this module was used to test the counts of generated configurations for certain input files (and memory usage). It can be used similarly as the Main Launcher, with the default settings available here, which needs to be copied to the folder with the executable. The output is not saved, only printed into the console.
- Input Generation Launcher - this module generated input files. Running it would generate around 4500 small files, totaling 4MB.
- Output Merging Launcher - this module merged the final result. The
mainmethod requires one argument, the path to the folder with JSON outputs (the folder is scanned recursively).
For more information, you can contact me via email.