+ Blueprint
+ Documentation
+ Paper
+ {% if site.github.is_project_page %}
+ View on GitHub
+ {% endif %}
+ {% if site.show_downloads %}
+ Download .zip
+ Download .tar.gz
+ {% endif %}
+
+
+
+ {{ content }}
+
+
+
+
+
+
diff --git a/docs/about.md b/docs/about.md
new file mode 100644
index 0000000..2aa6e31
--- /dev/null
+++ b/docs/about.md
@@ -0,0 +1,17 @@
+---
+title: About
+permalink: /about/
+---
+
+This is the base Jekyll theme. You can find out more info about customizing your Jekyll theme, as well as basic Jekyll usage documentation at [jekyllrb.com](https://jekyllrb.com/)
+
+You can find the source code for Minima at GitHub:
+[jekyll][jekyll-organization] /
+[minima](https://github.com/jekyll/minima)
+
+You can find the source code for Jekyll at GitHub:
+[jekyll][jekyll-organization] /
+[jekyll](https://github.com/jekyll/jekyll)
+
+
+[jekyll-organization]: https://github.com/jekyll
diff --git a/docs/assets/css/style.scss b/docs/assets/css/style.scss
new file mode 100644
index 0000000..efd5216
--- /dev/null
+++ b/docs/assets/css/style.scss
@@ -0,0 +1,17 @@
+---
+---
+
+@import "{{ site.theme }}";
+
+.page-header {
+ background-image: linear-gradient(120deg, #2d4fdc, #dc2ddc);
+}
+
+.main-content h1,
+.main-content h2,
+.main-content h3,
+.main-content h4,
+.main-content h5,
+.main-content h6 {
+ color: #6f1599;
+}
diff --git a/docs/index.md b/docs/index.md
new file mode 100644
index 0000000..9e025e8
--- /dev/null
+++ b/docs/index.md
@@ -0,0 +1,125 @@
+---
+# Feel free to add content and custom Front Matter to this file.
+# To modify the layout, see https://jekyllrb.com/docs/themes/#overriding-theme-defaults
+
+# layout: home
+---
+
+# Arithmetic Progressions - Almost Periodicity
+
+The purpose of this repository is to *digitise* some mathematical definitions, theorem statements
+and theorem proofs. Digitisation, or formalisation, is a process where the source material,
+typically a mathematical textbook or a pdf file or website or video, is transformed into definitions
+in a target system consisting of a computer implementation of a logical theory (such as set theory
+or type theory).
+
+## The source
+
+The definitions, theorems and proofs in this repository are taken from the exposition of Bloom and
+Sisask on the Kelley-Meka bound on Roth numbers [2302.07211](https://arxiv.org/abs/2302.07211).
+
+The main result is that there is some constant `c > 0` such that, if `A ⊆ {1, ..., N}` contains no
+non-trivial arithmetic progression of length 3, then `|A| ≤ N/exp(c * (log n)^(1/12)))` for some
+constant `c > 0`. This is an amazing improvement over previous bounds, which were all of the form
+`N/(log n)^c` for some constant `c`.
+
+## The target
+
+The formal system which we are using as a target system is Lean's dependent type theory. Lean is a
+project being developed at AWS and Microsoft Research by Leonardo de Moura and his team.
+
+At this stage, mathlib4 contains all the background material that we need. However, not all
+quality-of-life improvements that we know from Lean 3 have made it to Lean 4 (yet) and Lean 4
+suffers from its own problems that currently make it unsuitable for new formalisation of
+research-level mathematics. As a consequence, we are sticking to Lean 3 until the project is
+complete. Then we will port it to Lean 4 in order to upstream our basic results.
+
+## Content of this project
+
+This project currently contains about 3k lines of Lean code about the discrete (difference)
+convolution, discrete Lp norms, discrete Fourier transform. It also contains proofs of a version of
+almost periodicity and of a quantitative version of the Marcinkiewicz-Zygmund inequality.
+
+Once finished, this project will contain two main results (here `R` is the Roth number, the maximum
+size of a set without three term arithmetic progressions):
+* The **finite field case**: A proof that `R(F_q^n) ≤ q ^ (n - c * n ^ (1/9))` for some constant
+ `c`. This is worse than the Ellenberg-Gijswijt bound `R(F_q^n) ≤ q ^ (n - c * n)` which was
+ formalised in [Dahmen, Hölzl, Lewis](https://drops.dagstuhl.de/opus/volltexte/2019/11070/). The
+ goal here is therefore not to improve on the existing bound but instead demonstrate the
+ probability and Fourier analysis techniques, whereas Ellenberg-Gijswijt used the polynomial
+ method.
+* The **integer case**: A proof that `R(n) ≤ N/exp(c * (log n)^(1/9)))`, using the same techniques
+ as in the finite field case, except for the fact that we now use Bohr sets instead of subspaces.
+ This bound is a slight improvement over the Kelley-Meka bound (with `1/12` as the exponent instead
+ of `1/9`). It is due to Bloom and Sisask.
+
+### Code organisation
+
+The Lean code is contained in the directory `src/`. The subdirectories are:
+* `Mathlib`: Material missing from existing mathlib developments
+* `Prereqs`: New developments to be integrated to mathlib
+* `Physics`: The physical (as opposed to Fourier space) proof steps that are shared
+ between the finite field cases and integer case
+* `FiniteField`: The proof steps specific to the finite field case
+* `Integer`: The proof steps specific to the integer case
+
+### Current progress
+
+The project is not yet finished. The following table details live which files are unfinished, and
+how many 'sorries' (unproven statements) remain in each file.
+
+{% include sorries.md %}
+
+## What next?
+
+Almost periodicity is nowadays a standard tool in additive combinatorics. The version we formalised is sufficient for many applications. In particular, it gives one of the best known bounds on Freiman's theorem. As a side goal, we might tackle Freiman's theorem.
+
+The discrete convolution/Lp norm/Fourier transform material belongs in mathlib and we hope to PR it there once the transition to Lean 4 has completed. Almost periodicity should similarly be upstreamed to mathlib given the numerous applications. The rest of the material might forever live in this repository.
+
+On top of the new developments, there are many basic lemmas needed for this project that are currently missing from mathlib.
+
+Here is the list of files that do not depend on any other LeanAPAP file, indicating they are good candidates for upstreaming to mathlib:
+
+{% include files_to_upstream.md %}
+
+## Build the Lean files
+
+To build the Lean files of this project, you need to have a working version of Lean.
+See [the installation instructions](https://leanprover-community.github.io/get_started.html) (under Regular install).
+Alternatively, click on the button below to open a Gitpod workspace containing the project.
+
+[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/YaelDillies/LeanAPAP)
+
+In either case, run `lake exe cache get` and then `lake build` to build the project.
+
+## Build the blueprint
+
+To build the web version of the blueprint, you need a working LaTeX installation.
+Furthermore, you need some packages:
+```
+sudo apt install graphviz libgraphviz-dev
+pip install -r blueprint/requirements.txt
+```
+
+To actually build the blueprint, run
+```
+lake exe cache get
+lake build
+inv all
+```
+
+## Acknowledgements
+
+Our project builds on mathlib. We must therefore thank its numerous contributors without whom this
+project couldn't even have started.
+
+Much of the project infrastructure has been adapted from
+* [sphere eversion](https://leanprover-community.github.io/sphere-eversion/)
+* [liquid tensor experiment](https://github.com/leanprover-community/liquid/)
+* [unit fractions](https://github.com/b-mehta/unit-fractions/)
+
+## Source reference
+
+`[BS]` : https://arxiv.org/abs/2302.07211
+
+[BS]: https://arxiv.org/abs/2302.07211
diff --git a/scripts/count_sorries.py b/scripts/count_sorries.py
new file mode 100644
index 0000000..a609930
--- /dev/null
+++ b/scripts/count_sorries.py
@@ -0,0 +1,36 @@
+from glob import glob
+import os
+import re
+
+def ident_to_word(ident: str):
+ ident = ident.replace("_", " ")
+ return ident[0].upper() + ident[1:]
+
+def pretty_file(file: str):
+ segments = file[4:].replace(".lean", "").split("/")
+ name = ": ".join(ident_to_word(s) for s in segments)
+ url = f"https://github.com/alma-n/Polya-lean/blob/main/{file}"
+ return f"[{name}]({url})"
+
+files = [file for tree in os.walk("Polya") for file in glob(os.path.join(tree[0], '*.lean'))]
+sorries = {}
+
+for file in files:
+ with open(file, "r") as f:
+ contents = f.read()
+ matches = [m.start() for m in re.finditer("sorry", contents)]
+ if len(matches) != 0:
+ sorries[pretty_file(file)] = len(matches)
+
+result = """
+| File | Sorries |
+| ---- | ------- |
+"""
+for file in sorted(sorries.keys()):
+ result += f"| {file} | {sorries[file]} |\n"
+
+print(result)
+if not os.path.exists("docs/_includes"):
+ os.makedirs("docs/_includes")
+with open("docs/_includes/sorries.md", "w") as f:
+ f.write(result)