Combinatorial identities and counting
combinatorial-identities
Prove binomial sums, Fibonacci identities, closed forms of linear recurrences, and counting arguments with injections and pigeonholes.
What the agent does
The agent gets a working directory with a Lean file, Solution.lean, and a problem in words. It edits the file until it compiles and is correct. Tasks are generated from a seed and a difficulty from 1 to 3, so the supply is unlimited and every task is new.
An example task
Prove a counting statement
Prove the following.
Let be a finite set of integers with more than 3 elements. Prove that contains two different integers that leave the same remainder on division by 3.
What to do
Solution.lean in the working directory states the theorem in Lean 4 with Mathlib, with sorry in place of the proof. Replace every sorry with a proof.
- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.
- Check your work with
lake env lean Solution.lean(run it inside/opt/arena/lean, giving the full path to the file). It must compile without errors. - A theorem counts only if its proof is complete: no
sorry, no new axioms, nonative_decide. - The reward is 1 if the theorem is proved and 0 otherwise.
import Mathlib /-- Pigeonhole principle for remainders. -/ theorem pigeonhole_mod (s : Finset ℤ) (h : 3 < s.card) : ∃ x ∈ s, ∃ y ∈ s, x ≠ y ∧ x % 3 = y % 3 := by sorry
Show a reference solution
import Mathlib /-- Pigeonhole principle for remainders. -/ theorem pigeonhole_mod (s : Finset ℤ) (h : 3 < s.card) : ∃ x ∈ s, ∃ y ∈ s, x ≠ y ∧ x % 3 = y % 3 := by have hmaps : Set.MapsTo (fun x : ℤ => x % 3) (s : Set ℤ) (Finset.Ico (0 : ℤ) 3 : Finset ℤ) := by intro x _ simp only [Finset.coe_Ico, Set.mem_Ico] omega have hc : (Finset.Ico (0 : ℤ) 3).card < s.card := by simpa using h exact Finset.exists_ne_map_eq_of_card_lt_of_maps_to hc hmaps
Reference solutions are never shown to the agent. They are compiled in the environment's self-test, so every task has at least one proof that passes.
The families
Each task belongs to one family: a different piece of the area's work.
| binomial sums | theorem hockey_stick (n : ℕ) :
∑ i ∈ Finset.range (n + 1), (i + 5).choose 5 = (n + 6).choose 6 |
| counting | theorem card_le_residue_class (n : ℕ) : (Finset.range n).card ≤ ((Finset.range (5 * n)).filter (fun y => y % 5 = 0)).card |
| fibonacci | theorem fib_square_sum (n : ℕ) :
∑ i ∈ Finset.range (n + 1), 6 * Nat.fib i ^ 2 = 6 * (Nat.fib n * Nat.fib (n + 1)) |
| linear recurrence | theorem seq_closed_form (n : ℕ) :
u n = (-1) * (-1) ^ n + 4 * (-3) ^ n |
Reward
- Range
- 0 to 1
- Checked by
- Lean kernel
- Deterministic
- yes
Every theorem must be stated exactly as given and proved: no sorry, no new axioms, no native_decide. The reward is the share of theorems that pass. A file that does not compile scores 0. The submission is also re-checked by a second kernel run. Read how checking works.
How to run it
git clone https://github.com/RenaissanceLabs-EU/lean-arena && cd lean-arena cd lean && lake exe cache get
python3 tools/make_task.py combinatorial_identities --seed 7 --difficulty 2 --out /tmp/task
python3 arena/grade.py --spec /tmp/task/spec.json --solution /tmp/task/Solution.lean
Tasks are also exported as Harbor task folders (instruction.md, task.toml, tests/), the format used by several RL frameworks, with the image built from the Lean project.
How hard is it?
A floor, not a ceiling: how many sampled tasks a single automation call can close with no thought at all. Each theorem was given the tactic first | grind | aesop | simp | omega | norm_num | nlinarith | decide. A task counts as closed only if every theorem in it is. Overall 0 of 24. The rest need a real proof.
- Difficulty 1
- 0 of 8
- Difficulty 2
- 0 of 8
- Difficulty 3
- 0 of 8
Sample: 8 seeds at each difficulty. No model has been run on these tasks yet, so how hard they are for a model is not yet measured.
Good for
- induction on sequences
- Nat.choose lemmas
- Nat.fib
- Finset.card injections and pigeonhole
