FlagAlgebraToolbox: Flag Algebra Computations in SageMath
Levente Bodnár
TL;DR
This paper presents FlagAlgebraToolbox, a SageMath extension that automates flag algebra computations across graph, digraph, and hypergraph theories. It provides high-level APIs for constructing theories, generating flags, solving SDP-based extremal problems, and rounding results to exact certificates, enabling rigorous proofs (e.g., Mantel's bound $1/2$). Through worked examples—the Mantel bound, induced-density in $3$-graphs, and the Turán density of the tight $5$-cycle minus one edge—the paper demonstrates practical workflows and advanced constructions such as blow-ups and partitioned theories. The tool supports reproducibility and extensibility for extremal combinatorics research on Linux, with certificate verification and explicit versioning via a commit hash.
Abstract
We introduce FlagAlgebraToolbox, an extension of SageMath capable of automating flag algebra calculations and optimizations. FlagAlgebraToolbox has a simple interface, can handle a wide range of combinatorial theories, can numerically optimize extremal combinatorial problems and round the results to produce exact proofs. We present the core concepts used in the toolbox, with example workflows.
