birgermoell commited on
Commit
7931c0c
·
verified ·
1 Parent(s): 38aacb3

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. arena/__init__.py +0 -0
  2. arena/core.py +97 -0
  3. arena/grade.py +127 -0
  4. assets/social-preview.jpg +3 -0
  5. data/combinatorial-identities/eval.jsonl +24 -0
  6. data/combinatorial-identities/train.jsonl +0 -0
  7. data/definitions/eval.jsonl +24 -0
  8. data/definitions/train.jsonl +0 -0
  9. data/finite-sums/eval.jsonl +24 -0
  10. data/finite-sums/train.jsonl +0 -0
  11. data/group-theory/eval.jsonl +24 -0
  12. data/group-theory/train.jsonl +0 -0
  13. data/inequalities/eval.jsonl +24 -0
  14. data/inequalities/train.jsonl +0 -0
  15. data/linear-algebra/eval.jsonl +24 -0
  16. data/linear-algebra/train.jsonl +0 -0
  17. data/logic-and-sets/eval.jsonl +24 -0
  18. data/logic-and-sets/train.jsonl +0 -0
  19. data/modular-arithmetic/eval.jsonl +24 -0
  20. data/modular-arithmetic/train.jsonl +0 -0
  21. data/real-analysis/eval.jsonl +24 -0
  22. data/real-analysis/train.jsonl +0 -0
  23. docker/Dockerfile +16 -0
  24. envs/__init__.py +0 -0
  25. envs/combinatorial_identities/__init__.py +0 -0
  26. envs/combinatorial_identities/env.toml +8 -0
  27. envs/combinatorial_identities/gen.py +163 -0
  28. envs/definitions/__init__.py +0 -0
  29. envs/definitions/env.toml +8 -0
  30. envs/definitions/gen.py +170 -0
  31. envs/finite_sums/__init__.py +0 -0
  32. envs/finite_sums/env.toml +8 -0
  33. envs/finite_sums/gen.py +82 -0
  34. envs/group_theory/__init__.py +0 -0
  35. envs/group_theory/env.toml +8 -0
  36. envs/group_theory/gen.py +330 -0
  37. envs/inequalities/__init__.py +0 -0
  38. envs/inequalities/env.toml +8 -0
  39. envs/inequalities/gen.py +305 -0
  40. envs/linear_algebra/__init__.py +0 -0
  41. envs/linear_algebra/env.toml +8 -0
  42. envs/linear_algebra/gen.py +322 -0
  43. envs/logic_and_sets/__init__.py +0 -0
  44. envs/logic_and_sets/env.toml +8 -0
  45. envs/logic_and_sets/gen.py +355 -0
  46. envs/modular_arithmetic/__init__.py +0 -0
  47. envs/modular_arithmetic/env.toml +8 -0
  48. envs/modular_arithmetic/gen.py +229 -0
  49. envs/real_analysis/__init__.py +0 -0
  50. envs/real_analysis/env.toml +8 -0
arena/__init__.py ADDED
File without changes
arena/core.py ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Task model for the Lean environments. Python 3.9, standard library only."""
2
+ import hashlib, random
3
+ from dataclasses import dataclass, field
4
+ from typing import List, Optional, Dict
5
+
6
+ HEADER = "import Mathlib\n"
7
+
8
+ def rng_for(key, seed, difficulty):
9
+ h = hashlib.sha256(("%s|%d|%d" % (key, seed, difficulty)).encode()).digest()
10
+ return random.Random(int.from_bytes(h[:8], "big"))
11
+
12
+ @dataclass
13
+ class Theorem:
14
+ name: str # Lean identifier
15
+ statement: str # everything between the name and `:=`, e.g. "(x : ℝ) : x + 0 = x"
16
+ proof: str # reference proof: everything after `:=`, e.g. "by\n simp"
17
+ informal: str = "" # the statement in words; becomes the doc comment
18
+ weight: float = 1.0
19
+
20
+ @dataclass
21
+ class Task:
22
+ env: str
23
+ family: str
24
+ seed: int
25
+ difficulty: int
26
+ title: str
27
+ informal: str # the problem in words (Markdown, maths in \( \))
28
+ kind: str = "prove" # "prove" or "define"
29
+ preamble: str = "" # Lean text after the import: opens and fixed definitions
30
+ theorems: List[Theorem] = field(default_factory=list)
31
+ # define tasks only
32
+ stub: str = "" # what the solver sees, with `sorry` for each definition
33
+ solution: str = "" # reference definitions
34
+ free: List[str] = field(default_factory=list) # names the solver defines
35
+ tests: List[Theorem] = field(default_factory=list) # hidden; proved by the grader with native_decide
36
+ examples: str = "" # public example values, shown in the instruction
37
+ meta: Dict = field(default_factory=dict)
38
+
39
+ def _doc(self, t):
40
+ return ("/-- %s -/\n" % t.informal.replace("-/", "- /")) if t.informal else ""
41
+
42
+ def _body(self, proofs, defs):
43
+ out = [HEADER]
44
+ if self.preamble.strip(): out.append(self.preamble.strip() + "\n")
45
+ if defs.strip(): out.append(defs.strip() + "\n")
46
+ for t in self.theorems:
47
+ out.append("%stheorem %s %s := %s\n" % (self._doc(t), t.name, t.statement.strip(), t.proof.strip() if proofs else "by\n sorry"))
48
+ return "\n".join(out)
49
+
50
+ def start_file(self):
51
+ """Solution.lean as the solver first sees it."""
52
+ return self._body(False, self.stub)
53
+
54
+ def reference_solution(self):
55
+ return self._body(True, self.solution)
56
+
57
+ def hidden_reference(self):
58
+ text = self._body(False, self.stub)
59
+ for t in self.tests:
60
+ text += "\ntheorem %s %s := by\n sorry\n" % (t.name, t.statement.strip())
61
+ return text
62
+
63
+ def hidden_tests(self):
64
+ if not self.tests: return None
65
+ text = "import Solution\n"
66
+ for t in self.tests:
67
+ text += "\ntheorem %s %s := by\n native_decide\n" % (t.name, t.statement.strip())
68
+ return text
69
+
70
+ def spec(self):
71
+ graded = self.tests if self.tests else self.theorems
72
+ s = {"reference": self.hidden_reference(), "targets": [{"name": t.name, "weight": t.weight} for t in graded]}
73
+ if self.tests: s["tests"] = self.hidden_tests()
74
+ if self.free: s["free"] = list(self.free)
75
+ return s
76
+
77
+ def instruction(self):
78
+ lines = ["# %s" % self.title, "", self.informal.strip(), ""]
79
+ if self.kind == "prove":
80
+ n = len(self.theorems)
81
+ lines += ["## What to do", "",
82
+ "`Solution.lean` in the working directory states %s in Lean 4 with Mathlib, with `sorry` in place of %s. Replace every `sorry` with a proof." % (
83
+ "the theorem" if n == 1 else "%d theorems" % n, "the proof" if n == 1 else "each proof"),
84
+ "", "- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.",
85
+ "- 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.",
86
+ "- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.",
87
+ ("- The reward is 1 if the theorem is proved and 0 otherwise." if n == 1 else
88
+ "- The reward is the share of the %d theorems that are proved. If the file does not compile the reward is 0, so leave `sorry` on a theorem you cannot finish rather than a broken proof." % n)]
89
+ else:
90
+ lines += ["## What to do", "",
91
+ "`Solution.lean` in the working directory declares %s with `sorry` as its body. Replace each `sorry` with a definition that matches the description above." % ", ".join("`%s`" % f for f in self.free),
92
+ "", "- Keep the name and the type exactly as given. You may add helper definitions.",
93
+ "- The definition must be computable: it is checked by running it on hidden inputs, so do not use `noncomputable` or classical choice.",
94
+ "- Check that the file compiles with `lake env lean Solution.lean` (run it inside `/opt/arena/lean`, giving the full path to the file), and test your definition with `#eval`.",
95
+ "- The reward is 1 if the definition agrees with the description on every hidden input, and 0 otherwise."]
96
+ if self.examples.strip(): lines += ["", "## Examples", "", self.examples.strip()]
97
+ return "\n".join(lines) + "\n"
arena/grade.py ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Grade a Lean submission against a task. Standard library only.
3
+
4
+ python3 grade.py --spec spec.json --solution Solution.lean --out <dir>
5
+
6
+ `spec.json` holds the hidden reference file, the target theorem names and their weights (see
7
+ arena/core.py). The reward is the weighted share of targets that are proved: stated exactly as
8
+ asked, with no `sorry`, depending only on propext, Classical.choice and Quot.sound, and passing a
9
+ second kernel check by `leanchecker`. A submission that does not compile scores 0.
10
+
11
+ The Lean project (toolchain + Mathlib) is found through $ARENA_LEAN, default: ../lean next to this
12
+ file, then /opt/arena/lean.
13
+ """
14
+ import argparse, json, os, shutil, subprocess, sys, tempfile, time
15
+
16
+ HERE = os.path.dirname(os.path.abspath(__file__))
17
+ TIMEOUT = int(os.environ.get("ARENA_TIMEOUT", "600"))
18
+
19
+ def project():
20
+ for p in (os.environ.get("ARENA_LEAN"), os.path.join(HERE, "..", "lean"), "/opt/arena/lean"):
21
+ if p and os.path.exists(os.path.join(p, "lean-toolchain")): return os.path.abspath(p)
22
+ raise SystemExit("Lean project not found; set ARENA_LEAN")
23
+
24
+ _lp = {}
25
+ def lean_path(proj):
26
+ if proj not in _lp:
27
+ cache = os.path.join(proj, ".lake", "lean_path.txt")
28
+ if os.path.exists(cache): _lp[proj] = open(cache).read().strip()
29
+ else:
30
+ _lp[proj] = subprocess.run(["lake", "env", "printenv", "LEAN_PATH"], cwd=proj, capture_output=True, text=True, check=True).stdout.strip()
31
+ try: open(cache, "w").write(_lp[proj])
32
+ except OSError: pass
33
+ return _lp[proj]
34
+
35
+ class Slot:
36
+ """Optional machine-wide cap on concurrent Lean processes: ARENA_SLOTS=n, ARENA_LOCKDIR=dir."""
37
+ def __enter__(self):
38
+ self.path = None
39
+ n = int(os.environ.get("ARENA_SLOTS", "0"))
40
+ if not n: return self
41
+ d = os.environ.get("ARENA_LOCKDIR", os.path.join(tempfile.gettempdir(), "arena-locks")); os.makedirs(d, exist_ok=True)
42
+ while True:
43
+ for i in range(n):
44
+ p = os.path.join(d, "slot%d" % i)
45
+ try:
46
+ os.mkdir(p); open(os.path.join(p, "pid"), "w").write(str(os.getpid())); self.path = p; return self
47
+ except FileExistsError:
48
+ try:
49
+ pid = int(open(os.path.join(p, "pid")).read()); os.kill(pid, 0)
50
+ except (OSError, ValueError):
51
+ shutil.rmtree(p, ignore_errors=True) # stale
52
+ time.sleep(1)
53
+ def __exit__(self, *a):
54
+ if self.path: shutil.rmtree(self.path, ignore_errors=True)
55
+
56
+ def run(cmd, proj, extra_path=None, timeout=TIMEOUT):
57
+ env = dict(os.environ); env["LEAN_PATH"] = lean_path(proj) + ((":" + extra_path) if extra_path else "")
58
+ with Slot():
59
+ try:
60
+ r = subprocess.run(cmd, cwd=proj, env=env, capture_output=True, text=True, timeout=timeout)
61
+ return r.returncode, (r.stdout + r.stderr)
62
+ except subprocess.TimeoutExpired:
63
+ return 124, "timed out after %d s" % timeout
64
+
65
+ def compile_lean(proj, src, work):
66
+ """Compile work/<src>.lean to work/<src>.olean. Returns (ok, messages)."""
67
+ olean = os.path.join(work, src + ".olean")
68
+ if os.path.exists(olean): os.remove(olean)
69
+ code, out = run(["lean", "--root=" + work, "-o", olean, os.path.join(work, src + ".lean")], proj, work)
70
+ return code == 0 and os.path.exists(olean), out
71
+
72
+ def grade(spec, solution_text, keep=None):
73
+ proj = project(); work = keep or tempfile.mkdtemp(prefix="arena-")
74
+ os.makedirs(work, exist_ok=True)
75
+ targets = spec["targets"]; total = float(sum(t["weight"] for t in targets))
76
+ res = {"reward": 0.0, "stage": "", "targets": [], "log": ""}
77
+ def fail(stage, log):
78
+ res["stage"] = stage; res["log"] = log[-4000:]
79
+ res["targets"] = [{"target": t["name"], "ok": False, "why": stage} for t in targets]
80
+ return res
81
+ try:
82
+ open(os.path.join(work, "Reference.lean"), "w").write(spec["reference"])
83
+ open(os.path.join(work, "Solution.lean"), "w").write(solution_text)
84
+ ok, out = compile_lean(proj, "Reference", work)
85
+ if not ok: return fail("the reference file did not compile (a fault in the task, not in the submission)", out)
86
+ ok, out = compile_lean(proj, "Solution", work)
87
+ if not ok: return fail("the submission does not compile", out)
88
+ code, out = run(["leanchecker", "Solution"], proj, work)
89
+ if code != 0: return fail("the submission fails the kernel re-check", out)
90
+ sub = "Solution"; flags = []
91
+ if spec.get("tests"):
92
+ open(os.path.join(work, "Tests.lean"), "w").write(spec["tests"])
93
+ ok, out = compile_lean(proj, "Tests", work)
94
+ if not ok: return fail("the hidden tests do not pass", out)
95
+ code, out = run(["leanchecker", "Tests"], proj, work)
96
+ if code != 0: return fail("the tests fail the kernel re-check", out)
97
+ sub = "Tests"; flags = ["--native"]
98
+ if spec.get("free"): flags += ["--free", ",".join(spec["free"])]
99
+ verify = os.path.join(HERE, "Verify.lean")
100
+ if not os.path.exists(verify): verify = os.path.join(proj, "verifier", "Verify.lean")
101
+ code, out = run(["lean", "--run", verify] + flags + ["Reference", sub] + [t["name"] for t in targets], proj, work)
102
+ got = {}
103
+ for line in out.splitlines():
104
+ if line.startswith("{"):
105
+ try: j = json.loads(line); got[j["target"]] = j
106
+ except ValueError: pass
107
+ if code != 0 or len(got) != len(targets): return fail("the verifier did not finish", out)
108
+ res["targets"] = [got[t["name"]] for t in targets]
109
+ res["reward"] = round(sum(t["weight"] for t in targets if got[t["name"]]["ok"]) / total, 4)
110
+ res["stage"] = "graded"
111
+ return res
112
+ finally:
113
+ if not keep: shutil.rmtree(work, ignore_errors=True)
114
+
115
+ if __name__ == "__main__":
116
+ ap = argparse.ArgumentParser()
117
+ ap.add_argument("--spec", required=True); ap.add_argument("--solution", required=True); ap.add_argument("--out", default=None)
118
+ a = ap.parse_args()
119
+ spec = json.load(open(a.spec, encoding="utf-8"))
120
+ try: text = open(a.solution, encoding="utf-8").read()
121
+ except OSError: text = None
122
+ res = grade(spec, text) if text is not None else {"reward": 0.0, "stage": "no Solution.lean found", "targets": [], "log": ""}
123
+ print(json.dumps(res, indent=1, ensure_ascii=False))
124
+ if a.out:
125
+ os.makedirs(a.out, exist_ok=True)
126
+ open(os.path.join(a.out, "reward.txt"), "w").write("%g\n" % res["reward"])
127
+ json.dump(res, open(os.path.join(a.out, "result.json"), "w"), indent=1, ensure_ascii=False)
assets/social-preview.jpg ADDED

Git LFS Details

  • SHA256: 98bc05816fc00d9274e303e3ee5386a3d7e1e040805cb7cef1a6e947b673b6e6
  • Pointer size: 131 Bytes
  • Size of remote file: 152 kB
data/combinatorial-identities/eval.jsonl ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {"id": "combinatorial-identities-binomial_sums-d1-e0000", "env": "combinatorial-identities", "msc": "05", "family": "binomial_sums", "difficulty": 1, "seed": 10000, "kind": "prove", "instruction": "# Prove an identity for binomial coefficients\n\nProve the following.\n\nFor every natural number \\(n\\), \\[\\sum_{i=0}^{n} \\binom{n}{i}\\, 8^{i} = 9^{n}.\\]\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- A weighted sum of binomial coefficients. -/\ntheorem binomial_sum (n : ℕ) :\n ∑ i ∈ Finset.range (n + 1), n.choose i * 8 ^ i = 9 ^ n := by\n sorry\n", "path": "tasks/combinatorial-identities/combinatorial-identities-binomial_sums-d1-e0000"}
2
+ {"id": "combinatorial-identities-counting-d1-e0001", "env": "combinatorial-identities", "msc": "05", "family": "counting", "difficulty": 1, "seed": 10001, "kind": "prove", "instruction": "# Prove a counting statement\n\nProve the following.\n\nLet \\(s\\) be a finite set of integers with more than 3 elements. Prove that \\(s\\) contains two different integers \\(x \\ne y\\) that leave the same remainder on division by 3.\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- Pigeonhole principle for remainders. -/\ntheorem pigeonhole_mod (s : Finset ℤ) (h : 3 < s.card) :\n ∃ x ∈ s, ∃ y ∈ s, x ≠ y ∧ x % 3 = y % 3 := by\n sorry\n", "path": "tasks/combinatorial-identities/combinatorial-identities-counting-d1-e0001"}
3
+ {"id": "combinatorial-identities-fibonacci-d1-e0002", "env": "combinatorial-identities", "msc": "05", "family": "fibonacci", "difficulty": 1, "seed": 10002, "kind": "prove", "instruction": "# Prove an identity for Fibonacci numbers\n\nProve the following.\n\nFor every natural number \\(n\\), with \\(F\\) the Fibonacci sequence (\\(F_0 = 0\\), \\(F_1 = 1\\), \\(F_{k+2} = F_k + F_{k+1}\\)), \\[\\sum_{i=0}^{n-1} F_{i+3} + F_{4} = F_{n+4}.\\]\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- A telescoping sum of Fibonacci numbers. -/\ntheorem fib_shifted_sum (n : ℕ) :\n ∑ i ∈ Finset.range n, Nat.fib (i + 3) + Nat.fib 4 = Nat.fib (n + 4) := by\n sorry\n", "path": "tasks/combinatorial-identities/combinatorial-identities-fibonacci-d1-e0002"}
4
+ {"id": "combinatorial-identities-linear_recurrence-d1-e0003", "env": "combinatorial-identities", "msc": "05", "family": "linear_recurrence", "difficulty": 1, "seed": 10003, "kind": "prove", "instruction": "# Find the closed form of a recurrence\n\nProve the following.\n\nDefine a sequence of integers by \\(u_0 = -3\\), \\(u_1 = -7\\) and \\(u_{n+2} = 4\\,u_{n+1} - 3\\,u_{n}\\). Prove that for every natural number \\(n\\), \\[u_n = -2 \\cdot 3^{n} + -1 \\cdot 1^{n}.\\]\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\ndef u : ℕ → ℤ\n | 0 => (-3)\n | 1 => (-7)\n | (n + 2) => 4 * u (n + 1) - 3 * u n\n\n/-- A closed form for the sequence defined by the recurrence. -/\ntheorem seq_closed_form (n : ℕ) :\n u n = (-2) * 3 ^ n + (-1) * 1 ^ n := by\n sorry\n", "path": "tasks/combinatorial-identities/combinatorial-identities-linear_recurrence-d1-e0003"}
5
+ {"id": "combinatorial-identities-binomial_sums-d2-e0004", "env": "combinatorial-identities", "msc": "05", "family": "binomial_sums", "difficulty": 2, "seed": 10004, "kind": "prove", "instruction": "# Prove an identity for binomial coefficients\n\nProve the following.\n\nFor every natural number \\(n\\), \\[2 \\cdot \\sum_{i=0}^{n} \\binom{i+1}{1} = 2 \\cdot \\binom{n+2}{2}.\\] (This is the hockey stick identity.)\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- A hockey stick identity for binomial coefficients. -/\ntheorem hockey_stick (n : ℕ) :\n ∑ i ∈ Finset.range (n + 1), 2 * (i + 1).choose 1 = 2 * (n + 2).choose 2 := by\n sorry\n", "path": "tasks/combinatorial-identities/combinatorial-identities-binomial_sums-d2-e0004"}
6
+ {"id": "combinatorial-identities-counting-d2-e0005", "env": "combinatorial-identities", "msc": "05", "family": "counting", "difficulty": 2, "seed": 10005, "kind": "prove", "instruction": "# Prove a counting statement\n\nProve the following.\n\nLet \\(n\\) be a natural number. Prove that the set \\(\\{0, 1, \\dots, n-1\\}\\) has at most as many elements as the set of integers \\(y\\) with \\(0 \\le y < 4 n\\) and \\(y \\equiv 2 \\pmod{4}\\). (Construct an injection.)\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- An injection into a residue class gives a cardinality bound. -/\ntheorem card_le_residue_class (n : ℕ) :\n (Finset.range n).card ≤ ((Finset.range (4 * n)).filter (fun y => y % 4 = 2)).card := by\n sorry\n", "path": "tasks/combinatorial-identities/combinatorial-identities-counting-d2-e0005"}
7
+ {"id": "combinatorial-identities-fibonacci-d2-e0006", "env": "combinatorial-identities", "msc": "05", "family": "fibonacci", "difficulty": 2, "seed": 10006, "kind": "prove", "instruction": "# Prove an identity for Fibonacci numbers\n\nProve the following.\n\nFor every natural number \\(n\\), with \\(F\\) the Fibonacci sequence, \\[\\sum_{i=0}^{n} 3\\,F_i^2 = 3\\,F_n F_{n+1}.\\]\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- A sum of squares of Fibonacci numbers. -/\ntheorem fib_square_sum (n : ℕ) :\n ∑ i ∈ Finset.range (n + 1), 3 * Nat.fib i ^ 2 = 3 * (Nat.fib n * Nat.fib (n + 1)) := by\n sorry\n", "path": "tasks/combinatorial-identities/combinatorial-identities-fibonacci-d2-e0006"}
8
+ {"id": "combinatorial-identities-linear_recurrence-d2-e0007", "env": "combinatorial-identities", "msc": "05", "family": "linear_recurrence", "difficulty": 2, "seed": 10007, "kind": "prove", "instruction": "# Find the closed form of a recurrence\n\nProve the following.\n\nDefine a sequence of integers by \\(u_0 = -4\\), \\(u_1 = 11\\) and \\(u_{n+2} = -3\\,u_{n+1} - -4\\,u_{n}\\). Prove that for every natural number \\(n\\), \\[u_n = -3 \\cdot (-4)^{n} + -1 \\cdot 1^{n}.\\]\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\ndef u : ℕ → ℤ\n | 0 => (-4)\n | 1 => 11\n | (n + 2) => (-3) * u (n + 1) - (-4) * u n\n\n/-- A closed form for the sequence defined by the recurrence. -/\ntheorem seq_closed_form (n : ℕ) :\n u n = (-3) * (-4) ^ n + (-1) * 1 ^ n := by\n sorry\n", "path": "tasks/combinatorial-identities/combinatorial-identities-linear_recurrence-d2-e0007"}
9
+ {"id": "combinatorial-identities-binomial_sums-d3-e0008", "env": "combinatorial-identities", "msc": "05", "family": "binomial_sums", "difficulty": 3, "seed": 10008, "kind": "prove", "instruction": "# Prove an identity for binomial coefficients\n\nProve the following.\n\nFirst prove \\[\\sum_{i=0}^{n} i \\binom{n}{i} = n \\cdot 2^{n-1},\\] where \\(n - 1\\) is truncated subtraction on the natural numbers. Then use it, and the value of \\(\\sum_{i=0}^{n} \\binom{n}{i}\\), to prove \\[\\sum_{i=0}^{n} (2i + 7) \\binom{n}{i} = 2 \\cdot n \\cdot 2^{n-1} + 7 \\cdot 2^{n}.\\]\n\n## What to do\n\n`Solution.lean` in the working directory states 2 theorems in Lean 4 with Mathlib, with `sorry` in place of each proof. Replace every `sorry` with a proof.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is the share of the 2 theorems that are proved. If the file does not compile the reward is 0, so leave `sorry` on a theorem you cannot finish rather than a broken proof.\n", "start_file": "import Mathlib\n\n/-- The sum of i times n choose i. -/\ntheorem sum_i_choose (n : ℕ) :\n ∑ i ∈ Finset.range (n + 1), i * n.choose i = n * 2 ^ (n - 1) := by\n sorry\n\n/-- A weighted binomial sum. -/\ntheorem weighted_sum (n : ℕ) :\n ∑ i ∈ Finset.range (n + 1), (2 * i + 7) * n.choose i = 2 * (n * 2 ^ (n - 1)) + 7 * 2 ^ n := by\n sorry\n", "path": "tasks/combinatorial-identities/combinatorial-identities-binomial_sums-d3-e0008"}
10
+ {"id": "combinatorial-identities-counting-d3-e0009", "env": "combinatorial-identities", "msc": "05", "family": "counting", "difficulty": 3, "seed": 10009, "kind": "prove", "instruction": "# Prove a counting statement\n\nProve the following.\n\nLet \\(s\\) be a set of natural numbers that are all less than \\(4 \\cdot 2 = 8\\), and suppose \\(s\\) has more than 2 elements. Prove that \\(s\\) contains two elements \\(x < y\\) with \\(y - x < 4\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- Pigeonhole principle for blocks of consecutive numbers. -/\ntheorem close_pair (s : Finset ℕ) (hs : s ⊆ Finset.range (4 * 2)) (h : 2 < s.card) :\n ∃ x ∈ s, ∃ y ∈ s, x < y ∧ y < x + 4 := by\n sorry\n", "path": "tasks/combinatorial-identities/combinatorial-identities-counting-d3-e0009"}
11
+ {"id": "combinatorial-identities-fibonacci-d3-e0010", "env": "combinatorial-identities", "msc": "05", "family": "fibonacci", "difficulty": 3, "seed": 10010, "kind": "prove", "instruction": "# Prove an identity for Fibonacci numbers\n\nProve the following.\n\nFirst prove Cassini's identity: for every natural number \\(n\\), \\[F_{n+1}^2 - F_n F_{n+2} = (-1)^n,\\] computed in the integers, where \\(F\\) is the Fibonacci sequence. Then conclude that \\(F_{m+1}^2 - F_m F_{m+2}\\) is either \\(1\\) or \\(-1\\) when \\(m = 7n + 2\\).\n\n## What to do\n\n`Solution.lean` in the working directory states 2 theorems in Lean 4 with Mathlib, with `sorry` in place of each proof. Replace every `sorry` with a proof.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is the share of the 2 theorems that are proved. If the file does not compile the reward is 0, so leave `sorry` on a theorem you cannot finish rather than a broken proof.\n", "start_file": "import Mathlib\n\n/-- Cassini's identity for Fibonacci numbers. -/\ntheorem cassini (n : ℕ) :\n (Nat.fib (n + 1) : ℤ) ^ 2 - Nat.fib n * Nat.fib (n + 2) = (-1) ^ n := by\n sorry\n\n/-- Cassini's determinant is plus or minus one at the index given. -/\ntheorem cassini_pm_one (n : ℕ) :\n (Nat.fib (7 * n + 2 + 1) : ℤ) ^ 2 - Nat.fib (7 * n + 2) * Nat.fib (7 * n + 2 + 2) = 1 ∨ (Nat.fib (7 * n + 2 + 1) : ℤ) ^ 2 - Nat.fib (7 * n + 2) * Nat.fib (7 * n + 2 + 2) = -1 := by\n sorry\n", "path": "tasks/combinatorial-identities/combinatorial-identities-fibonacci-d3-e0010"}
12
+ {"id": "combinatorial-identities-linear_recurrence-d3-e0011", "env": "combinatorial-identities", "msc": "05", "family": "linear_recurrence", "difficulty": 3, "seed": 10011, "kind": "prove", "instruction": "# Find the closed form of a recurrence\n\nProve the following.\n\nDefine a sequence of integers by \\(u_0 = 3\\), \\(u_1 = 14\\) and \\(u_{n+2} = 4\\,u_{n+1} - 4\\,u_{n}\\). Prove that for every natural number \\(n\\), \\[u_n = (3 + 4 n) \\cdot 2^{n}.\\]\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\ndef u : ℕ → ℤ\n | 0 => 3\n | 1 => 14\n | (n + 2) => 4 * u (n + 1) - 4 * u n\n\n/-- A closed form for the sequence defined by the recurrence. -/\ntheorem seq_closed_form (n : ℕ) :\n u n = (3 + 4 * (n : ℤ)) * 2 ^ n := by\n sorry\n", "path": "tasks/combinatorial-identities/combinatorial-identities-linear_recurrence-d3-e0011"}
13
+ {"id": "combinatorial-identities-binomial_sums-d1-e0012", "env": "combinatorial-identities", "msc": "05", "family": "binomial_sums", "difficulty": 1, "seed": 10012, "kind": "prove", "instruction": "# Prove an identity for binomial coefficients\n\nProve the following.\n\nFor every natural number \\(n\\), \\[\\sum_{i=0}^{n} \\binom{n}{i}\\, 7^{i} = 8^{n}.\\]\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- A weighted sum of binomial coefficients. -/\ntheorem binomial_sum (n : ℕ) :\n ∑ i ∈ Finset.range (n + 1), n.choose i * 7 ^ i = 8 ^ n := by\n sorry\n", "path": "tasks/combinatorial-identities/combinatorial-identities-binomial_sums-d1-e0012"}
14
+ {"id": "combinatorial-identities-counting-d1-e0013", "env": "combinatorial-identities", "msc": "05", "family": "counting", "difficulty": 1, "seed": 10013, "kind": "prove", "instruction": "# Prove a counting statement\n\nProve the following.\n\nLet \\(s\\) be a finite set of integers with more than 2 elements. Prove that \\(s\\) contains two different integers \\(x \\ne y\\) that leave the same remainder on division by 2.\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- Pigeonhole principle for remainders. -/\ntheorem pigeonhole_mod (s : Finset ℤ) (h : 2 < s.card) :\n ∃ x ∈ s, ∃ y ∈ s, x ≠ y ∧ x % 2 = y % 2 := by\n sorry\n", "path": "tasks/combinatorial-identities/combinatorial-identities-counting-d1-e0013"}
15
+ {"id": "combinatorial-identities-fibonacci-d1-e0014", "env": "combinatorial-identities", "msc": "05", "family": "fibonacci", "difficulty": 1, "seed": 10014, "kind": "prove", "instruction": "# Prove an identity for Fibonacci numbers\n\nProve the following.\n\nFor every natural number \\(n\\), with \\(F\\) the Fibonacci sequence (\\(F_0 = 0\\), \\(F_1 = 1\\), \\(F_{k+2} = F_k + F_{k+1}\\)), \\[\\sum_{i=0}^{n-1} F_{i+12} + F_{13} = F_{n+13}.\\]\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- A telescoping sum of Fibonacci numbers. -/\ntheorem fib_shifted_sum (n : ℕ) :\n ∑ i ∈ Finset.range n, Nat.fib (i + 12) + Nat.fib 13 = Nat.fib (n + 13) := by\n sorry\n", "path": "tasks/combinatorial-identities/combinatorial-identities-fibonacci-d1-e0014"}
16
+ {"id": "combinatorial-identities-linear_recurrence-d1-e0015", "env": "combinatorial-identities", "msc": "05", "family": "linear_recurrence", "difficulty": 1, "seed": 10015, "kind": "prove", "instruction": "# Find the closed form of a recurrence\n\nProve the following.\n\nDefine a sequence of integers by \\(u_0 = 4\\), \\(u_1 = 17\\) and \\(u_{n+2} = 7\\,u_{n+1} - 10\\,u_{n}\\). Prove that for every natural number \\(n\\), \\[u_n = 1 \\cdot 2^{n} + 3 \\cdot 5^{n}.\\]\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\ndef u : ℕ → ℤ\n | 0 => 4\n | 1 => 17\n | (n + 2) => 7 * u (n + 1) - 10 * u n\n\n/-- A closed form for the sequence defined by the recurrence. -/\ntheorem seq_closed_form (n : ℕ) :\n u n = 1 * 2 ^ n + 3 * 5 ^ n := by\n sorry\n", "path": "tasks/combinatorial-identities/combinatorial-identities-linear_recurrence-d1-e0015"}
17
+ {"id": "combinatorial-identities-binomial_sums-d2-e0016", "env": "combinatorial-identities", "msc": "05", "family": "binomial_sums", "difficulty": 2, "seed": 10016, "kind": "prove", "instruction": "# Prove an identity for binomial coefficients\n\nProve the following.\n\nFor every natural number \\(n\\), \\[5 \\cdot \\sum_{i=0}^{n} \\binom{i+1}{1} = 5 \\cdot \\binom{n+2}{2}.\\] (This is the hockey stick identity.)\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- A hockey stick identity for binomial coefficients. -/\ntheorem hockey_stick (n : ℕ) :\n ∑ i ∈ Finset.range (n + 1), 5 * (i + 1).choose 1 = 5 * (n + 2).choose 2 := by\n sorry\n", "path": "tasks/combinatorial-identities/combinatorial-identities-binomial_sums-d2-e0016"}
18
+ {"id": "combinatorial-identities-counting-d2-e0017", "env": "combinatorial-identities", "msc": "05", "family": "counting", "difficulty": 2, "seed": 10017, "kind": "prove", "instruction": "# Prove a counting statement\n\nProve the following.\n\nLet \\(n\\) be a natural number. Prove that the set \\(\\{0, 1, \\dots, n-1\\}\\) has at most as many elements as the set of integers \\(y\\) with \\(0 \\le y < 6 n\\) and \\(y \\equiv 4 \\pmod{6}\\). (Construct an injection.)\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- An injection into a residue class gives a cardinality bound. -/\ntheorem card_le_residue_class (n : ℕ) :\n (Finset.range n).card ≤ ((Finset.range (6 * n)).filter (fun y => y % 6 = 4)).card := by\n sorry\n", "path": "tasks/combinatorial-identities/combinatorial-identities-counting-d2-e0017"}
19
+ {"id": "combinatorial-identities-fibonacci-d2-e0018", "env": "combinatorial-identities", "msc": "05", "family": "fibonacci", "difficulty": 2, "seed": 10018, "kind": "prove", "instruction": "# Prove an identity for Fibonacci numbers\n\nProve the following.\n\nFor every natural number \\(n\\), with \\(F\\) the Fibonacci sequence, \\[\\sum_{i=0}^{n-1} F_{2i+11} + F_{10} = F_{2n+10}.\\]\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- A sum of every second Fibonacci number. -/\ntheorem fib_odd_sum (n : ℕ) :\n ∑ i ∈ Finset.range n, Nat.fib (2 * i + 11) + Nat.fib 10 = Nat.fib (2 * n + 10) := by\n sorry\n", "path": "tasks/combinatorial-identities/combinatorial-identities-fibonacci-d2-e0018"}
20
+ {"id": "combinatorial-identities-linear_recurrence-d2-e0019", "env": "combinatorial-identities", "msc": "05", "family": "linear_recurrence", "difficulty": 2, "seed": 10019, "kind": "prove", "instruction": "# Find the closed form of a recurrence\n\nProve the following.\n\nDefine a sequence of integers by \\(u_0 = 5\\), \\(u_1 = 5\\) and \\(u_{n+2} = 3\\,u_{n+1} - -4\\,u_{n}\\). Prove that for every natural number \\(n\\), \\[u_n = 3 \\cdot (-1)^{n} + 2 \\cdot 4^{n}.\\]\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\ndef u : ℕ → ℤ\n | 0 => 5\n | 1 => 5\n | (n + 2) => 3 * u (n + 1) - (-4) * u n\n\n/-- A closed form for the sequence defined by the recurrence. -/\ntheorem seq_closed_form (n : ℕ) :\n u n = 3 * (-1) ^ n + 2 * 4 ^ n := by\n sorry\n", "path": "tasks/combinatorial-identities/combinatorial-identities-linear_recurrence-d2-e0019"}
21
+ {"id": "combinatorial-identities-binomial_sums-d3-e0020", "env": "combinatorial-identities", "msc": "05", "family": "binomial_sums", "difficulty": 3, "seed": 10020, "kind": "prove", "instruction": "# Prove an identity for binomial coefficients\n\nProve the following.\n\nFirst prove \\[\\sum_{i=0}^{n} i \\binom{n}{i} = n \\cdot 2^{n-1},\\] where \\(n - 1\\) is truncated subtraction on the natural numbers. Then use it, and the value of \\(\\sum_{i=0}^{n} \\binom{n}{i}\\), to prove \\[\\sum_{i=0}^{n} (5i + 6) \\binom{n}{i} = 5 \\cdot n \\cdot 2^{n-1} + 6 \\cdot 2^{n}.\\]\n\n## What to do\n\n`Solution.lean` in the working directory states 2 theorems in Lean 4 with Mathlib, with `sorry` in place of each proof. Replace every `sorry` with a proof.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is the share of the 2 theorems that are proved. If the file does not compile the reward is 0, so leave `sorry` on a theorem you cannot finish rather than a broken proof.\n", "start_file": "import Mathlib\n\n/-- The sum of i times n choose i. -/\ntheorem sum_i_choose (n : ℕ) :\n ∑ i ∈ Finset.range (n + 1), i * n.choose i = n * 2 ^ (n - 1) := by\n sorry\n\n/-- A weighted binomial sum. -/\ntheorem weighted_sum (n : ℕ) :\n ∑ i ∈ Finset.range (n + 1), (5 * i + 6) * n.choose i = 5 * (n * 2 ^ (n - 1)) + 6 * 2 ^ n := by\n sorry\n", "path": "tasks/combinatorial-identities/combinatorial-identities-binomial_sums-d3-e0020"}
22
+ {"id": "combinatorial-identities-counting-d3-e0021", "env": "combinatorial-identities", "msc": "05", "family": "counting", "difficulty": 3, "seed": 10021, "kind": "prove", "instruction": "# Prove a counting statement\n\nProve the following.\n\nLet \\(s\\) be a set of natural numbers that are all less than \\(6 \\cdot 7 = 42\\), and suppose \\(s\\) has more than 7 elements. Prove that \\(s\\) contains two elements \\(x < y\\) with \\(y - x < 6\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- Pigeonhole principle for blocks of consecutive numbers. -/\ntheorem close_pair (s : Finset ℕ) (hs : s ⊆ Finset.range (6 * 7)) (h : 7 < s.card) :\n ∃ x ∈ s, ∃ y ∈ s, x < y ∧ y < x + 6 := by\n sorry\n", "path": "tasks/combinatorial-identities/combinatorial-identities-counting-d3-e0021"}
23
+ {"id": "combinatorial-identities-fibonacci-d3-e0022", "env": "combinatorial-identities", "msc": "05", "family": "fibonacci", "difficulty": 3, "seed": 10022, "kind": "prove", "instruction": "# Prove an identity for Fibonacci numbers\n\nProve the following.\n\nFirst prove Cassini's identity: for every natural number \\(n\\), \\[F_{n+1}^2 - F_n F_{n+2} = (-1)^n,\\] computed in the integers, where \\(F\\) is the Fibonacci sequence. Then conclude that \\(F_{m+1}^2 - F_m F_{m+2}\\) is either \\(1\\) or \\(-1\\) when \\(m = 3n + 6\\).\n\n## What to do\n\n`Solution.lean` in the working directory states 2 theorems in Lean 4 with Mathlib, with `sorry` in place of each proof. Replace every `sorry` with a proof.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is the share of the 2 theorems that are proved. If the file does not compile the reward is 0, so leave `sorry` on a theorem you cannot finish rather than a broken proof.\n", "start_file": "import Mathlib\n\n/-- Cassini's identity for Fibonacci numbers. -/\ntheorem cassini (n : ℕ) :\n (Nat.fib (n + 1) : ℤ) ^ 2 - Nat.fib n * Nat.fib (n + 2) = (-1) ^ n := by\n sorry\n\n/-- Cassini's determinant is plus or minus one at the index given. -/\ntheorem cassini_pm_one (n : ℕ) :\n (Nat.fib (3 * n + 6 + 1) : ℤ) ^ 2 - Nat.fib (3 * n + 6) * Nat.fib (3 * n + 6 + 2) = 1 ∨ (Nat.fib (3 * n + 6 + 1) : ℤ) ^ 2 - Nat.fib (3 * n + 6) * Nat.fib (3 * n + 6 + 2) = -1 := by\n sorry\n", "path": "tasks/combinatorial-identities/combinatorial-identities-fibonacci-d3-e0022"}
24
+ {"id": "combinatorial-identities-linear_recurrence-d3-e0023", "env": "combinatorial-identities", "msc": "05", "family": "linear_recurrence", "difficulty": 3, "seed": 10023, "kind": "prove", "instruction": "# Find the closed form of a recurrence\n\nProve the following.\n\nDefine a sequence of integers by \\(u_0 = -3\\), \\(u_1 = 4\\) and \\(u_{n+2} = 8\\,u_{n+1} - 16\\,u_{n}\\). Prove that for every natural number \\(n\\), \\[u_n = (-3 + 4 n) \\cdot 4^{n}.\\]\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\ndef u : ℕ → ℤ\n | 0 => (-3)\n | 1 => 4\n | (n + 2) => 8 * u (n + 1) - 16 * u n\n\n/-- A closed form for the sequence defined by the recurrence. -/\ntheorem seq_closed_form (n : ℕ) :\n u n = ((-3) + 4 * (n : ℤ)) * 4 ^ n := by\n sorry\n", "path": "tasks/combinatorial-identities/combinatorial-identities-linear_recurrence-d3-e0023"}
data/combinatorial-identities/train.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
data/definitions/eval.jsonl ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {"id": "definitions-count-d1-e0000", "env": "definitions", "msc": "11", "family": "count", "difficulty": 1, "seed": 10000, "kind": "define", "instruction": "# Define a function from its description\n\nDefine the function \\(f\\) from the natural numbers (including 0) to the natural numbers as follows.\n\n\\(f(n)\\) is the number of integers \\(k\\) with \\(1 \\le k \\le n\\) such that the decimal digits of \\(k\\) read the same forwards and backwards.\n\n## What to do\n\n`Solution.lean` in the working directory declares `f` with `sorry` as its body. Replace each `sorry` with a definition that matches the description above.\n\n- Keep the name and the type exactly as given. You may add helper definitions.\n- The definition must be computable: it is checked by running it on hidden inputs, so do not use `noncomputable` or classical choice.\n- Check that the file compiles with `lake env lean Solution.lean` (run it inside `/opt/arena/lean`, giving the full path to the file), and test your definition with `#eval`.\n- The reward is 1 if the definition agrees with the description on every hidden input, and 0 otherwise.\n\n## Examples\n\n- \\(f(3) = 3\\)\n- \\(f(10) = 9\\)\n- \\(f(17) = 10\\)\n- \\(f(24) = 11\\)\n", "start_file": "import Mathlib\n\ndef f (n : ℕ) : ℕ := sorry\n", "path": "tasks/definitions/definitions-count-d1-e0000"}
2
+ {"id": "definitions-divisors-d1-e0001", "env": "definitions", "msc": "11", "family": "divisors", "difficulty": 1, "seed": 10001, "kind": "define", "instruction": "# Define a function from its description\n\nDefine the function \\(f\\) from the natural numbers (including 0) to the natural numbers as follows.\n\n\\(f(n)\\) is the number of positive divisors \\(d\\) of \\(n\\) such that the decimal digits of \\(d\\) read the same forwards and backwards. Take \\(f(0) = 0\\).\n\n## What to do\n\n`Solution.lean` in the working directory declares `f` with `sorry` as its body. Replace each `sorry` with a definition that matches the description above.\n\n- Keep the name and the type exactly as given. You may add helper definitions.\n- The definition must be computable: it is checked by running it on hidden inputs, so do not use `noncomputable` or classical choice.\n- Check that the file compiles with `lake env lean Solution.lean` (run it inside `/opt/arena/lean`, giving the full path to the file), and test your definition with `#eval`.\n- The reward is 1 if the definition agrees with the description on every hidden input, and 0 otherwise.\n\n## Examples\n\n- \\(f(3) = 2\\)\n- \\(f(10) = 3\\)\n- \\(f(17) = 1\\)\n- \\(f(24) = 6\\)\n", "start_file": "import Mathlib\n\ndef f (n : ℕ) : ℕ := sorry\n", "path": "tasks/definitions/definitions-divisors-d1-e0001"}
3
+ {"id": "definitions-extremum-d1-e0002", "env": "definitions", "msc": "11", "family": "extremum", "difficulty": 1, "seed": 10002, "kind": "define", "instruction": "# Define a function from its description\n\nDefine the function \\(f\\) from the natural numbers (including 0) to the natural numbers as follows.\n\n\\(f(n)\\) is the largest integer \\(k\\) with \\(1 \\le k \\le n\\) such that \\(k\\) leaves remainder 1 on division by 3. If there is no such \\(k\\), then \\(f(n) = 0\\).\n\n## What to do\n\n`Solution.lean` in the working directory declares `f` with `sorry` as its body. Replace each `sorry` with a definition that matches the description above.\n\n- Keep the name and the type exactly as given. You may add helper definitions.\n- The definition must be computable: it is checked by running it on hidden inputs, so do not use `noncomputable` or classical choice.\n- Check that the file compiles with `lake env lean Solution.lean` (run it inside `/opt/arena/lean`, giving the full path to the file), and test your definition with `#eval`.\n- The reward is 1 if the definition agrees with the description on every hidden input, and 0 otherwise.\n\n## Examples\n\n- \\(f(3) = 1\\)\n- \\(f(10) = 10\\)\n- \\(f(17) = 16\\)\n- \\(f(24) = 22\\)\n", "start_file": "import Mathlib\n\ndef f (n : ℕ) : ℕ := sorry\n", "path": "tasks/definitions/definitions-extremum-d1-e0002"}
4
+ {"id": "definitions-pairs-d1-e0003", "env": "definitions", "msc": "11", "family": "pairs", "difficulty": 1, "seed": 10003, "kind": "define", "instruction": "# Define a function from its description\n\nDefine the function \\(f\\) from the natural numbers (including 0) to the natural numbers as follows.\n\n\\(f(n)\\) is the number of ordered pairs \\((a, b)\\) of integers with \\(1 \\le a \\le n\\) and \\(1 \\le b \\le n\\) such that \\(a + b\\) is divisible by 5.\n\n## What to do\n\n`Solution.lean` in the working directory declares `f` with `sorry` as its body. Replace each `sorry` with a definition that matches the description above.\n\n- Keep the name and the type exactly as given. You may add helper definitions.\n- The definition must be computable: it is checked by running it on hidden inputs, so do not use `noncomputable` or classical choice.\n- Check that the file compiles with `lake env lean Solution.lean` (run it inside `/opt/arena/lean`, giving the full path to the file), and test your definition with `#eval`.\n- The reward is 1 if the definition agrees with the description on every hidden input, and 0 otherwise.\n\n## Examples\n\n- \\(f(3) = 2\\)\n- \\(f(10) = 20\\)\n- \\(f(17) = 57\\)\n- \\(f(24) = 116\\)\n", "start_file": "import Mathlib\n\ndef f (n : ℕ) : ℕ := sorry\n", "path": "tasks/definitions/definitions-pairs-d1-e0003"}
5
+ {"id": "definitions-sequence-d1-e0004", "env": "definitions", "msc": "11", "family": "sequence", "difficulty": 1, "seed": 10004, "kind": "define", "instruction": "# Define a function from its description\n\nDefine the function \\(f\\) from the natural numbers (including 0) to the natural numbers as follows.\n\nLet \\(a(0) = 3\\), \\(a(1) = 2\\) and, for \\(n \\ge 0\\), let \\(a(n+2)\\) be the remainder of \\(2\\,a(n+1) + \\,a(n)\\) on division by 11. Then \\(f(n) = a(n)\\).\n\n## What to do\n\n`Solution.lean` in the working directory declares `f` with `sorry` as its body. Replace each `sorry` with a definition that matches the description above.\n\n- Keep the name and the type exactly as given. You may add helper definitions.\n- The definition must be computable: it is checked by running it on hidden inputs, so do not use `noncomputable` or classical choice.\n- Check that the file compiles with `lake env lean Solution.lean` (run it inside `/opt/arena/lean`, giving the full path to the file), and test your definition with `#eval`.\n- The reward is 1 if the definition agrees with the description on every hidden input, and 0 otherwise.\n\n## Examples\n\n- \\(f(3) = 5\\)\n- \\(f(10) = 0\\)\n- \\(f(17) = 5\\)\n- \\(f(24) = 3\\)\n", "start_file": "import Mathlib\n\ndef f (n : ℕ) : ℕ := sorry\n", "path": "tasks/definitions/definitions-sequence-d1-e0004"}
6
+ {"id": "definitions-sum-d1-e0005", "env": "definitions", "msc": "11", "family": "sum", "difficulty": 1, "seed": 10005, "kind": "define", "instruction": "# Define a function from its description\n\nDefine the function \\(f\\) from the natural numbers (including 0) to the natural numbers as follows.\n\n\\(f(n)\\) is the sum of \\(k\\) over all integers \\(k\\) with \\(1 \\le k \\le n\\) such that \\(k\\) leaves remainder 2 on division by 3. An empty sum is 0.\n\n## What to do\n\n`Solution.lean` in the working directory declares `f` with `sorry` as its body. Replace each `sorry` with a definition that matches the description above.\n\n- Keep the name and the type exactly as given. You may add helper definitions.\n- The definition must be computable: it is checked by running it on hidden inputs, so do not use `noncomputable` or classical choice.\n- Check that the file compiles with `lake env lean Solution.lean` (run it inside `/opt/arena/lean`, giving the full path to the file), and test your definition with `#eval`.\n- The reward is 1 if the definition agrees with the description on every hidden input, and 0 otherwise.\n\n## Examples\n\n- \\(f(3) = 2\\)\n- \\(f(10) = 15\\)\n- \\(f(17) = 57\\)\n- \\(f(24) = 100\\)\n", "start_file": "import Mathlib\n\ndef f (n : ℕ) : ℕ := sorry\n", "path": "tasks/definitions/definitions-sum-d1-e0005"}
7
+ {"id": "definitions-count-d2-e0006", "env": "definitions", "msc": "11", "family": "count", "difficulty": 2, "seed": 10006, "kind": "define", "instruction": "# Define a function from its description\n\nDefine the function \\(f\\) from the natural numbers (including 0) to the natural numbers as follows.\n\n\\(f(n)\\) is the number of integers \\(k\\) with \\(1 \\le k \\le n\\) such that the decimal digits of \\(k\\) read the same forwards and backwards but it is not the case that \\(k\\) leaves remainder 1 on division by 7.\n\n## What to do\n\n`Solution.lean` in the working directory declares `f` with `sorry` as its body. Replace each `sorry` with a definition that matches the description above.\n\n- Keep the name and the type exactly as given. You may add helper definitions.\n- The definition must be computable: it is checked by running it on hidden inputs, so do not use `noncomputable` or classical choice.\n- Check that the file compiles with `lake env lean Solution.lean` (run it inside `/opt/arena/lean`, giving the full path to the file), and test your definition with `#eval`.\n- The reward is 1 if the definition agrees with the description on every hidden input, and 0 otherwise.\n\n## Examples\n\n- \\(f(3) = 2\\)\n- \\(f(10) = 7\\)\n- \\(f(17) = 8\\)\n- \\(f(24) = 8\\)\n", "start_file": "import Mathlib\n\ndef f (n : ℕ) : ℕ := sorry\n", "path": "tasks/definitions/definitions-count-d2-e0006"}
8
+ {"id": "definitions-divisors-d2-e0007", "env": "definitions", "msc": "11", "family": "divisors", "difficulty": 2, "seed": 10007, "kind": "define", "instruction": "# Define a function from its description\n\nDefine the function \\(f\\) from the natural numbers (including 0) to the natural numbers as follows.\n\n\\(f(n)\\) is the sum of \\(d^2\\) over all positive divisors \\(d\\) of \\(n\\) such that the decimal digits of \\(d\\) read the same forwards and backwards. An empty sum is 0, and \\(f(0) = 0\\).\n\n## What to do\n\n`Solution.lean` in the working directory declares `f` with `sorry` as its body. Replace each `sorry` with a definition that matches the description above.\n\n- Keep the name and the type exactly as given. You may add helper definitions.\n- The definition must be computable: it is checked by running it on hidden inputs, so do not use `noncomputable` or classical choice.\n- Check that the file compiles with `lake env lean Solution.lean` (run it inside `/opt/arena/lean`, giving the full path to the file), and test your definition with `#eval`.\n- The reward is 1 if the definition agrees with the description on every hidden input, and 0 otherwise.\n\n## Examples\n\n- \\(f(3) = 10\\)\n- \\(f(10) = 30\\)\n- \\(f(17) = 1\\)\n- \\(f(24) = 130\\)\n", "start_file": "import Mathlib\n\ndef f (n : ℕ) : ℕ := sorry\n", "path": "tasks/definitions/definitions-divisors-d2-e0007"}
9
+ {"id": "definitions-extremum-d2-e0008", "env": "definitions", "msc": "11", "family": "extremum", "difficulty": 2, "seed": 10008, "kind": "define", "instruction": "# Define a function from its description\n\nDefine the function \\(f\\) from the natural numbers (including 0) to the natural numbers as follows.\n\n\\(f(n)\\) is the largest integer \\(k\\) with \\(1 \\le k \\le n\\) such that \\(k\\) is squarefree (no square larger than 1 divides it) or \\(k\\) is coprime to 12 (or both). If there is no such \\(k\\), then \\(f(n) = 0\\).\n\n## What to do\n\n`Solution.lean` in the working directory declares `f` with `sorry` as its body. Replace each `sorry` with a definition that matches the description above.\n\n- Keep the name and the type exactly as given. You may add helper definitions.\n- The definition must be computable: it is checked by running it on hidden inputs, so do not use `noncomputable` or classical choice.\n- Check that the file compiles with `lake env lean Solution.lean` (run it inside `/opt/arena/lean`, giving the full path to the file), and test your definition with `#eval`.\n- The reward is 1 if the definition agrees with the description on every hidden input, and 0 otherwise.\n\n## Examples\n\n- \\(f(3) = 3\\)\n- \\(f(10) = 10\\)\n- \\(f(17) = 17\\)\n- \\(f(24) = 23\\)\n", "start_file": "import Mathlib\n\ndef f (n : ℕ) : ℕ := sorry\n", "path": "tasks/definitions/definitions-extremum-d2-e0008"}
10
+ {"id": "definitions-pairs-d2-e0009", "env": "definitions", "msc": "11", "family": "pairs", "difficulty": 2, "seed": 10009, "kind": "define", "instruction": "# Define a function from its description\n\nDefine the function \\(f\\) from the natural numbers (including 0) to the natural numbers as follows.\n\n\\(f(n)\\) is the number of ordered pairs \\((a, b)\\) of integers with \\(1 \\le a \\le n\\) and \\(1 \\le b \\le n\\) such that \\(a\\) divides \\(b\\) and \\(a < b\\).\n\n## What to do\n\n`Solution.lean` in the working directory declares `f` with `sorry` as its body. Replace each `sorry` with a definition that matches the description above.\n\n- Keep the name and the type exactly as given. You may add helper definitions.\n- The definition must be computable: it is checked by running it on hidden inputs, so do not use `noncomputable` or classical choice.\n- Check that the file compiles with `lake env lean Solution.lean` (run it inside `/opt/arena/lean`, giving the full path to the file), and test your definition with `#eval`.\n- The reward is 1 if the definition agrees with the description on every hidden input, and 0 otherwise.\n\n## Examples\n\n- \\(f(3) = 2\\)\n- \\(f(10) = 17\\)\n- \\(f(17) = 35\\)\n- \\(f(24) = 60\\)\n", "start_file": "import Mathlib\n\ndef f (n : ℕ) : ℕ := sorry\n", "path": "tasks/definitions/definitions-pairs-d2-e0009"}
11
+ {"id": "definitions-sequence-d2-e0010", "env": "definitions", "msc": "11", "family": "sequence", "difficulty": 2, "seed": 10010, "kind": "define", "instruction": "# Define a function from its description\n\nDefine the function \\(f\\) from the natural numbers (including 0) to the natural numbers as follows.\n\nLet \\(a(0) = 4\\), \\(a(1) = 2\\) and, for \\(n \\ge 0\\), let \\(a(n+2)\\) be the remainder of \\(3\\,a(n+1) + 4\\,a(n) + 3\\) on division by 17. Then \\(f(n) = a(0) + a(1) + \\dots + a(n)\\).\n\n## What to do\n\n`Solution.lean` in the working directory declares `f` with `sorry` as its body. Replace each `sorry` with a definition that matches the description above.\n\n- Keep the name and the type exactly as given. You may add helper definitions.\n- The definition must be computable: it is checked by running it on hidden inputs, so do not use `noncomputable` or classical choice.\n- Check that the file compiles with `lake env lean Solution.lean` (run it inside `/opt/arena/lean`, giving the full path to the file), and test your definition with `#eval`.\n- The reward is 1 if the definition agrees with the description on every hidden input, and 0 otherwise.\n\n## Examples\n\n- \\(f(3) = 15\\)\n- \\(f(10) = 44\\)\n- \\(f(17) = 66\\)\n- \\(f(24) = 94\\)\n", "start_file": "import Mathlib\n\ndef f (n : ℕ) : ℕ := sorry\n", "path": "tasks/definitions/definitions-sequence-d2-e0010"}
12
+ {"id": "definitions-sum-d2-e0011", "env": "definitions", "msc": "11", "family": "sum", "difficulty": 2, "seed": 10011, "kind": "define", "instruction": "# Define a function from its description\n\nDefine the function \\(f\\) from the natural numbers (including 0) to the natural numbers as follows.\n\n\\(f(n)\\) is the sum of the values \\(\\tau(k)\\), where \\(\\tau(m)\\) is the number of positive divisors of \\(m\\), over all integers \\(k\\) with \\(1 \\le k \\le n\\) such that the sum of the decimal digits of \\(k\\) leaves remainder 0 on division by 3. An empty sum is 0.\n\n## What to do\n\n`Solution.lean` in the working directory declares `f` with `sorry` as its body. Replace each `sorry` with a definition that matches the description above.\n\n- Keep the name and the type exactly as given. You may add helper definitions.\n- The definition must be computable: it is checked by running it on hidden inputs, so do not use `noncomputable` or classical choice.\n- Check that the file compiles with `lake env lean Solution.lean` (run it inside `/opt/arena/lean`, giving the full path to the file), and test your definition with `#eval`.\n- The reward is 1 if the definition agrees with the description on every hidden input, and 0 otherwise.\n\n## Examples\n\n- \\(f(3) = 2\\)\n- \\(f(10) = 9\\)\n- \\(f(17) = 19\\)\n- \\(f(24) = 37\\)\n", "start_file": "import Mathlib\n\ndef f (n : ℕ) : ℕ := sorry\n", "path": "tasks/definitions/definitions-sum-d2-e0011"}
13
+ {"id": "definitions-count-d3-e0012", "env": "definitions", "msc": "11", "family": "count", "difficulty": 3, "seed": 10012, "kind": "define", "instruction": "# Define a function from its description\n\nDefine the function \\(f\\) from the natural numbers (including 0) to the natural numbers as follows.\n\n\\(f(n)\\) is the number of integers \\(k\\) with \\(1 \\le k \\le n\\) such that \\(k\\) is divisible by 5 or \\(k\\) is squarefree (no square larger than 1 divides it) (or both).\n\n## What to do\n\n`Solution.lean` in the working directory declares `f` with `sorry` as its body. Replace each `sorry` with a definition that matches the description above.\n\n- Keep the name and the type exactly as given. You may add helper definitions.\n- The definition must be computable: it is checked by running it on hidden inputs, so do not use `noncomputable` or classical choice.\n- Check that the file compiles with `lake env lean Solution.lean` (run it inside `/opt/arena/lean`, giving the full path to the file), and test your definition with `#eval`.\n- The reward is 1 if the definition agrees with the description on every hidden input, and 0 otherwise.\n\n## Examples\n\n- \\(f(3) = 3\\)\n- \\(f(10) = 7\\)\n- \\(f(17) = 12\\)\n- \\(f(24) = 17\\)\n", "start_file": "import Mathlib\n\ndef f (n : ℕ) : ℕ := sorry\n", "path": "tasks/definitions/definitions-count-d3-e0012"}
14
+ {"id": "definitions-divisors-d3-e0013", "env": "definitions", "msc": "11", "family": "divisors", "difficulty": 3, "seed": 10013, "kind": "define", "instruction": "# Define a function from its description\n\nDefine the function \\(f\\) from the natural numbers (including 0) to the natural numbers as follows.\n\n\\(f(n)\\) is the sum of \\(d^2\\) over all positive divisors \\(d\\) of \\(n\\) such that \\(d\\) is divisible by 2 and \\(d\\) is coprime to 15. An empty sum is 0, and \\(f(0) = 0\\).\n\n## What to do\n\n`Solution.lean` in the working directory declares `f` with `sorry` as its body. Replace each `sorry` with a definition that matches the description above.\n\n- Keep the name and the type exactly as given. You may add helper definitions.\n- The definition must be computable: it is checked by running it on hidden inputs, so do not use `noncomputable` or classical choice.\n- Check that the file compiles with `lake env lean Solution.lean` (run it inside `/opt/arena/lean`, giving the full path to the file), and test your definition with `#eval`.\n- The reward is 1 if the definition agrees with the description on every hidden input, and 0 otherwise.\n\n## Examples\n\n- \\(f(3) = 0\\)\n- \\(f(10) = 4\\)\n- \\(f(17) = 0\\)\n- \\(f(24) = 84\\)\n", "start_file": "import Mathlib\n\ndef f (n : ℕ) : ℕ := sorry\n", "path": "tasks/definitions/definitions-divisors-d3-e0013"}
15
+ {"id": "definitions-extremum-d3-e0014", "env": "definitions", "msc": "11", "family": "extremum", "difficulty": 3, "seed": 10014, "kind": "define", "instruction": "# Define a function from its description\n\nDefine the function \\(f\\) from the natural numbers (including 0) to the natural numbers as follows.\n\n\\(f(n)\\) is the largest integer \\(k\\) with \\(1 \\le k \\le n\\) such that \\(k\\) is squarefree (no square larger than 1 divides it) but it is not the case that the sum of the decimal digits of \\(k\\) leaves remainder 0 on division by 5. If there is no such \\(k\\), then \\(f(n) = 0\\).\n\n## What to do\n\n`Solution.lean` in the working directory declares `f` with `sorry` as its body. Replace each `sorry` with a definition that matches the description above.\n\n- Keep the name and the type exactly as given. You may add helper definitions.\n- The definition must be computable: it is checked by running it on hidden inputs, so do not use `noncomputable` or classical choice.\n- Check that the file compiles with `lake env lean Solution.lean` (run it inside `/opt/arena/lean`, giving the full path to the file), and test your definition with `#eval`.\n- The reward is 1 if the definition agrees with the description on every hidden input, and 0 otherwise.\n\n## Examples\n\n- \\(f(3) = 3\\)\n- \\(f(10) = 10\\)\n- \\(f(17) = 17\\)\n- \\(f(24) = 22\\)\n", "start_file": "import Mathlib\n\ndef f (n : ℕ) : ℕ := sorry\n", "path": "tasks/definitions/definitions-extremum-d3-e0014"}
16
+ {"id": "definitions-pairs-d3-e0015", "env": "definitions", "msc": "11", "family": "pairs", "difficulty": 3, "seed": 10015, "kind": "define", "instruction": "# Define a function from its description\n\nDefine the function \\(f\\) from the natural numbers (including 0) to the natural numbers as follows.\n\n\\(f(n)\\) is the number of ordered pairs \\((a, b)\\) of integers with \\(1 \\le a \\le n\\) and \\(1 \\le b \\le n\\) such that \\(a + b\\) is prime, \\(a \\cdot b \\le n\\) and \\(a \\le b\\).\n\n## What to do\n\n`Solution.lean` in the working directory declares `f` with `sorry` as its body. Replace each `sorry` with a definition that matches the description above.\n\n- Keep the name and the type exactly as given. You may add helper definitions.\n- The definition must be computable: it is checked by running it on hidden inputs, so do not use `noncomputable` or classical choice.\n- Check that the file compiles with `lake env lean Solution.lean` (run it inside `/opt/arena/lean`, giving the full path to the file), and test your definition with `#eval`.\n- The reward is 1 if the definition agrees with the description on every hidden input, and 0 otherwise.\n\n## Examples\n\n- \\(f(3) = 2\\)\n- \\(f(10) = 7\\)\n- \\(f(17) = 10\\)\n- \\(f(24) = 15\\)\n", "start_file": "import Mathlib\n\ndef f (n : ℕ) : ℕ := sorry\n", "path": "tasks/definitions/definitions-pairs-d3-e0015"}
17
+ {"id": "definitions-sequence-d3-e0016", "env": "definitions", "msc": "11", "family": "sequence", "difficulty": 3, "seed": 10016, "kind": "define", "instruction": "# Define a function from its description\n\nDefine the function \\(f\\) from the natural numbers (including 0) to the natural numbers as follows.\n\nLet \\(a(0) = 4\\), \\(a(1) = 3\\) and, for \\(n \\ge 0\\), let \\(a(n+2)\\) be the remainder of \\(3\\,a(n+1) + 4\\,a(n)\\) on division by 13. Then \\(f(n)\\) is the number of indices \\(i\\) with \\(0 \\le i < n\\) such that \\(a(i) < a(i+1)\\).\n\n## What to do\n\n`Solution.lean` in the working directory declares `f` with `sorry` as its body. Replace each `sorry` with a definition that matches the description above.\n\n- Keep the name and the type exactly as given. You may add helper definitions.\n- The definition must be computable: it is checked by running it on hidden inputs, so do not use `noncomputable` or classical choice.\n- Check that the file compiles with `lake env lean Solution.lean` (run it inside `/opt/arena/lean`, giving the full path to the file), and test your definition with `#eval`.\n- The reward is 1 if the definition agrees with the description on every hidden input, and 0 otherwise.\n\n## Examples\n\n- \\(f(3) = 1\\)\n- \\(f(10) = 5\\)\n- \\(f(17) = 8\\)\n- \\(f(24) = 12\\)\n", "start_file": "import Mathlib\n\ndef f (n : ℕ) : ℕ := sorry\n", "path": "tasks/definitions/definitions-sequence-d3-e0016"}
18
+ {"id": "definitions-sum-d3-e0017", "env": "definitions", "msc": "11", "family": "sum", "difficulty": 3, "seed": 10017, "kind": "define", "instruction": "# Define a function from its description\n\nDefine the function \\(f\\) from the natural numbers (including 0) to the natural numbers as follows.\n\n\\(f(n)\\) is the sum of the digit sums \\(s(k)\\), where \\(s(m)\\) is the sum of the decimal digits of \\(m\\), over all integers \\(k\\) with \\(1 \\le k \\le n\\) such that \\(k\\) is prime but it is not the case that \\(k\\) is divisible by 7. An empty sum is 0.\n\n## What to do\n\n`Solution.lean` in the working directory declares `f` with `sorry` as its body. Replace each `sorry` with a definition that matches the description above.\n\n- Keep the name and the type exactly as given. You may add helper definitions.\n- The definition must be computable: it is checked by running it on hidden inputs, so do not use `noncomputable` or classical choice.\n- Check that the file compiles with `lake env lean Solution.lean` (run it inside `/opt/arena/lean`, giving the full path to the file), and test your definition with `#eval`.\n- The reward is 1 if the definition agrees with the description on every hidden input, and 0 otherwise.\n\n## Examples\n\n- \\(f(3) = 5\\)\n- \\(f(10) = 10\\)\n- \\(f(17) = 24\\)\n- \\(f(24) = 39\\)\n", "start_file": "import Mathlib\n\ndef f (n : ℕ) : ℕ := sorry\n", "path": "tasks/definitions/definitions-sum-d3-e0017"}
19
+ {"id": "definitions-count-d1-e0018", "env": "definitions", "msc": "11", "family": "count", "difficulty": 1, "seed": 10018, "kind": "define", "instruction": "# Define a function from its description\n\nDefine the function \\(f\\) from the natural numbers (including 0) to the natural numbers as follows.\n\n\\(f(n)\\) is the number of integers \\(k\\) with \\(1 \\le k \\le n\\) such that \\(k\\) is a perfect square.\n\n## What to do\n\n`Solution.lean` in the working directory declares `f` with `sorry` as its body. Replace each `sorry` with a definition that matches the description above.\n\n- Keep the name and the type exactly as given. You may add helper definitions.\n- The definition must be computable: it is checked by running it on hidden inputs, so do not use `noncomputable` or classical choice.\n- Check that the file compiles with `lake env lean Solution.lean` (run it inside `/opt/arena/lean`, giving the full path to the file), and test your definition with `#eval`.\n- The reward is 1 if the definition agrees with the description on every hidden input, and 0 otherwise.\n\n## Examples\n\n- \\(f(3) = 1\\)\n- \\(f(10) = 3\\)\n- \\(f(17) = 4\\)\n- \\(f(24) = 4\\)\n", "start_file": "import Mathlib\n\ndef f (n : ℕ) : ℕ := sorry\n", "path": "tasks/definitions/definitions-count-d1-e0018"}
20
+ {"id": "definitions-divisors-d1-e0019", "env": "definitions", "msc": "11", "family": "divisors", "difficulty": 1, "seed": 10019, "kind": "define", "instruction": "# Define a function from its description\n\nDefine the function \\(f\\) from the natural numbers (including 0) to the natural numbers as follows.\n\n\\(f(n)\\) is the number of positive divisors \\(d\\) of \\(n\\) such that \\(d\\) is divisible by 3. Take \\(f(0) = 0\\).\n\n## What to do\n\n`Solution.lean` in the working directory declares `f` with `sorry` as its body. Replace each `sorry` with a definition that matches the description above.\n\n- Keep the name and the type exactly as given. You may add helper definitions.\n- The definition must be computable: it is checked by running it on hidden inputs, so do not use `noncomputable` or classical choice.\n- Check that the file compiles with `lake env lean Solution.lean` (run it inside `/opt/arena/lean`, giving the full path to the file), and test your definition with `#eval`.\n- The reward is 1 if the definition agrees with the description on every hidden input, and 0 otherwise.\n\n## Examples\n\n- \\(f(3) = 1\\)\n- \\(f(10) = 0\\)\n- \\(f(17) = 0\\)\n- \\(f(24) = 4\\)\n", "start_file": "import Mathlib\n\ndef f (n : ℕ) : ℕ := sorry\n", "path": "tasks/definitions/definitions-divisors-d1-e0019"}
21
+ {"id": "definitions-extremum-d1-e0020", "env": "definitions", "msc": "11", "family": "extremum", "difficulty": 1, "seed": 10020, "kind": "define", "instruction": "# Define a function from its description\n\nDefine the function \\(f\\) from the natural numbers (including 0) to the natural numbers as follows.\n\n\\(f(n)\\) is the largest integer \\(k\\) with \\(1 \\le k \\le n\\) such that \\(k\\) is prime. If there is no such \\(k\\), then \\(f(n) = 0\\).\n\n## What to do\n\n`Solution.lean` in the working directory declares `f` with `sorry` as its body. Replace each `sorry` with a definition that matches the description above.\n\n- Keep the name and the type exactly as given. You may add helper definitions.\n- The definition must be computable: it is checked by running it on hidden inputs, so do not use `noncomputable` or classical choice.\n- Check that the file compiles with `lake env lean Solution.lean` (run it inside `/opt/arena/lean`, giving the full path to the file), and test your definition with `#eval`.\n- The reward is 1 if the definition agrees with the description on every hidden input, and 0 otherwise.\n\n## Examples\n\n- \\(f(3) = 3\\)\n- \\(f(10) = 7\\)\n- \\(f(17) = 17\\)\n- \\(f(24) = 23\\)\n", "start_file": "import Mathlib\n\ndef f (n : ℕ) : ℕ := sorry\n", "path": "tasks/definitions/definitions-extremum-d1-e0020"}
22
+ {"id": "definitions-pairs-d1-e0021", "env": "definitions", "msc": "11", "family": "pairs", "difficulty": 1, "seed": 10021, "kind": "define", "instruction": "# Define a function from its description\n\nDefine the function \\(f\\) from the natural numbers (including 0) to the natural numbers as follows.\n\n\\(f(n)\\) is the number of ordered pairs \\((a, b)\\) of integers with \\(1 \\le a \\le n\\) and \\(1 \\le b \\le n\\) such that \\(a \\cdot b \\le n\\).\n\n## What to do\n\n`Solution.lean` in the working directory declares `f` with `sorry` as its body. Replace each `sorry` with a definition that matches the description above.\n\n- Keep the name and the type exactly as given. You may add helper definitions.\n- The definition must be computable: it is checked by running it on hidden inputs, so do not use `noncomputable` or classical choice.\n- Check that the file compiles with `lake env lean Solution.lean` (run it inside `/opt/arena/lean`, giving the full path to the file), and test your definition with `#eval`.\n- The reward is 1 if the definition agrees with the description on every hidden input, and 0 otherwise.\n\n## Examples\n\n- \\(f(3) = 5\\)\n- \\(f(10) = 27\\)\n- \\(f(17) = 52\\)\n- \\(f(24) = 84\\)\n", "start_file": "import Mathlib\n\ndef f (n : ℕ) : ℕ := sorry\n", "path": "tasks/definitions/definitions-pairs-d1-e0021"}
23
+ {"id": "definitions-sequence-d1-e0022", "env": "definitions", "msc": "11", "family": "sequence", "difficulty": 1, "seed": 10022, "kind": "define", "instruction": "# Define a function from its description\n\nDefine the function \\(f\\) from the natural numbers (including 0) to the natural numbers as follows.\n\nLet \\(a(0) = 3\\), \\(a(1) = 5\\) and, for \\(n \\ge 0\\), let \\(a(n+2)\\) be the remainder of \\(4\\,a(n+1) + \\,a(n)\\) on division by 101. Then \\(f(n) = a(n)\\).\n\n## What to do\n\n`Solution.lean` in the working directory declares `f` with `sorry` as its body. Replace each `sorry` with a definition that matches the description above.\n\n- Keep the name and the type exactly as given. You may add helper definitions.\n- The definition must be computable: it is checked by running it on hidden inputs, so do not use `noncomputable` or classical choice.\n- Check that the file compiles with `lake env lean Solution.lean` (run it inside `/opt/arena/lean`, giving the full path to the file), and test your definition with `#eval`.\n- The reward is 1 if the definition agrees with the description on every hidden input, and 0 otherwise.\n\n## Examples\n\n- \\(f(3) = 97\\)\n- \\(f(10) = 15\\)\n- \\(f(17) = 1\\)\n- \\(f(24) = 49\\)\n", "start_file": "import Mathlib\n\ndef f (n : ℕ) : ℕ := sorry\n", "path": "tasks/definitions/definitions-sequence-d1-e0022"}
24
+ {"id": "definitions-sum-d1-e0023", "env": "definitions", "msc": "11", "family": "sum", "difficulty": 1, "seed": 10023, "kind": "define", "instruction": "# Define a function from its description\n\nDefine the function \\(f\\) from the natural numbers (including 0) to the natural numbers as follows.\n\n\\(f(n)\\) is the sum of \\(k\\) over all integers \\(k\\) with \\(1 \\le k \\le n\\) such that \\(k\\) is a perfect square. An empty sum is 0.\n\n## What to do\n\n`Solution.lean` in the working directory declares `f` with `sorry` as its body. Replace each `sorry` with a definition that matches the description above.\n\n- Keep the name and the type exactly as given. You may add helper definitions.\n- The definition must be computable: it is checked by running it on hidden inputs, so do not use `noncomputable` or classical choice.\n- Check that the file compiles with `lake env lean Solution.lean` (run it inside `/opt/arena/lean`, giving the full path to the file), and test your definition with `#eval`.\n- The reward is 1 if the definition agrees with the description on every hidden input, and 0 otherwise.\n\n## Examples\n\n- \\(f(3) = 1\\)\n- \\(f(10) = 14\\)\n- \\(f(17) = 30\\)\n- \\(f(24) = 30\\)\n", "start_file": "import Mathlib\n\ndef f (n : ℕ) : ℕ := sorry\n", "path": "tasks/definitions/definitions-sum-d1-e0023"}
data/definitions/train.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
data/finite-sums/eval.jsonl ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {"id": "finite-sums-geometric-d1-e0000", "env": "finite-sums", "msc": "40", "family": "geometric", "difficulty": 1, "seed": 10000, "kind": "prove", "instruction": "# Prove a closed form for a finite sum\n\nProve the following identity.\n\nFor every natural number \\(n\\), \\[8 \\sum_{i=0}^{n-1} 9^{i} = 1\\left(9^{n} - 1\\right).\\] The sum is over the integers and is empty when \\(n = 0\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The closed form stated in the task. -/\ntheorem sum_closed_form (n : ℕ) :\n (8 : ℤ) * ∑ i ∈ Finset.range n, (9 : ℤ) ^ i = 1 * ((9 : ℤ) ^ n - 1) := by\n sorry\n", "path": "tasks/finite-sums/finite-sums-geometric-d1-e0000"}
2
+ {"id": "finite-sums-polynomial-d1-e0001", "env": "finite-sums", "msc": "40", "family": "polynomial", "difficulty": 1, "seed": 10001, "kind": "prove", "instruction": "# Prove a closed form for a finite sum\n\nProve the following identity.\n\nFor every natural number \\(n\\), \\[\\sum_{i=0}^{n} \\left(4i + 4\\right) = 4 \\cdot \\frac{n(n+1)}{2} + 4 \\cdot (n+1).\\]\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The closed form stated in the task. -/\ntheorem sum_closed_form (n : ℕ) :\n ∑ i ∈ Finset.range (n + 1), (4 * (i : ℚ) + 4) = 4 * ((n : ℚ) * ((n : ℚ) + 1) / 2) + 4 * (((n : ℚ) + 1)) := by\n sorry\n", "path": "tasks/finite-sums/finite-sums-polynomial-d1-e0001"}
3
+ {"id": "finite-sums-telescoping-d1-e0002", "env": "finite-sums", "msc": "40", "family": "telescoping", "difficulty": 1, "seed": 10002, "kind": "prove", "instruction": "# Prove a closed form for a finite sum\n\nProve the following identity.\n\nFor every natural number \\(n\\), \\[\\sum_{i=0}^{n-1} \\frac{1}{(i+2)(i+3)} = \\frac{n}{2(n+2)}.\\] The sum is over the rationals and is empty when \\(n = 0\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The closed form stated in the task. -/\ntheorem sum_closed_form (n : ℕ) :\n ∑ i ∈ Finset.range n, (1 : ℚ) / (((i : ℚ) + 2) * ((i : ℚ) + 3)) = 1 * (n : ℚ) / (2 * ((n : ℚ) + 2)) := by\n sorry\n", "path": "tasks/finite-sums/finite-sums-telescoping-d1-e0002"}
4
+ {"id": "finite-sums-geometric-d2-e0003", "env": "finite-sums", "msc": "40", "family": "geometric", "difficulty": 2, "seed": 10003, "kind": "prove", "instruction": "# Prove a closed form for a finite sum\n\nProve the following identity.\n\nFor every natural number \\(n\\), \\[5 \\sum_{i=0}^{n-1} 5 \\cdot 6^{i} = 5\\left(6^{n} - 1\\right).\\] The sum is over the integers and is empty when \\(n = 0\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The closed form stated in the task. -/\ntheorem sum_closed_form (n : ℕ) :\n (5 : ℤ) * ∑ i ∈ Finset.range n, 5 * (6 : ℤ) ^ i = 5 * ((6 : ℤ) ^ n - 1) := by\n sorry\n", "path": "tasks/finite-sums/finite-sums-geometric-d2-e0003"}
5
+ {"id": "finite-sums-polynomial-d2-e0004", "env": "finite-sums", "msc": "40", "family": "polynomial", "difficulty": 2, "seed": 10004, "kind": "prove", "instruction": "# Prove a closed form for a finite sum\n\nProve the following identity.\n\nFor every natural number \\(n\\), \\[\\sum_{i=0}^{n} \\left(4i^2 - 4i\\right) = 4 \\cdot \\frac{n(n+1)(2n+1)}{6} - 4 \\cdot \\frac{n(n+1)}{2}.\\]\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The closed form stated in the task. -/\ntheorem sum_closed_form (n : ℕ) :\n ∑ i ∈ Finset.range (n + 1), (4 * (i : ℚ) ^ 2 + -4 * (i : ℚ)) = 4 * ((n : ℚ) * ((n : ℚ) + 1) * (2 * (n : ℚ) + 1) / 6) + -4 * ((n : ℚ) * ((n : ℚ) + 1) / 2) := by\n sorry\n", "path": "tasks/finite-sums/finite-sums-polynomial-d2-e0004"}
6
+ {"id": "finite-sums-telescoping-d2-e0005", "env": "finite-sums", "msc": "40", "family": "telescoping", "difficulty": 2, "seed": 10005, "kind": "prove", "instruction": "# Prove a closed form for a finite sum\n\nProve the following identity.\n\nFor every natural number \\(n\\), \\[\\sum_{i=0}^{n-1} \\frac{1}{(i+4)(i+5)} = \\frac{n}{4(n+4)}.\\] The sum is over the rationals and is empty when \\(n = 0\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The closed form stated in the task. -/\ntheorem sum_closed_form (n : ℕ) :\n ∑ i ∈ Finset.range n, (1 : ℚ) / (((i : ℚ) + 4) * ((i : ℚ) + 5)) = 1 * (n : ℚ) / (4 * ((n : ℚ) + 4)) := by\n sorry\n", "path": "tasks/finite-sums/finite-sums-telescoping-d2-e0005"}
7
+ {"id": "finite-sums-geometric-d3-e0006", "env": "finite-sums", "msc": "40", "family": "geometric", "difficulty": 3, "seed": 10006, "kind": "prove", "instruction": "# Prove a closed form for a finite sum\n\nProve the following identity.\n\nFor every natural number \\(n\\), \\[4 \\sum_{i=0}^{n-1} 8 \\cdot 5^{i+1} = 40\\left(5^{n} - 1\\right).\\] The sum is over the integers and is empty when \\(n = 0\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The closed form stated in the task. -/\ntheorem sum_closed_form (n : ℕ) :\n (4 : ℤ) * ∑ i ∈ Finset.range n, 8 * (5 : ℤ) ^ (i + 1) = 40 * ((5 : ℤ) ^ n - 1) := by\n sorry\n", "path": "tasks/finite-sums/finite-sums-geometric-d3-e0006"}
8
+ {"id": "finite-sums-polynomial-d3-e0007", "env": "finite-sums", "msc": "40", "family": "polynomial", "difficulty": 3, "seed": 10007, "kind": "prove", "instruction": "# Prove a closed form for a finite sum\n\nProve the following identity.\n\nFor every natural number \\(n\\), \\[\\sum_{i=0}^{n} \\left(3i^3 + 3i^2 + i - 4\\right) = 3 \\cdot \\frac{n^2(n+1)^2}{4} + 3 \\cdot \\frac{n(n+1)(2n+1)}{6} + 1 \\cdot \\frac{n(n+1)}{2} - 4 \\cdot (n+1).\\]\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The closed form stated in the task. -/\ntheorem sum_closed_form (n : ℕ) :\n ∑ i ∈ Finset.range (n + 1), (3 * (i : ℚ) ^ 3 + 3 * (i : ℚ) ^ 2 + (i : ℚ) + -4) = 3 * ((n : ℚ) ^ 2 * ((n : ℚ) + 1) ^ 2 / 4) + 3 * ((n : ℚ) * ((n : ℚ) + 1) * (2 * (n : ℚ) + 1) / 6) + 1 * ((n : ℚ) * ((n : ℚ) + 1) / 2) + -4 * (((n : ℚ) + 1)) := by\n sorry\n", "path": "tasks/finite-sums/finite-sums-polynomial-d3-e0007"}
9
+ {"id": "finite-sums-telescoping-d3-e0008", "env": "finite-sums", "msc": "40", "family": "telescoping", "difficulty": 3, "seed": 10008, "kind": "prove", "instruction": "# Prove a closed form for a finite sum\n\nProve the following identity.\n\nFor every natural number \\(n\\), \\[\\sum_{i=0}^{n-1} \\frac{7}{(i+7)(i+8)} = \\frac{7n}{7(n+7)}.\\] The sum is over the rationals and is empty when \\(n = 0\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The closed form stated in the task. -/\ntheorem sum_closed_form (n : ℕ) :\n ∑ i ∈ Finset.range n, (7 : ℚ) / (((i : ℚ) + 7) * ((i : ℚ) + 8)) = 7 * (n : ℚ) / (7 * ((n : ℚ) + 7)) := by\n sorry\n", "path": "tasks/finite-sums/finite-sums-telescoping-d3-e0008"}
10
+ {"id": "finite-sums-geometric-d1-e0009", "env": "finite-sums", "msc": "40", "family": "geometric", "difficulty": 1, "seed": 10009, "kind": "prove", "instruction": "# Prove a closed form for a finite sum\n\nProve the following identity.\n\nFor every natural number \\(n\\), \\[2 \\sum_{i=0}^{n-1} 2 \\cdot 3^{i} = 2\\left(3^{n} - 1\\right).\\] The sum is over the integers and is empty when \\(n = 0\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The closed form stated in the task. -/\ntheorem sum_closed_form (n : ℕ) :\n (2 : ℤ) * ∑ i ∈ Finset.range n, 2 * (3 : ℤ) ^ i = 2 * ((3 : ℤ) ^ n - 1) := by\n sorry\n", "path": "tasks/finite-sums/finite-sums-geometric-d1-e0009"}
11
+ {"id": "finite-sums-polynomial-d1-e0010", "env": "finite-sums", "msc": "40", "family": "polynomial", "difficulty": 1, "seed": 10010, "kind": "prove", "instruction": "# Prove a closed form for a finite sum\n\nProve the following identity.\n\nFor every natural number \\(n\\), \\[\\sum_{i=0}^{n} \\left(i - 3\\right) = 1 \\cdot \\frac{n(n+1)}{2} - 3 \\cdot (n+1).\\]\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The closed form stated in the task. -/\ntheorem sum_closed_form (n : ℕ) :\n ∑ i ∈ Finset.range (n + 1), ((i : ℚ) + -3) = 1 * ((n : ℚ) * ((n : ℚ) + 1) / 2) + -3 * (((n : ℚ) + 1)) := by\n sorry\n", "path": "tasks/finite-sums/finite-sums-polynomial-d1-e0010"}
12
+ {"id": "finite-sums-telescoping-d1-e0011", "env": "finite-sums", "msc": "40", "family": "telescoping", "difficulty": 1, "seed": 10011, "kind": "prove", "instruction": "# Prove a closed form for a finite sum\n\nProve the following identity.\n\nFor every natural number \\(n\\), \\[\\sum_{i=0}^{n-1} \\frac{1}{(i+2)(i+3)} = \\frac{n}{2(n+2)}.\\] The sum is over the rationals and is empty when \\(n = 0\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The closed form stated in the task. -/\ntheorem sum_closed_form (n : ℕ) :\n ∑ i ∈ Finset.range n, (1 : ℚ) / (((i : ℚ) + 2) * ((i : ℚ) + 3)) = 1 * (n : ℚ) / (2 * ((n : ℚ) + 2)) := by\n sorry\n", "path": "tasks/finite-sums/finite-sums-telescoping-d1-e0011"}
13
+ {"id": "finite-sums-geometric-d2-e0012", "env": "finite-sums", "msc": "40", "family": "geometric", "difficulty": 2, "seed": 10012, "kind": "prove", "instruction": "# Prove a closed form for a finite sum\n\nProve the following identity.\n\nFor every natural number \\(n\\), \\[6 \\sum_{i=0}^{n-1} 9 \\cdot 7^{i} = 9\\left(7^{n} - 1\\right).\\] The sum is over the integers and is empty when \\(n = 0\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The closed form stated in the task. -/\ntheorem sum_closed_form (n : ℕ) :\n (6 : ℤ) * ∑ i ∈ Finset.range n, 9 * (7 : ℤ) ^ i = 9 * ((7 : ℤ) ^ n - 1) := by\n sorry\n", "path": "tasks/finite-sums/finite-sums-geometric-d2-e0012"}
14
+ {"id": "finite-sums-polynomial-d2-e0013", "env": "finite-sums", "msc": "40", "family": "polynomial", "difficulty": 2, "seed": 10013, "kind": "prove", "instruction": "# Prove a closed form for a finite sum\n\nProve the following identity.\n\nFor every natural number \\(n\\), \\[\\sum_{i=0}^{n} \\left(i^2 - 2i + 3\\right) = 1 \\cdot \\frac{n(n+1)(2n+1)}{6} - 2 \\cdot \\frac{n(n+1)}{2} + 3 \\cdot (n+1).\\]\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The closed form stated in the task. -/\ntheorem sum_closed_form (n : ℕ) :\n ∑ i ∈ Finset.range (n + 1), ((i : ℚ) ^ 2 + -2 * (i : ℚ) + 3) = 1 * ((n : ℚ) * ((n : ℚ) + 1) * (2 * (n : ℚ) + 1) / 6) + -2 * ((n : ℚ) * ((n : ℚ) + 1) / 2) + 3 * (((n : ℚ) + 1)) := by\n sorry\n", "path": "tasks/finite-sums/finite-sums-polynomial-d2-e0013"}
15
+ {"id": "finite-sums-telescoping-d2-e0014", "env": "finite-sums", "msc": "40", "family": "telescoping", "difficulty": 2, "seed": 10014, "kind": "prove", "instruction": "# Prove a closed form for a finite sum\n\nProve the following identity.\n\nFor every natural number \\(n\\), \\[\\sum_{i=0}^{n-1} \\frac{2}{(i+2)(i+3)} = \\frac{2n}{2(n+2)}.\\] The sum is over the rationals and is empty when \\(n = 0\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The closed form stated in the task. -/\ntheorem sum_closed_form (n : ℕ) :\n ∑ i ∈ Finset.range n, (2 : ℚ) / (((i : ℚ) + 2) * ((i : ℚ) + 3)) = 2 * (n : ℚ) / (2 * ((n : ℚ) + 2)) := by\n sorry\n", "path": "tasks/finite-sums/finite-sums-telescoping-d2-e0014"}
16
+ {"id": "finite-sums-geometric-d3-e0015", "env": "finite-sums", "msc": "40", "family": "geometric", "difficulty": 3, "seed": 10015, "kind": "prove", "instruction": "# Prove a closed form for a finite sum\n\nProve the following identity.\n\nFor every natural number \\(n\\), \\[6 \\sum_{i=0}^{n-1} 7^{i+2} = 49\\left(7^{n} - 1\\right).\\] The sum is over the integers and is empty when \\(n = 0\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The closed form stated in the task. -/\ntheorem sum_closed_form (n : ℕ) :\n (6 : ℤ) * ∑ i ∈ Finset.range n, (7 : ℤ) ^ (i + 2) = 49 * ((7 : ℤ) ^ n - 1) := by\n sorry\n", "path": "tasks/finite-sums/finite-sums-geometric-d3-e0015"}
17
+ {"id": "finite-sums-polynomial-d3-e0016", "env": "finite-sums", "msc": "40", "family": "polynomial", "difficulty": 3, "seed": 10016, "kind": "prove", "instruction": "# Prove a closed form for a finite sum\n\nProve the following identity.\n\nFor every natural number \\(n\\), \\[\\sum_{i=0}^{n} \\left(4i^3 - i^2 + 4i + 1\\right) = 4 \\cdot \\frac{n^2(n+1)^2}{4} - 1 \\cdot \\frac{n(n+1)(2n+1)}{6} + 4 \\cdot \\frac{n(n+1)}{2} + 1 \\cdot (n+1).\\]\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The closed form stated in the task. -/\ntheorem sum_closed_form (n : ℕ) :\n ∑ i ∈ Finset.range (n + 1), (4 * (i : ℚ) ^ 3 + -1 * (i : ℚ) ^ 2 + 4 * (i : ℚ) + 1) = 4 * ((n : ℚ) ^ 2 * ((n : ℚ) + 1) ^ 2 / 4) + -1 * ((n : ℚ) * ((n : ℚ) + 1) * (2 * (n : ℚ) + 1) / 6) + 4 * ((n : ℚ) * ((n : ℚ) + 1) / 2) + 1 * (((n : ℚ) + 1)) := by\n sorry\n", "path": "tasks/finite-sums/finite-sums-polynomial-d3-e0016"}
18
+ {"id": "finite-sums-telescoping-d3-e0017", "env": "finite-sums", "msc": "40", "family": "telescoping", "difficulty": 3, "seed": 10017, "kind": "prove", "instruction": "# Prove a closed form for a finite sum\n\nProve the following identity.\n\nFor every natural number \\(n\\), \\[\\sum_{i=0}^{n-1} \\frac{7}{(i+4)(i+5)} = \\frac{7n}{4(n+4)}.\\] The sum is over the rationals and is empty when \\(n = 0\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The closed form stated in the task. -/\ntheorem sum_closed_form (n : ℕ) :\n ∑ i ∈ Finset.range n, (7 : ℚ) / (((i : ℚ) + 4) * ((i : ℚ) + 5)) = 7 * (n : ℚ) / (4 * ((n : ℚ) + 4)) := by\n sorry\n", "path": "tasks/finite-sums/finite-sums-telescoping-d3-e0017"}
19
+ {"id": "finite-sums-geometric-d1-e0018", "env": "finite-sums", "msc": "40", "family": "geometric", "difficulty": 1, "seed": 10018, "kind": "prove", "instruction": "# Prove a closed form for a finite sum\n\nProve the following identity.\n\nFor every natural number \\(n\\), \\[2 \\sum_{i=0}^{n-1} 3^{i} = 1\\left(3^{n} - 1\\right).\\] The sum is over the integers and is empty when \\(n = 0\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The closed form stated in the task. -/\ntheorem sum_closed_form (n : ℕ) :\n (2 : ℤ) * ∑ i ∈ Finset.range n, (3 : ℤ) ^ i = 1 * ((3 : ℤ) ^ n - 1) := by\n sorry\n", "path": "tasks/finite-sums/finite-sums-geometric-d1-e0018"}
20
+ {"id": "finite-sums-polynomial-d1-e0019", "env": "finite-sums", "msc": "40", "family": "polynomial", "difficulty": 1, "seed": 10019, "kind": "prove", "instruction": "# Prove a closed form for a finite sum\n\nProve the following identity.\n\nFor every natural number \\(n\\), \\[\\sum_{i=0}^{n} \\left(5i - 1\\right) = 5 \\cdot \\frac{n(n+1)}{2} - 1 \\cdot (n+1).\\]\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The closed form stated in the task. -/\ntheorem sum_closed_form (n : ℕ) :\n ∑ i ∈ Finset.range (n + 1), (5 * (i : ℚ) + -1) = 5 * ((n : ℚ) * ((n : ℚ) + 1) / 2) + -1 * (((n : ℚ) + 1)) := by\n sorry\n", "path": "tasks/finite-sums/finite-sums-polynomial-d1-e0019"}
21
+ {"id": "finite-sums-telescoping-d1-e0020", "env": "finite-sums", "msc": "40", "family": "telescoping", "difficulty": 1, "seed": 10020, "kind": "prove", "instruction": "# Prove a closed form for a finite sum\n\nProve the following identity.\n\nFor every natural number \\(n\\), \\[\\sum_{i=0}^{n-1} \\frac{1}{(i+2)(i+3)} = \\frac{n}{2(n+2)}.\\] The sum is over the rationals and is empty when \\(n = 0\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The closed form stated in the task. -/\ntheorem sum_closed_form (n : ℕ) :\n ∑ i ∈ Finset.range n, (1 : ℚ) / (((i : ℚ) + 2) * ((i : ℚ) + 3)) = 1 * (n : ℚ) / (2 * ((n : ℚ) + 2)) := by\n sorry\n", "path": "tasks/finite-sums/finite-sums-telescoping-d1-e0020"}
22
+ {"id": "finite-sums-geometric-d2-e0021", "env": "finite-sums", "msc": "40", "family": "geometric", "difficulty": 2, "seed": 10021, "kind": "prove", "instruction": "# Prove a closed form for a finite sum\n\nProve the following identity.\n\nFor every natural number \\(n\\), \\[2 \\sum_{i=0}^{n-1} 9 \\cdot 3^{i} = 9\\left(3^{n} - 1\\right).\\] The sum is over the integers and is empty when \\(n = 0\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The closed form stated in the task. -/\ntheorem sum_closed_form (n : ℕ) :\n (2 : ℤ) * ∑ i ∈ Finset.range n, 9 * (3 : ℤ) ^ i = 9 * ((3 : ℤ) ^ n - 1) := by\n sorry\n", "path": "tasks/finite-sums/finite-sums-geometric-d2-e0021"}
23
+ {"id": "finite-sums-polynomial-d2-e0022", "env": "finite-sums", "msc": "40", "family": "polynomial", "difficulty": 2, "seed": 10022, "kind": "prove", "instruction": "# Prove a closed form for a finite sum\n\nProve the following identity.\n\nFor every natural number \\(n\\), \\[\\sum_{i=0}^{n} \\left(5i^2 - i + 4\\right) = 5 \\cdot \\frac{n(n+1)(2n+1)}{6} - 1 \\cdot \\frac{n(n+1)}{2} + 4 \\cdot (n+1).\\]\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The closed form stated in the task. -/\ntheorem sum_closed_form (n : ℕ) :\n ∑ i ∈ Finset.range (n + 1), (5 * (i : ℚ) ^ 2 + -1 * (i : ℚ) + 4) = 5 * ((n : ℚ) * ((n : ℚ) + 1) * (2 * (n : ℚ) + 1) / 6) + -1 * ((n : ℚ) * ((n : ℚ) + 1) / 2) + 4 * (((n : ℚ) + 1)) := by\n sorry\n", "path": "tasks/finite-sums/finite-sums-polynomial-d2-e0022"}
24
+ {"id": "finite-sums-telescoping-d2-e0023", "env": "finite-sums", "msc": "40", "family": "telescoping", "difficulty": 2, "seed": 10023, "kind": "prove", "instruction": "# Prove a closed form for a finite sum\n\nProve the following identity.\n\nFor every natural number \\(n\\), \\[\\sum_{i=0}^{n-1} \\frac{1}{(i+6)(i+7)} = \\frac{n}{6(n+6)}.\\] The sum is over the rationals and is empty when \\(n = 0\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The closed form stated in the task. -/\ntheorem sum_closed_form (n : ℕ) :\n ∑ i ∈ Finset.range n, (1 : ℚ) / (((i : ℚ) + 6) * ((i : ℚ) + 7)) = 1 * (n : ℚ) / (6 * ((n : ℚ) + 6)) := by\n sorry\n", "path": "tasks/finite-sums/finite-sums-telescoping-d2-e0023"}
data/finite-sums/train.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
data/group-theory/eval.jsonl ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {"id": "group-theory-hom-d1-e0000", "env": "group-theory", "msc": "20", "family": "hom", "difficulty": 1, "seed": 10000, "kind": "prove", "instruction": "# Kernels of group homomorphisms\n\nProve the following statement.\n\nLet \\(f : G \\to H\\) be a group homomorphism and \\(x, y \\in G\\) with \\(f(x) = e\\). Then \\(y x y^{-1} x^{-1}\\) lies in the kernel of \\(f\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- Commutators with a kernel element lie in the kernel. -/\ntheorem commutator_in_kernel {G H : Type*} [Group G] [Group H] (f : G →* H) (x y : G)\n (hx : f x = 1) : y * x * y⁻¹ * x⁻¹ ∈ f.ker := by\n sorry\n", "path": "tasks/group-theory/group-theory-hom-d1-e0000"}
2
+ {"id": "group-theory-inverse-d1-e0001", "env": "group-theory", "msc": "20", "family": "inverse", "difficulty": 1, "seed": 10001, "kind": "prove", "instruction": "# Inverses and cancellation\n\nProve the following statement.\n\nLet \\(M\\) be a monoid and \\(g, k, m \\in M\\) with \\(g k = 1\\) and \\(m g = 1\\). Then \\(k = m\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- A left inverse and a right inverse of the same element are equal. -/\ntheorem inverses_agree {N : Type*} [Monoid N] (g k m : N)\n (h1 : m * g = 1) (h2 : g * k = 1) : k = m := by\n sorry\n", "path": "tasks/group-theory/group-theory-inverse-d1-e0001"}
3
+ {"id": "group-theory-involution-d1-e0002", "env": "group-theory", "msc": "20", "family": "involution", "difficulty": 1, "seed": 10002, "kind": "prove", "instruction": "# Commutativity from a group law\n\nProve the following statement.\n\nLet \\(G\\) be a group such that \\(g^{-1} = g \\text{ for every } g\\). Then \\(G\\) is commutative: \\(ab = ba\\) for all \\(a, b \\in G\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The stated consequence of the hypothesis on the group. -/\ntheorem group_commutes {Q : Type*} [Group Q] (h : ∀ g : Q, g⁻¹ = g) :\n ∀ g k : Q, g * k = k * g := by\n sorry\n", "path": "tasks/group-theory/group-theory-involution-d1-e0002"}
4
+ {"id": "group-theory-subgroup-d1-e0003", "env": "group-theory", "msc": "20", "family": "subgroup", "difficulty": 1, "seed": 10003, "kind": "prove", "instruction": "# Subgroups and their orders\n\nProve the following statement.\n\nLet \\(L\\) be a subgroup of a group \\(G\\) and let \\(p\\), \\(q\\), \\(r\\) lie in \\(L\\). Then \\(p^{-1} q^{-1} r \\in L\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- A product of elements of a subgroup, with inverses and powers, lies in the subgroup. -/\ntheorem product_mem {A : Type*} [Group A] (L : Subgroup A) {p q r : A}\n (hp : p ∈ L) (hq : q ∈ L) (hr : r ∈ L) : p⁻¹ * q⁻�� * r ∈ L := by\n sorry\n", "path": "tasks/group-theory/group-theory-subgroup-d1-e0003"}
5
+ {"id": "group-theory-hom-d2-e0004", "env": "group-theory", "msc": "20", "family": "hom", "difficulty": 2, "seed": 10004, "kind": "prove", "instruction": "# Kernels of group homomorphisms\n\nProve the following statement.\n\nLet \\(f : G \\to H\\) and \\(g : H \\to K\\) be group homomorphisms. Then every element of the kernel of \\(f\\) lies in the kernel of \\(g \\circ f\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The kernel of f lies in the kernel of g after f. -/\ntheorem ker_le_ker_comp {G K Z : Type*} [Group G] [Group K] [Group Z] (f : G →* K) (g : K →* Z) :\n f.ker ≤ (g.comp f).ker := by\n sorry\n", "path": "tasks/group-theory/group-theory-hom-d2-e0004"}
6
+ {"id": "group-theory-inverse-d2-e0005", "env": "group-theory", "msc": "20", "family": "inverse", "difficulty": 2, "seed": 10005, "kind": "prove", "instruction": "# Inverses and cancellation\n\nProve the following statement.\n\nLet \\(M\\) be a monoid and \\(x, y \\in M\\) with \\(x y = 1\\). Then \\(x^n y^n = 1\\) for every \\(n \\in \\mathbb{N}\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- If xy = 1 then x^n y^n = 1. -/\ntheorem pow_pair_one {M : Type*} [Monoid M] (x y : M) (h : x * y = 1) (n : ℕ) :\n x ^ n * y ^ n = 1 := by\n sorry\n", "path": "tasks/group-theory/group-theory-inverse-d2-e0005"}
7
+ {"id": "group-theory-involution-d2-e0006", "env": "group-theory", "msc": "20", "family": "involution", "difficulty": 2, "seed": 10006, "kind": "prove", "instruction": "# Commutativity from a group law\n\nProve the following statement.\n\nLet \\(G\\) be a group such that \\((ab)^2 = a^2 b^2 \\text{ for all } a, b\\). Then \\(a b a^{-1} = b\\) for all \\(a, b \\in G\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The stated consequence of the hypothesis on the group. -/\ntheorem group_commutes {G : Type*} [Group G] (h : ∀ u v : G, (u * v) ^ 2 = u ^ 2 * v ^ 2) :\n ∀ u v : G, u * v * u⁻¹ = v := by\n sorry\n", "path": "tasks/group-theory/group-theory-involution-d2-e0006"}
8
+ {"id": "group-theory-subgroup-d2-e0007", "env": "group-theory", "msc": "20", "family": "subgroup", "difficulty": 2, "seed": 10007, "kind": "prove", "instruction": "# Subgroups and their orders\n\nProve the following statement.\n\nLet \\(G\\) be a group with \\(|G| = 4\\) and \\(H\\) a subgroup of \\(G\\). Then \\(|H|\\) divides 4.\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- Lagrange: the order of a subgroup divides the order of the group. -/\ntheorem subgroup_card_dvd {A : Type*} [Group A] (hG : Nat.card A = 4) (H : Subgroup A) :\n Nat.card H ∣ 4 := by\n sorry\n", "path": "tasks/group-theory/group-theory-subgroup-d2-e0007"}
9
+ {"id": "group-theory-hom-d3-e0008", "env": "group-theory", "msc": "20", "family": "hom", "difficulty": 3, "seed": 10008, "kind": "prove", "instruction": "# Kernels of group homomorphisms\n\nProve the following statement.\n\nLet \\(f : G \\to H\\) be a group homomorphism such that \\(f(u) = e\\) implies \\(u = e\\) for every \\(u \\in G\\). Then \\(f\\) is injective.\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- A homomorphism with trivial kernel is injective. -/\ntheorem injective_of_trivial_kernel {X Y : Type*} [Group X] [Group Y] (f : X →* Y)\n (h : ∀ u : X, f u = 1 → u = 1) : Function.Injective f := by\n sorry\n", "path": "tasks/group-theory/group-theory-hom-d3-e0008"}
10
+ {"id": "group-theory-inverse-d3-e0009", "env": "group-theory", "msc": "20", "family": "inverse", "difficulty": 3, "seed": 10009, "kind": "prove", "instruction": "# Inverses and cancellation\n\nProve the following statement.\n\nLet \\(M\\) be a monoid in which every element \\(x\\) has some \\(y\\) with \\(xy = 1\\). Then \\(xy = 1\\) implies \\(yx = 1\\) for all \\(x, y \\in M\\). Under the same hypothesis, if \\(a b = 1\\) and \\(a c = 1\\) then \\(b = c\\).\n\n## What to do\n\n`Solution.lean` in the working directory states 2 theorems in Lean 4 with Mathlib, with `sorry` in place of each proof. Replace every `sorry` with a proof.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is the share of the 2 theorems that are proved. If the file does not compile the reward is 0, so leave `sorry` on a theorem you cannot finish rather than a broken proof.\n", "start_file": "import Mathlib\n\n/-- One-sided inverses are two-sided. -/\ntheorem right_inverse_comm {M : Type*} [Monoid M] (h : ∀ a : M, ∃ b, a * b = 1) :\n ∀ a b : M, a * b = 1 → b * a = 1 := by\n sorry\n\n/-- The inverse is unique. -/\ntheorem inverse_unique {M : Type*} [Monoid M] (h : ∀ a : M, ∃ b, a * b = 1) (a b c : M)\n (h1 : a * b = 1) (h2 : a * c = 1) : b = c := by\n sorry\n", "path": "tasks/group-theory/group-theory-inverse-d3-e0009"}
11
+ {"id": "group-theory-involution-d3-e0010", "env": "group-theory", "msc": "20", "family": "involution", "difficulty": 3, "seed": 10010, "kind": "prove", "instruction": "# Commutativity from a group law\n\nProve the following statement.\n\nLet \\(G\\) be a group such that \\((ab)^{-1} = a^{-1} b^{-1} \\text{ for all } a, b\\). Then every element of \\(G\\) lies in the center of \\(G\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The stated consequence of the hypothesis on the group. -/\ntheorem group_commutes {A : Type*} [Group A] (h : ∀ x y : A, (x * y)⁻¹ = x⁻¹ * y⁻¹) :\n ∀ z : A, z ∈ Subgroup.center A := by\n sorry\n", "path": "tasks/group-theory/group-theory-involution-d3-e0010"}
12
+ {"id": "group-theory-subgroup-d3-e0011", "env": "group-theory", "msc": "20", "family": "subgroup", "difficulty": 3, "seed": 10011, "kind": "prove", "instruction": "# Subgroups and their orders\n\nProve the following statement.\n\nLet \\(G\\) be a group with \\(|G| = 5\\). Then \\(x^{5} = e\\) for every \\(x \\in G\\), and every element \\(p \\neq e\\) has order exactly 5.\n\n## What to do\n\n`Solution.lean` in the working directory states 2 theorems in Lean 4 with Mathlib, with `sorry` in place of each proof. Replace every `sorry` with a proof.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is the share of the 2 theorems that are proved. If the file does not compile the reward is 0, so leave `sorry` on a theorem you cannot finish rather than a broken proof.\n", "start_file": "import Mathlib\n\n/-- Every element satisfies x^|G| = 1. -/\ntheorem pow_card {A : Type*} [Group A] (hG : Nat.card A = 5) (x : A) :\n x ^ 5 = 1 := by\n sorry\n\n/-- In a group of prime order p, every non-identity element has order p. -/\ntheorem order_prime {A : Type*} [Group A] (hG : Nat.card A = 5) (p : A) (hne : p ≠ 1) :\n orderOf p = 5 := by\n sorry\n", "path": "tasks/group-theory/group-theory-subgroup-d3-e0011"}
13
+ {"id": "group-theory-hom-d1-e0012", "env": "group-theory", "msc": "20", "family": "hom", "difficulty": 1, "seed": 10012, "kind": "prove", "instruction": "# Kernels of group homomorphisms\n\nProve the following statement.\n\nLet \\(f : G \\to H\\) be a group homomorphism and \\(a\\) an element of \\(G\\) with \\(f(a) = e\\). Then \\(f(a^{7}) = e\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- Powers of kernel elements are in the kernel. -/\ntheorem image_of_power {G H : Type*} [Group G] [Group H] (f : G →* H) (a : G)\n (hx : f a = 1) : f (a ^ 7) = 1 := by\n sorry\n", "path": "tasks/group-theory/group-theory-hom-d1-e0012"}
14
+ {"id": "group-theory-inverse-d1-e0013", "env": "group-theory", "msc": "20", "family": "inverse", "difficulty": 1, "seed": 10013, "kind": "prove", "instruction": "# Inverses and cancellation\n\nProve the following statement.\n\nLet \\(M\\) be a monoid and \\(a, b, c \\in M\\) with \\(a b = 1\\) and \\(c a = 1\\). Then \\(b = c\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- A left inverse and a right inverse of the same element are equal. -/\ntheorem inverses_agree {S : Type*} [Monoid S] (a b c : S)\n (h1 : a * b = 1) (h2 : c * a = 1) : b = c := by\n sorry\n", "path": "tasks/group-theory/group-theory-inverse-d1-e0013"}
15
+ {"id": "group-theory-involution-d1-e0014", "env": "group-theory", "msc": "20", "family": "involution", "difficulty": 1, "seed": 10014, "kind": "prove", "instruction": "# Commutativity from a group law\n\nProve the following statement.\n\nLet \\(G\\) be a group such that \\(g^{-1} = g \\text{ for every } g\\). Then \\(G\\) is commutative: \\(ab = ba\\) for all \\(a, b \\in G\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The stated consequence of the hypothesis on the group. -/\ntheorem group_commutes {A : Type*} [Group A] (h : ∀ g : A, g⁻¹ = g) :\n ∀ g k : A, g * k = k * g := by\n sorry\n", "path": "tasks/group-theory/group-theory-involution-d1-e0014"}
16
+ {"id": "group-theory-subgroup-d1-e0015", "env": "group-theory", "msc": "20", "family": "subgroup", "difficulty": 1, "seed": 10015, "kind": "prove", "instruction": "# Subgroups and their orders\n\nProve the following statement.\n\nLet \\(N\\) be a subgroup of a group \\(G\\) and let \\(x\\), \\(y\\) lie in \\(N\\). Then \\(x^{-1} y \\in N\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- A product of elements of a subgroup, with inverses and powers, lies in the subgroup. -/\ntheorem product_mem {G : Type*} [Group G] (N : Subgroup G) {x y : G}\n (hx : x ∈ N) (hy : y ∈ N) : x⁻¹ * y ∈ N := by\n sorry\n", "path": "tasks/group-theory/group-theory-subgroup-d1-e0015"}
17
+ {"id": "group-theory-hom-d2-e0016", "env": "group-theory", "msc": "20", "family": "hom", "difficulty": 2, "seed": 10016, "kind": "prove", "instruction": "# Kernels of group homomorphisms\n\nProve the following statement.\n\nLet \\(f : G \\to H\\) be a group homomorphism such that \\(f(a) = e\\) implies \\(a = e\\) for every \\(a \\in G\\). Then \\(f\\) is injective.\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- A homomorphism with trivial kernel is injective. -/\ntheorem injective_of_trivial_kernel {G H : Type*} [Group G] [Group H] (f : G →* H)\n (h : ∀ a : G, f a = 1 → a = 1) : Function.Injective f := by\n sorry\n", "path": "tasks/group-theory/group-theory-hom-d2-e0016"}
18
+ {"id": "group-theory-inverse-d2-e0017", "env": "group-theory", "msc": "20", "family": "inverse", "difficulty": 2, "seed": 10017, "kind": "prove", "instruction": "# Inverses and cancellation\n\nProve the following statement.\n\nLet \\(G\\) be a group and \\(g_{1}, g_{2}, g_{3}, g_{4}, g_{5}, g_{6} \\in G\\) with \\(g_{1} g_{2} g_{3} g_{4} g_{5} g_{6} = e\\). Then \\(g_{6} g_{1} g_{2} g_{3} g_{4} g_{5} = e\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- A product equal to the identity stays equal to the identity after a cyclic rotation. -/\ntheorem rotate_product {Q : Type*} [Group Q] (g₁ g₂ g₃ g₄ g₅ g₆ : Q)\n (h : g₁ * g₂ * g₃ * g₄ * g₅ * g₆ = 1) : g₆ * g₁ * g₂ * g₃ * g₄ * g₅ = 1 := by\n sorry\n", "path": "tasks/group-theory/group-theory-inverse-d2-e0017"}
19
+ {"id": "group-theory-involution-d2-e0018", "env": "group-theory", "msc": "20", "family": "involution", "difficulty": 2, "seed": 10018, "kind": "prove", "instruction": "# Commutativity from a group law\n\nProve the following statement.\n\nLet \\(G\\) be a group such that \\((ab)^2 = a^2 b^2 \\text{ for all } a, b\\). Then every element of \\(G\\) lies in the center of \\(G\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The stated consequence of the hypothesis on the group. -/\ntheorem group_commutes {A : Type*} [Group A] (h : ∀ p q : A, (p * q) ^ 2 = p ^ 2 * q ^ 2) :\n ∀ z : A, z ∈ Subgroup.center A := by\n sorry\n", "path": "tasks/group-theory/group-theory-involution-d2-e0018"}
20
+ {"id": "group-theory-subgroup-d2-e0019", "env": "group-theory", "msc": "20", "family": "subgroup", "difficulty": 2, "seed": 10019, "kind": "prove", "instruction": "# Subgroups and their orders\n\nProve the following statement.\n\nLet \\(N\\) be a normal subgroup of a group \\(G\\), let \\(p \\in N\\) and \\(q \\in G\\). Then \\(q p q^{-1} p^{-1} \\in N\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- Conjugates of elements of a normal subgroup stay in it. -/\ntheorem normal_conj {Q : Type*} [Group Q] (N : Subgroup Q) (hN : N.Normal) {p : Q} (hx : p ∈ N) (q : Q) :\n q * p * q⁻¹ * p⁻¹ ∈ N := by\n sorry\n", "path": "tasks/group-theory/group-theory-subgroup-d2-e0019"}
21
+ {"id": "group-theory-hom-d3-e0020", "env": "group-theory", "msc": "20", "family": "hom", "difficulty": 3, "seed": 10020, "kind": "prove", "instruction": "# Kernels of group homomorphisms\n\nProve the following statement.\n\nLet \\(f : G \\to H\\) be a group homomorphism such that \\(f(s) = e\\) implies \\(s = e\\) for every \\(s \\in G\\). Then \\(f\\) is injective.\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- A homomorphism with trivial kernel is injective. -/\ntheorem injective_of_trivial_kernel {G K : Type*} [Group G] [Group K] (f : G →* K)\n (h : ∀ s : G, f s = 1 → s = 1) : Function.Injective f := by\n sorry\n", "path": "tasks/group-theory/group-theory-hom-d3-e0020"}
22
+ {"id": "group-theory-inverse-d3-e0021", "env": "group-theory", "msc": "20", "family": "inverse", "difficulty": 3, "seed": 10021, "kind": "prove", "instruction": "# Inverses and cancellation\n\nProve the following statement.\n\nLet \\(M\\) be a monoid in which every element \\(x\\) has some \\(y\\) with \\(xy = 1\\). Then \\(xy = 1\\) implies \\(yx = 1\\) for all \\(x, y \\in M\\). Under the same hypothesis, if \\(x y = 1\\) and \\(x z = 1\\) then \\(y = z\\).\n\n## What to do\n\n`Solution.lean` in the working directory states 2 theorems in Lean 4 with Mathlib, with `sorry` in place of each proof. Replace every `sorry` with a proof.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is the share of the 2 theorems that are proved. If the file does not compile the reward is 0, so leave `sorry` on a theorem you cannot finish rather than a broken proof.\n", "start_file": "import Mathlib\n\n/-- One-sided inverses are two-sided. -/\ntheorem right_inverse_comm {S : Type*} [Monoid S] (h : ∀ x : S, ∃ y, x * y = 1) :\n ∀ x y : S, x * y = 1 → y * x = 1 := by\n sorry\n\n/-- The inverse is unique. -/\ntheorem inverse_unique {S : Type*} [Monoid S] (h : ∀ x : S, ∃ y, x * y = 1) (x y z : S)\n (h1 : x * y = 1) (h2 : x * z = 1) : y = z := by\n sorry\n", "path": "tasks/group-theory/group-theory-inverse-d3-e0021"}
23
+ {"id": "group-theory-involution-d3-e0022", "env": "group-theory", "msc": "20", "family": "involution", "difficulty": 3, "seed": 10022, "kind": "prove", "instruction": "# Commutativity from a group law\n\nProve the following statement.\n\nLet \\(G\\) be a group such that \\((ab)^{-1} = a^{-1} b^{-1} \\text{ for all } a, b\\). Then every element of \\(G\\) lies in the center of \\(G\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The stated consequence of the hypothesis on the group. -/\ntheorem group_commutes {G : Type*} [Group G] (h : ∀ u v : G, (u * v)⁻¹ = u⁻¹ * v⁻¹) :\n ∀ z : G, z ∈ Subgroup.center G := by\n sorry\n", "path": "tasks/group-theory/group-theory-involution-d3-e0022"}
24
+ {"id": "group-theory-subgroup-d3-e0023", "env": "group-theory", "msc": "20", "family": "subgroup", "difficulty": 3, "seed": 10023, "kind": "prove", "instruction": "# Subgroups and their orders\n\nProve the following statement.\n\nLet \\(G\\) be a group with \\(|G| = 63\\) and \\(L\\) a subgroup with \\(|L| = 9\\). Then \\(L\\) has index 7 in \\(G\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- Lagrange: the cardinality is the product of subgroup order and index. -/\ntheorem subgroup_index {A : Type*} [Group A] (hG : Nat.card A = 63) (L : Subgroup A) (hH : Nat.card L = 9) :\n L.index = 7 := by\n sorry\n", "path": "tasks/group-theory/group-theory-subgroup-d3-e0023"}
data/group-theory/train.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
data/inequalities/eval.jsonl ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {"id": "inequalities-abs_ineq-d1-e0000", "env": "inequalities", "msc": "26", "family": "abs_ineq", "difficulty": 1, "seed": 10000, "kind": "prove", "instruction": "# Prove an inequality over the reals\n\nLet \\(x\\) and \\(y\\) be real numbers with \\(|x - 6| \\le 2\\) and \\(|y - 7| \\le 1\\). Prove that \\(|x - 3y + 15| \\le 5\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- An error bound for a linear combination. -/\ntheorem abs_linear_bound (x y : ℝ) (hx : |x - 6| ≤ 2) (hy : |y - 7| ≤ 1) :\n |x - 3 * y + 15| ≤ 5 := by\n sorry\n", "path": "tasks/inequalities/inequalities-abs_ineq-d1-e0000"}
2
+ {"id": "inequalities-amgm-d1-e0001", "env": "inequalities", "msc": "26", "family": "amgm", "difficulty": 1, "seed": 10001, "kind": "prove", "instruction": "# Prove an inequality over the reals\n\nLet \\(a\\) and \\(b\\) be real numbers with \\(4a + 6b = 12\\). Prove that \\[24ab \\le \\frac{12^2}{4}.\\]\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The product is at most a quarter of the squared sum. -/\ntheorem amgm_constraint (a b : ℝ) (h : 4 * a + 6 * b = 12) :\n 24 * a * b ≤ 12 ^ 2 / 4 := by\n sorry\n", "path": "tasks/inequalities/inequalities-amgm-d1-e0001"}
3
+ {"id": "inequalities-cauchy-d1-e0002", "env": "inequalities", "msc": "26", "family": "cauchy", "difficulty": 1, "seed": 10002, "kind": "prove", "instruction": "# Prove an inequality over the reals\n\nProve that for all real numbers \\(x\\) and \\(y\\), \\[(10x + 8y)^2 \\le 164\\,(x^2 + y^2).\\]\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- A two-term Cauchy-Schwarz bound. -/\ntheorem cauchy_two (x y : ℝ) :\n (10 * x + 8 * y) ^ 2 ≤ 164 * (x ^ 2 + y ^ 2) := by\n sorry\n", "path": "tasks/inequalities/inequalities-cauchy-d1-e0002"}
4
+ {"id": "inequalities-monotone-d1-e0003", "env": "inequalities", "msc": "26", "family": "monotone", "difficulty": 1, "seed": 10003, "kind": "prove", "instruction": "# Prove an inequality over the reals\n\nProve that for all real numbers \\(x \\le y\\), \\[x^5 + 8\\,x \\le y^5 + 8\\,y.\\]\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The function is non-decreasing. -/\ntheorem monotone_sum (x y : ℝ) (h : x ≤ y) :\n x ^ 5 + 8 * x ≤ y ^ 5 + 8 * y := by\n sorry\n", "path": "tasks/inequalities/inequalities-monotone-d1-e0003"}
5
+ {"id": "inequalities-abs_ineq-d2-e0004", "env": "inequalities", "msc": "26", "family": "abs_ineq", "difficulty": 2, "seed": 10004, "kind": "prove", "instruction": "# Prove an inequality over the reals\n\nProve that for every real number \\(x\\), \\[9 \\le |x - 4| + |x - 13|.\\]\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The sum of two distances is at least p times the gap. -/\ntheorem abs_two_points (x : ℝ) :\n 9 ≤ |x - 4| + |x - 13| := by\n sorry\n", "path": "tasks/inequalities/inequalities-abs_ineq-d2-e0004"}
6
+ {"id": "inequalities-amgm-d2-e0005", "env": "inequalities", "msc": "26", "family": "amgm", "difficulty": 2, "seed": 10005, "kind": "prove", "instruction": "# Prove an inequality over the reals\n\nLet \\(a\\) and \\(b\\) be positive real numbers. Prove that \\[60 \\le 50\\frac{a}{b} + 18\\frac{b}{a}.\\]\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- A weighted sum of a ratio and its reciprocal is bounded below. -/\ntheorem amgm_ratio (a b : ℝ) (ha : 0 < a) (hb : 0 < b) :\n 60 ≤ 50 * (a / b) + 18 * (b / a) := by\n sorry\n", "path": "tasks/inequalities/inequalities-amgm-d2-e0005"}
7
+ {"id": "inequalities-cauchy-d2-e0006", "env": "inequalities", "msc": "26", "family": "cauchy", "difficulty": 2, "seed": 10006, "kind": "prove", "instruction": "# Prove an inequality over the reals\n\nLet \\(x\\) and \\(y\\) be real numbers with \\(x^2 + y^2 \\le 16\\). Prove that \\(8x + 15y \\le 68\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- A linear form is bounded on a disc by the Cauchy-Schwarz inequality. -/\ntheorem cauchy_bound_circle (x y : ℝ) (h : x ^ 2 + y ^ 2 ≤ 16) :\n 8 * x + 15 * y ≤ 68 := by\n sorry\n", "path": "tasks/inequalities/inequalities-cauchy-d2-e0006"}
8
+ {"id": "inequalities-monotone-d2-e0007", "env": "inequalities", "msc": "26", "family": "monotone", "difficulty": 2, "seed": 10007, "kind": "prove", "instruction": "# Prove an inequality over the reals\n\nProve that the function \\(f(x) = 5\\,e^{x} + 4\\,x^5\\) is monotone on the real numbers: \\(x \\le y\\) implies \\(f(x) \\le f(y)\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The function is monotone. -/\ntheorem monotone_function : Monotone (fun x : ℝ => 5 * Real.exp x + 4 * x ^ 5) := by\n sorry\n", "path": "tasks/inequalities/inequalities-monotone-d2-e0007"}
9
+ {"id": "inequalities-abs_ineq-d3-e0008", "env": "inequalities", "msc": "26", "family": "abs_ineq", "difficulty": 3, "seed": 10008, "kind": "prove", "instruction": "# Prove an inequality over the reals\n\nProve that for all real numbers \\(a \\le c\\) and \\(x\\), \\(c - a \\le |x - a| + |x - c|\\). Then prove that for every real \\(x\\), \\[11 \\le |x - 1| + |x - 6| + |x - 9| + |x - 9|.\\]\n\n## What to do\n\n`Solution.lean` in the working directory states 2 theorems in Lean 4 with Mathlib, with `sorry` in place of each proof. Replace every `sorry` with a proof.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is the share of the 2 theorems that are proved. If the file does not compile the reward is 0, so leave `sorry` on a theorem you cannot finish rather than a broken proof.\n", "start_file": "import Mathlib\n\n/-- The sum of the distances to two points is at least their gap. -/\ntheorem pair_abs_bound (x a c : ℝ) (h : a ≤ c) :\n c - a ≤ |x - a| + |x - c| := by\n sorry\n\n/-- The sum of four distances is bounded below. -/\ntheorem four_points_abs (x : ℝ) :\n 11 ≤ |x - 1| + |x - 6| + |x - 9| + |x - 9| := by\n sorry\n", "path": "tasks/inequalities/inequalities-abs_ineq-d3-e0008"}
10
+ {"id": "inequalities-amgm-d3-e0009", "env": "inequalities", "msc": "26", "family": "amgm", "difficulty": 3, "seed": 10009, "kind": "prove", "instruction": "# Prove an inequality over the reals\n\nProve that \\(27xyz \\le (x+y+z)^3\\) for all non-negative real numbers \\(x, y, z\\). Then prove that for all non-negative real numbers \\(a, b, c\\), \\[486\\,abc \\le (a + 3b + 6c)^3.\\]\n\n## What to do\n\n`Solution.lean` in the working directory states 2 theorems in Lean 4 with Mathlib, with `sorry` in place of each proof. Replace every `sorry` with a proof.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is the share of the 2 theorems that are proved. If the file does not compile the reward is 0, so leave `sorry` on a theorem you cannot finish rather than a broken proof.\n", "start_file": "import Mathlib\n\n/-- The three-variable AM-GM inequality in cubic form. -/\ntheorem amgm_three (x y z : ℝ) (hx : 0 ≤ x) (hy : 0 ≤ y) (hz : 0 ≤ z) :\n 27 * x * y * z ≤ (x + y + z) ^ 3 := by\n sorry\n\n/-- The scaled three-variable inequality. -/\ntheorem amgm_three_scaled (a b c : ℝ) (ha : 0 ≤ a) (hb : 0 ≤ b) (hc : 0 ≤ c) :\n 486 * a * b * c ≤ (a + 3 * b + 6 * c) ^ 3 := by\n sorry\n", "path": "tasks/inequalities/inequalities-amgm-d3-e0009"}
11
+ {"id": "inequalities-cauchy-d3-e0010", "env": "inequalities", "msc": "26", "family": "cauchy", "difficulty": 3, "seed": 10010, "kind": "prove", "instruction": "# Prove an inequality over the reals\n\nProve that for all real numbers \\(u, v, w, x, y, z\\), \\[(ux + vy + wz)^2 \\le (u^2 + v^2 + w^2)(x^2 + y^2 + z^2).\\] Then let \\(x, y, z\\) be real numbers with \\(x^2 + y^2 + z^2 \\le 4\\) and prove that \\(4x - 4y - 7z \\le 18\\).\n\n## What to do\n\n`Solution.lean` in the working directory states 2 theorems in Lean 4 with Mathlib, with `sorry` in place of each proof. Replace every `sorry` with a proof.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is the share of the 2 theorems that are proved. If the file does not compile the reward is 0, so leave `sorry` on a theorem you cannot finish rather than a broken proof.\n", "start_file": "import Mathlib\n\n/-- Cauchy-Schwarz for three-term sums. -/\ntheorem cauchy_three (u v w x y z : ℝ) :\n (u * x + v * y + w * z) ^ 2 ≤ (u ^ 2 + v ^ 2 + w ^ 2) * (x ^ 2 + y ^ 2 + z ^ 2) := by\n sorry\n\n/-- A linear form is bounded on a ball. -/\ntheorem cauchy_bound_ball (x y z : ℝ) (h : x ^ 2 + y ^ 2 + z ^ 2 ≤ 4) :\n 4 * x - 4 * y - 7 * z ≤ 18 := by\n sorry\n", "path": "tasks/inequalities/inequalities-cauchy-d3-e0010"}
12
+ {"id": "inequalities-monotone-d3-e0011", "env": "inequalities", "msc": "26", "family": "monotone", "difficulty": 3, "seed": 10011, "kind": "prove", "instruction": "# Prove an inequality over the reals\n\nProve that \\(0 \\le \\ln(1 + y^2) - \\ln(1 + x^2)\\) for real numbers \\(0 < x \\le y\\). Then prove that for such \\(x, y\\), \\[0 \\le \\left(\\sqrt{y} + \\sinh y + 2\\,y^5 + 2\\,\\ln y + \\ln(1 + y^2)\\right) - \\left(\\sqrt{x} + \\sinh x + 2\\,x^5 + 2\\,\\ln x + \\ln(1 + x^2)\\right).\\]\n\n## What to do\n\n`Solution.lean` in the working directory states 2 theorems in Lean 4 with Mathlib, with `sorry` in place of each proof. Replace every `sorry` with a proof.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is the share of the 2 theorems that are proved. If the file does not compile the reward is 0, so leave `sorry` on a theorem you cannot finish rather than a broken proof.\n", "start_file": "import Mathlib\n\n/-- The logarithm of one plus a square is increasing on the positive reals. -/\ntheorem log_one_add_sq_mono (x y : ℝ) (hx : 0 < x) (h : x ≤ y) :\n 0 ≤ Real.log (1 + y ^ 2) - Real.log (1 + x ^ 2) := by\n sorry\n\n/-- The combination is non-decreasing on the positive reals. -/\ntheorem monotone_combination (x y : ℝ) (hx : 0 < x) (h : x ≤ y) :\n 0 ≤ (Real.sqrt y + Real.sinh y + 2 * y ^ 5 + 2 * Real.log y + Real.log (1 + y ^ 2)) - (Real.sqrt x + Real.sinh x + 2 * x ^ 5 + 2 * Real.log x + Real.log (1 + x ^ 2)) := by\n sorry\n", "path": "tasks/inequalities/inequalities-monotone-d3-e0011"}
13
+ {"id": "inequalities-abs_ineq-d1-e0012", "env": "inequalities", "msc": "26", "family": "abs_ineq", "difficulty": 1, "seed": 10012, "kind": "prove", "instruction": "# Prove an inequality over the reals\n\nLet \\(x\\) and \\(y\\) be real numbers with \\(|x + 1| \\le 5\\) and \\(|y - 8| \\le 1\\). Prove that \\(|6x - y + 14| \\le 31\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- An error bound for a linear combination. -/\ntheorem abs_linear_bound (x y : ℝ) (hx : |x + 1| ≤ 5) (hy : |y - 8| ≤ 1) :\n |6 * x - y + 14| ≤ 31 := by\n sorry\n", "path": "tasks/inequalities/inequalities-abs_ineq-d1-e0012"}
14
+ {"id": "inequalities-amgm-d1-e0013", "env": "inequalities", "msc": "26", "family": "amgm", "difficulty": 1, "seed": 10013, "kind": "prove", "instruction": "# Prove an inequality over the reals\n\nProve that for all real numbers \\(a\\) and \\(b\\), \\[108\\,ab \\le (9a + 3b)^2.\\]\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- A square-completion bound for two real numbers. -/\ntheorem two_var_amgm (a b : ℝ) :\n 108 * a * b ≤ (9 * a + 3 * b) ^ 2 := by\n sorry\n", "path": "tasks/inequalities/inequalities-amgm-d1-e0013"}
15
+ {"id": "inequalities-cauchy-d1-e0014", "env": "inequalities", "msc": "26", "family": "cauchy", "difficulty": 1, "seed": 10014, "kind": "prove", "instruction": "# Prove an inequality over the reals\n\nProve that for all real numbers \\(x\\) and \\(y\\), \\[(9x + 4y)^2 \\le 97\\,(x^2 + y^2).\\]\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- A two-term Cauchy-Schwarz bound. -/\ntheorem cauchy_two (x y : ℝ) :\n (9 * x + 4 * y) ^ 2 ≤ 97 * (x ^ 2 + y ^ 2) := by\n sorry\n", "path": "tasks/inequalities/inequalities-cauchy-d1-e0014"}
16
+ {"id": "inequalities-monotone-d1-e0015", "env": "inequalities", "msc": "26", "family": "monotone", "difficulty": 1, "seed": 10015, "kind": "prove", "instruction": "# Prove an inequality over the reals\n\nProve that for all real numbers \\(x \\le y\\), \\[2\\,e^{x} \\le 2\\,e^{y}.\\]\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The function is non-decreasing. -/\ntheorem monotone_sum (x y : ℝ) (h : x ≤ y) :\n 2 * Real.exp x ≤ 2 * Real.exp y := by\n sorry\n", "path": "tasks/inequalities/inequalities-monotone-d1-e0015"}
17
+ {"id": "inequalities-abs_ineq-d2-e0016", "env": "inequalities", "msc": "26", "family": "abs_ineq", "difficulty": 2, "seed": 10016, "kind": "prove", "instruction": "# Prove an inequality over the reals\n\nProve that for every real number \\(x\\), \\[12 \\le 3|x - 5| + 3|x - 9|.\\]\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The sum of two distances is at least p times the gap. -/\ntheorem abs_two_points (x : ℝ) :\n 12 ≤ 3 * |x - 5| + 3 * |x - 9| := by\n sorry\n", "path": "tasks/inequalities/inequalities-abs_ineq-d2-e0016"}
18
+ {"id": "inequalities-amgm-d2-e0017", "env": "inequalities", "msc": "26", "family": "amgm", "difficulty": 2, "seed": 10017, "kind": "prove", "instruction": "# Prove an inequality over the reals\n\nLet \\(x\\) be a positive real number. Prove that \\[24 \\le 8x + \\frac{18}{x}.\\]\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The sum of a linear term and an inverse term is bounded below. -/\ntheorem amgm_linear_plus_inverse (x : ℝ) (hx : 0 < x) :\n 24 ≤ 8 * x + 18 / x := by\n sorry\n", "path": "tasks/inequalities/inequalities-amgm-d2-e0017"}
19
+ {"id": "inequalities-cauchy-d2-e0018", "env": "inequalities", "msc": "26", "family": "cauchy", "difficulty": 2, "seed": 10018, "kind": "prove", "instruction": "# Prove an inequality over the reals\n\nLet \\(x\\) and \\(y\\) be real numbers with \\(x^2 + y^2 \\le 25\\). Prove that \\(16x + 12y \\le 100\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- A linear form is bounded on a disc by the Cauchy-Schwarz inequality. -/\ntheorem cauchy_bound_circle (x y : ℝ) (h : x ^ 2 + y ^ 2 ≤ 25) :\n 16 * x + 12 * y ≤ 100 := by\n sorry\n", "path": "tasks/inequalities/inequalities-cauchy-d2-e0018"}
20
+ {"id": "inequalities-monotone-d2-e0019", "env": "inequalities", "msc": "26", "family": "monotone", "difficulty": 2, "seed": 10019, "kind": "prove", "instruction": "# Prove an inequality over the reals\n\nProve that the function \\(f(x) = 2\\,\\arctan x + x^5\\) is monotone on the real numbers: \\(x \\le y\\) implies \\(f(x) \\le f(y)\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The function is monotone. -/\ntheorem monotone_function : Monotone (fun x : ℝ => 2 * Real.arctan x + x ^ 5) := by\n sorry\n", "path": "tasks/inequalities/inequalities-monotone-d2-e0019"}
21
+ {"id": "inequalities-abs_ineq-d3-e0020", "env": "inequalities", "msc": "26", "family": "abs_ineq", "difficulty": 3, "seed": 10020, "kind": "prove", "instruction": "# Prove an inequality over the reals\n\nProve that for all real numbers \\(a \\le c\\) and \\(x\\), \\(c - a \\le |x - a| + |x - c|\\). Then prove that for every real \\(x\\), \\[6 \\le |x - 5| + |x - 7| + |x - 9| + |x - 9|.\\]\n\n## What to do\n\n`Solution.lean` in the working directory states 2 theorems in Lean 4 with Mathlib, with `sorry` in place of each proof. Replace every `sorry` with a proof.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is the share of the 2 theorems that are proved. If the file does not compile the reward is 0, so leave `sorry` on a theorem you cannot finish rather than a broken proof.\n", "start_file": "import Mathlib\n\n/-- The sum of the distances to two points is at least their gap. -/\ntheorem pair_abs_bound (x a c : ℝ) (h : a ≤ c) :\n c - a ≤ |x - a| + |x - c| := by\n sorry\n\n/-- The sum of four distances is bounded below. -/\ntheorem four_points_abs (x : ℝ) :\n 6 ≤ |x - 5| + |x - 7| + |x - 9| + |x - 9| := by\n sorry\n", "path": "tasks/inequalities/inequalities-abs_ineq-d3-e0020"}
22
+ {"id": "inequalities-amgm-d3-e0021", "env": "inequalities", "msc": "26", "family": "amgm", "difficulty": 3, "seed": 10021, "kind": "prove", "instruction": "# Prove an inequality over the reals\n\nProve that \\(27xyz \\le (x+y+z)^3\\) for all non-negative real numbers \\(x, y, z\\). Then prove that for all non-negative real numbers \\(a, b, c\\), \\[378\\,abc \\le (7a + 2b + c)^3.\\]\n\n## What to do\n\n`Solution.lean` in the working directory states 2 theorems in Lean 4 with Mathlib, with `sorry` in place of each proof. Replace every `sorry` with a proof.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is the share of the 2 theorems that are proved. If the file does not compile the reward is 0, so leave `sorry` on a theorem you cannot finish rather than a broken proof.\n", "start_file": "import Mathlib\n\n/-- The three-variable AM-GM inequality in cubic form. -/\ntheorem amgm_three (x y z : ℝ) (hx : 0 ≤ x) (hy : 0 ≤ y) (hz : 0 ≤ z) :\n 27 * x * y * z ≤ (x + y + z) ^ 3 := by\n sorry\n\n/-- The scaled three-variable inequality. -/\ntheorem amgm_three_scaled (a b c : ℝ) (ha : 0 ≤ a) (hb : 0 ≤ b) (hc : 0 ≤ c) :\n 378 * a * b * c ≤ (7 * a + 2 * b + c) ^ 3 := by\n sorry\n", "path": "tasks/inequalities/inequalities-amgm-d3-e0021"}
23
+ {"id": "inequalities-cauchy-d3-e0022", "env": "inequalities", "msc": "26", "family": "cauchy", "difficulty": 3, "seed": 10022, "kind": "prove", "instruction": "# Prove an inequality over the reals\n\nProve that for all real numbers \\(u, v, w, x, y, z\\), \\[(ux + vy + wz)^2 \\le (u^2 + v^2 + w^2)(x^2 + y^2 + z^2).\\] Then let \\(x, y, z\\) be real numbers with \\(x^2 + y^2 + z^2 \\le 9\\) and prove that \\(-4x - 3y - 12z \\le 39\\).\n\n## What to do\n\n`Solution.lean` in the working directory states 2 theorems in Lean 4 with Mathlib, with `sorry` in place of each proof. Replace every `sorry` with a proof.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is the share of the 2 theorems that are proved. If the file does not compile the reward is 0, so leave `sorry` on a theorem you cannot finish rather than a broken proof.\n", "start_file": "import Mathlib\n\n/-- Cauchy-Schwarz for three-term sums. -/\ntheorem cauchy_three (u v w x y z : ℝ) :\n (u * x + v * y + w * z) ^ 2 ≤ (u ^ 2 + v ^ 2 + w ^ 2) * (x ^ 2 + y ^ 2 + z ^ 2) := by\n sorry\n\n/-- A linear form is bounded on a ball. -/\ntheorem cauchy_bound_ball (x y z : ℝ) (h : x ^ 2 + y ^ 2 + z ^ 2 ≤ 9) :\n -4 * x - 3 * y - 12 * z ≤ 39 := by\n sorry\n", "path": "tasks/inequalities/inequalities-cauchy-d3-e0022"}
24
+ {"id": "inequalities-monotone-d3-e0023", "env": "inequalities", "msc": "26", "family": "monotone", "difficulty": 3, "seed": 10023, "kind": "prove", "instruction": "# Prove an inequality over the reals\n\nProve that \\(0 \\le \\ln(1 + y^2) - \\ln(1 + x^2)\\) for real numbers \\(0 < x \\le y\\). Then prove that for such \\(x, y\\), \\[0 \\le \\left(5\\,e^{y} + 2\\,y^5 + 2\\,\\ln y + 3\\,\\ln(1 + y^2)\\right) - \\left(5\\,e^{x} + 2\\,x^5 + 2\\,\\ln x + 3\\,\\ln(1 + x^2)\\right).\\]\n\n## What to do\n\n`Solution.lean` in the working directory states 2 theorems in Lean 4 with Mathlib, with `sorry` in place of each proof. Replace every `sorry` with a proof.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is the share of the 2 theorems that are proved. If the file does not compile the reward is 0, so leave `sorry` on a theorem you cannot finish rather than a broken proof.\n", "start_file": "import Mathlib\n\n/-- The logarithm of one plus a square is increasing on the positive reals. -/\ntheorem log_one_add_sq_mono (x y : ℝ) (hx : 0 < x) (h : x ≤ y) :\n 0 ≤ Real.log (1 + y ^ 2) - Real.log (1 + x ^ 2) := by\n sorry\n\n/-- The combination is non-decreasing on the positive reals. -/\ntheorem monotone_combination (x y : ℝ) (hx : 0 < x) (h : x ≤ y) :\n 0 ≤ (5 * Real.exp y + 2 * y ^ 5 + 2 * Real.log y + 3 * Real.log (1 + y ^ 2)) - (5 * Real.exp x + 2 * x ^ 5 + 2 * Real.log x + 3 * Real.log (1 + x ^ 2)) := by\n sorry\n", "path": "tasks/inequalities/inequalities-monotone-d3-e0023"}
data/inequalities/train.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
data/linear-algebra/eval.jsonl ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {"id": "linear-algebra-det_trace-d1-e0000", "env": "linear-algebra", "msc": "15", "family": "det_trace", "difficulty": 1, "seed": 10000, "kind": "prove", "instruction": "# Determinant and trace of 2x2 matrices\n\nProve the following statement.\n\nCompute the determinant of the product \\(\\begin{pmatrix} 4 & 1 \\\\ 1 & -3 \\end{pmatrix}\\) \\(\\begin{pmatrix} 3 & 1 \\\\ 1 & 1 \\end{pmatrix}\\) of integer matrices. Show that it equals -26.\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The determinant of the product is the product of the determinants. -/\ntheorem det_of_product : Matrix.det (!![4, 1; 1, -3] * !![3, 1; 1, 1] : Matrix (Fin 2) (Fin 2) ℤ) = (-26 : ℤ) := by\n sorry\n", "path": "tasks/linear-algebra/linear-algebra-det_trace-d1-e0000"}
2
+ {"id": "linear-algebra-independence-d1-e0001", "env": "linear-algebra", "msc": "15", "family": "independence", "difficulty": 1, "seed": 10001, "kind": "prove", "instruction": "# Linear independence of explicit vectors\n\nProve the following statement.\n\nIn \\(\\mathbb{Q}^2\\) consider the vectors \\(\\begin{pmatrix} 0 \\\\ -2 \\end{pmatrix}\\), \\(\\begin{pmatrix} 0 \\\\ 6 \\end{pmatrix}\\). Show that they are not linearly independent over \\(\\mathbb{Q}\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The given vectors are linearly dependent over the rationals. -/\ntheorem vectors_dependent : ¬ LinearIndependent ℚ ![(![0, -2] : Fin 2 → ℚ), ![0, 6]] := by\n sorry\n", "path": "tasks/linear-algebra/linear-algebra-independence-d1-e0001"}
3
+ {"id": "linear-algebra-linear_map-d1-e0002", "env": "linear-algebra", "msc": "15", "family": "linear_map", "difficulty": 1, "seed": 10002, "kind": "prove", "instruction": "# Kernels, ranges and projections\n\nProve the following statement.\n\nLet \\(q : V \\to V\\) be a linear map over \\(\\mathbb{Q}\\) with \\(q(v(v)) = v(v)\\) for every \\(v\\). Then \\(u - q(u)\\) lies in the kernel of \\(q\\) for every \\(u \\in V\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- x - p x lies in the kernel of an idempotent map p. -/\ntheorem sub_proj_mem_ker {V : Type*} [AddCommGroup V] [Module ℚ V] (q : V →ₗ[ℚ] V) (hp : ∀ x, q (q x) = q x) (u : V) :\n u - q u ∈ LinearMap.ker q := by\n sorry\n", "path": "tasks/linear-algebra/linear-algebra-linear_map-d1-e0002"}
4
+ {"id": "linear-algebra-matrix_pow-d1-e0003", "env": "linear-algebra", "msc": "15", "family": "matrix_pow", "difficulty": 1, "seed": 10003, "kind": "prove", "instruction": "# Powers of 2x2 matrices\n\nProve the following statement.\n\nFor every natural number \\(n\\), \\[\\begin{pmatrix} 1 & 2 \\\\ 0 & 1 \\end{pmatrix}^n = \\begin{pmatrix} 1 & 2n \\\\ 0 & 1 \\end{pmatrix}.\\]\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- Powers of a shear matrix. -/\ntheorem shear_power (n : ℕ) :\n (!![1, 2; 0, 1] : Matrix (Fin 2) (Fin 2) ℤ) ^ n = !![1, (n : ℤ) * 2; 0, 1] := by\n sorry\n", "path": "tasks/linear-algebra/linear-algebra-matrix_pow-d1-e0003"}
5
+ {"id": "linear-algebra-det_trace-d2-e0004", "env": "linear-algebra", "msc": "15", "family": "det_trace", "difficulty": 2, "seed": 10004, "kind": "prove", "instruction": "# Determinant and trace of 2x2 matrices\n\nProve the following statement.\n\nFor every integer \\(x\\), the determinant of \\[\\begin{pmatrix} x-3 & 2 \\\\ 2 & x-1 \\end{pmatrix}\\begin{pmatrix} x & -1 \\\\ -1 & x+0 \\end{pmatrix}\\] equals \\(x^4 - 4x^3 - 2x^2 + 4x + 1\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The determinant of a product of matrices with a variable entry. -/\ntheorem det_of_polynomial_product (x : ℤ) :\n Matrix.det (!![x - 3, 2; 2, x - 1] * !![x, -1; -1, x + 0] : Matrix (Fin 2) (Fin 2) ℤ) = x ^ 4 - 4 * x ^ 3 - 2 * x ^ 2 + 4 * x + 1 := by\n sorry\n", "path": "tasks/linear-algebra/linear-algebra-det_trace-d2-e0004"}
6
+ {"id": "linear-algebra-independence-d2-e0005", "env": "linear-algebra", "msc": "15", "family": "independence", "difficulty": 2, "seed": 10005, "kind": "prove", "instruction": "# Linear independence of explicit vectors\n\nProve the following statement.\n\nIn \\(\\mathbb{Q}^2\\) consider the vectors \\(\\begin{pmatrix} 3 \\\\ 3 \\end{pmatrix}\\), \\(\\begin{pmatrix} -3 \\\\ -3 \\end{pmatrix}\\). Show that they are not linearly independent over \\(\\mathbb{Q}\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The given vectors are linearly dependent over the rationals. -/\ntheorem vectors_dependent : ¬ LinearIndependent ℚ ![(![3, 3] : Fin 2 → ℚ), ![-3, -3]] := by\n sorry\n", "path": "tasks/linear-algebra/linear-algebra-independence-d2-e0005"}
7
+ {"id": "linear-algebra-linear_map-d2-e0006", "env": "linear-algebra", "msc": "15", "family": "linear_map", "difficulty": 2, "seed": 10006, "kind": "prove", "instruction": "# Kernels, ranges and projections\n\nProve the following statement.\n\nLet \\(f : V \\to W\\) and \\(g : W \\to U\\) be linear maps over \\(\\mathbb{R}\\). Then the kernel of \\(f\\) is contained in the kernel of \\(g \\circ f\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- ker f ≤ ker (g ∘ f). -/\ntheorem ker_le_comp {V W U : Type*} [AddCommGroup V] [Module ℝ V] [AddCommGroup W] [Module ℝ W] [AddCommGroup U] [Module ℝ U] (f : V →ₗ[ℝ] W) (g : W →ₗ[ℝ] U) :\n LinearMap.ker f ≤ LinearMap.ker (g ∘ₗ f) := by\n sorry\n", "path": "tasks/linear-algebra/linear-algebra-linear_map-d2-e0006"}
8
+ {"id": "linear-algebra-matrix_pow-d2-e0007", "env": "linear-algebra", "msc": "15", "family": "matrix_pow", "difficulty": 2, "seed": 10007, "kind": "prove", "instruction": "# Powers of 2x2 matrices\n\nProve the following statement.\n\nFor every natural number \\(n\\), \\[\\begin{pmatrix} 3 & 1 \\\\ 0 & 3 \\end{pmatrix}^{n+1} = \\begin{pmatrix} (3)^{n+1} & (n+1)(3)^n \\\\ 0 & (3)^{n+1} \\end{pmatrix}.\\]\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- Powers of a 2x2 Jordan block. -/\ntheorem jordan_power (n : ℕ) :\n (!![3, 1; 0, 3] : Matrix (Fin 2) (Fin 2) ℤ) ^ (n + 1) = !![3 ^ (n + 1), ((n : ℤ) + 1) * 3 ^ n; 0, 3 ^ (n + 1)] := by\n sorry\n", "path": "tasks/linear-algebra/linear-algebra-matrix_pow-d2-e0007"}
9
+ {"id": "linear-algebra-det_trace-d3-e0008", "env": "linear-algebra", "msc": "15", "family": "det_trace", "difficulty": 3, "seed": 10008, "kind": "prove", "instruction": "# Determinant and trace of 2x2 matrices\n\nProve the following statement.\n\nLet \\(A\\) be a \\(2 \\times 2\\) integer matrix with trace -1 and determinant -3. Then the trace of \\(A^2\\) is 7. You may first prove \\(A^2 = (\\operatorname{tr} A) A - (\\det A) I\\) for every \\(2 \\times 2\\) integer matrix.\n\n## What to do\n\n`Solution.lean` in the working directory states 2 theorems in Lean 4 with Mathlib, with `sorry` in place of each proof. Replace every `sorry` with a proof.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is the share of the 2 theorems that are proved. If the file does not compile the reward is 0, so leave `sorry` on a theorem you cannot finish rather than a broken proof.\n", "start_file": "import Mathlib\n\n/-- Cayley-Hamilton for 2x2 integer matrices. -/\ntheorem cayley_hamilton_two (A : Matrix (Fin 2) (Fin 2) ℤ) :\n A ^ 2 = Matrix.trace A • A - Matrix.det A • (1 : Matrix (Fin 2) (Fin 2) ℤ) := by\n sorry\n\n/-- The trace of A^2 from the trace and determinant of A. -/\ntheorem trace_of_square (A : Matrix (Fin 2) (Fin 2) ℤ) (ht : Matrix.trace A = (-1 : ℤ)) (hd : Matrix.det A = (-3 : ℤ)) :\n Matrix.trace (A ^ 2) = 7 := by\n sorry\n", "path": "tasks/linear-algebra/linear-algebra-det_trace-d3-e0008"}
10
+ {"id": "linear-algebra-independence-d3-e0009", "env": "linear-algebra", "msc": "15", "family": "independence", "difficulty": 3, "seed": 10009, "kind": "prove", "instruction": "# Linear independence of explicit vectors\n\nProve the following statement.\n\nIn \\(\\mathbb{Q}^3\\) consider the vectors \\(\\begin{pmatrix} 6 \\\\ 0 \\\\ -4 \\end{pmatrix}\\), \\(\\begin{pmatrix} 4 \\\\ 6 \\\\ 3 \\end{pmatrix}\\), \\(\\begin{pmatrix} -4 \\\\ 12 \\\\ 14 \\end{pmatrix}\\). Show that they are not linearly independent over \\(\\mathbb{Q}\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The given vectors are linearly dependent over the rationals. -/\ntheorem vectors_dependent : ¬ LinearIndependent ℚ ![(![6, 0, -4] : Fin 3 → ℚ), ![4, 6, 3], ![-4, 12, 14]] := by\n sorry\n", "path": "tasks/linear-algebra/linear-algebra-independence-d3-e0009"}
11
+ {"id": "linear-algebra-linear_map-d3-e0010", "env": "linear-algebra", "msc": "15", "family": "linear_map", "difficulty": 3, "seed": 10010, "kind": "prove", "instruction": "# Kernels, ranges and projections\n\nProve the following statement.\n\nLet \\(p : V \\to V\\) be a linear map over \\(\\mathbb{R}\\) with \\(p \\circ p = p\\). Then \\(\\mathrm{id} - p\\) is also idempotent, and \\(p \\circ (\\mathrm{id} - p) = 0\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- If p is idempotent then so is id - p, and p kills its image. -/\ntheorem complement_idempotent {V : Type*} [AddCommGroup V] [Module ℝ V] (p : V →ₗ[ℝ] V) (hp : p ∘ₗ p = p) :\n (LinearMap.id - p) ∘ₗ (LinearMap.id - p) = LinearMap.id - p ∧ p ∘ₗ (LinearMap.id - p) = 0 := by\n sorry\n", "path": "tasks/linear-algebra/linear-algebra-linear_map-d3-e0010"}
12
+ {"id": "linear-algebra-matrix_pow-d3-e0011", "env": "linear-algebra", "msc": "15", "family": "matrix_pow", "difficulty": 3, "seed": 10011, "kind": "prove", "instruction": "# Powers of 2x2 matrices\n\nProve the following statement.\n\nFor every integer \\(k\\) and natural number \\(n\\), \\[\\begin{pmatrix} 1 & k \\\\ 0 & 1 \\end{pmatrix}^n = \\begin{pmatrix} 1 & nk \\\\ 0 & 1 \\end{pmatrix}.\\] Deduce that for all natural numbers \\(n, m\\), \\[\\begin{pmatrix} 1 & 6 \\\\ 0 & 1 \\end{pmatrix}^n \\begin{pmatrix} 1 & -1 \\\\ 0 & 1 \\end{pmatrix}^m = \\begin{pmatrix} 1 & 6n + -1m \\\\ 0 & 1 \\end{pmatrix}.\\]\n\n## What to do\n\n`Solution.lean` in the working directory states 2 theorems in Lean 4 with Mathlib, with `sorry` in place of each proof. Replace every `sorry` with a proof.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is the share of the 2 theorems that are proved. If the file does not compile the reward is 0, so leave `sorry` on a theorem you cannot finish rather than a broken proof.\n", "start_file": "import Mathlib\n\n/-- Powers of a shear matrix. -/\ntheorem shear_power (k : ℤ) (n : ℕ) :\n (!![1, k; 0, 1] : Matrix (Fin 2) (Fin 2) ℤ) ^ n = !![1, (n : ℤ) * k; 0, 1] := by\n sorry\n\n/-- A product of powers of two shears. -/\ntheorem shear_product (n m : ℕ) :\n (!![1, 6; 0, 1] : Matrix (Fin 2) (Fin 2) ℤ) ^ n * (!![1, (-1 : ℤ); 0, 1] : Matrix (Fin 2) (Fin 2) ℤ) ^ m = !![1, (n : ℤ) * 6 + (m : ℤ) * (-1 : ℤ); 0, 1] := by\n sorry\n", "path": "tasks/linear-algebra/linear-algebra-matrix_pow-d3-e0011"}
13
+ {"id": "linear-algebra-det_trace-d1-e0012", "env": "linear-algebra", "msc": "15", "family": "det_trace", "difficulty": 1, "seed": 10012, "kind": "prove", "instruction": "# Determinant and trace of 2x2 matrices\n\nProve the following statement.\n\nCompute the determinant of the product \\(\\begin{pmatrix} 3 & 1 \\\\ -2 & 2 \\end{pmatrix}\\) \\(\\begin{pmatrix} 4 & -1 \\\\ -3 & 2 \\end{pmatrix}\\) of integer matrices. Show that it equals 40.\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The determinant of the product is the product of the determinants. -/\ntheorem det_of_product : Matrix.det (!![3, 1; -2, 2] * !![4, -1; -3, 2] : Matrix (Fin 2) (Fin 2) ℤ) = 40 := by\n sorry\n", "path": "tasks/linear-algebra/linear-algebra-det_trace-d1-e0012"}
14
+ {"id": "linear-algebra-independence-d1-e0013", "env": "linear-algebra", "msc": "15", "family": "independence", "difficulty": 1, "seed": 10013, "kind": "prove", "instruction": "# Linear independence of explicit vectors\n\nProve the following statement.\n\nIn \\(\\mathbb{Q}^2\\) consider the vectors \\(\\begin{pmatrix} 2 \\\\ -3 \\end{pmatrix}\\), \\(\\begin{pmatrix} 1 \\\\ -1 \\end{pmatrix}\\). Show that they are linearly independent over \\(\\mathbb{Q}\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The given vectors are linearly independent over the rationals. -/\ntheorem vectors_independent : LinearIndependent ℚ ![(![2, -3] : Fin 2 → ℚ), ![1, -1]] := by\n sorry\n", "path": "tasks/linear-algebra/linear-algebra-independence-d1-e0013"}
15
+ {"id": "linear-algebra-linear_map-d1-e0014", "env": "linear-algebra", "msc": "15", "family": "linear_map", "difficulty": 1, "seed": 10014, "kind": "prove", "instruction": "# Kernels, ranges and projections\n\nProve the following statement.\n\nLet \\(f : V \\to W\\) be a linear map of vector spaces over \\(\\mathbb{Q}\\) and \\(a, b \\in V\\) with \\(f(a) = 0\\) and \\(f(b) = 0\\). Then \\(f(7a + 2b) = 0\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The kernel is closed under linear combinations. -/\ntheorem kernel_combination {V W : Type*} [AddCommGroup V] [Module ℚ V] [AddCommGroup W] [Module ℚ W] (f : V →ₗ[ℚ] W) {a b : V}\n (hx : f a = 0) (hy : f b = 0) : f ((7 : ℚ) • a + (2 : ℚ) • b) = 0 := by\n sorry\n", "path": "tasks/linear-algebra/linear-algebra-linear_map-d1-e0014"}
16
+ {"id": "linear-algebra-matrix_pow-d1-e0015", "env": "linear-algebra", "msc": "15", "family": "matrix_pow", "difficulty": 1, "seed": 10015, "kind": "prove", "instruction": "# Powers of 2x2 matrices\n\nProve the following statement.\n\nFor every natural number \\(n\\), \\[\\begin{pmatrix} 1 & 2 \\\\ 0 & 1 \\end{pmatrix}^n = \\begin{pmatrix} 1 & 2n \\\\ 0 & 1 \\end{pmatrix}.\\]\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- Powers of a shear matrix. -/\ntheorem shear_power (n : ℕ) :\n (!![1, 2; 0, 1] : Matrix (Fin 2) (Fin 2) ℤ) ^ n = !![1, (n : ℤ) * 2; 0, 1] := by\n sorry\n", "path": "tasks/linear-algebra/linear-algebra-matrix_pow-d1-e0015"}
17
+ {"id": "linear-algebra-det_trace-d2-e0016", "env": "linear-algebra", "msc": "15", "family": "det_trace", "difficulty": 2, "seed": 10016, "kind": "prove", "instruction": "# Determinant and trace of 2x2 matrices\n\nProve the following statement.\n\nFor every integer \\(x\\), \\[\\det\\left(x I - \\begin{pmatrix} 0 & 2 \\\\ -1 & -2 \\end{pmatrix}\\right) = x^2 - (-2)\\,x + (2),\\] where \\(I\\) is the \\(2 \\times 2\\) identity matrix.\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The characteristic polynomial of a 2x2 matrix is x^2 - tr x + det. -/\ntheorem char_poly_value (x : ℤ) :\n Matrix.det (x • (1 : Matrix (Fin 2) (Fin 2) ℤ) - !![0, 2; -1, -2]) = x ^ 2 - (-2 : ℤ) * x + 2 := by\n sorry\n", "path": "tasks/linear-algebra/linear-algebra-det_trace-d2-e0016"}
18
+ {"id": "linear-algebra-independence-d2-e0017", "env": "linear-algebra", "msc": "15", "family": "independence", "difficulty": 2, "seed": 10017, "kind": "prove", "instruction": "# Linear independence of explicit vectors\n\nProve the following statement.\n\nIn \\(\\mathbb{Q}^2\\) consider the vectors \\(\\begin{pmatrix} -6 \\\\ -6 \\end{pmatrix}\\), \\(\\begin{pmatrix} -3 \\\\ 2 \\end{pmatrix}\\). Show that they are linearly independent over \\(\\mathbb{Q}\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The given vectors are linearly independent over the rationals. -/\ntheorem vectors_independent : LinearIndependent ℚ ![(![-6, -6] : Fin 2 → ℚ), ![-3, 2]] := by\n sorry\n", "path": "tasks/linear-algebra/linear-algebra-independence-d2-e0017"}
19
+ {"id": "linear-algebra-linear_map-d2-e0018", "env": "linear-algebra", "msc": "15", "family": "linear_map", "difficulty": 2, "seed": 10018, "kind": "prove", "instruction": "# Kernels, ranges and projections\n\nProve the following statement.\n\nLet \\(f : V \\to W\\) be a linear map of vector spaces over \\(\\mathbb{R}\\). Then the kernel of \\(-1f\\) equals the kernel of \\(f\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- A nonzero scalar multiple has the same kernel. -/\ntheorem ker_smul_eq {V W : Type*} [AddCommGroup V] [Module ℝ V] [AddCommGroup W] [Module ℝ W] (f : V →ₗ[ℝ] W) :\n LinearMap.ker ((-1 : ℝ) • f) = LinearMap.ker f := by\n sorry\n", "path": "tasks/linear-algebra/linear-algebra-linear_map-d2-e0018"}
20
+ {"id": "linear-algebra-matrix_pow-d2-e0019", "env": "linear-algebra", "msc": "15", "family": "matrix_pow", "difficulty": 2, "seed": 10019, "kind": "prove", "instruction": "# Powers of 2x2 matrices\n\nProve the following statement.\n\nFor every natural number \\(n\\), \\[\\begin{pmatrix} 5 & 1 \\\\ 0 & 5 \\end{pmatrix}^{n+1} = \\begin{pmatrix} (5)^{n+1} & (n+1)(5)^n \\\\ 0 & (5)^{n+1} \\end{pmatrix}.\\]\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- Powers of a 2x2 Jordan block. -/\ntheorem jordan_power (n : ℕ) :\n (!![5, 1; 0, 5] : Matrix (Fin 2) (Fin 2) ℤ) ^ (n + 1) = !![5 ^ (n + 1), ((n : ℤ) + 1) * 5 ^ n; 0, 5 ^ (n + 1)] := by\n sorry\n", "path": "tasks/linear-algebra/linear-algebra-matrix_pow-d2-e0019"}
21
+ {"id": "linear-algebra-det_trace-d3-e0020", "env": "linear-algebra", "msc": "15", "family": "det_trace", "difficulty": 3, "seed": 10020, "kind": "prove", "instruction": "# Determinant and trace of 2x2 matrices\n\nProve the following statement.\n\nLet \\(A\\) be a \\(2 \\times 2\\) integer matrix with trace 2 and determinant -2. Then the trace of \\(A^2\\) is 8. You may first prove \\(A^2 = (\\operatorname{tr} A) A - (\\det A) I\\) for every \\(2 \\times 2\\) integer matrix.\n\n## What to do\n\n`Solution.lean` in the working directory states 2 theorems in Lean 4 with Mathlib, with `sorry` in place of each proof. Replace every `sorry` with a proof.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is the share of the 2 theorems that are proved. If the file does not compile the reward is 0, so leave `sorry` on a theorem you cannot finish rather than a broken proof.\n", "start_file": "import Mathlib\n\n/-- Cayley-Hamilton for 2x2 integer matrices. -/\ntheorem cayley_hamilton_two (A : Matrix (Fin 2) (Fin 2) ℤ) :\n A ^ 2 = Matrix.trace A • A - Matrix.det A • (1 : Matrix (Fin 2) (Fin 2) ℤ) := by\n sorry\n\n/-- The trace of A^2 from the trace and determinant of A. -/\ntheorem trace_of_square (A : Matrix (Fin 2) (Fin 2) ℤ) (ht : Matrix.trace A = (2 : ℤ)) (hd : Matrix.det A = (-2 : ℤ)) :\n Matrix.trace (A ^ 2) = 8 := by\n sorry\n", "path": "tasks/linear-algebra/linear-algebra-det_trace-d3-e0020"}
22
+ {"id": "linear-algebra-independence-d3-e0021", "env": "linear-algebra", "msc": "15", "family": "independence", "difficulty": 3, "seed": 10021, "kind": "prove", "instruction": "# Linear independence of explicit vectors\n\nProve the following statement.\n\nIn \\(\\mathbb{Q}^3\\) consider the vectors \\(\\begin{pmatrix} -5 \\\\ 6 \\\\ -5 \\end{pmatrix}\\), \\(\\begin{pmatrix} 2 \\\\ 1 \\\\ 4 \\end{pmatrix}\\), \\(\\begin{pmatrix} -2 \\\\ 4 \\\\ 0 \\end{pmatrix}\\). Show that they are linearly independent over \\(\\mathbb{Q}\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The given vectors are linearly independent over the rationals. -/\ntheorem vectors_independent : LinearIndependent ℚ ![(![-5, 6, -5] : Fin 3 → ℚ), ![2, 1, 4], ![-2, 4, 0]] := by\n sorry\n", "path": "tasks/linear-algebra/linear-algebra-independence-d3-e0021"}
23
+ {"id": "linear-algebra-linear_map-d3-e0022", "env": "linear-algebra", "msc": "15", "family": "linear_map", "difficulty": 3, "seed": 10022, "kind": "prove", "instruction": "# Kernels, ranges and projections\n\nProve the following statement.\n\nLet \\(e : V \\to V\\) be a linear map over \\(\\mathbb{R}\\) with \\(e^2 = e\\). Show that \\(\\ker e\\) and \\(\\operatorname{range} e\\) are complementary subspaces: their intersection is \\(\\{0\\}\\) and together they span \\(V\\).\n\n## What to do\n\n`Solution.lean` in the working directory states 2 theorems in Lean 4 with Mathlib, with `sorry` in place of each proof. Replace every `sorry` with a proof.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is the share of the 2 theorems that are proved. If the file does not compile the reward is 0, so leave `sorry` on a theorem you cannot finish rather than a broken proof.\n", "start_file": "import Mathlib\n\n/-- The kernel and the range of an idempotent map meet only in 0. -/\ntheorem disjoint_ker_range {V : Type*} [AddCommGroup V] [Module ℝ V] (e : V →ₗ[ℝ] V) (hp : e * e = e) :\n Disjoint (LinearMap.ker e) (LinearMap.range e) := by\n sorry\n\n/-- The kernel and the range of an idempotent map are complements. -/\ntheorem ker_range_isCompl {V : Type*} [AddCommGroup V] [Module ℝ V] (e : V →ₗ[ℝ] V) (hp : e * e = e) :\n IsCompl (LinearMap.ker e) (LinearMap.range e) := by\n sorry\n", "path": "tasks/linear-algebra/linear-algebra-linear_map-d3-e0022"}
24
+ {"id": "linear-algebra-matrix_pow-d3-e0023", "env": "linear-algebra", "msc": "15", "family": "matrix_pow", "difficulty": 3, "seed": 10023, "kind": "prove", "instruction": "# Powers of 2x2 matrices\n\nProve the following statement.\n\nFor every integer \\(k\\) and natural number \\(n\\), \\[\\begin{pmatrix} 1 & k \\\\ 0 & 1 \\end{pmatrix}^n = \\begin{pmatrix} 1 & nk \\\\ 0 & 1 \\end{pmatrix}.\\] Deduce that for all natural numbers \\(n, m\\), \\[\\begin{pmatrix} 1 & 5 \\\\ 0 & 1 \\end{pmatrix}^n \\begin{pmatrix} 1 & 1 \\\\ 0 & 1 \\end{pmatrix}^m = \\begin{pmatrix} 1 & 5n + 1m \\\\ 0 & 1 \\end{pmatrix}.\\]\n\n## What to do\n\n`Solution.lean` in the working directory states 2 theorems in Lean 4 with Mathlib, with `sorry` in place of each proof. Replace every `sorry` with a proof.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is the share of the 2 theorems that are proved. If the file does not compile the reward is 0, so leave `sorry` on a theorem you cannot finish rather than a broken proof.\n", "start_file": "import Mathlib\n\n/-- Powers of a shear matrix. -/\ntheorem shear_power (k : ℤ) (n : ℕ) :\n (!![1, k; 0, 1] : Matrix (Fin 2) (Fin 2) ℤ) ^ n = !![1, (n : ℤ) * k; 0, 1] := by\n sorry\n\n/-- A product of powers of two shears. -/\ntheorem shear_product (n m : ℕ) :\n (!![1, 5; 0, 1] : Matrix (Fin 2) (Fin 2) ℤ) ^ n * (!![1, 1; 0, 1] : Matrix (Fin 2) (Fin 2) ℤ) ^ m = !![1, (n : ℤ) * 5 + (m : ℤ) * 1; 0, 1] := by\n sorry\n", "path": "tasks/linear-algebra/linear-algebra-matrix_pow-d3-e0023"}
data/linear-algebra/train.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
data/logic-and-sets/eval.jsonl ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {"id": "logic-and-sets-finset_card-d1-e0000", "env": "logic-and-sets", "msc": "03", "family": "finset_card", "difficulty": 1, "seed": 10000, "kind": "prove", "instruction": "# Prove a cardinality fact about finite sets\n\nProve the following.\n\nLet \\(f(x) = 3x + 2\\) on the natural numbers and let \\(s, t\\) be finite sets of natural numbers. Prove that the product \\(f(s) \\times t\\) has \\(|s| \\cdot |t|\\) elements.\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- A cardinality fact about finite sets. -/\ntheorem card_fact (s t : Finset ℕ) :\n ((s.image (fun x : ℕ => 3 * x + 2)) ×ˢ t).card = s.card * t.card := by\n sorry\n", "path": "tasks/logic-and-sets/logic-and-sets-finset_card-d1-e0000"}
2
+ {"id": "logic-and-sets-relations-d1-e0001", "env": "logic-and-sets", "msc": "03", "family": "relations", "difficulty": 1, "seed": 10001, "kind": "prove", "instruction": "# Prove properties of a relation\n\nProve the following.\n\nOn the integers define \\(x \\sim y \\iff 2 \\mid x - y\\). Prove that \\(\\sim\\) is an equivalence relation.\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The relation is reflexive, symmetric and transitive. -/\ntheorem rel_equiv :\n Equivalence (fun x y : ℤ => 2 ∣ x - y) := by\n sorry\n", "path": "tasks/logic-and-sets/logic-and-sets-relations-d1-e0001"}
3
+ {"id": "logic-and-sets-set_identities-d1-e0002", "env": "logic-and-sets", "msc": "03", "family": "set_identities", "difficulty": 1, "seed": 10002, "kind": "prove", "instruction": "# Prove an identity between sets\n\nProve the following.\n\nLet \\(S, T, U\\) be subsets of a type \\(\\alpha\\). Prove the set identity \\[U \\setminus (S \\cup T) = (U \\setminus S) \\cap (U \\setminus T).\\]\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The stated identity between sets. -/\ntheorem set_identity {α : Type*} (S T U : Set α) :\n U \\ (S ∪ T) = (U \\ S) ∩ (U \\ T) := by\n sorry\n", "path": "tasks/logic-and-sets/logic-and-sets-set_identities-d1-e0002"}
4
+ {"id": "logic-and-sets-finset_card-d2-e0003", "env": "logic-and-sets", "msc": "03", "family": "finset_card", "difficulty": 2, "seed": 10003, "kind": "prove", "instruction": "# Prove a cardinality fact about finite sets\n\nProve the following.\n\nLet \\(f(x) = 5x + 3\\) on the natural numbers and let \\(s, t\\) be finite sets of natural numbers. Prove that \\[|f(s \\setminus t)| + |s \\cap t| = |s|.\\]\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- A cardinality fact about finite sets. -/\ntheorem card_fact (s t : Finset ℕ) :\n ((s \\ t).image (fun x : ℕ => 5 * x + 3)).card + (s ∩ t).card = s.card := by\n sorry\n", "path": "tasks/logic-and-sets/logic-and-sets-finset_card-d2-e0003"}
5
+ {"id": "logic-and-sets-relations-d2-e0004", "env": "logic-and-sets", "msc": "03", "family": "relations", "difficulty": 2, "seed": 10004, "kind": "prove", "instruction": "# Prove properties of a relation\n\nProve the following.\n\nOn pairs of natural numbers define \\((x_1, y_1) \\sim (x_2, y_2) \\iff x_1 + 7 y_2 = x_2 + 7 y_1\\). Prove that \\(\\sim\\) is an equivalence relation.\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The relation is reflexive, symmetric and transitive. -/\ntheorem rel_equiv :\n Equivalence (fun p q : ℕ × ℕ => p.1 + 7 * q.2 = q.1 + 7 * p.2) := by\n sorry\n", "path": "tasks/logic-and-sets/logic-and-sets-relations-d2-e0004"}
6
+ {"id": "logic-and-sets-set_identities-d2-e0005", "env": "logic-and-sets", "msc": "03", "family": "set_identities", "difficulty": 2, "seed": 10005, "kind": "prove", "instruction": "# Prove an identity between sets\n\nProve the following.\n\nLet \\(g : \\alpha \\to \\beta\\) be a function that is injective and let \\(C\\) be subsets of \\(\\alpha\\). Write \\(g(X)\\) for the image and \\(g^{-1}(X)\\) for the preimage of a set \\(X\\). Prove \\[g^{-1}(g(C)) = C.\\]\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The stated statement about images and preimages. -/\ntheorem image_identity {α β : Type*} (g : α → β) (C : Set α) (hf : Function.Injective g) :\n g ⁻¹' (g '' C) = C := by\n sorry\n", "path": "tasks/logic-and-sets/logic-and-sets-set_identities-d2-e0005"}
7
+ {"id": "logic-and-sets-finset_card-d3-e0006", "env": "logic-and-sets", "msc": "03", "family": "finset_card", "difficulty": 3, "seed": 10006, "kind": "prove", "instruction": "# Prove a cardinality fact about finite sets\n\nProve the following.\n\nLet \\(s, t, u\\) be finite sets of natural numbers. First prove the identity \\[|s \\cup t \\cup u| + |s \\cap t| + |s \\cap u| + |t \\cap u| = |s| + |t| + |u| + |s \\cap t \\cap u|.\\] Then use it to prove the following, where subtraction is truncated subtraction on the natural numbers: \\[|s \\cup t \\cup u| = |s| + |t| + |u| - |s \\cap t| - |s \\cap u| - |t \\cap u| + |s \\cap t \\cap u|.\\]\n\n## What to do\n\n`Solution.lean` in the working directory states 2 theorems in Lean 4 with Mathlib, with `sorry` in place of each proof. Replace every `sorry` with a proof.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is the share of the 2 theorems that are proved. If the file does not compile the reward is 0, so leave `sorry` on a theorem you cannot finish rather than a broken proof.\n", "start_file": "import Mathlib\n\n/-- Inclusion and exclusion for three finite sets. -/\ntheorem incl_excl (s t u : Finset ℕ) :\n (s ∪ t ∪ u).card + (s ∩ t).card + (s ∩ u).card + (t ∩ u).card = s.card + t.card + u.card + (s ∩ t ∩ u).card := by\n sorry\n\n/-- The size of a union of three finite sets, in terms of the sizes of the intersections. -/\ntheorem card_union_three (s t u : Finset ℕ) :\n (s ∪ t ∪ u).card = s.card + t.card + u.card - (s ∩ t).card - (s ∩ u).card - (t ∩ u).card + (s ∩ t ∩ u).card := by\n sorry\n", "path": "tasks/logic-and-sets/logic-and-sets-finset_card-d3-e0006"}
8
+ {"id": "logic-and-sets-relations-d3-e0007", "env": "logic-and-sets", "msc": "03", "family": "relations", "difficulty": 3, "seed": 10007, "kind": "prove", "instruction": "# Prove properties of a relation\n\nProve the following.\n\nFor an integer \\(q\\), define a relation on the integers by \\(x \\sim y \\iff x \\equiv y \\pmod{q}\\). Prove three things: (1) \\(\\sim\\) is an equivalence relation; (2) \\(\\sim\\) is compatible with addition: if \\(a \\equiv b \\pmod{q}\\) and \\(c \\equiv d \\pmod{q}\\) then \\(a+c \\equiv b+d \\pmod{q}\\); (3) \\(\\sim\\) is compatible with powers: if \\(a \\equiv b \\pmod{q}\\) then \\(a^k \\equiv b^k \\pmod{q}\\) for every natural number \\(k\\).\n\n## What to do\n\n`Solution.lean` in the working directory states 3 theorems in Lean 4 with Mathlib, with `sorry` in place of each proof. Replace every `sorry` with a proof.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is the share of the 3 theorems that are proved. If the file does not compile the reward is 0, so leave `sorry` on a theorem you cannot finish rather than a broken proof.\n", "start_file": "import Mathlib\n\n/-- The relation is reflexive, symmetric and transitive. -/\ntheorem rel_equiv (q : ℤ) :\n Equivalence (fun x y : ℤ => x ≡ y [ZMOD q]) := by\n sorry\n\n/-- The relation is compatible with addition. -/\ntheorem rel_add (q a b c d : ℤ) (h1 : a ≡ b [ZMOD q]) (h2 : c ≡ d [ZMOD q]) :\n a + c ≡ b + d [ZMOD q] := by\n sorry\n\n/-- The relation is compatible with taking powers. -/\ntheorem rel_pow (q a b : ℤ) (k : ℕ) (h : a ≡ b [ZMOD q]) :\n a ^ k ≡ b ^ k [ZMOD q] := by\n sorry\n", "path": "tasks/logic-and-sets/logic-and-sets-relations-d3-e0007"}
9
+ {"id": "logic-and-sets-set_identities-d3-e0008", "env": "logic-and-sets", "msc": "03", "family": "set_identities", "difficulty": 3, "seed": 10008, "kind": "prove", "instruction": "# Prove an identity between sets\n\nProve the following.\n\nLet \\(h : \\alpha \\to \\beta\\) be a function that is injective and let \\(T, S\\) be subsets of \\(\\alpha\\). Write \\(h(X)\\) for the image and \\(h^{-1}(X)\\) for the preimage of a set \\(X\\). Prove \\[h^{-1}(h(T)) \\cap S = T \\cap S.\\]\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The stated statement about images and preimages. -/\ntheorem image_identity {α β : Type*} (h : α → β) (T S : Set α) (hf : Function.Injective h) :\n h ⁻¹' (h '' T) ∩ S = T ∩ S := by\n sorry\n", "path": "tasks/logic-and-sets/logic-and-sets-set_identities-d3-e0008"}
10
+ {"id": "logic-and-sets-finset_card-d1-e0009", "env": "logic-and-sets", "msc": "03", "family": "finset_card", "difficulty": 1, "seed": 10009, "kind": "prove", "instruction": "# Prove a cardinality fact about finite sets\n\nProve the following.\n\nLet \\(f(x) = 5x + 3\\) on the natural numbers and let \\(s, t\\) be finite sets of natural numbers. Prove that the product \\(f(s) \\times t\\) has \\(|s| \\cdot |t|\\) elements.\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- A cardinality fact about finite sets. -/\ntheorem card_fact (s t : Finset ℕ) :\n ((s.image (fun x : ℕ => 5 * x + 3)) ×ˢ t).card = s.card * t.card := by\n sorry\n", "path": "tasks/logic-and-sets/logic-and-sets-finset_card-d1-e0009"}
11
+ {"id": "logic-and-sets-relations-d1-e0010", "env": "logic-and-sets", "msc": "03", "family": "relations", "difficulty": 1, "seed": 10010, "kind": "prove", "instruction": "# Prove properties of a relation\n\nProve the following.\n\nOn the integers define \\(x \\sim y \\iff 7 \\mid x - y\\). Prove that \\(\\sim\\) is an equivalence relation.\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The relation is reflexive, symmetric and transitive. -/\ntheorem rel_equiv :\n Equivalence (fun x y : ℤ => 7 ∣ x - y) := by\n sorry\n", "path": "tasks/logic-and-sets/logic-and-sets-relations-d1-e0010"}
12
+ {"id": "logic-and-sets-set_identities-d1-e0011", "env": "logic-and-sets", "msc": "03", "family": "set_identities", "difficulty": 1, "seed": 10011, "kind": "prove", "instruction": "# Prove an identity between sets\n\nProve the following.\n\nLet \\(B, A, C\\) be subsets of a type \\(\\alpha\\). Prove the set identity \\[(A \\setminus B)^{c} = A^{c} \\cup B.\\]\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The stated identity between sets. -/\ntheorem set_identity {α : Type*} (B A C : Set α) :\n (A \\ B)ᶜ = Aᶜ ∪ B := by\n sorry\n", "path": "tasks/logic-and-sets/logic-and-sets-set_identities-d1-e0011"}
13
+ {"id": "logic-and-sets-finset_card-d2-e0012", "env": "logic-and-sets", "msc": "03", "family": "finset_card", "difficulty": 2, "seed": 10012, "kind": "prove", "instruction": "# Prove a cardinality fact about finite sets\n\nProve the following.\n\nLet \\(f(x) = 5x + 8\\) on the natural numbers and let \\(s, t\\) be finite sets of natural numbers. Prove that \\[|f(s \\cup t)| + |f(s \\cap t)| = |s| + |t|.\\]\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- A cardinality fact about finite sets. -/\ntheorem card_fact (s t : Finset ℕ) :\n ((s ∪ t).image (fun x : ℕ => 5 * x + 8)).card + ((s ∩ t).image (fun x : ℕ => 5 * x + 8)).card = s.card + t.card := by\n sorry\n", "path": "tasks/logic-and-sets/logic-and-sets-finset_card-d2-e0012"}
14
+ {"id": "logic-and-sets-relations-d2-e0013", "env": "logic-and-sets", "msc": "03", "family": "relations", "difficulty": 2, "seed": 10013, "kind": "prove", "instruction": "# Prove properties of a relation\n\nProve the following.\n\nOn the integers define \\(x \\sim y \\iff 12 \\mid x^{4} - y^{4}\\). Prove that \\(\\sim\\) is an equivalence relation.\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The relation is reflexive, symmetric and transitive. -/\ntheorem rel_equiv :\n Equivalence (fun x y : ℤ => 12 ∣ x ^ 4 - y ^ 4) := by\n sorry\n", "path": "tasks/logic-and-sets/logic-and-sets-relations-d2-e0013"}
15
+ {"id": "logic-and-sets-set_identities-d2-e0014", "env": "logic-and-sets", "msc": "03", "family": "set_identities", "difficulty": 2, "seed": 10014, "kind": "prove", "instruction": "# Prove an identity between sets\n\nProve the following.\n\nLet \\(f : \\alpha \\to \\beta\\) be a function and let \\(T\\) be subsets of \\(\\beta\\). Write \\(f(X)\\) for the image and \\(f^{-1}(X)\\) for the preimage of a set \\(X\\). Prove \\[f(f^{-1}(T)) = T \\cap \\operatorname{range} f.\\]\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The stated statement about images and preimages. -/\ntheorem image_identity {α β : Type*} (f : α → β) (T : Set β) :\n f '' (f ⁻¹' T) = T ∩ Set.range f := by\n sorry\n", "path": "tasks/logic-and-sets/logic-and-sets-set_identities-d2-e0014"}
16
+ {"id": "logic-and-sets-finset_card-d3-e0015", "env": "logic-and-sets", "msc": "03", "family": "finset_card", "difficulty": 3, "seed": 10015, "kind": "prove", "instruction": "# Prove a cardinality fact about finite sets\n\nProve the following.\n\nLet \\(f(x) = 4x + 2\\) on the natural numbers and let \\(s, t\\) be disjoint finite sets of natural numbers. Prove that \\(|f(s \\cup t)| = |s| + |t|\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- A cardinality fact about finite sets. -/\ntheorem card_fact (s t : Finset ℕ) (h : Disjoint s t) :\n ((s ∪ t).image (fun x : ℕ => 4 * x + 2)).card = s.card + t.card := by\n sorry\n", "path": "tasks/logic-and-sets/logic-and-sets-finset_card-d3-e0015"}
17
+ {"id": "logic-and-sets-relations-d3-e0016", "env": "logic-and-sets", "msc": "03", "family": "relations", "difficulty": 3, "seed": 10016, "kind": "prove", "instruction": "# Prove properties of a relation\n\nProve the following.\n\nFor an integer \\(m\\), define a relation on the integers by \\(x \\sim y \\iff m \\mid x - y\\). Prove three things: (1) \\(\\sim\\) is an equivalence relation; (2) \\(\\sim\\) is compatible with addition: if \\(m \\mid a - b\\) and \\(m \\mid c - d\\) then \\(m \\mid (a+c) - (b+d)\\); (3) \\(\\sim\\) is compatible with multiplication: if \\(m \\mid a - b\\) and \\(m \\mid c - d\\) then \\(m \\mid ac - bd\\).\n\n## What to do\n\n`Solution.lean` in the working directory states 3 theorems in Lean 4 with Mathlib, with `sorry` in place of each proof. Replace every `sorry` with a proof.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is the share of the 3 theorems that are proved. If the file does not compile the reward is 0, so leave `sorry` on a theorem you cannot finish rather than a broken proof.\n", "start_file": "import Mathlib\n\n/-- The relation is reflexive, symmetric and transitive. -/\ntheorem rel_equiv (m : ℤ) :\n Equivalence (fun x y : ℤ => m ∣ x - y) := by\n sorry\n\n/-- The relation is compatible with addition. -/\ntheorem rel_add (m a b c d : ℤ) (h1 : m ∣ a - b) (h2 : m ∣ c - d) :\n m ∣ (a + c) - (b + d) := by\n sorry\n\n/-- The relation is compatible with multiplication. -/\ntheorem rel_mul (m a b c d : ℤ) (h1 : m ∣ a - b) (h2 : m ∣ c - d) :\n m ∣ a * c - b * d := by\n sorry\n", "path": "tasks/logic-and-sets/logic-and-sets-relations-d3-e0016"}
18
+ {"id": "logic-and-sets-set_identities-d3-e0017", "env": "logic-and-sets", "msc": "03", "family": "set_identities", "difficulty": 3, "seed": 10017, "kind": "prove", "instruction": "# Prove an identity between sets\n\nProve the following.\n\nLet \\(Y, A, C\\) be subsets of a type \\(\\alpha\\). Assume that \\(C \\subseteq Y\\). Prove the set identity \\[(A \\setminus (Y \\cup A)) \\cup C = (Y^{c} \\cup (Y \\setminus C))^{c}.\\]\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The stated identity between sets. -/\ntheorem set_identity {α : Type*} (Y A C : Set α) (h : C ⊆ Y) :\n (A \\ (Y ∪ A)) ∪ C = (Yᶜ ∪ (Y \\ C))ᶜ := by\n sorry\n", "path": "tasks/logic-and-sets/logic-and-sets-set_identities-d3-e0017"}
19
+ {"id": "logic-and-sets-finset_card-d1-e0018", "env": "logic-and-sets", "msc": "03", "family": "finset_card", "difficulty": 1, "seed": 10018, "kind": "prove", "instruction": "# Prove a cardinality fact about finite sets\n\nProve the following.\n\nLet \\(f(x) = 2x + 6\\) on the natural numbers and let \\(s, t\\) be finite sets of natural numbers. Prove that the product \\(f(s) \\times t\\) has \\(|s| \\cdot |t|\\) elements.\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- A cardinality fact about finite sets. -/\ntheorem card_fact (s t : Finset ℕ) :\n ((s.image (fun x : ℕ => 2 * x + 6)) ×ˢ t).card = s.card * t.card := by\n sorry\n", "path": "tasks/logic-and-sets/logic-and-sets-finset_card-d1-e0018"}
20
+ {"id": "logic-and-sets-relations-d1-e0019", "env": "logic-and-sets", "msc": "03", "family": "relations", "difficulty": 1, "seed": 10019, "kind": "prove", "instruction": "# Prove properties of a relation\n\nProve the following.\n\nOn the integers define \\(x \\sim y \\iff x \\bmod 9 = y \\bmod 9\\). Prove that \\(\\sim\\) is an equivalence relation.\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The relation is reflexive, symmetric and transitive. -/\ntheorem rel_equiv :\n Equivalence (fun x y : ℤ => x % 9 = y % 9) := by\n sorry\n", "path": "tasks/logic-and-sets/logic-and-sets-relations-d1-e0019"}
21
+ {"id": "logic-and-sets-set_identities-d1-e0020", "env": "logic-and-sets", "msc": "03", "family": "set_identities", "difficulty": 1, "seed": 10020, "kind": "prove", "instruction": "# Prove an identity between sets\n\nProve the following.\n\nLet \\(C, T, B\\) be subsets of a type \\(\\alpha\\). Prove the set identity \\[T \\cup (B \\cap C) = (T \\cup B) \\cap (T \\cup C).\\]\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The stated identity between sets. -/\ntheorem set_identity {α : Type*} (C T B : Set α) :\n T ∪ (B ∩ C) = (T ∪ B) ∩ (T ∪ C) := by\n sorry\n", "path": "tasks/logic-and-sets/logic-and-sets-set_identities-d1-e0020"}
22
+ {"id": "logic-and-sets-finset_card-d2-e0021", "env": "logic-and-sets", "msc": "03", "family": "finset_card", "difficulty": 2, "seed": 10021, "kind": "prove", "instruction": "# Prove a cardinality fact about finite sets\n\nProve the following.\n\nLet \\(f(x) = 2x + 6\\) on the natural numbers and let \\(s, t\\) be finite sets of natural numbers. Prove that \\[|f(s \\setminus t)| + |s \\cap t| = |s|.\\]\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- A cardinality fact about finite sets. -/\ntheorem card_fact (s t : Finset ℕ) :\n ((s \\ t).image (fun x : ℕ => 2 * x + 6)).card + (s ∩ t).card = s.card := by\n sorry\n", "path": "tasks/logic-and-sets/logic-and-sets-finset_card-d2-e0021"}
23
+ {"id": "logic-and-sets-relations-d2-e0022", "env": "logic-and-sets", "msc": "03", "family": "relations", "difficulty": 2, "seed": 10022, "kind": "prove", "instruction": "# Prove properties of a relation\n\nProve the following.\n\nOn pairs of natural numbers define \\((x_1, y_1) \\sim (x_2, y_2) \\iff x_1 + 6 y_2 = x_2 + 6 y_1\\). Prove that \\(\\sim\\) is an equivalence relation.\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The relation is reflexive, symmetric and transitive. -/\ntheorem rel_equiv :\n Equivalence (fun p q : ℕ × ℕ => p.1 + 6 * q.2 = q.1 + 6 * p.2) := by\n sorry\n", "path": "tasks/logic-and-sets/logic-and-sets-relations-d2-e0022"}
24
+ {"id": "logic-and-sets-set_identities-d2-e0023", "env": "logic-and-sets", "msc": "03", "family": "set_identities", "difficulty": 2, "seed": 10023, "kind": "prove", "instruction": "# Prove an identity between sets\n\nProve the following.\n\nLet \\(h : \\alpha \\to \\beta\\) be a function that is injective and let \\(B\\) be subsets of \\(\\alpha\\). Write \\(h(X)\\) for the image and \\(h^{-1}(X)\\) for the preimage of a set \\(X\\). Prove \\[h^{-1}(h(B)) = B.\\]\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The stated statement about images and preimages. -/\ntheorem image_identity {α β : Type*} (h : α → β) (B : Set α) (hf : Function.Injective h) :\n h ⁻¹' (h '' B) = B := by\n sorry\n", "path": "tasks/logic-and-sets/logic-and-sets-set_identities-d2-e0023"}
data/logic-and-sets/train.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
data/modular-arithmetic/eval.jsonl ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {"id": "modular-arithmetic-congruence_chain-d1-e0000", "env": "modular-arithmetic", "msc": "11", "family": "congruence_chain", "difficulty": 1, "seed": 10000, "kind": "prove", "instruction": "# Prove a fact about divisibility and residues\n\nLet \\(x\\) be an integer with \\(x \\equiv 5 \\pmod{6}\\). Prove that \\(6x^2 + 3x + 5 \\equiv 2 \\pmod{6}\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The polynomial is congruent to the stated residue. -/\ntheorem congr_poly (x : ℤ) (h : x ≡ 5 [ZMOD 6]) :\n 6 * x ^ 2 + 3 * x + 5 ≡ 2 [ZMOD 6] := by\n sorry\n", "path": "tasks/modular-arithmetic/modular-arithmetic-congruence_chain-d1-e0000"}
2
+ {"id": "modular-arithmetic-divisibility-d1-e0001", "env": "modular-arithmetic", "msc": "11", "family": "divisibility", "difficulty": 1, "seed": 10001, "kind": "prove", "instruction": "# Prove a fact about divisibility and residues\n\nProve that for every integer \\(n\\), the number \\(6\\) divides \\(13n^3 - 19n\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The integer divides the polynomial value. -/\ntheorem dvd_poly (n : ℤ) :\n (6 : ℤ) ∣ 13 * n ^ 3 - 19 * n := by\n sorry\n", "path": "tasks/modular-arithmetic/modular-arithmetic-divisibility-d1-e0001"}
3
+ {"id": "modular-arithmetic-gcd_coprime-d1-e0002", "env": "modular-arithmetic", "msc": "11", "family": "gcd_coprime", "difficulty": 1, "seed": 10002, "kind": "prove", "instruction": "# Prove a fact about divisibility and residues\n\nProve that for every integer \\(n\\), the integers \\(5n + 2\\) and \\(8n + 3\\) are coprime, in the sense that \\(u(5n + 2) + v(8n + 3) = 1\\) for some integers \\(u, v\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The two linear forms are coprime. -/\ntheorem coprime_int (n : ℤ) :\n IsCoprime (5 * n + 2) (8 * n + 3) := by\n sorry\n", "path": "tasks/modular-arithmetic/modular-arithmetic-gcd_coprime-d1-e0002"}
4
+ {"id": "modular-arithmetic-power_residues-d1-e0003", "env": "modular-arithmetic", "msc": "11", "family": "power_residues", "difficulty": 1, "seed": 10003, "kind": "prove", "instruction": "# Prove a fact about divisibility and residues\n\nProve that for every natural number \\(n\\), the remainder of \\(7n^2\\) on division by \\(8\\) is one of \\(0, 4, 7\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The remainder of the expression is one of the listed values. -/\ntheorem residues_of_power (n : ℕ) :\n (7 * n ^ 2) % 8 = 0 ∨ (7 * n ^ 2) % 8 = 4 ∨ (7 * n ^ 2) % 8 = 7 := by\n sorry\n", "path": "tasks/modular-arithmetic/modular-arithmetic-power_residues-d1-e0003"}
5
+ {"id": "modular-arithmetic-congruence_chain-d2-e0004", "env": "modular-arithmetic", "msc": "11", "family": "congruence_chain", "difficulty": 2, "seed": 10004, "kind": "prove", "instruction": "# Prove a fact about divisibility and residues\n\nLet \\(x\\) and \\(y\\) be integers with \\(x \\equiv 7 \\pmod{13}\\) and \\(y \\equiv 4 \\pmod{13}\\). Prove that \\(4xy + 3y^2 + 7x \\equiv 1 \\pmod{13}\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The expression is congruent to the stated residue. -/\ntheorem congr_poly2 (x y : ℤ) (hx : x ≡ 7 [ZMOD 13]) (hy : y ≡ 4 [ZMOD 13]) :\n 4 * (x * y) + 3 * y ^ 2 + 7 * x ≡ 1 [ZMOD 13] := by\n sorry\n", "path": "tasks/modular-arithmetic/modular-arithmetic-congruence_chain-d2-e0004"}
6
+ {"id": "modular-arithmetic-divisibility-d2-e0005", "env": "modular-arithmetic", "msc": "11", "family": "divisibility", "difficulty": 2, "seed": 10005, "kind": "prove", "instruction": "# Prove a fact about divisibility and residues\n\nProve that for every integer \\(n\\), the number \\(42\\) divides \\(25n^7 + 101n\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The integer divides the polynomial value. -/\ntheorem dvd_poly (n : ℤ) :\n (42 : ℤ) ∣ 25 * n ^ 7 + 101 * n := by\n sorry\n", "path": "tasks/modular-arithmetic/modular-arithmetic-divisibility-d2-e0005"}
7
+ {"id": "modular-arithmetic-gcd_coprime-d2-e0006", "env": "modular-arithmetic", "msc": "11", "family": "gcd_coprime", "difficulty": 2, "seed": 10006, "kind": "prove", "instruction": "# Prove a fact about divisibility and residues\n\nProve that for every natural number \\(n\\), the numbers \\(3n + 1\\) and \\(7n + 2\\) are coprime.\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The two linear forms are coprime. -/\ntheorem coprime_nat (n : ℕ) :\n Nat.Coprime (3 * n + 1) (7 * n + 2) := by\n sorry\n", "path": "tasks/modular-arithmetic/modular-arithmetic-gcd_coprime-d2-e0006"}
8
+ {"id": "modular-arithmetic-power_residues-d2-e0007", "env": "modular-arithmetic", "msc": "11", "family": "power_residues", "difficulty": 2, "seed": 10007, "kind": "prove", "instruction": "# Prove a fact about divisibility and residues\n\nProve that for every natural number \\(n\\), the remainder of \\(4n^3 + 4\\) on division by \\(9\\) is one of \\(0, 4, 8\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The remainder of the expression is one of the listed values. -/\ntheorem residues_of_power (n : ℕ) :\n (4 * n ^ 3 + 4) % 9 = 0 ∨ (4 * n ^ 3 + 4) % 9 = 4 ∨ (4 * n ^ 3 + 4) % 9 = 8 := by\n sorry\n", "path": "tasks/modular-arithmetic/modular-arithmetic-power_residues-d2-e0007"}
9
+ {"id": "modular-arithmetic-congruence_chain-d3-e0008", "env": "modular-arithmetic", "msc": "11", "family": "congruence_chain", "difficulty": 3, "seed": 10008, "kind": "prove", "instruction": "# Prove a fact about divisibility and residues\n\nLet \\(x\\) and \\(y\\) be integers with \\(x \\equiv 3 \\pmod{10}\\) and \\(y \\equiv 4 \\pmod{10}\\). Prove that \\(x^{18} \\equiv 9 \\pmod{10}\\), and then that \\(x^{18} y^{12} + 4 \\equiv 8 \\pmod{10}\\).\n\n## What to do\n\n`Solution.lean` in the working directory states 2 theorems in Lean 4 with Mathlib, with `sorry` in place of each proof. Replace every `sorry` with a proof.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is the share of the 2 theorems that are proved. If the file does not compile the reward is 0, so leave `sorry` on a theorem you cannot finish rather than a broken proof.\n", "start_file": "import Mathlib\n\n/-- A large power of x has the stated residue. -/\ntheorem congr_pow (x : ℤ) (h : x ≡ 3 [ZMOD 10]) :\n x ^ 18 ≡ 9 [ZMOD 10] := by\n sorry\n\n/-- The combined expression has the stated residue. -/\ntheorem congr_product (x y : ℤ) (hx : x ≡ 3 [ZMOD 10]) (hy : y ≡ 4 [ZMOD 10]) :\n x ^ 18 * y ^ 12 + 4 ≡ 8 [ZMOD 10] := by\n sorry\n", "path": "tasks/modular-arithmetic/modular-arithmetic-congruence_chain-d3-e0008"}
10
+ {"id": "modular-arithmetic-divisibility-d3-e0009", "env": "modular-arithmetic", "msc": "11", "family": "divisibility", "difficulty": 3, "seed": 10009, "kind": "prove", "instruction": "# Prove a fact about divisibility and residues\n\nProve that for every integer \\(n\\), the number \\(42\\) divides \\(29n^7 - 155n\\). Prove it first for each prime factor of \\(42\\), then combine.\n\n## What to do\n\n`Solution.lean` in the working directory states 4 theorems in Lean 4 with Mathlib, with `sorry` in place of each proof. Replace every `sorry` with a proof.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is the share of the 4 theorems that are proved. If the file does not compile the reward is 0, so leave `sorry` on a theorem you cannot finish rather than a broken proof.\n", "start_file": "import Mathlib\n\n/-- The prime 2 divides the polynomial value. -/\ntheorem dvd_by_2 (n : ℤ) :\n (2 : ℤ) ∣ 29 * n ^ 7 - 155 * n := by\n sorry\n\n/-- The prime 3 divides the polynomial value. -/\ntheorem dvd_by_3 (n : ℤ) :\n (3 : ℤ) ∣ 29 * n ^ 7 - 155 * n := by\n sorry\n\n/-- The prime 7 divides the polynomial value. -/\ntheorem dvd_by_7 (n : ℤ) :\n (7 : ℤ) ∣ 29 * n ^ 7 - 155 * n := by\n sorry\n\n/-- The product of the primes divides the polynomial value. -/\ntheorem dvd_poly (n : ℤ) :\n (42 : ℤ) ∣ 29 * n ^ 7 - 155 * n := by\n sorry\n", "path": "tasks/modular-arithmetic/modular-arithmetic-divisibility-d3-e0009"}
11
+ {"id": "modular-arithmetic-gcd_coprime-d3-e0010", "env": "modular-arithmetic", "msc": "11", "family": "gcd_coprime", "difficulty": 3, "seed": 10010, "kind": "prove", "instruction": "# Prove a fact about divisibility and residues\n\nLet \\(n\\) be a natural number and \\(g = \\gcd(5n + 7, 6n + 9)\\). Prove that \\(g\\) divides \\(3\\), and conclude that \\(g = 1\\) or \\(g = 3\\).\n\n## What to do\n\n`Solution.lean` in the working directory states 2 theorems in Lean 4 with Mathlib, with `sorry` in place of each proof. Replace every `sorry` with a proof.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is the share of the 2 theorems that are proved. If the file does not compile the reward is 0, so leave `sorry` on a theorem you cannot finish rather than a broken proof.\n", "start_file": "import Mathlib\n\n/-- The gcd divides the determinant. -/\ntheorem gcd_dvd_det (n : ℕ) :\n Nat.gcd (5 * n + 7) (6 * n + 9) ∣ 3 := by\n sorry\n\n/-- The gcd is 1 or the prime determinant. -/\ntheorem gcd_one_or_prime (n : ℕ) :\n Nat.gcd (5 * n + 7) (6 * n + 9) = 1 ∨ Nat.gcd (5 * n + 7) (6 * n + 9) = 3 := by\n sorry\n", "path": "tasks/modular-arithmetic/modular-arithmetic-gcd_coprime-d3-e0010"}
12
+ {"id": "modular-arithmetic-power_residues-d3-e0011", "env": "modular-arithmetic", "msc": "11", "family": "power_residues", "difficulty": 3, "seed": 10011, "kind": "prove", "instruction": "# Prove a fact about divisibility and residues\n\nProve that for all natural numbers \\(a\\) and \\(b\\), the number \\(a^2 + 3b^2 + 6\\) never leaves remainder \\(8\\) on division by \\(9\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The expression never leaves the stated remainder. -/\ntheorem residue_never_attained (a b : ℕ) :\n (a ^ 2 + 3 * b ^ 2 + 6) % 9 ≠ 8 := by\n sorry\n", "path": "tasks/modular-arithmetic/modular-arithmetic-power_residues-d3-e0011"}
13
+ {"id": "modular-arithmetic-congruence_chain-d1-e0012", "env": "modular-arithmetic", "msc": "11", "family": "congruence_chain", "difficulty": 1, "seed": 10012, "kind": "prove", "instruction": "# Prove a fact about divisibility and residues\n\nLet \\(x\\) be an integer with \\(x \\equiv 1 \\pmod{7}\\). Prove that \\(6x^2 + 7x + 4 \\equiv 3 \\pmod{7}\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The polynomial is congruent to the stated residue. -/\ntheorem congr_poly (x : ℤ) (h : x ≡ 1 [ZMOD 7]) :\n 6 * x ^ 2 + 7 * x + 4 ≡ 3 [ZMOD 7] := by\n sorry\n", "path": "tasks/modular-arithmetic/modular-arithmetic-congruence_chain-d1-e0012"}
14
+ {"id": "modular-arithmetic-divisibility-d1-e0013", "env": "modular-arithmetic", "msc": "11", "family": "divisibility", "difficulty": 1, "seed": 10013, "kind": "prove", "instruction": "# Prove a fact about divisibility and residues\n\nProve that for every integer \\(n\\), the number \\(30\\) divides \\(31n^5 + 29n\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The integer divides the polynomial value. -/\ntheorem dvd_poly (n : ℤ) :\n (30 : ℤ) ∣ 31 * n ^ 5 + 29 * n := by\n sorry\n", "path": "tasks/modular-arithmetic/modular-arithmetic-divisibility-d1-e0013"}
15
+ {"id": "modular-arithmetic-gcd_coprime-d1-e0014", "env": "modular-arithmetic", "msc": "11", "family": "gcd_coprime", "difficulty": 1, "seed": 10014, "kind": "prove", "instruction": "# Prove a fact about divisibility and residues\n\nProve that for every integer \\(n\\), the integers \\(n + 8\\) and \\(3n + 23\\) are coprime, in the sense that \\(u(n + 8) + v(3n + 23) = 1\\) for some integers \\(u, v\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The two linear forms are coprime. -/\ntheorem coprime_int (n : ℤ) :\n IsCoprime (n + 8) (3 * n + 23) := by\n sorry\n", "path": "tasks/modular-arithmetic/modular-arithmetic-gcd_coprime-d1-e0014"}
16
+ {"id": "modular-arithmetic-power_residues-d1-e0015", "env": "modular-arithmetic", "msc": "11", "family": "power_residues", "difficulty": 1, "seed": 10015, "kind": "prove", "instruction": "# Prove a fact about divisibility and residues\n\nProve that for every natural number \\(n\\), the remainder of \\(4n^2 + 3\\) on division by \\(5\\) is one of \\(2, 3, 4\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The remainder of the expression is one of the listed values. -/\ntheorem residues_of_power (n : ℕ) :\n (4 * n ^ 2 + 3) % 5 = 2 ∨ (4 * n ^ 2 + 3) % 5 = 3 ∨ (4 * n ^ 2 + 3) % 5 = 4 := by\n sorry\n", "path": "tasks/modular-arithmetic/modular-arithmetic-power_residues-d1-e0015"}
17
+ {"id": "modular-arithmetic-congruence_chain-d2-e0016", "env": "modular-arithmetic", "msc": "11", "family": "congruence_chain", "difficulty": 2, "seed": 10016, "kind": "prove", "instruction": "# Prove a fact about divisibility and residues\n\nLet \\(x\\) and \\(y\\) be integers with \\(x \\equiv 2 \\pmod{9}\\) and \\(y \\equiv 8 \\pmod{9}\\). Prove that \\(3xy + y^2 + 3x \\equiv 1 \\pmod{9}\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The expression is congruent to the stated residue. -/\ntheorem congr_poly2 (x y : ℤ) (hx : x ≡ 2 [ZMOD 9]) (hy : y ≡ 8 [ZMOD 9]) :\n 3 * (x * y) + y ^ 2 + 3 * x ≡ 1 [ZMOD 9] := by\n sorry\n", "path": "tasks/modular-arithmetic/modular-arithmetic-congruence_chain-d2-e0016"}
18
+ {"id": "modular-arithmetic-divisibility-d2-e0017", "env": "modular-arithmetic", "msc": "11", "family": "divisibility", "difficulty": 2, "seed": 10017, "kind": "prove", "instruction": "# Prove a fact about divisibility and residues\n\nProve that for every integer \\(n\\), the number \\(6\\) divides \\(29n^3 - 35n\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The integer divides the polynomial value. -/\ntheorem dvd_poly (n : ℤ) :\n (6 : ℤ) ∣ 29 * n ^ 3 - 35 * n := by\n sorry\n", "path": "tasks/modular-arithmetic/modular-arithmetic-divisibility-d2-e0017"}
19
+ {"id": "modular-arithmetic-gcd_coprime-d2-e0018", "env": "modular-arithmetic", "msc": "11", "family": "gcd_coprime", "difficulty": 2, "seed": 10018, "kind": "prove", "instruction": "# Prove a fact about divisibility and residues\n\nProve that for every natural number \\(n\\), the numbers \\(2n + 5\\) and \\(9n + 23\\) are coprime.\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The two linear forms are coprime. -/\ntheorem coprime_nat (n : ℕ) :\n Nat.Coprime (2 * n + 5) (9 * n + 23) := by\n sorry\n", "path": "tasks/modular-arithmetic/modular-arithmetic-gcd_coprime-d2-e0018"}
20
+ {"id": "modular-arithmetic-power_residues-d2-e0019", "env": "modular-arithmetic", "msc": "11", "family": "power_residues", "difficulty": 2, "seed": 10019, "kind": "prove", "instruction": "# Prove a fact about divisibility and residues\n\nProve that for every natural number \\(n\\), the remainder of \\(2n^4 + 4\\) on division by \\(7\\) is one of \\(1, 4, 5, 6\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The remainder of the expression is one of the listed values. -/\ntheorem residues_of_power (n : ℕ) :\n (2 * n ^ 4 + 4) % 7 = 1 ∨ (2 * n ^ 4 + 4) % 7 = 4 ∨ (2 * n ^ 4 + 4) % 7 = 5 ∨ (2 * n ^ 4 + 4) % 7 = 6 := by\n sorry\n", "path": "tasks/modular-arithmetic/modular-arithmetic-power_residues-d2-e0019"}
21
+ {"id": "modular-arithmetic-congruence_chain-d3-e0020", "env": "modular-arithmetic", "msc": "11", "family": "congruence_chain", "difficulty": 3, "seed": 10020, "kind": "prove", "instruction": "# Prove a fact about divisibility and residues\n\nLet \\(x\\) and \\(y\\) be integers with \\(x \\equiv 5 \\pmod{12}\\) and \\(y \\equiv 11 \\pmod{12}\\). Prove that \\(x^{36} \\equiv 1 \\pmod{12}\\), and then that \\(x^{36} y^{39} + 6 \\equiv 5 \\pmod{12}\\).\n\n## What to do\n\n`Solution.lean` in the working directory states 2 theorems in Lean 4 with Mathlib, with `sorry` in place of each proof. Replace every `sorry` with a proof.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is the share of the 2 theorems that are proved. If the file does not compile the reward is 0, so leave `sorry` on a theorem you cannot finish rather than a broken proof.\n", "start_file": "import Mathlib\n\n/-- A large power of x has the stated residue. -/\ntheorem congr_pow (x : ℤ) (h : x ≡ 5 [ZMOD 12]) :\n x ^ 36 ≡ 1 [ZMOD 12] := by\n sorry\n\n/-- The combined expression has the stated residue. -/\ntheorem congr_product (x y : ℤ) (hx : x ≡ 5 [ZMOD 12]) (hy : y ≡ 11 [ZMOD 12]) :\n x ^ 36 * y ^ 39 + 6 ≡ 5 [ZMOD 12] := by\n sorry\n", "path": "tasks/modular-arithmetic/modular-arithmetic-congruence_chain-d3-e0020"}
22
+ {"id": "modular-arithmetic-divisibility-d3-e0021", "env": "modular-arithmetic", "msc": "11", "family": "divisibility", "difficulty": 3, "seed": 10021, "kind": "prove", "instruction": "# Prove a fact about divisibility and residues\n\nProve that for every integer \\(n\\), the number \\(42\\) divides \\(n^7 - n\\). Prove it first for each prime factor of \\(42\\), then combine.\n\n## What to do\n\n`Solution.lean` in the working directory states 4 theorems in Lean 4 with Mathlib, with `sorry` in place of each proof. Replace every `sorry` with a proof.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is the share of the 4 theorems that are proved. If the file does not compile the reward is 0, so leave `sorry` on a theorem you cannot finish rather than a broken proof.\n", "start_file": "import Mathlib\n\n/-- The prime 2 divides the polynomial value. -/\ntheorem dvd_by_2 (n : ℤ) :\n (2 : ℤ) ∣ n ^ 7 - n := by\n sorry\n\n/-- The prime 3 divides the polynomial value. -/\ntheorem dvd_by_3 (n : ℤ) :\n (3 : ℤ) ∣ n ^ 7 - n := by\n sorry\n\n/-- The prime 7 divides the polynomial value. -/\ntheorem dvd_by_7 (n : ℤ) :\n (7 : ℤ) ∣ n ^ 7 - n := by\n sorry\n\n/-- The product of the primes divides the polynomial value. -/\ntheorem dvd_poly (n : ℤ) :\n (42 : ℤ) ∣ n ^ 7 - n := by\n sorry\n", "path": "tasks/modular-arithmetic/modular-arithmetic-divisibility-d3-e0021"}
23
+ {"id": "modular-arithmetic-gcd_coprime-d3-e0022", "env": "modular-arithmetic", "msc": "11", "family": "gcd_coprime", "difficulty": 3, "seed": 10022, "kind": "prove", "instruction": "# Prove a fact about divisibility and residues\n\nLet \\(n\\) be a natural number and \\(g = \\gcd(7n + 6, 8n + 5)\\). Prove that \\(g\\) divides \\(13\\), and conclude that \\(g = 1\\) or \\(g = 13\\).\n\n## What to do\n\n`Solution.lean` in the working directory states 2 theorems in Lean 4 with Mathlib, with `sorry` in place of each proof. Replace every `sorry` with a proof.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is the share of the 2 theorems that are proved. If the file does not compile the reward is 0, so leave `sorry` on a theorem you cannot finish rather than a broken proof.\n", "start_file": "import Mathlib\n\n/-- The gcd divides the determinant. -/\ntheorem gcd_dvd_det (n : ℕ) :\n Nat.gcd (7 * n + 6) (8 * n + 5) ∣ 13 := by\n sorry\n\n/-- The gcd is 1 or the prime determinant. -/\ntheorem gcd_one_or_prime (n : ℕ) :\n Nat.gcd (7 * n + 6) (8 * n + 5) = 1 ∨ Nat.gcd (7 * n + 6) (8 * n + 5) = 13 := by\n sorry\n", "path": "tasks/modular-arithmetic/modular-arithmetic-gcd_coprime-d3-e0022"}
24
+ {"id": "modular-arithmetic-power_residues-d3-e0023", "env": "modular-arithmetic", "msc": "11", "family": "power_residues", "difficulty": 3, "seed": 10023, "kind": "prove", "instruction": "# Prove a fact about divisibility and residues\n\nProve that for all natural numbers \\(a\\) and \\(b\\), the number \\(a^2 + 3b^2 + 1\\) never leaves remainder \\(7\\) on division by \\(8\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The expression never leaves the stated remainder. -/\ntheorem residue_never_attained (a b : ℕ) :\n (a ^ 2 + 3 * b ^ 2 + 1) % 8 ≠ 7 := by\n sorry\n", "path": "tasks/modular-arithmetic/modular-arithmetic-power_residues-d3-e0023"}
data/modular-arithmetic/train.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
data/real-analysis/eval.jsonl ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {"id": "real-analysis-continuity-d1-e0000", "env": "real-analysis", "msc": "26", "family": "continuity", "difficulty": 1, "seed": 10000, "kind": "prove", "instruction": "# Prove continuity from the epsilon-delta definition\n\nProve, from the epsilon-delta definition, that \\(f(x) = -4x + 3\\) is continuous at \\(x_0 = 0\\): for every \\(\\varepsilon > 0\\) there is \\(\\delta > 0\\) such that \\(|f(x) - f(x_0)| < \\varepsilon\\) whenever \\(|x - x_0| < \\delta\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- Epsilon-delta continuity of a linear function at a point. -/\ntheorem continuous_at :\n ∀ ε > 0, ∃ δ > 0, ∀ x : ℝ, |x - (0 : ℝ)| < δ → |((-4 : ℝ) * x + (3 : ℝ)) - ((-4 : ℝ) * (0 : ℝ) + (3 : ℝ))| < ε := by\n sorry\n", "path": "tasks/real-analysis/real-analysis-continuity-d1-e0000"}
2
+ {"id": "real-analysis-limit_sequence-d1-e0001", "env": "real-analysis", "msc": "26", "family": "limit_sequence", "difficulty": 1, "seed": 10001, "kind": "prove", "instruction": "# Prove a limit from the definition\n\nProve, directly from the definition of a limit, that the sequence \\(u_n = \\dfrac{4}{n + 3}\\) tends to \\(0\\): for every \\(\\varepsilon > 0\\) there is \\(N\\) such that \\(|u_n - 0| < \\varepsilon\\) for all \\(n \\ge N\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The sequence tends to 0 (epsilon-N definition). -/\ntheorem seq_limit :\n ∀ ε > 0, ∃ N : ℕ, ∀ n ≥ N, |(4 : ℝ) / ((n : ℝ) + (3 : ℝ)) - 0| < ε := by\n sorry\n", "path": "tasks/real-analysis/real-analysis-limit_sequence-d1-e0001"}
3
+ {"id": "real-analysis-sequence_bounds-d1-e0002", "env": "real-analysis", "msc": "26", "family": "sequence_bounds", "difficulty": 1, "seed": 10002, "kind": "prove", "instruction": "# Bound a recursive sequence\n\nDefine a real sequence by \\(a_0 = \\frac{8}{3}\\) and \\(a_{n+1} = \\frac{a_n}{2} + \\frac{4}{3}\\). Prove that \\(0 \\le a_n \\le \\frac{8}{3}\\) for every \\(n\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\nnoncomputable def a : ℕ → ℝ\n | 0 => (8 / 3 : ℝ)\n | (n + 1) => a n / 2 + (4 / 3 : ℝ)\n\n/-- The sequence stays between 0 and its upper bound. -/\ntheorem a_bounds :\n ∀ n : ℕ, 0 ≤ a n ∧ a n ≤ (8 / 3 : ℝ) := by\n sorry\n", "path": "tasks/real-analysis/real-analysis-sequence_bounds-d1-e0002"}
4
+ {"id": "real-analysis-uniform_bounds-d1-e0003", "env": "real-analysis", "msc": "26", "family": "uniform_bounds", "difficulty": 1, "seed": 10003, "kind": "prove", "instruction": "# Prove a uniform bound\n\nProve that for every natural number \\(n\\) and every real \\(x\\) with \\(-\\frac{4}{5} \\le x \\le \\frac{4}{5}\\), \\[|3\\,x^{n+1}| \\le 3 \\cdot \\frac{4}{5}^{n+1}.\\]\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- A bound that does not depend on the point x. -/\ntheorem uniform_bound :\n ∀ n : ℕ, ∀ x ∈ Set.Icc (-(4 / 5 : ℝ)) (4 / 5 : ℝ), |3 * x ^ (n + 1)| ≤ 3 * (4 / 5 : ℝ) ^ (n + 1) := by\n sorry\n", "path": "tasks/real-analysis/real-analysis-uniform_bounds-d1-e0003"}
5
+ {"id": "real-analysis-continuity-d2-e0004", "env": "real-analysis", "msc": "26", "family": "continuity", "difficulty": 2, "seed": 10004, "kind": "prove", "instruction": "# Prove continuity from the epsilon-delta definition\n\nProve, from the epsilon-delta definition, that \\(f(x) = x^2 + 5\\) is continuous at \\(x_0 = -4\\): for every \\(\\varepsilon > 0\\) there is \\(\\delta > 0\\) such that \\(|f(x) - f(x_0)| < \\varepsilon\\) whenever \\(|x - x_0| < \\delta\\). Do not use any continuity lemma from the library.\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- Epsilon-delta continuity of a quadratic function at a point. -/\ntheorem continuous_at :\n ∀ ε > 0, ∃ δ > 0, ∀ x : ℝ, |x - (-4 : ℝ)| < δ → |((1 : ℝ) * x ^ 2 + (5 : ℝ)) - ((1 : ℝ) * (-4 : ℝ) ^ 2 + (5 : ℝ))| < ε := by\n sorry\n", "path": "tasks/real-analysis/real-analysis-continuity-d2-e0004"}
6
+ {"id": "real-analysis-limit_sequence-d2-e0005", "env": "real-analysis", "msc": "26", "family": "limit_sequence", "difficulty": 2, "seed": 10005, "kind": "prove", "instruction": "# Prove a limit from the definition\n\nProve, directly from the definition of a limit, that \\(u_n = \\dfrac{2n + 8}{2n + 3}\\) tends to \\(\\dfrac{2}{2}\\): for every \\(\\varepsilon > 0\\) there is \\(N\\) such that \\(\\left|u_n - \\frac{2}{2}\\right| < \\varepsilon\\) for all \\(n \\ge N\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The sequence converges to a/c (epsilon-N definition). -/\ntheorem seq_limit :\n ∀ ε > 0, ∃ N : ℕ, ∀ n ≥ N, |((2 : ℝ) * (n : ℝ) + (8 : ℝ)) / ((2 : ℝ) * (n : ℝ) + (3 : ℝ)) - (2 : ℝ) / (2 : ℝ)| < ε := by\n sorry\n", "path": "tasks/real-analysis/real-analysis-limit_sequence-d2-e0005"}
7
+ {"id": "real-analysis-sequence_bounds-d2-e0006", "env": "real-analysis", "msc": "26", "family": "sequence_bounds", "difficulty": 2, "seed": 10006, "kind": "prove", "instruction": "# Bound a recursive sequence\n\nDefine a real sequence by \\(a_0 = \\frac{5}{2}\\) and \\(a_{n+1} = \\frac{a_n}{2} + \\frac{5}{2}\\). Prove that \\(0 \\le a_n \\le 5\\) for every \\(n\\), and then that the sequence is monotone (non-decreasing).\n\n## What to do\n\n`Solution.lean` in the working directory states 2 theorems in Lean 4 with Mathlib, with `sorry` in place of each proof. Replace every `sorry` with a proof.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is the share of the 2 theorems that are proved. If the file does not compile the reward is 0, so leave `sorry` on a theorem you cannot finish rather than a broken proof.\n", "start_file": "import Mathlib\n\nnoncomputable def a : ℕ → ℝ\n | 0 => (5 / 2 : ℝ)\n | (n + 1) => a n / 2 + (5 / 2 : ℝ)\n\n/-- The sequence stays between 0 and its upper bound. -/\ntheorem a_bounds :\n ∀ n : ℕ, 0 ≤ a n ∧ a n ≤ (5 : ℝ) := by\n sorry\n\n/-- The sequence is increasing. -/\ntheorem a_monotone :\n Monotone a := by\n sorry\n", "path": "tasks/real-analysis/real-analysis-sequence_bounds-d2-e0006"}
8
+ {"id": "real-analysis-uniform_bounds-d2-e0007", "env": "real-analysis", "msc": "26", "family": "uniform_bounds", "difficulty": 2, "seed": 10007, "kind": "prove", "instruction": "# Prove a uniform bound\n\nProve that for every natural number \\(n\\) and every real \\(x\\) with \\(0 \\le x \\le \\frac{1}{4}\\), \\[\\sum_{i=0}^{n-1} x^{i} \\le \\frac{1}{1 - \\frac{1}{4}}.\\] The sum is empty when \\(n = 0\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- A bound on partial geometric sums that does not depend on n or x. -/\ntheorem uniform_bound :\n ∀ n : ℕ, ∀ x ∈ Set.Icc (0 : ℝ) (1 / 4 : ℝ), ∑ i ∈ Finset.range n, x ^ i ≤ 1 / (1 - (1 / 4 : ℝ)) := by\n sorry\n", "path": "tasks/real-analysis/real-analysis-uniform_bounds-d2-e0007"}
9
+ {"id": "real-analysis-continuity-d3-e0008", "env": "real-analysis", "msc": "26", "family": "continuity", "difficulty": 3, "seed": 10008, "kind": "prove", "instruction": "# Prove continuity from the epsilon-delta definition\n\nProve, from the epsilon-delta definition, that \\(f(x) = \\dfrac{2}{x}\\) is continuous at \\(x_0 = 5\\): for every \\(\\varepsilon > 0\\) there is \\(\\delta > 0\\) such that \\(|f(x) - f(x_0)| < \\varepsilon\\) whenever \\(|x - x_0| < \\delta\\). Here \\(x\\) ranges over all real numbers (in Lean, division by 0 gives 0, which does not matter for small \\(\\delta\\)).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- Epsilon-delta continuity of the reciprocal function at a point. -/\ntheorem continuous_at :\n ∀ ε > 0, ∃ δ > 0, ∀ x : ℝ, |x - (5 : ℝ)| < δ → |(2 : ℝ) / x - (2 : ℝ) / (5 : ℝ)| < ε := by\n sorry\n", "path": "tasks/real-analysis/real-analysis-continuity-d3-e0008"}
10
+ {"id": "real-analysis-limit_sequence-d3-e0009", "env": "real-analysis", "msc": "26", "family": "limit_sequence", "difficulty": 3, "seed": 10009, "kind": "prove", "instruction": "# Prove a limit from the definition\n\nProve, directly from the definition of a limit, that \\(u_n = \\dfrac{6n + 4}{n^2 + 6}\\) tends to \\(0\\): for every \\(\\varepsilon > 0\\) there is \\(N\\) such that \\(|u_n - 0| < \\varepsilon\\) for all \\(n \\ge N\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The sequence tends to 0 (epsilon-N definition). -/\ntheorem seq_limit :\n ∀ ε > 0, ∃ N : ℕ, ∀ n ≥ N, |((6 : ℝ) * (n : ℝ) + (4 : ℝ)) / ((n : ℝ) ^ 2 + (6 : ℝ)) - 0| < ε := by\n sorry\n", "path": "tasks/real-analysis/real-analysis-limit_sequence-d3-e0009"}
11
+ {"id": "real-analysis-sequence_bounds-d3-e0010", "env": "real-analysis", "msc": "26", "family": "sequence_bounds", "difficulty": 3, "seed": 10010, "kind": "prove", "instruction": "# Bound a recursive sequence\n\nDefine a real sequence by \\(a_0 = \\frac{2}{5}\\) and \\(a_{n+1} = \\dfrac{a_n^2 + \\frac{16}{25}}{2}\\). Prove that \\(0 \\le a_n \\le \\frac{2}{5}\\) for every \\(n\\) (note that \\(\\frac{2}{5}\\) is a fixed point of the recursion), and then that the sequence is monotone (non-decreasing).\n\n## What to do\n\n`Solution.lean` in the working directory states 2 theorems in Lean 4 with Mathlib, with `sorry` in place of each proof. Replace every `sorry` with a proof.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is the share of the 2 theorems that are proved. If the file does not compile the reward is 0, so leave `sorry` on a theorem you cannot finish rather than a broken proof.\n", "start_file": "import Mathlib\n\nnoncomputable def a : ℕ → ℝ\n | 0 => (2 / 5 : ℝ)\n | (n + 1) => (a n ^ 2 + (16 / 25 : ℝ)) / 2\n\n/-- The sequence stays between 0 and the smaller fixed point. -/\ntheorem a_bounds :\n ∀ n : ℕ, 0 ≤ a n ∧ a n ≤ (2 / 5 : ℝ) := by\n sorry\n\n/-- The sequence is increasing. -/\ntheorem a_monotone :\n Monotone a := by\n sorry\n", "path": "tasks/real-analysis/real-analysis-sequence_bounds-d3-e0010"}
12
+ {"id": "real-analysis-uniform_bounds-d3-e0011", "env": "real-analysis", "msc": "26", "family": "uniform_bounds", "difficulty": 3, "seed": 10011, "kind": "prove", "instruction": "# Prove a uniform bound\n\nProve that \\(c\\,x^n\\) with \\(c = 5\\) tends to \\(0\\) uniformly on \\([-\\frac{1}{4}, \\frac{1}{4}]\\): for every \\(\\varepsilon > 0\\) there is \\(N\\) such that \\(|5\\,x^n| < \\varepsilon\\) for all \\(n \\ge N\\) and all real \\(x\\) with \\(|x| \\le \\frac{1}{4}\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- Uniform convergence of a geometric sequence on an interval. -/\ntheorem uniform_convergence :\n ∀ ε > 0, ∃ N : ℕ, ∀ n ≥ N, ∀ x : ℝ, |x| ≤ (1 / 4 : ℝ) → |5 * x ^ n| < ε := by\n sorry\n", "path": "tasks/real-analysis/real-analysis-uniform_bounds-d3-e0011"}
13
+ {"id": "real-analysis-continuity-d1-e0012", "env": "real-analysis", "msc": "26", "family": "continuity", "difficulty": 1, "seed": 10012, "kind": "prove", "instruction": "# Prove continuity from the epsilon-delta definition\n\nProve, from the epsilon-delta definition, that \\(f(x) = -6x - 1\\) is continuous at \\(x_0 = -3\\): for every \\(\\varepsilon > 0\\) there is \\(\\delta > 0\\) such that \\(|f(x) - f(x_0)| < \\varepsilon\\) whenever \\(|x - x_0| < \\delta\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- Epsilon-delta continuity of a linear function at a point. -/\ntheorem continuous_at :\n ∀ ε > 0, ∃ δ > 0, ∀ x : ℝ, |x - (-3 : ℝ)| < δ → |((-6 : ℝ) * x + (-1 : ℝ)) - ((-6 : ℝ) * (-3 : ℝ) + (-1 : ℝ))| < ε := by\n sorry\n", "path": "tasks/real-analysis/real-analysis-continuity-d1-e0012"}
14
+ {"id": "real-analysis-limit_sequence-d1-e0013", "env": "real-analysis", "msc": "26", "family": "limit_sequence", "difficulty": 1, "seed": 10013, "kind": "prove", "instruction": "# Prove a limit from the definition\n\nProve, directly from the definition of a limit, that the sequence \\(u_n = \\dfrac{4}{n + 9}\\) tends to \\(0\\): for every \\(\\varepsilon > 0\\) there is \\(N\\) such that \\(|u_n - 0| < \\varepsilon\\) for all \\(n \\ge N\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The sequence tends to 0 (epsilon-N definition). -/\ntheorem seq_limit :\n ∀ ε > 0, ∃ N : ℕ, ∀ n ≥ N, |(4 : ℝ) / ((n : ℝ) + (9 : ℝ)) - 0| < ε := by\n sorry\n", "path": "tasks/real-analysis/real-analysis-limit_sequence-d1-e0013"}
15
+ {"id": "real-analysis-sequence_bounds-d1-e0014", "env": "real-analysis", "msc": "26", "family": "sequence_bounds", "difficulty": 1, "seed": 10014, "kind": "prove", "instruction": "# Bound a recursive sequence\n\nDefine a real sequence by \\(a_0 = \\frac{7}{2}\\) and \\(a_{n+1} = \\frac{a_n}{2} + \\frac{7}{2}\\). Prove that \\(0 \\le a_n \\le 7\\) for every \\(n\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\nnoncomputable def a : ℕ → ℝ\n | 0 => (7 / 2 : ℝ)\n | (n + 1) => a n / 2 + (7 / 2 : ℝ)\n\n/-- The sequence stays between 0 and its upper bound. -/\ntheorem a_bounds :\n ∀ n : ℕ, 0 ≤ a n ∧ a n ≤ (7 : ℝ) := by\n sorry\n", "path": "tasks/real-analysis/real-analysis-sequence_bounds-d1-e0014"}
16
+ {"id": "real-analysis-uniform_bounds-d1-e0015", "env": "real-analysis", "msc": "26", "family": "uniform_bounds", "difficulty": 1, "seed": 10015, "kind": "prove", "instruction": "# Prove a uniform bound\n\nProve that for every natural number \\(n\\) and every real \\(x\\) with \\(-\\frac{4}{5} \\le x \\le \\frac{4}{5}\\), \\[|7\\,x^{n+1}| \\le 7 \\cdot \\frac{4}{5}^{n+1}.\\]\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- A bound that does not depend on the point x. -/\ntheorem uniform_bound :\n ∀ n : ℕ, ∀ x ∈ Set.Icc (-(4 / 5 : ℝ)) (4 / 5 : ℝ), |7 * x ^ (n + 1)| ≤ 7 * (4 / 5 : ℝ) ^ (n + 1) := by\n sorry\n", "path": "tasks/real-analysis/real-analysis-uniform_bounds-d1-e0015"}
17
+ {"id": "real-analysis-continuity-d2-e0016", "env": "real-analysis", "msc": "26", "family": "continuity", "difficulty": 2, "seed": 10016, "kind": "prove", "instruction": "# Prove continuity from the epsilon-delta definition\n\nProve, from the epsilon-delta definition, that \\(f(x) = 2x^2 + 4\\) is continuous at \\(x_0 = 4\\): for every \\(\\varepsilon > 0\\) there is \\(\\delta > 0\\) such that \\(|f(x) - f(x_0)| < \\varepsilon\\) whenever \\(|x - x_0| < \\delta\\). Do not use any continuity lemma from the library.\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- Epsilon-delta continuity of a quadratic function at a point. -/\ntheorem continuous_at :\n ∀ ε > 0, ∃ δ > 0, ∀ x : ℝ, |x - (4 : ℝ)| < δ → |((2 : ℝ) * x ^ 2 + (4 : ℝ)) - ((2 : ℝ) * (4 : ℝ) ^ 2 + (4 : ℝ))| < ε := by\n sorry\n", "path": "tasks/real-analysis/real-analysis-continuity-d2-e0016"}
18
+ {"id": "real-analysis-limit_sequence-d2-e0017", "env": "real-analysis", "msc": "26", "family": "limit_sequence", "difficulty": 2, "seed": 10017, "kind": "prove", "instruction": "# Prove a limit from the definition\n\nProve, directly from the definition of a limit, that \\(u_n = \\dfrac{-3n + 4}{2n + 5}\\) tends to \\(\\dfrac{-3}{2}\\): for every \\(\\varepsilon > 0\\) there is \\(N\\) such that \\(\\left|u_n - \\frac{-3}{2}\\right| < \\varepsilon\\) for all \\(n \\ge N\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The sequence converges to a/c (epsilon-N definition). -/\ntheorem seq_limit :\n ∀ ε > 0, ∃ N : ℕ, ∀ n ≥ N, |((-3 : ℝ) * (n : ℝ) + (4 : ℝ)) / ((2 : ℝ) * (n : ℝ) + (5 : ℝ)) - (-3 : ℝ) / (2 : ℝ)| < ε := by\n sorry\n", "path": "tasks/real-analysis/real-analysis-limit_sequence-d2-e0017"}
19
+ {"id": "real-analysis-sequence_bounds-d2-e0018", "env": "real-analysis", "msc": "26", "family": "sequence_bounds", "difficulty": 2, "seed": 10018, "kind": "prove", "instruction": "# Bound a recursive sequence\n\nDefine a real sequence by \\(a_0 = 9\\) and \\(a_{n+1} = \\frac{a_n}{2} + 6\\). Prove that \\(0 \\le a_n \\le 12\\) for every \\(n\\), and then that the sequence is monotone (non-decreasing).\n\n## What to do\n\n`Solution.lean` in the working directory states 2 theorems in Lean 4 with Mathlib, with `sorry` in place of each proof. Replace every `sorry` with a proof.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is the share of the 2 theorems that are proved. If the file does not compile the reward is 0, so leave `sorry` on a theorem you cannot finish rather than a broken proof.\n", "start_file": "import Mathlib\n\nnoncomputable def a : ℕ → ℝ\n | 0 => (9 : ℝ)\n | (n + 1) => a n / 2 + (6 : ℝ)\n\n/-- The sequence stays between 0 and its upper bound. -/\ntheorem a_bounds :\n ∀ n : ℕ, 0 ≤ a n ∧ a n ≤ (12 : ℝ) := by\n sorry\n\n/-- The sequence is increasing. -/\ntheorem a_monotone :\n Monotone a := by\n sorry\n", "path": "tasks/real-analysis/real-analysis-sequence_bounds-d2-e0018"}
20
+ {"id": "real-analysis-uniform_bounds-d2-e0019", "env": "real-analysis", "msc": "26", "family": "uniform_bounds", "difficulty": 2, "seed": 10019, "kind": "prove", "instruction": "# Prove a uniform bound\n\nProve that for every natural number \\(n\\) and every real \\(x\\) with \\(0 \\le x \\le \\frac{1}{2}\\), \\[\\sum_{i=0}^{n-1} x^{i} \\le \\frac{1}{1 - \\frac{1}{2}}.\\] The sum is empty when \\(n = 0\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- A bound on partial geometric sums that does not depend on n or x. -/\ntheorem uniform_bound :\n ∀ n : ℕ, ∀ x ∈ Set.Icc (0 : ℝ) (1 / 2 : ℝ), ∑ i ∈ Finset.range n, x ^ i ≤ 1 / (1 - (1 / 2 : ℝ)) := by\n sorry\n", "path": "tasks/real-analysis/real-analysis-uniform_bounds-d2-e0019"}
21
+ {"id": "real-analysis-continuity-d3-e0020", "env": "real-analysis", "msc": "26", "family": "continuity", "difficulty": 3, "seed": 10020, "kind": "prove", "instruction": "# Prove continuity from the epsilon-delta definition\n\nProve, from the epsilon-delta definition, that \\(f(x) = \\dfrac{3}{x}\\) is continuous at \\(x_0 = 5\\): for every \\(\\varepsilon > 0\\) there is \\(\\delta > 0\\) such that \\(|f(x) - f(x_0)| < \\varepsilon\\) whenever \\(|x - x_0| < \\delta\\). Here \\(x\\) ranges over all real numbers (in Lean, division by 0 gives 0, which does not matter for small \\(\\delta\\)).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- Epsilon-delta continuity of the reciprocal function at a point. -/\ntheorem continuous_at :\n ∀ ε > 0, ∃ δ > 0, ∀ x : ℝ, |x - (5 : ℝ)| < δ → |(3 : ℝ) / x - (3 : ℝ) / (5 : ℝ)| < ε := by\n sorry\n", "path": "tasks/real-analysis/real-analysis-continuity-d3-e0020"}
22
+ {"id": "real-analysis-limit_sequence-d3-e0021", "env": "real-analysis", "msc": "26", "family": "limit_sequence", "difficulty": 3, "seed": 10021, "kind": "prove", "instruction": "# Prove a limit from the definition\n\nProve, directly from the definition of a limit, that \\(u_n = \\dfrac{n + 1}{n^2 + 1}\\) tends to \\(0\\): for every \\(\\varepsilon > 0\\) there is \\(N\\) such that \\(|u_n - 0| < \\varepsilon\\) for all \\(n \\ge N\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- The sequence tends to 0 (epsilon-N definition). -/\ntheorem seq_limit :\n ∀ ε > 0, ∃ N : ℕ, ∀ n ≥ N, |((1 : ℝ) * (n : ℝ) + (1 : ℝ)) / ((n : ℝ) ^ 2 + (1 : ℝ)) - 0| < ε := by\n sorry\n", "path": "tasks/real-analysis/real-analysis-limit_sequence-d3-e0021"}
23
+ {"id": "real-analysis-sequence_bounds-d3-e0022", "env": "real-analysis", "msc": "26", "family": "sequence_bounds", "difficulty": 3, "seed": 10022, "kind": "prove", "instruction": "# Bound a recursive sequence\n\nDefine a real sequence by \\(a_0 = \\frac{1}{2}\\) and \\(a_{n+1} = \\dfrac{a_n^2 + \\frac{8}{9}}{2}\\). Prove that \\(0 \\le a_n \\le \\frac{2}{3}\\) for every \\(n\\) (note that \\(\\frac{2}{3}\\) is a fixed point of the recursion), and then that the sequence is monotone (non-decreasing).\n\n## What to do\n\n`Solution.lean` in the working directory states 2 theorems in Lean 4 with Mathlib, with `sorry` in place of each proof. Replace every `sorry` with a proof.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is the share of the 2 theorems that are proved. If the file does not compile the reward is 0, so leave `sorry` on a theorem you cannot finish rather than a broken proof.\n", "start_file": "import Mathlib\n\nnoncomputable def a : ℕ → ℝ\n | 0 => (1 / 2 : ℝ)\n | (n + 1) => (a n ^ 2 + (8 / 9 : ℝ)) / 2\n\n/-- The sequence stays between 0 and the smaller fixed point. -/\ntheorem a_bounds :\n ∀ n : ℕ, 0 ≤ a n ∧ a n ≤ (2 / 3 : ℝ) := by\n sorry\n\n/-- The sequence is increasing. -/\ntheorem a_monotone :\n Monotone a := by\n sorry\n", "path": "tasks/real-analysis/real-analysis-sequence_bounds-d3-e0022"}
24
+ {"id": "real-analysis-uniform_bounds-d3-e0023", "env": "real-analysis", "msc": "26", "family": "uniform_bounds", "difficulty": 3, "seed": 10023, "kind": "prove", "instruction": "# Prove a uniform bound\n\nProve that \\(c\\,x^n\\) with \\(c = 4\\) tends to \\(0\\) uniformly on \\([-\\frac{1}{3}, \\frac{1}{3}]\\): for every \\(\\varepsilon > 0\\) there is \\(N\\) such that \\(|4\\,x^n| < \\varepsilon\\) for all \\(n \\ge N\\) and all real \\(x\\) with \\(|x| \\le \\frac{1}{3}\\).\n\n## What to do\n\n`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.\n\n- Do not change the statement of any theorem or any definition the file gives you. You may add your own lemmas and definitions.\n- 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.\n- A theorem counts only if its proof is complete: no `sorry`, no new axioms, no `native_decide`.\n- The reward is 1 if the theorem is proved and 0 otherwise.\n", "start_file": "import Mathlib\n\n/-- Uniform convergence of a geometric sequence on an interval. -/\ntheorem uniform_convergence :\n ∀ ε > 0, ∃ N : ℕ, ∀ n ≥ N, ∀ x : ℝ, |x| ≤ (1 / 3 : ℝ) → |4 * x ^ n| < ε := by\n sorry\n", "path": "tasks/real-analysis/real-analysis-uniform_bounds-d3-e0023"}
data/real-analysis/train.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
docker/Dockerfile ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Image for the Lean arena tasks: Lean 4 toolchain, Mathlib with its prebuilt cache, the grader.
2
+ # Build once, run every task from it. Needs network at build time only; tasks run offline.
3
+ # docker build -t lean-arena -f docker/Dockerfile .
4
+ FROM debian:bookworm-slim
5
+ RUN apt-get update && apt-get install -y --no-install-recommends curl ca-certificates git python3 zstd xz-utils \
6
+ && rm -rf /var/lib/apt/lists/*
7
+ ENV ELAN_HOME=/opt/elan PATH=/opt/elan/bin:$PATH
8
+ RUN curl -sSf https://raw.githubusercontent.com/leanprover/elan/master/elan-init.sh | sh -s -- -y --default-toolchain none
9
+ COPY lean/lean-toolchain lean/lakefile.toml lean/lake-manifest.json lean/Arena.lean /opt/arena/lean/
10
+ WORKDIR /opt/arena/lean
11
+ RUN lake exe cache get && lake build Arena
12
+ COPY lean/verifier/Verify.lean /opt/arena/Verify.lean
13
+ COPY arena/grade.py /opt/arena/grade.py
14
+ RUN lake env printenv LEAN_PATH > .lake/lean_path.txt && chmod -R a+rX /opt/arena /opt/elan
15
+ ENV ARENA_LEAN=/opt/arena/lean
16
+ WORKDIR /app
envs/__init__.py ADDED
File without changes
envs/combinatorial_identities/__init__.py ADDED
File without changes
envs/combinatorial_identities/env.toml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ name = "combinatorial-identities"
2
+ title = "Combinatorial identities and counting"
3
+ msc = "05"
4
+ kind = "prove"
5
+ summary = "Prove binomial sums, Fibonacci identities, closed forms of linear recurrences, and counting arguments with injections and pigeonholes."
6
+ skill = "Induction, binomial identities, pigeonhole"
7
+ good_for = ["induction on sequences", "Nat.choose lemmas", "Nat.fib", "Finset.card injections and pigeonhole"]
8
+ families = ["binomial_sums", "counting", "fibonacci", "linear_recurrence"]
envs/combinatorial_identities/gen.py ADDED
@@ -0,0 +1,163 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Combinatorial identities and counting (MSC 05: combinatorics; 05A10, 05A19, 05D05).
2
+
3
+ Families: sums of binomial coefficients; Fibonacci identities by induction; closed forms for
4
+ linear recurrences defined in a preamble; counting with injections and the pigeonhole principle.
5
+ Second code path: every identity is checked in Python on small cases (math.comb, a direct
6
+ Fibonacci/recurrence loop, brute-force pigeonhole and injection counts) before it is returned.
7
+ """
8
+ from math import comb
9
+ from itertools import combinations
10
+ from arena.core import Task, Theorem, rng_for
11
+
12
+ ENV = "combinatorial_identities"
13
+ FAMILIES = ["binomial_sums", "counting", "fibonacci", "linear_recurrence"]
14
+
15
+ def fibs(n):
16
+ f = [0, 1]
17
+ while len(f) <= n: f.append(f[-1] + f[-2])
18
+ return f
19
+
20
+ # ---------------------------------------------------------------- binomial sums
21
+ def binomial_sums(rng, difficulty):
22
+ if difficulty == 1:
23
+ a = rng.randrange(2, 10)
24
+ assert all(sum(comb(n, i) * a ** i for i in range(n + 1)) == (a + 1) ** n for n in range(9))
25
+ stmt = "(n : ℕ) :\n ∑ i ∈ Finset.range (n + 1), n.choose i * %d ^ i = %d ^ n" % (a, a + 1)
26
+ proof = ("by\n have h := (add_pow (%d : ℕ) 1 n).symm\n simp only [one_pow, mul_one, Nat.cast_id] at h\n rw [Finset.sum_congr rfl (fun i _ => mul_comm (n.choose i) (%d ^ i))]\n exact h" % (a, a))
27
+ info = "For every natural number \\(n\\), \\[\\sum_{i=0}^{n} \\binom{n}{i}\\, %d^{i} = %d^{n}.\\]" % (a, a + 1)
28
+ return info, [Theorem("binomial_sum", stmt, proof, "A weighted sum of binomial coefficients.")]
29
+ if difficulty == 2:
30
+ k = rng.randrange(1, 8); c = rng.choice([1, 1, 2, 3, 5])
31
+ assert all(sum(c * comb(i + k, k) for i in range(n + 1)) == c * comb(n + k + 1, k + 1) for n in range(10))
32
+ stmt = "(n : ℕ) :\n ∑ i ∈ Finset.range (n + 1), %s(i + %d).choose %d = %s(n + %d).choose %d" % (
33
+ ("%d * " % c) if c != 1 else "", k, k, ("%d * " % c) if c != 1 else "", k + 1, k + 1)
34
+ proof = ("by\n rw [← Finset.mul_sum, Nat.sum_range_add_choose n %d]" % k) if c != 1 else "by\n exact Nat.sum_range_add_choose n %d" % k
35
+ info = "For every natural number \\(n\\), \\[%s\\sum_{i=0}^{n} \\binom{i+%d}{%d} = %s\\binom{n+%d}{%d}.\\]" % (("%d \\cdot " % c) if c != 1 else "", k, k, ("%d \\cdot " % c) if c != 1 else "", k + 1, k + 1)
36
+ info += " (This is the hockey stick identity.)"
37
+ return info, [Theorem("hockey_stick", stmt, proof, "A hockey stick identity for binomial coefficients.")]
38
+ a = rng.randrange(1, 6); c = rng.randrange(1, 8)
39
+ def lhs(n): return sum((a * i + c) * comb(n, i) for i in range(n + 1))
40
+ assert all(lhs(n) == a * n * 2 ** max(n - 1, 0) + c * 2 ** n for n in range(10))
41
+ lemma = Theorem("sum_i_choose", "(n : ℕ) :\n ∑ i ∈ Finset.range (n + 1), i * n.choose i = n * 2 ^ (n - 1)", "by\n exact Nat.sum_range_mul_choose n", "The sum of i times n choose i.")
42
+ main = Theorem("weighted_sum", "(n : ℕ) :\n ∑ i ∈ Finset.range (n + 1), (%d * i + %d) * n.choose i = %d * (n * 2 ^ (n - 1)) + %d * 2 ^ n" % (a, c, a, c),
43
+ "by\n have h1 := sum_i_choose n\n have h2 := Nat.sum_range_choose n\n have e : ∀ i : ℕ, (%d * i + %d) * n.choose i = %d * (i * n.choose i) + %d * n.choose i := fun i => by ring\n simp only [e, Finset.sum_add_distrib, ← Finset.mul_sum, h1, h2]" % (a, c, a, c),
44
+ "A weighted binomial sum.", weight=2.0)
45
+ info = ("First prove \\[\\sum_{i=0}^{n} i \\binom{n}{i} = n \\cdot 2^{n-1},\\] where \\(n - 1\\) is truncated subtraction on the natural numbers. Then use it, and the value of \\(\\sum_{i=0}^{n} \\binom{n}{i}\\), to prove "
46
+ "\\[\\sum_{i=0}^{n} (%di + %d) \\binom{n}{i} = %d \\cdot n \\cdot 2^{n-1} + %d \\cdot 2^{n}.\\]") % (a, c, a, c)
47
+ return info, [lemma, main]
48
+
49
+ # ---------------------------------------------------------------- Fibonacci
50
+ def fibonacci(rng, difficulty):
51
+ f = fibs(120)
52
+ if difficulty == 1:
53
+ a = rng.randrange(0, 15)
54
+ assert all(sum(f[i + a] for i in range(n)) + f[a + 1] == f[n + a + 1] for n in range(12))
55
+ stmt = "(n : ℕ) :\n ∑ i ∈ Finset.range n, Nat.fib (i + %d) + Nat.fib %d = Nat.fib (n + %d)" % (a, a + 1, a + 1)
56
+ proof = ("by\n induction n with\n | zero => simp\n | succ k ih =>\n have e : Nat.fib (k + 1 + %d) = Nat.fib (k + %d) + Nat.fib (k + %d) := by\n rw [show k + 1 + %d = (k + %d) + 2 from by omega, show k + %d = (k + %d) + 1 from by omega]\n exact Nat.fib_add_two\n rw [Finset.sum_range_succ, e]\n omega" % (a + 1, a, a + 1, a + 1, a, a + 1, a))
57
+ info = "For every natural number \\(n\\), with \\(F\\) the Fibonacci sequence (\\(F_0 = 0\\), \\(F_1 = 1\\), \\(F_{k+2} = F_k + F_{k+1}\\)), \\[\\sum_{i=0}^{n-1} F_{i+%d} + F_{%d} = F_{n+%d}.\\]" % (a, a + 1, a + 1)
58
+ return info, [Theorem("fib_shifted_sum", stmt, proof, "A telescoping sum of Fibonacci numbers.")]
59
+ if difficulty == 2:
60
+ if rng.random() < 0.5:
61
+ a = rng.randrange(0, 12)
62
+ assert all(sum(f[2 * i + a + 1] for i in range(n)) + f[a] == f[2 * n + a] for n in range(12))
63
+ stmt = "(n : ℕ) :\n ∑ i ∈ Finset.range n, Nat.fib (2 * i + %d) + Nat.fib %d = Nat.fib (2 * n + %d)" % (a + 1, a, a)
64
+ proof = ("by\n induction n with\n | zero => simp\n | succ k ih =>\n have e : Nat.fib (2 * (k + 1) + %d) = Nat.fib (2 * k + %d) + Nat.fib (2 * k + %d) := by\n rw [show 2 * (k + 1) + %d = (2 * k + %d) + 2 from by omega, show 2 * k + %d = (2 * k + %d) + 1 from by omega]\n exact Nat.fib_add_two\n rw [Finset.sum_range_succ, e]\n omega" % (a, a, a + 1, a, a, a + 1, a))
65
+ info = "For every natural number \\(n\\), with \\(F\\) the Fibonacci sequence, \\[\\sum_{i=0}^{n-1} F_{2i+%d} + F_{%d} = F_{2n+%d}.\\]" % (a + 1, a, a)
66
+ return info, [Theorem("fib_odd_sum", stmt, proof, "A sum of every second Fibonacci number.")]
67
+ c = rng.randrange(1, 9)
68
+ assert all(sum(c * f[i] ** 2 for i in range(n + 1)) == c * f[n] * f[n + 1] for n in range(12))
69
+ stmt = "(n : ℕ) :\n ∑ i ∈ Finset.range (n + 1), %d * Nat.fib i ^ 2 = %d * (Nat.fib n * Nat.fib (n + 1))" % (c, c)
70
+ proof = "by\n induction n with\n | zero => simp\n | succ k ih =>\n rw [Finset.sum_range_succ, ih, Nat.fib_add_two (n := k)]\n ring"
71
+ info = "For every natural number \\(n\\), with \\(F\\) the Fibonacci sequence, \\[\\sum_{i=0}^{n} %d\\,F_i^2 = %d\\,F_n F_{n+1}.\\]" % (c, c)
72
+ return info, [Theorem("fib_square_sum", stmt, proof, "A sum of squares of Fibonacci numbers.")]
73
+ while True:
74
+ c = rng.randrange(1, 8); b = rng.randrange(0, 9)
75
+ if (c, b) != (1, 0): break
76
+ for n in range(10):
77
+ idx = c * n + b
78
+ assert f[idx + 1] ** 2 - f[idx] * f[idx + 2] == (-1) ** idx
79
+ lemma = Theorem("cassini", "(n : ℕ) :\n (Nat.fib (n + 1) : ℤ) ^ 2 - Nat.fib n * Nat.fib (n + 2) = (-1) ^ n",
80
+ "by\n induction n with\n | zero => simp\n | succ k ih =>\n have e1 : Nat.fib (k + 2) = Nat.fib k + Nat.fib (k + 1) := Nat.fib_add_two\n have e2 : Nat.fib (k + 1 + 2) = Nat.fib (k + 1) + Nat.fib (k + 2) := Nat.fib_add_two\n rw [e2, pow_succ]\n rw [e1] at ih ⊢\n push_cast at ih ⊢\n linear_combination (-1 : ℤ) * ih",
81
+ "Cassini's identity for Fibonacci numbers.")
82
+ cn = ("%d * n" % c) if c != 1 else "n"
83
+ idx = ("%s + %d" % (cn, b)) if b else cn
84
+ main = Theorem("cassini_pm_one", "(n : ℕ) :\n (Nat.fib (%s + 1) : ℤ) ^ 2 - Nat.fib (%s) * Nat.fib (%s + 2) = 1 ∨ (Nat.fib (%s + 1) : ℤ) ^ 2 - Nat.fib (%s) * Nat.fib (%s + 2) = -1" % ((idx,) * 6),
85
+ "by\n rw [cassini (%s)]\n rcases neg_one_pow_eq_or ℤ (%s) with h | h\n · exact Or.inl h\n · exact Or.inr h" % (idx, idx),
86
+ "Cassini's determinant is plus or minus one at the index given.", weight=2.0)
87
+ info = ("First prove Cassini's identity: for every natural number \\(n\\), \\[F_{n+1}^2 - F_n F_{n+2} = (-1)^n,\\] computed in the integers, where \\(F\\) is the Fibonacci sequence. "
88
+ "Then conclude that \\(F_{m+1}^2 - F_m F_{m+2}\\) is either \\(1\\) or \\(-1\\) when \\(m = %s\\).") % (("%sn + %d" % ("" if c == 1 else c, b)) if b else "%sn" % ("" if c == 1 else c))
89
+ return info, [lemma, main]
90
+
91
+ # ---------------------------------------------------------------- linear recurrences
92
+ def linear_recurrence(rng, difficulty):
93
+ def sgn(x): return "(%d)" % x if x < 0 else "%d" % x
94
+ if difficulty < 3:
95
+ pool = [1, 2, 3, 4, 5] if difficulty == 1 else [-4, -3, -2, -1, 1, 2, 3, 4, 5]
96
+ r, s = rng.sample(pool, 2)
97
+ A = rng.choice([x for x in range(-3, 5) if x]); B = rng.choice([x for x in range(-3, 5) if x])
98
+ u0, u1 = A + B, A * r + B * s; p, q = r + s, r * s
99
+ closed = lambda n: A * r ** n + B * s ** n
100
+ form = "%s * %s ^ n + %s * %s ^ n" % (sgn(A), sgn(r), sgn(B), sgn(s))
101
+ tx = "%d \\cdot %s^{n} + %d \\cdot %s^{n}" % (A, "(%d)" % r if r < 0 else r, B, "(%d)" % s if s < 0 else s)
102
+ desc_roots = "\\(%s\\) and \\(%s\\)" % (r, s)
103
+ else:
104
+ r = rng.choice([-3, -2, -1, 2, 3, 4]); A = rng.choice([x for x in range(-3, 5) if x]); B = rng.choice([x for x in range(-3, 5) if x])
105
+ u0, u1 = A, (A + B) * r; p, q = 2 * r, r * r
106
+ closed = lambda n: (A + B * n) * r ** n
107
+ form = "(%s + %s * (n : ℤ)) * %s ^ n" % (sgn(A), sgn(B), sgn(r))
108
+ tx = "(%d + %d n) \\cdot %s^{n}" % (A, B, "(%d)" % r if r < 0 else r)
109
+ seq = [u0, u1]
110
+ while len(seq) < 15: seq.append(p * seq[-1] - q * seq[-2])
111
+ assert all(seq[n] == closed(n) for n in range(15))
112
+ rec = "%s * u (n + 1) - %s * u n" % (sgn(p), sgn(q))
113
+ pre = "def u : ℕ → ℤ\n | 0 => %s\n | 1 => %s\n | (n + 2) => %s" % (sgn(u0), sgn(u1), rec)
114
+ stmt = "(n : ℕ) :\n u n = %s" % form
115
+ proof = ("by\n induction n using Nat.strong_induction_on with\n | _ n ih =>\n match n, ih with\n | 0, _ => norm_num [u]\n | 1, _ => norm_num [u]\n"
116
+ " | n + 2, ih =>\n have h1 := ih (n + 1) (by omega)\n have h0 := ih n (by omega)\n rw [u, h1, h0]\n push_cast\n ring")
117
+ info = ("Define a sequence of integers by \\(u_0 = %d\\), \\(u_1 = %d\\) and \\(u_{n+2} = %d\\,u_{n+1} - %d\\,u_{n}\\). Prove that for every natural number \\(n\\), \\[u_n = %s.\\]" % (u0, u1, p, q, tx))
118
+ return info, pre, [Theorem("seq_closed_form", stmt, proof, "A closed form for the sequence defined by the recurrence.")]
119
+
120
+ # ---------------------------------------------------------------- counting
121
+ def counting(rng, difficulty):
122
+ if difficulty == 1:
123
+ m = rng.randrange(2, 9)
124
+ # brute-force check: any m+1 integers in a window contain two with the same residue
125
+ for _ in range(50):
126
+ xs = rng.sample(range(-20, 20), m + 1)
127
+ assert len({x % m for x in xs}) <= m
128
+ stmt = "(s : Finset ℤ) (h : %d < s.card) :\n ∃ x ∈ s, ∃ y ∈ s, x ≠ y ∧ x %% %d = y %% %d" % (m, m, m)
129
+ proof = ("by\n have hmaps : Set.MapsTo (fun x : ℤ => x %% %d) (s : Set ℤ) (Finset.Ico (0 : ℤ) %d : Finset ℤ) := by\n intro x _\n simp only [Finset.coe_Ico, Set.mem_Ico]\n omega\n"
130
+ " have hc : (Finset.Ico (0 : ℤ) %d).card < s.card := by simpa using h\n exact Finset.exists_ne_map_eq_of_card_lt_of_maps_to hc hmaps" % (m, m, m))
131
+ info = "Let \\(s\\) be a finite set of integers with more than %d elements. Prove that \\(s\\) contains two different integers \\(x \\ne y\\) that leave the same remainder on division by %d." % (m, m)
132
+ return info, [], [Theorem("pigeonhole_mod", stmt, proof, "Pigeonhole principle for remainders.")]
133
+ if difficulty == 2:
134
+ p = rng.randrange(2, 7); r = rng.randrange(0, p)
135
+ for n in range(1, 15):
136
+ assert len([y for y in range(p * n) if y % p == r]) == n >= n
137
+ stmt = "(n : ℕ) :\n (Finset.range n).card ≤ ((Finset.range (%d * n)).filter (fun y => y %% %d = %d)).card" % (p, p, r)
138
+ proof = ("by\n apply Finset.card_le_card_of_injOn (fun x => %d * x + %d)\n · intro x hx\n simp only [Finset.coe_range, Set.mem_Iio] at hx\n simp only [Finset.coe_filter, Finset.mem_range, Set.mem_setOf_eq]\n constructor <;> omega\n"
139
+ " · intro x _ y _ h\n simp only at h\n omega" % (p, r))
140
+ info = "Let \\(n\\) be a natural number. Prove that the set \\(\\{0, 1, \\dots, n-1\\}\\) has at most as many elements as the set of integers \\(y\\) with \\(0 \\le y < %d n\\) and \\(y \\equiv %d \\pmod{%d}\\). (Construct an injection.)" % (p, r, p)
141
+ return info, [], [Theorem("card_le_residue_class", stmt, proof, "An injection into a residue class gives a cardinality bound.")]
142
+ k = rng.randrange(2, 8); m = rng.randrange(2, 8)
143
+ stmt = "(s : Finset ℕ) (hs : s ⊆ Finset.range (%d * %d)) (h : %d < s.card) :\n ∃ x ∈ s, ∃ y ∈ s, x < y ∧ y < x + %d" % (k, m, m, k)
144
+ proof = ("by\n have hmaps : Set.MapsTo (fun x : ℕ => x / %d) (s : Set ℕ) (Finset.range %d : Finset ℕ) := by\n intro x hx\n have hx' := hs hx\n simp only [Finset.mem_range] at hx'\n simp only [Finset.coe_range, Set.mem_Iio]\n omega\n"
145
+ " have hc : (Finset.range %d).card < s.card := by simpa using h\n obtain ⟨x, hx, y, hy, hne, heq⟩ := Finset.exists_ne_map_eq_of_card_lt_of_maps_to hc hmaps\n"
146
+ " replace heq : x / %d = y / %d := heq\n rcases lt_or_gt_of_ne hne with hlt | hgt\n · exact ⟨x, hx, y, hy, hlt, by omega⟩\n · exact ⟨y, hy, x, hx, hgt, by omega⟩" % (k, m, m, k, k))
147
+ info = ("Let \\(s\\) be a set of natural numbers that are all less than \\(%d \\cdot %d = %d\\), and suppose \\(s\\) has more than %d elements. Prove that \\(s\\) contains two elements \\(x < y\\) with \\(y - x < %d\\)." % (k, m, k * m, m, k))
148
+ return info, [], [Theorem("close_pair", stmt, proof, "Pigeonhole principle for blocks of consecutive numbers.")]
149
+
150
+ def generate(seed, difficulty, family=None):
151
+ family = family or sorted(FAMILIES)[seed % len(FAMILIES)]
152
+ rng = rng_for(ENV + "/" + family, seed, difficulty)
153
+ pre = ""
154
+ if family == "linear_recurrence":
155
+ info, pre, thms = linear_recurrence(rng, difficulty)
156
+ elif family == "counting":
157
+ info, _, thms = counting(rng, difficulty)
158
+ else:
159
+ info, thms = {"binomial_sums": binomial_sums, "fibonacci": fibonacci}[family](rng, difficulty)
160
+ titles = {"binomial_sums": "Prove an identity for binomial coefficients", "fibonacci": "Prove an identity for Fibonacci numbers",
161
+ "linear_recurrence": "Find the closed form of a recurrence", "counting": "Prove a counting statement"}
162
+ return Task(env=ENV, family=family, seed=seed, difficulty=difficulty, kind="prove", title=titles[family],
163
+ informal="Prove the following.\n\n" + info, preamble=pre, theorems=thms)
envs/definitions/__init__.py ADDED
File without changes
envs/definitions/env.toml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ name = "definitions"
2
+ title = "Definitions from words"
3
+ msc = "11"
4
+ kind = "define"
5
+ summary = "Turn a number-theoretic definition written in words into a computable Lean function that agrees with it on hidden inputs."
6
+ skill = "Autoformalization of definitions"
7
+ good_for = ["autoformalization", "reading a specification exactly", "boundary cases"]
8
+ families = ["count", "divisors", "extremum", "pairs", "sequence", "sum"]
envs/definitions/gen.py ADDED
@@ -0,0 +1,170 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Definitions from words: write `f : ℕ → ℕ` from an English description.
2
+
3
+ Two code paths: the Lean reference definition and the expected values are produced separately.
4
+ The expected values in the hidden test come from the Python functions below; the Lean reference
5
+ is compiled and run against them in the self-test. Elementary number theory only (MSC 11A, 11B).
6
+ """
7
+ from math import gcd, isqrt
8
+ from arena.core import Task, Theorem, rng_for
9
+
10
+ ENV = "definitions"
11
+ FAMILIES = ["count", "divisors", "extremum", "pairs", "sequence", "sum"]
12
+
13
+ def digits(k): return [int(c) for c in str(k)] if k > 0 else []
14
+ def is_prime(k): return k >= 2 and all(k % d for d in range(2, isqrt(k) + 1))
15
+ def is_square(k): return isqrt(k) ** 2 == k
16
+ def squarefree(k): return k >= 1 and all(k % (d * d) for d in range(2, isqrt(k) + 1))
17
+ def ndiv(k): return sum(1 for d in range(1, k + 1) if k % d == 0)
18
+
19
+ # A predicate on a positive integer k: (words, lean, python, period or None)
20
+ def pred(rng, var, allow_n=False, periodic=False):
21
+ lv = var; var = "\\(%s\\)" % var # `var` for words, `lv` for Lean
22
+ kinds = ["div", "mod", "coprime_c"] + ([] if periodic else ["prime", "square", "digitsum", "palin", "squarefree"]) + (["coprime_n", "divides_n"] if allow_n else [])
23
+ kind = rng.choice(kinds)
24
+ if kind == "div":
25
+ d = rng.choice([2, 3, 4, 5, 6, 7])
26
+ return ("%s is divisible by %d" % (var, d), "%d ∣ %s" % (d, lv), lambda k, n, d=d: k % d == 0, d)
27
+ if kind == "mod":
28
+ m = rng.choice([3, 4, 5, 6, 7, 8, 9]); r = rng.randrange(1, m)
29
+ return ("%s leaves remainder %d on division by %d" % (var, r, m), "%s %% %d = %d" % (lv, m, r), lambda k, n, m=m, r=r: k % m == r, m)
30
+ if kind == "coprime_c":
31
+ c = rng.choice([6, 10, 12, 14, 15, 21, 30])
32
+ return ("%s is coprime to %d" % (var, c), "Nat.Coprime %s %d" % (lv, c), lambda k, n, c=c: gcd(k, c) == 1, c)
33
+ if kind == "prime":
34
+ return ("%s is prime" % var, "Nat.Prime %s" % lv, lambda k, n: is_prime(k), None)
35
+ if kind == "square":
36
+ return ("%s is a perfect square" % var, "IsSquare %s" % lv, lambda k, n: is_square(k), None)
37
+ if kind == "squarefree":
38
+ return ("%s is squarefree (no square larger than 1 divides it)" % var, "Squarefree %s" % lv, lambda k, n: squarefree(k), None)
39
+ if kind == "digitsum":
40
+ m = rng.choice([3, 4, 5, 7]); r = rng.randrange(0, m)
41
+ return ("the sum of the decimal digits of %s leaves remainder %d on division by %d" % (var, r, m),
42
+ "(Nat.digits 10 %s).sum %% %d = %d" % (lv, m, r), lambda k, n, m=m, r=r: sum(digits(k)) % m == r, None)
43
+ if kind == "palin":
44
+ return ("the decimal digits of %s read the same forwards and backwards" % var,
45
+ "Nat.digits 10 %s = (Nat.digits 10 %s).reverse" % (lv, lv), lambda k, n: str(k) == str(k)[::-1], None)
46
+ if kind == "coprime_n":
47
+ return ("%s is coprime to \\(n\\)" % var, "Nat.Coprime %s n" % lv, lambda k, n: gcd(k, n) == 1, None)
48
+ return ("%s divides \\(n\\)" % var, "%s ∣ n" % lv, lambda k, n: n % k == 0, None)
49
+
50
+ def combine(rng, difficulty, var, allow_n=False, periodic=False):
51
+ """One predicate at difficulty 1, two joined by and / or / and-not above that."""
52
+ a = pred(rng, var, allow_n, periodic)
53
+ if difficulty == 1: return a
54
+ while True:
55
+ b = pred(rng, var, allow_n, periodic)
56
+ if b[1].split()[0:2] != a[1].split()[0:2] and b[1] != a[1]: break
57
+ op = rng.choice(["and", "or", "andnot"])
58
+ per = (a[3] * b[3] // gcd(a[3], b[3])) if a[3] and b[3] else None
59
+ if op == "and": return ("%s and %s" % (a[0], b[0]), "(%s) ∧ (%s)" % (a[1], b[1]), lambda k, n: a[2](k, n) and b[2](k, n), per)
60
+ if op == "or": return ("%s or %s (or both)" % (a[0], b[0]), "(%s) ∨ (%s)" % (a[1], b[1]), lambda k, n: a[2](k, n) or b[2](k, n), per)
61
+ return ("%s but it is not the case that %s" % (a[0], b[0]), "(%s) ∧ ¬ (%s)" % (a[1], b[1]), lambda k, n: a[2](k, n) and not b[2](k, n), per)
62
+
63
+ def weight(rng, var):
64
+ return rng.choice([
65
+ ("\\(%s\\)" % var, "%s" % var, lambda k: k),
66
+ ("\\(%s^2\\)" % var, "%s ^ 2" % var, lambda k: k * k),
67
+ ("the digit sums \\(s(%s)\\), where \\(s(m)\\) is the sum of the decimal digits of \\(m\\)," % var, "(Nat.digits 10 %s).sum" % var, lambda k: sum(digits(k))),
68
+ ("the values \\(\\tau(%s)\\), where \\(\\tau(m)\\) is the number of positive divisors of \\(m\\)," % var, "(Nat.divisors %s).card" % var, lambda k: ndiv(k)),
69
+ ])
70
+
71
+ def build(rng, family, difficulty):
72
+ """Returns (description, lean body with `n` free or a full equation-style definition, python f, N)."""
73
+ N = 40
74
+ if family == "count":
75
+ w, l, p, _ = combine(rng, difficulty, "k", allow_n=difficulty == 3)
76
+ desc = "\\(f(n)\\) is the number of integers \\(k\\) with \\(1 \\le k \\le n\\) such that %s." % w
77
+ return desc, "((Finset.Icc 1 n).filter (fun k => %s)).card" % l, lambda n: sum(1 for k in range(1, n + 1) if p(k, n)), N
78
+ if family == "sum":
79
+ w, l, p, _ = combine(rng, max(1, difficulty - 1), "k", allow_n=difficulty == 3)
80
+ gw, gl, g = weight(rng, "k") if difficulty > 1 else ("\\(k\\)", "k", lambda k: k)
81
+ desc = "\\(f(n)\\) is the sum of %s over all integers \\(k\\) with \\(1 \\le k \\le n\\) such that %s. An empty sum is 0." % (gw, w)
82
+ return desc, "∑ k ∈ (Finset.Icc 1 n).filter (fun k => %s), %s" % (l, gl), lambda n: sum(g(k) for k in range(1, n + 1) if p(k, n)), N
83
+ if family == "divisors":
84
+ w, l, p, _ = combine(rng, max(1, difficulty - 1), "d")
85
+ if difficulty == 1:
86
+ desc = "\\(f(n)\\) is the number of positive divisors \\(d\\) of \\(n\\) such that %s. Take \\(f(0) = 0\\)." % w
87
+ return desc, "((Nat.divisors n).filter (fun d => %s)).card" % l, lambda n: sum(1 for d in range(1, n + 1) if n % d == 0 and p(d, n)), N
88
+ gw, gl, g = weight(rng, "d")
89
+ desc = "\\(f(n)\\) is the sum of %s over all positive divisors \\(d\\) of \\(n\\) such that %s. An empty sum is 0, and \\(f(0) = 0\\)." % (gw, w)
90
+ return desc, "∑ d ∈ (Nat.divisors n).filter (fun d => %s), %s" % (l, gl), lambda n: sum(g(d) for d in range(1, n + 1) if n % d == 0 and p(d, n)), N
91
+ if family == "extremum":
92
+ if rng.random() < 0.5:
93
+ w, l, p, _ = combine(rng, difficulty, "k")
94
+ desc = "\\(f(n)\\) is the largest integer \\(k\\) with \\(1 \\le k \\le n\\) such that %s. If there is no such \\(k\\), then \\(f(n) = 0\\)." % w
95
+ return desc, "((List.range (n + 1)).filter (fun k => decide (1 ≤ k ∧ (%s)))).foldl max 0" % l, lambda n: max([k for k in range(1, n + 1) if p(k, n)] or [0]), N
96
+ w, l, p, per = combine(rng, min(difficulty, 2), "k", periodic=True)
97
+ while not any(p(k, 0) for k in range(1, per + 1)):
98
+ w, l, p, per = combine(rng, min(difficulty, 2), "k", periodic=True)
99
+ strict = difficulty == 3 or rng.random() < 0.5
100
+ desc = "\\(f(n)\\) is the smallest integer \\(k\\) with \\(k %s n\\) and \\(k \\ge 1\\) such that %s." % (">" if strict else "\\ge", w)
101
+ start = "n + 1" if strict else "max n 1"
102
+ def py(n, p=p, strict=strict):
103
+ k = n + 1 if strict else max(n, 1)
104
+ while not p(k, n): k += 1
105
+ return k
106
+ return desc, "(((List.range %d).map (fun i => %s + i)).find? (fun k => decide (%s))).getD 0" % (per + 1, start, l), py, N
107
+ if family == "pairs":
108
+ N = 25
109
+ rels = [
110
+ ("\\(\\gcd(a, b) = %d\\)", "Nat.gcd p.1 p.2 = %d", lambda a, b, n, c: gcd(a, b) == c, [1, 2, 3]),
111
+ ("\\(a \\cdot b \\le n\\)", "p.1 * p.2 ≤ n", lambda a, b, n, c: a * b <= n, [0]),
112
+ ("\\(a\\) divides \\(b\\)", "p.1 ∣ p.2", lambda a, b, n, c: b % a == 0, [0]),
113
+ ("\\(a^2 + b^2 \\le n^2\\)", "p.1 ^ 2 + p.2 ^ 2 ≤ n ^ 2", lambda a, b, n, c: a * a + b * b <= n * n, [0]),
114
+ ("\\(a + b\\) is prime", "Nat.Prime (p.1 + p.2)", lambda a, b, n, c: is_prime(a + b), [0]),
115
+ ("\\(a \\cdot b\\) is a perfect square", "IsSquare (p.1 * p.2)", lambda a, b, n, c: is_square(a * b), [0]),
116
+ ("\\(a + b\\) is divisible by %d", "%d ∣ p.1 + p.2", lambda a, b, n, c: (a + b) % c == 0, [3, 4, 5]),
117
+ ("\\(a \\cdot b = n\\)", "p.1 * p.2 = n", lambda a, b, n, c: a * b == n, [0]),
118
+ ]
119
+ def pick():
120
+ w, l, r, cs = rng.choice(rels); c = rng.choice(cs)
121
+ return (w % c if "%d" in w else w), (l % c if "%d" in l else l), (lambda a, b, n, r=r, c=c: r(a, b, n, c))
122
+ w, l, r = pick()
123
+ order = ""
124
+ if difficulty >= 2:
125
+ order_kind = rng.choice(["le", "lt"])
126
+ order = " and \\(a %s b\\)" % ("\\le" if order_kind == "le" else "<")
127
+ l = "(%s) ∧ p.1 %s p.2" % (l, "≤" if order_kind == "le" else "<")
128
+ r0 = r; r = (lambda a, b, n, r0=r0, k=order_kind: r0(a, b, n) and (a <= b if k == "le" else a < b))
129
+ if difficulty == 3:
130
+ w2, l2, r2 = pick()
131
+ while w2 == w: w2, l2, r2 = pick()
132
+ w = w + ", " + w2; l = "(%s) ∧ (%s)" % (l, l2); r1 = r; r = (lambda a, b, n, r1=r1, r2=r2: r1(a, b, n) and r2(a, b, n))
133
+ desc = "\\(f(n)\\) is the number of ordered pairs \\((a, b)\\) of integers with \\(1 \\le a \\le n\\) and \\(1 \\le b \\le n\\) such that %s%s." % (w, order)
134
+ return desc, "((Finset.Icc 1 n ×ˢ Finset.Icc 1 n).filter (fun p => %s)).card" % l, lambda n: sum(1 for a in range(1, n + 1) for b in range(1, n + 1) if r(a, b, n)), N
135
+ # sequence
136
+ N = 28
137
+ m = rng.choice([7, 10, 11, 13, 17, 100, 101]); c0, c1 = rng.randrange(0, 5), rng.randrange(1, 6)
138
+ p, q = rng.randrange(1, 5), rng.randrange(1, 5); r = rng.randrange(0, 4) if difficulty >= 2 else 0
139
+ rec = "%s\\,a(n+1) + %s\\,a(n)%s" % (p if p > 1 else "", q if q > 1 else "", (" + %d" % r) if r else "")
140
+ lean_rec = "(%d * a (n + 1) + %d * a n + %d) %% %d" % (p, q, r, m)
141
+ seqdesc = "Let \\(a(0) = %d\\), \\(a(1) = %d\\) and, for \\(n \\ge 0\\), let \\(a(n+2)\\) be the remainder of \\(%s\\) on division by %d." % (c0, c1, rec, m)
142
+ def a(n, memo={}):
143
+ key = (c0, c1, p, q, r, m)
144
+ vals = memo.setdefault(key, [c0, c1])
145
+ while len(vals) <= n: vals.append((p * vals[-1] + q * vals[-2] + r) % m)
146
+ return vals[n]
147
+ helper = "def a : ℕ → ℕ\n | 0 => %d\n | 1 => %d\n | n + 2 => %s\n" % (c0, c1, lean_rec)
148
+ if difficulty == 1:
149
+ return seqdesc + " Then \\(f(n) = a(n)\\).", ("FULL", "def f : ℕ → ℕ\n | 0 => %d\n | 1 => %d\n | n + 2 => (%d * f (n + 1) + %d * f n + %d) %% %d\n" % (c0, c1, p, q, r, m)), a, N
150
+ if difficulty == 2:
151
+ return seqdesc + " Then \\(f(n) = a(0) + a(1) + \\dots + a(n)\\).", ("FULL", helper + "\ndef f (n : ℕ) : ℕ := ∑ i ∈ Finset.range (n + 1), a i\n"), lambda n: sum(a(i) for i in range(n + 1)), N
152
+ return (seqdesc + " Then \\(f(n)\\) is the number of indices \\(i\\) with \\(0 \\le i < n\\) such that \\(a(i) < a(i+1)\\).",
153
+ ("FULL", helper + "\ndef f (n : ℕ) : ℕ := ((Finset.range n).filter (fun i => a i < a (i + 1))).card\n"), lambda n: sum(1 for i in range(n) if a(i) < a(i + 1)), N)
154
+
155
+ def generate(seed, difficulty, family=None):
156
+ family = family or sorted(FAMILIES)[seed % len(FAMILIES)]
157
+ rng = rng_for(ENV + "/" + family, seed, difficulty)
158
+ while True:
159
+ desc, lean, py, N = build(rng, family, difficulty)
160
+ vals = [py(n) for n in range(N)]
161
+ if len(set(vals)) >= 6: break # reject near-constant functions
162
+ solution = lean[1] if isinstance(lean, tuple) else "def f (n : ℕ) : ℕ := %s\n" % lean
163
+ shown = [n for n in (3, 10, 17, 24) if n < N]
164
+ examples = "\n".join("- \\(f(%d) = %d\\)" % (n, vals[n]) for n in shown)
165
+ test = Theorem("hidden_values", ": (List.range %d).map f = [%s]" % (N, ", ".join(map(str, vals))), "by native_decide")
166
+ return Task(env=ENV, family=family, seed=seed, difficulty=difficulty, kind="define",
167
+ title="Define a function from its description",
168
+ informal="Define the function \\(f\\) from the natural numbers (including 0) to the natural numbers as follows.\n\n" + desc,
169
+ stub="def f (n : ℕ) : ℕ := sorry\n", solution=solution, free=["f"], tests=[test], examples=examples,
170
+ meta={"values_tested": N})
envs/finite_sums/__init__.py ADDED
File without changes
envs/finite_sums/env.toml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ name = "finite-sums"
2
+ title = "Closed forms for finite sums"
3
+ msc = "40"
4
+ kind = "prove"
5
+ summary = "Prove a closed form for a finite sum: polynomial, geometric or telescoping, by induction on the number of terms."
6
+ skill = "Induction over Finset sums"
7
+ good_for = ["induction", "Finset.sum lemmas", "casts and field arithmetic"]
8
+ families = ["geometric", "polynomial", "telescoping"]
envs/finite_sums/gen.py ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Closed forms for finite sums (MSC 40: sequences, series, summability; 05A19 identities).
2
+
3
+ Formulas: sum_{i=0}^{n} i = n(n+1)/2, sum i^2 = n(n+1)(2n+1)/6, sum i^3 = n^2(n+1)^2/4;
4
+ geometric (r-1) * sum_{i<n} c r^i = c (r^n - 1); telescoping sum_{i<n} 1/((i+a)(i+a+1)) = n/(a(n+a)).
5
+ Second code path: every generated identity is checked numerically with exact fractions before
6
+ it is returned; the Lean reference proof is compiled in the self-test.
7
+ """
8
+ from fractions import Fraction as F
9
+ from arena.core import Task, Theorem, rng_for
10
+
11
+ ENV = "finite_sums"
12
+ FAMILIES = ["geometric", "polynomial", "telescoping"]
13
+ IND = "by\n induction n with\n | zero => simp\n | succ k ih =>\n rw [Finset.sum_range_succ, ih]\n push_cast\n ring"
14
+
15
+ def term(c, var, power):
16
+ """Lean text for c * var^power, with c a nonzero int."""
17
+ v = "" if power == 0 else ("(%s : ℚ)" % var if power == 1 else "(%s : ℚ) ^ %d" % (var, power))
18
+ if power == 0: return "%d" % c
19
+ return v if c == 1 else "%d * %s" % (c, v)
20
+
21
+ def tex_poly(cs, var):
22
+ out = []
23
+ for power in range(len(cs) - 1, -1, -1):
24
+ c = cs[power]
25
+ if not c: continue
26
+ v = "" if power == 0 else (var if power == 1 else "%s^%d" % (var, power))
27
+ mag = abs(c); body = v if (mag == 1 and power) else "%d%s" % (mag, v)
28
+ out.append(("- " if c < 0 else ("+ " if out else "")) + body)
29
+ return " ".join(out)
30
+
31
+ def polynomial(rng, difficulty):
32
+ deg = difficulty
33
+ while True:
34
+ cs = [rng.randrange(-4, 6) for _ in range(deg + 1)] # cs[p] multiplies i^p
35
+ if cs[deg] > 0 and sum(1 for c in cs if c) >= min(2, deg + 1): break
36
+ summand = " + ".join(term(c, "i", p) for p, c in reversed(list(enumerate(cs))) if c)
37
+ n = "(n : ℚ)"
38
+ closed = {0: "(%s + 1)" % n, 1: "%s * (%s + 1) / 2" % (n, n), 2: "%s * (%s + 1) * (2 * %s + 1) / 6" % (n, n, n), 3: "%s ^ 2 * (%s + 1) ^ 2 / 4" % (n, n)}
39
+ rhs = " + ".join(("%d * (%s)" % (c, closed[p])) for p, c in reversed(list(enumerate(cs))) if c)
40
+ def lhs_val(m): return sum(sum(F(c) * i ** p for p, c in enumerate(cs)) for i in range(m + 1))
41
+ def rhs_val(m):
42
+ cl = {0: F(m + 1), 1: F(m * (m + 1), 2), 2: F(m * (m + 1) * (2 * m + 1), 6), 3: F(m * m * (m + 1) ** 2, 4)}
43
+ return sum(c * cl[p] for p, c in enumerate(cs))
44
+ assert all(lhs_val(m) == rhs_val(m) for m in range(8))
45
+ tex_closed = {0: "(n+1)", 1: "\\frac{n(n+1)}{2}", 2: "\\frac{n(n+1)(2n+1)}{6}", 3: "\\frac{n^2(n+1)^2}{4}"}
46
+ tex_rhs = " + ".join("%d \\cdot %s" % (c, tex_closed[p]) for p, c in reversed(list(enumerate(cs))) if c).replace("+ -", "- ")
47
+ informal = "For every natural number \\(n\\), \\[\\sum_{i=0}^{n} \\left(%s\\right) = %s.\\]" % (tex_poly(cs, "i"), tex_rhs)
48
+ stmt = "(n : ℕ) :\n ∑ i ∈ Finset.range (n + 1), (%s) = %s" % (summand, rhs)
49
+ return informal, stmt, IND
50
+
51
+ def geometric(rng, difficulty):
52
+ r = rng.choice([2, 3, 4, 5, 6, 7, 8, 9] if difficulty < 3 else [-2, -3, -4, 3, 5, 6, 7]); c = rng.randrange(1, 10) if difficulty > 1 else rng.choice([1, 1, 2, 3])
53
+ shift = rng.randrange(1, 4) if difficulty == 3 else 0
54
+ rl = "(%d : ℤ)" % r
55
+ summand = ("%d * " % c if c != 1 else "") + "%s ^ (i + %d)" % (rl, shift) if shift else ("%d * " % c if c != 1 else "") + "%s ^ i" % rl
56
+ stmt = "(n : ℕ) :\n (%d : ℤ) * ∑ i ∈ Finset.range n, %s = %d * (%s ^ n - 1)" % (r - 1, summand, c * r ** shift, rl)
57
+ assert all((r - 1) * sum(c * r ** (i + shift) for i in range(m)) == c * r ** shift * (r ** m - 1) for m in range(8))
58
+ tex_r = "(%d)" % r if r < 0 else "%d" % r
59
+ informal = "For every natural number \\(n\\), \\[%d \\sum_{i=0}^{n-1} %s%s^{%s} = %d\\left(%s^{n} - 1\\right).\\] The sum is over the integers and is empty when \\(n = 0\\)." % (
60
+ r - 1, ("%d \\cdot " % c) if c != 1 else "", tex_r, "i+%d" % shift if shift else "i", c * r ** shift, tex_r)
61
+ proof = "by\n induction n with\n | zero => simp\n | succ k ih =>\n rw [Finset.sum_range_succ, mul_add, ih]\n ring"
62
+ return informal, stmt, proof
63
+
64
+ def telescoping(rng, difficulty):
65
+ a = rng.randrange(1, 5) if difficulty == 1 else rng.randrange(2, 9); c = rng.choice([1, 1, 2]) if difficulty < 3 else rng.randrange(2, 9)
66
+ # sum_{i<n} c / ((i+a)(i+a+1)) = c n / (a (n+a))
67
+ stmt = "(n : ℕ) :\n ∑ i ∈ Finset.range n, (%d : ℚ) / (((i : ℚ) + %d) * ((i : ℚ) + %d)) = %d * (n : ℚ) / (%d * ((n : ℚ) + %d))" % (c, a, a + 1, c, a, a)
68
+ assert all(sum(F(c, (i + a) * (i + a + 1)) for i in range(m)) == F(c * m, a * (m + a)) for m in range(8))
69
+ informal = "For every natural number \\(n\\), \\[\\sum_{i=0}^{n-1} \\frac{%d}{(i+%d)(i+%d)} = \\frac{%s}{%s}.\\] The sum is over the rationals and is empty when \\(n = 0\\)." % (
70
+ c, a, a + 1, ("%dn" % c) if c != 1 else "n", ("%d(n+%d)" % (a, a)) if a != 1 else "n+1")
71
+ proof = ("by\n induction n with\n | zero => simp\n | succ k ih =>\n rw [Finset.sum_range_succ, ih]\n"
72
+ " have h1 : ((k : ℚ) + %d) ≠ 0 := by positivity\n have h2 : ((k : ℚ) + %d) ≠ 0 := by positivity\n"
73
+ " have h3 : (((k + 1 : ℕ) : ℚ) + %d) ≠ 0 := by positivity\n push_cast\n field_simp\n ring") % (a, a + 1, a)
74
+ return informal, stmt, proof
75
+
76
+ def generate(seed, difficulty, family=None):
77
+ family = family or sorted(FAMILIES)[seed % len(FAMILIES)]
78
+ rng = rng_for(ENV + "/" + family, seed, difficulty)
79
+ informal, stmt, proof = {"polynomial": polynomial, "geometric": geometric, "telescoping": telescoping}[family](rng, difficulty)
80
+ return Task(env=ENV, family=family, seed=seed, difficulty=difficulty, kind="prove",
81
+ title="Prove a closed form for a finite sum", informal="Prove the following identity.\n\n" + informal,
82
+ theorems=[Theorem("sum_closed_form", stmt, proof, "The closed form stated in the task.")])
envs/group_theory/__init__.py ADDED
File without changes
envs/group_theory/env.toml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ name = "group-theory"
2
+ title = "Proofs about groups and subgroups"
3
+ msc = "20"
4
+ kind = "prove"
5
+ summary = "Prove facts about abstract groups: commutativity from exponent laws, inverses, subgroup membership and Lagrange, homomorphism kernels."
6
+ skill = "Group identities and the Subgroup API"
7
+ good_for = ["calc chains in groups", "Subgroup and MonoidHom.ker API", "Nat.card and orderOf"]
8
+ families = ["hom", "inverse", "involution", "subgroup"]
envs/group_theory/gen.py ADDED
@@ -0,0 +1,330 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Group theory (MSC 20: group theory and generalizations).
2
+
3
+ Families: involution (an exponent or inverse law forces commutativity), inverse (uniqueness and
4
+ cancellation facts in monoids and groups), subgroup (membership, normal subgroups, a union of two
5
+ subgroups, Lagrange with Nat.card), hom (kernels of group homomorphisms).
6
+ Second code path: numeric parameters (cyclic rotation, cardinalities) are checked in Python with
7
+ permutations and integer arithmetic before the task is returned; the Lean reference proofs are
8
+ compiled in the self-test.
9
+ """
10
+ import itertools
11
+ from arena.core import Task, Theorem, rng_for
12
+
13
+ ENV = "group_theory"
14
+ FAMILIES = ["hom", "inverse", "involution", "subgroup"]
15
+ TYPES = ["G", "A", "Q"]
16
+ NAMES3 = [("x", "y", "z"), ("a", "b", "c"), ("g", "k", "m"), ("p", "q", "r"), ("u", "v", "w")]
17
+ NAMES2 = [("x", "y"), ("a", "b"), ("g", "k"), ("u", "v"), ("s", "t"), ("p", "q")]
18
+
19
+ def indent(text, n):
20
+ pad = " " * n
21
+ return "\n".join(pad + l if l.strip() else l for l in text.split("\n"))
22
+
23
+ def sub(n): return "".join("₀₁₂₃₄₅₆₇₈₉"[int(c)] for c in str(n))
24
+
25
+ # ---------------------------------------------------------------- involution
26
+
27
+ def inv_hyps(T, u, v):
28
+ """kind -> (lean hypothesis, TeX hypothesis, proof of `∀ u v : T, u * v = v * u` from h)."""
29
+ return {
30
+ "self": ("∀ g : %s, g * g = 1" % T, "g \\cdot g = e \\text{ for every } g",
31
+ "by\n intro %s %s\n have hi : ∀ g : %s, g⁻¹ = g := fun g => inv_eq_of_mul_eq_one_right (h g)\n"
32
+ " calc %s * %s = (%s * %s)⁻¹ := (hi _).symm\n _ = %s⁻¹ * %s⁻¹ := mul_inv_rev %s %s\n _ = %s * %s := by rw [hi, hi]" % (u, v, T, u, v, u, v, v, u, u, v, v, u)),
33
+ "inveq": ("∀ g : %s, g⁻¹ = g" % T, "g^{-1} = g \\text{ for every } g",
34
+ "by\n intro %s %s\n calc %s * %s = (%s * %s)⁻¹ := (h _).symm\n _ = %s⁻¹ * %s⁻¹ := mul_inv_rev %s %s\n _ = %s * %s := by rw [h, h]" % (u, v, u, v, u, v, v, u, u, v, v, u)),
35
+ "sq": ("∀ g : %s, g ^ 2 = 1" % T, "g^2 = e \\text{ for every } g",
36
+ "by\n intro %s %s\n have hi : ∀ g : %s, g⁻¹ = g := fun g => inv_eq_of_mul_eq_one_right (by rw [← pow_two]; exact h g)\n"
37
+ " calc %s * %s = (%s * %s)⁻¹ := (hi _).symm\n _ = %s⁻¹ * %s⁻¹ := mul_inv_rev %s %s\n _ = %s * %s := by rw [hi, hi]" % (u, v, T, u, v, u, v, v, u, u, v, v, u)),
38
+ "sqmul": ("∀ %s %s : %s, (%s * %s) ^ 2 = %s ^ 2 * %s ^ 2" % (u, v, T, u, v, u, v), "(ab)^2 = a^2 b^2 \\text{ for all } a, b",
39
+ "by\n intro %s %s\n have h1 := h %s %s\n simp only [pow_two, mul_assoc] at h1\n have h2 := mul_left_cancel h1\n"
40
+ " have h3 : (%s * %s) * %s = (%s * %s) * %s := by simpa [mul_assoc] using h2\n exact (mul_right_cancel h3).symm" % (u, v, u, v, v, u, v, u, v, v)),
41
+ "invmul": ("∀ %s %s : %s, (%s * %s)⁻¹ = %s⁻¹ * %s⁻¹" % (u, v, T, u, v, u, v), "(ab)^{-1} = a^{-1} b^{-1} \\text{ for all } a, b",
42
+ "by\n intro %s %s\n have h1 := h %s⁻¹ %s⁻¹\n simp at h1\n exact h1.symm" % (u, v, u, v)),
43
+ "aba": ("∀ %(u)s %(v)s : %(T)s, %(u)s * %(v)s * %(u)s = %(v)s" % dict(u=u, v=v, T=T), "aba = b \\text{ for all } a, b",
44
+ ("by\n intro %(u)s %(v)s\n have h1 : ∀ g : %(T)s, g * g = 1 := fun g => by\n have := h g 1\n rwa [mul_one] at this\n"
45
+ " calc %(u)s * %(v)s = %(u)s * %(v)s * (%(u)s * %(u)s) := by rw [h1 %(u)s, mul_one]\n"
46
+ " _ = (%(u)s * %(v)s * %(u)s) * %(u)s := by rw [mul_assoc (%(u)s * %(v)s)]\n _ = %(v)s * %(u)s := by rw [h %(u)s %(v)s]") % dict(u=u, v=v, T=T)),
47
+ }
48
+
49
+ def involution(rng, difficulty):
50
+ T = rng.choice(TYPES); u, v = rng.choice(NAMES2)
51
+ kinds = {1: ["self", "inveq"], 2: ["sq", "sqmul", "invmul"], 3: ["aba", "sqmul", "invmul", "sq"]}[difficulty]
52
+ kind = rng.choice(kinds)
53
+ hl, ht, proof = inv_hyps(T, u, v)[kind]
54
+ concl = rng.choice(["comm"] if difficulty == 1 else ["comm", "conj", "center"])
55
+ if concl == "comm":
56
+ goal = "∀ %s %s : %s, %s * %s = %s * %s" % (u, v, T, u, v, v, u)
57
+ words = "Then \\(G\\) is commutative: \\(ab = ba\\) for all \\(a, b \\in G\\)."
58
+ final = proof
59
+ else:
60
+ key = "have key : ∀ %s %s : %s, %s * %s = %s * %s := %s" % (u, v, T, u, v, v, u, indent(proof, 2).lstrip())
61
+ if concl == "conj":
62
+ goal = "∀ %s %s : %s, %s * %s * %s⁻¹ = %s" % (u, v, T, u, v, u, v)
63
+ words = "Then \\(a b a^{-1} = b\\) for all \\(a, b \\in G\\)."
64
+ final = "by\n %s\n intro %s %s\n rw [mul_inv_eq_iff_eq_mul]\n exact key %s %s" % (key, u, v, u, v)
65
+ else:
66
+ goal = "∀ z : %s, z ∈ Subgroup.center %s" % (T, T)
67
+ words = "Then every element of \\(G\\) lies in the center of \\(G\\)."
68
+ final = "by\n %s\n intro z\n rw [Subgroup.mem_center_iff]\n intro g\n exact key g z" % key
69
+ informal = "Let \\(G\\) be a group such that \\(%s\\). %s" % (ht, words)
70
+ ths = []
71
+ if difficulty == 3 and concl == "comm":
72
+ n = rng.randrange(3, 10)
73
+ lem = Theorem("involution_comm", "{%s : Type*} [Group %s] (h : %s) :\n %s" % (T, T, hl, goal), final, "The group is commutative.", 0.4)
74
+ main = Theorem("power_of_product", "{%s : Type*} [Group %s] (h : %s) (%s %s : %s) :\n (%s * %s) ^ %d = %s ^ %d * %s ^ %d" % (T, T, hl, u, v, T, u, v, n, u, n, v, n),
75
+ "by\n exact Commute.mul_pow (involution_comm h %s %s) %d" % (u, v, n), "In this group \\((ab)^%d = a^%d b^%d\\)." % (n, n, n), 0.6)
76
+ informal += " Deduce that \\((ab)^{%d} = a^{%d} b^{%d}\\) for all \\(a, b \\in G\\)." % (n, n, n)
77
+ return informal, [lem, main]
78
+ return informal, [Theorem("group_commutes", "{%s : Type*} [Group %s] (h : %s) :\n %s" % (T, T, hl, goal), final,
79
+ "The stated consequence of the hypothesis on the group.")]
80
+
81
+ # ---------------------------------------------------------------- inverse
82
+
83
+ def perm_mul(p, q): return tuple(p[i] for i in q) # (p * q)(i) = p(q(i))
84
+ def perm_inv(p):
85
+ r = [0] * len(p)
86
+ for i, x in enumerate(p): r[x] = i
87
+ return tuple(r)
88
+
89
+ def cyclic(rng, difficulty):
90
+ k = {1: 3, 2: rng.randrange(4, 7), 3: rng.randrange(6, 9)}[difficulty]
91
+ r = rng.randrange(1, k)
92
+ base = rng.choice(["x", "a", "g", "t"]); T = rng.choice(TYPES)
93
+ names = [base + sub(i + 1) for i in range(k)]
94
+ # second code path: in S_5, choose a_2..a_k at random, a_1 = (a_2...a_k)^{-1}; then the rotation is e
95
+ for _ in range(5):
96
+ els = [tuple(rng.sample(range(5), 5)) for _ in range(k - 1)]
97
+ prod = tuple(range(5))
98
+ for e in els: prod = perm_mul(prod, e)
99
+ els = [perm_inv(prod)] + els
100
+ full = tuple(range(5))
101
+ for e in els: full = perm_mul(full, e)
102
+ assert full == tuple(range(5))
103
+ rot = els[r:] + els[:r]; res = tuple(range(5))
104
+ for e in rot: res = perm_mul(res, e)
105
+ assert res == tuple(range(5))
106
+ prod_l = " * ".join(names); rot_l = " * ".join(names[r:] + names[:r])
107
+ pre = " * ".join(names[:r])
108
+ stmt = "{%s : Type*} [Group %s] (%s : %s)\n (h : %s = 1) : %s = 1" % (T, T, " ".join(names), T, prod_l, rot_l)
109
+ proof = "by\n calc %s = (%s)⁻¹ * (%s) * (%s) := by group\n _ = 1 := by rw [h]; group" % (rot_l, pre, prod_l, pre)
110
+ tp = lambda ns: " ".join(n.replace(base, "a_") if False else n for n in ns)
111
+ tex = lambda ns: " ".join("%s_{%d}" % (base, int(n[len(base):].translate(str.maketrans("₀₁₂₃₄₅₆₇₈₉", "0123456789")))) for n in ns)
112
+ informal = "Let \\(G\\) be a group and \\(%s \\in G\\) with \\(%s = e\\). Then \\(%s = e\\)." % (
113
+ ", ".join("%s_{%d}" % (base, i + 1) for i in range(k)), tex(names), tex(names[r:] + names[:r]))
114
+ return informal, [Theorem("rotate_product", stmt, proof, "A product equal to the identity stays equal to the identity after a cyclic rotation.")]
115
+
116
+ def inverse(rng, difficulty):
117
+ kinds = {1: ["unique", "cyclic"], 2: ["cyclic", "conj", "conj", "powinv"], 3: ["right", "right", "cyclic"]}[difficulty]
118
+ kind = rng.choice(kinds)
119
+ if kind == "cyclic": return cyclic(rng, difficulty)
120
+ T = rng.choice(["M", "S", "N"]); x, y, z = rng.choice(NAMES3)
121
+ if kind == "unique":
122
+ order = rng.choice([0, 1])
123
+ h1, h2 = ("%s * %s = 1" % (x, y), "%s * %s = 1" % (z, x)) if order == 0 else ("%s * %s = 1" % (z, x), "%s * %s = 1" % (x, y))
124
+ informal = "Let \\(M\\) be a monoid and \\(%s, %s, %s \\in M\\) with \\(%s %s = 1\\) and \\(%s %s = 1\\). Then \\(%s = %s\\)." % (x, y, z, x, y, z, x, y, z)
125
+ proof = ("by\n calc %s = (%s * %s) * %s := by rw [%s, one_mul]\n _ = %s * (%s * %s) := mul_assoc _ _ _\n _ = %s := by rw [%s, mul_one]" % (
126
+ y, z, x, y, "h2" if order == 0 else "h1", z, x, y, z, "h1" if order == 0 else "h2"))
127
+ return informal, [Theorem("inverses_agree", "{%s : Type*} [Monoid %s] (%s %s %s : %s)\n (h1 : %s) (h2 : %s) : %s = %s" % (T, T, x, y, z, T, h1, h2, y, z), proof,
128
+ "A left inverse and a right inverse of the same element are equal.")]
129
+ if kind == "conj":
130
+ shape = rng.choice(["conj", "invconj", "order"]); T = rng.choice(TYPES)
131
+ if shape == "conj":
132
+ stmt = "{%s : Type*} [Group %s] (%s %s : %s) (n : ℕ) :\n (%s * %s * %s⁻¹) ^ n = %s * %s ^ n * %s⁻¹" % (T, T, x, y, T, x, y, x, x, y, x)
133
+ proof = "by\n induction n with\n | zero => simp\n | succ j ih =>\n rw [pow_succ, ih]\n group"
134
+ informal = "Let \\(G\\) be a group, \\(%s, %s \\in G\\) and \\(n \\in \\mathbb{N}\\). Then \\((%s %s %s^{-1})^n = %s %s^n %s^{-1}\\)." % (x, y, x, y, x, x, y, x)
135
+ elif shape == "invconj":
136
+ stmt = "{%s : Type*} [Group %s] (%s %s : %s) (n : ℕ) :\n (%s⁻¹ * %s * %s) ^ n = %s⁻¹ * %s ^ n * %s" % (T, T, x, y, T, x, y, x, x, y, x)
137
+ proof = "by\n induction n with\n | zero => simp\n | succ j ih =>\n rw [pow_succ, ih]\n group"
138
+ informal = "Let \\(G\\) be a group, \\(%s, %s \\in G\\) and \\(n \\in \\mathbb{N}\\). Then \\((%s^{-1} %s %s)^n = %s^{-1} %s^n %s\\)." % (x, y, x, y, x, x, y, x)
139
+ else:
140
+ stmt = "{%s : Type*} [Group %s] (%s %s : %s) :\n orderOf (%s * %s * %s⁻¹) = orderOf %s" % (T, T, x, y, T, x, y, x, y)
141
+ proof = "by\n exact orderOf_injective (MulAut.conj %s).toMonoidHom (MulAut.conj %s).injective %s" % (x, x, y)
142
+ informal = "Let \\(G\\) be a group and \\(%s, %s \\in G\\). Then the order of \\(%s %s %s^{-1}\\) equals the order of \\(%s\\) (orders are in \\(\\mathbb{N}\\), with 0 meaning infinite order)." % (x, y, x, y, x, y)
143
+ return informal, [Theorem("conjugate_fact", stmt, proof, "A fact about conjugation and powers.")]
144
+ if kind == "powinv":
145
+ T = rng.choice(["M", "S"])
146
+ proof = ("by\n induction n with\n | zero => simp\n | succ j ih =>\n calc %(x)s ^ (j + 1) * %(y)s ^ (j + 1) = %(x)s ^ j * (%(x)s * %(y)s) * %(y)s ^ j := by rw [pow_succ, pow_succ']; simp only [mul_assoc]\n"
147
+ " _ = 1 := by rw [h, mul_one]; exact ih") % dict(x=x, y=y)
148
+ informal = "Let \\(M\\) be a monoid and \\(%s, %s \\in M\\) with \\(%s %s = 1\\). Then \\(%s^n %s^n = 1\\) for every \\(n \\in \\mathbb{N}\\)." % (x, y, x, y, x, y)
149
+ return informal, [Theorem("pow_pair_one", "{%s : Type*} [Monoid %s] (%s %s : %s) (h : %s * %s = 1) (n : ℕ) :\n %s ^ n * %s ^ n = 1" % (T, T, x, y, T, x, y, x, y), proof,
150
+ "If xy = 1 then x^n y^n = 1.")]
151
+ # right: elements with a right inverse are invertible on both sides
152
+ left = rng.choice([0, 1])
153
+ hh = "∀ %s : %s, ∃ %s, %s * %s = 1" % (x, T, y, x, y) if left == 0 else "∀ %s : %s, ∃ %s, %s * %s = 1" % (x, T, y, y, x)
154
+ if left == 0:
155
+ goal = "∀ %s %s : %s, %s * %s = 1 → %s * %s = 1" % (x, y, T, x, y, y, x)
156
+ proof = ("by\n intro %s %s hxy\n obtain ⟨%s, hyz⟩ := h %s\n calc %s * %s = %s * %s * (%s * %s) := by rw [hyz, mul_one]\n _ = %s * (%s * %s) * %s := by simp only [mul_assoc]\n _ = %s * %s := by rw [hxy, mul_one]\n _ = 1 := hyz" % (
157
+ x, y, z, y, y, x, y, x, y, z, y, x, y, z, y, z))
158
+ informal = "Let \\(M\\) be a monoid in which every element \\(x\\) has some \\(y\\) with \\(xy = 1\\). Then \\(xy = 1\\) implies \\(yx = 1\\) for all \\(x, y \\in M\\)."
159
+ main_stmt = "{%s : Type*} [Monoid %s] (h : %s) (%s %s %s : %s)\n (h1 : %s * %s = 1) (h2 : %s * %s = 1) : %s = %s" % (T, T, hh, x, y, z, T, x, y, x, z, y, z)
160
+ main_proof = "by\n have hyx := right_inverse_comm h %s %s h1\n calc %s = %s * (%s * %s) := by rw [h2, mul_one]\n _ = (%s * %s) * %s := (mul_assoc _ _ _).symm\n _ = %s := by rw [hyx, one_mul]" % (x, y, y, y, x, z, y, x, z, z)
161
+ main_inf = "Under the same hypothesis, if \\(%s %s = 1\\) and \\(%s %s = 1\\) then \\(%s = %s\\)." % (x, y, x, z, y, z)
162
+ else:
163
+ goal = "∀ %s %s : %s, %s * %s = 1 → %s * %s = 1" % (x, y, T, y, x, x, y)
164
+ proof = ("by\n intro %s %s hyx\n obtain ⟨%s, hzy⟩ := h %s\n have hzx : %s = %s := by\n calc %s = %s * (%s * %s) := by rw [hyx, mul_one]\n _ = (%s * %s) * %s := (mul_assoc _ _ _).symm\n _ = %s := by rw [hzy, one_mul]\n rw [← hzx]\n exact hzy" % (
165
+ x, y, z, y, z, x, z, z, y, x, z, y, x, x))
166
+ informal = "Let \\(M\\) be a monoid in which every element \\(x\\) has some \\(y\\) with \\(yx = 1\\). Then \\(yx = 1\\) implies \\(xy = 1\\) for all \\(x, y \\in M\\)."
167
+ main_stmt = "{%s : Type*} [Monoid %s] (h : %s) (%s %s %s : %s)\n (h1 : %s * %s = 1) (h2 : %s * %s = 1) : %s = %s" % (T, T, hh, x, y, z, T, y, x, z, x, y, z)
168
+ main_proof = ("by\n have hxy := right_inverse_comm h %s %s h1\n calc %s = (%s * %s) * %s := by rw [h2, one_mul]\n _ = %s * (%s * %s) := mul_assoc _ _ _\n _ = %s := by rw [hxy, mul_one]") % (
169
+ x, y, y, z, x, y, z, x, y, z)
170
+ main_inf = "Under the same hypothesis, if \\(%s %s = 1\\) and \\(%s %s = 1\\) then \\(%s = %s\\)." % (y, x, z, x, y, z)
171
+ lem = Theorem("right_inverse_comm", "{%s : Type*} [Monoid %s] (h : %s) :\n %s" % (T, T, hh, goal), proof, "One-sided inverses are two-sided.", 0.4)
172
+ main = Theorem("inverse_unique", main_stmt, main_proof, "The inverse is unique.", 0.6)
173
+ return informal + " " + main_inf, [lem, main]
174
+
175
+ # ---------------------------------------------------------------- subgroup
176
+
177
+ def member(rng, difficulty, S, names):
178
+ """A random product of elements of the subgroup S. Returns (Lean expression, TeX, proof term)."""
179
+ k = {1: rng.randrange(2, 4), 2: rng.randrange(4, 6), 3: 5}[difficulty]
180
+ facs = []
181
+ for i in range(k):
182
+ n = names[i % len(names)]
183
+ form = rng.choice(["plain", "inv", "pow"] if difficulty > 1 else ["plain", "inv"])
184
+ facs.append((n, form, rng.randrange(2, 6)))
185
+ def fl(f): return f[0] if f[1] == "plain" else (f[0] + "⁻¹" if f[1] == "inv" else "%s ^ %d" % (f[0], f[2]))
186
+ def ft(f): return f[0] if f[1] == "plain" else (f[0] + "^{-1}" if f[1] == "inv" else "%s^{%d}" % (f[0], f[2]))
187
+ def fp(f): return "h" + f[0] if f[1] == "plain" else ("(inv_mem h%s)" % f[0] if f[1] == "inv" else "(pow_mem h%s %d)" % (f[0], f[2]))
188
+ expr = " * ".join(fl(f) for f in facs); tex = " ".join(ft(f) for f in facs)
189
+ proof = fp(facs[0])
190
+ for f in facs[1:]: proof = "(mul_mem %s %s)" % (proof, fp(f))
191
+ if proof.startswith("(") and len(facs) > 1: proof = proof[1:-1]
192
+ return expr, tex, proof, sorted({f[0] for f in facs})
193
+
194
+ def lagrange_numbers(rng, difficulty):
195
+ m = rng.choice([2, 3, 4, 5, 6, 8, 9, 10]); k = rng.choice([2, 3, 4, 5, 6, 7]); n = m * k
196
+ assert Nat_card_check(m, k, n)
197
+ return m, k, n
198
+ def Nat_card_check(m, k, n): return m * k == n and n % m == 0 and n // m == k
199
+
200
+ def subgroup(rng, difficulty):
201
+ T = rng.choice(TYPES)
202
+ kinds = {1: ["member"], 2: ["normal", "lagrange", "index"], 3: ["union", "union2", "prime", "index"]}[difficulty]
203
+ kind = rng.choice(kinds)
204
+ S = rng.choice(["H", "K", "N", "L"]); names = list(rng.choice(NAMES3))
205
+ if kind == "member":
206
+ expr, tex, pr, used = member(rng, difficulty, S, names)
207
+ binders = " ".join(used)
208
+ hyps = " ".join("(h%s : %s ∈ %s)" % (n, n, S) for n in used)
209
+ informal = "Let \\(%s\\) be a subgroup of a group \\(G\\) and let %s lie in \\(%s\\). Then \\(%s \\in %s\\)." % (S, ", ".join("\\(%s\\)" % n for n in used), S, tex, S)
210
+ return informal, [Theorem("product_mem", "{%s : Type*} [Group %s] (%s : Subgroup %s) {%s : %s}\n %s : %s ∈ %s" % (T, T, S, T, binders, T, hyps, expr, S), "by\n exact " + pr,
211
+ "A product of elements of a subgroup, with inverses and powers, lies in the subgroup.")]
212
+ if kind == "normal":
213
+ x, g = names[0], names[1]; n = rng.randrange(2, 8); shape = rng.choice(["pow", "comm"])
214
+ if shape == "pow":
215
+ goal = "%s * %s ^ %d * %s⁻¹ ∈ %s" % (g, x, n, g, S); pr = "hN.conj_mem _ (pow_mem hx %d) %s" % (n, g)
216
+ words = "\\(%s %s^{%d} %s^{-1} \\in %s\\)" % (g, x, n, g, S)
217
+ else:
218
+ goal = "%s * %s * %s⁻¹ * %s⁻¹ ∈ %s" % (g, x, g, x, S); pr = "mul_mem (hN.conj_mem _ hx %s) (inv_mem hx)" % g
219
+ words = "\\(%s %s %s^{-1} %s^{-1} \\in %s\\)" % (g, x, g, x, S)
220
+ informal = "Let \\(%s\\) be a normal subgroup of a group \\(G\\), let \\(%s \\in %s\\) and \\(%s \\in G\\). Then %s." % (S, x, S, g, words)
221
+ return informal, [Theorem("normal_conj", "{%s : Type*} [Group %s] (%s : Subgroup %s) (hN : %s.Normal) {%s : %s} (hx : %s ∈ %s) (%s : %s) :\n %s" % (T, T, S, T, S, x, T, x, S, g, T, goal),
222
+ "by\n exact " + pr, "Conjugates of elements of a normal subgroup stay in it.")]
223
+ if kind == "lagrange":
224
+ m, k, n = lagrange_numbers(rng, difficulty); n_ord = n
225
+ shape = rng.choice(["card", "order"])
226
+ if shape == "card":
227
+ informal = "Let \\(G\\) be a group with \\(|G| = %d\\) and \\(%s\\) a subgroup of \\(G\\). Then \\(|%s|\\) divides %d." % (n, S, S, n)
228
+ return informal, [Theorem("subgroup_card_dvd", "{%s : Type*} [Group %s] (hG : Nat.card %s = %d) (%s : Subgroup %s) :\n Nat.card %s ∣ %d" % (T, T, T, n, S, T, S, n),
229
+ "by\n rw [← hG]\n exact Subgroup.card_subgroup_dvd_card %s" % S, "Lagrange: the order of a subgroup divides the order of the group.")]
230
+ informal = "Let \\(G\\) be a group with \\(|G| = %d\\) and \\(%s \\in G\\). Then the order of \\(%s\\) divides %d." % (n, names[0], names[0], n)
231
+ return informal, [Theorem("order_dvd", "{%s : Type*} [Group %s] (hG : Nat.card %s = %d) (%s : %s) :\n orderOf %s ∣ %d" % (T, T, T, n, names[0], T, names[0], n),
232
+ "by\n rw [← hG]\n exact orderOf_dvd_natCard %s" % names[0], "The order of an element divides the order of the group.")]
233
+ if kind == "index":
234
+ m, k, n = lagrange_numbers(rng, difficulty)
235
+ informal = "Let \\(G\\) be a group with \\(|G| = %d\\) and \\(%s\\) a subgroup with \\(|%s| = %d\\). Then \\(%s\\) has index %d in \\(G\\)." % (n, S, S, m, S, k)
236
+ return informal, [Theorem("subgroup_index", "{%s : Type*} [Group %s] (hG : Nat.card %s = %d) (%s : Subgroup %s) (hH : Nat.card %s = %d) :\n %s.index = %d" % (T, T, T, n, S, T, S, m, S, k),
237
+ "by\n have h := Subgroup.card_mul_index %s\n rw [hG, hH] at h\n omega" % S, "Lagrange: the cardinality is the product of subgroup order and index.")]
238
+ if kind in ("union", "union2"):
239
+ A, B = rng.choice([("H", "K"), ("A", "B"), ("P", "R")])
240
+ if kind == "union":
241
+ hyp = "∀ a b : %s, (a ∈ %s ∨ a ∈ %s) → (b ∈ %s ∨ b ∈ %s) → (a * b ∈ %s ∨ a * b ∈ %s)" % (T, A, B, A, B, A, B)
242
+ use = "h a b (Or.inl haH) (Or.inr hbK)"
243
+ words = "whenever \\(a\\) and \\(b\\) each lie in \\(%s\\) or in \\(%s\\), the product \\(ab\\) lies in \\(%s\\) or in \\(%s\\)" % (A, B, A, B)
244
+ else:
245
+ hyp = "∀ a ∈ %s, ∀ b ∈ %s, a * b ∈ %s ∨ a * b ∈ %s" % (A, B, A, B)
246
+ use = "h a haH b hbK"
247
+ words = "for all \\(a \\in %s\\) and \\(b \\in %s\\) the product \\(ab\\) lies in \\(%s\\) or in \\(%s\\)" % (A, B, A, B)
248
+ stmt = "{%s : Type*} [Group %s] (%s %s : Subgroup %s)\n (h : %s) : %s ≤ %s ∨ %s ≤ %s" % (T, T, A, B, T, hyp, A, B, B, A)
249
+ proof = ("by\n by_contra hcon\n rw [not_or] at hcon\n obtain ⟨h1, h2⟩ := hcon\n rw [SetLike.not_le_iff_exists] at h1 h2\n"
250
+ " obtain ⟨a, haH, haK⟩ := h1\n obtain ⟨b, hbK, hbH⟩ := h2\n rcases %s with hab | hab\n"
251
+ " · exact hbH (by simpa using mul_mem (inv_mem haH) hab)\n · exact haK (by simpa using mul_mem hab (inv_mem hbK))") % use
252
+ informal = "Let \\(%s\\) and \\(%s\\) be subgroups of a group \\(G\\) such that %s. Then \\(%s \\subseteq %s\\) or \\(%s \\subseteq %s\\)." % (A, B, words, A, B, B, A)
253
+ return informal, [Theorem("subgroup_union", stmt, proof, "A product-closed union of two subgroups is one of them.")]
254
+ # prime
255
+ p = rng.choice([3, 5, 7, 11, 13, 17, 19])
256
+ assert all(p % d for d in range(2, p))
257
+ g = names[0]
258
+ informal = "Let \\(G\\) be a group with \\(|G| = %d\\). Then \\(x^{%d} = e\\) for every \\(x \\in G\\), and every element \\(%s \\neq e\\) has order exactly %d." % (p, p, g, p)
259
+ lem = Theorem("pow_card", "{%s : Type*} [Group %s] (hG : Nat.card %s = %d) (x : %s) :\n x ^ %d = 1" % (T, T, T, p, T, p), "by\n rw [← hG]\n exact pow_card_eq_one'", "Every element satisfies x^|G| = 1.", 0.4)
260
+ main = Theorem("order_prime", "{%s : Type*} [Group %s] (hG : Nat.card %s = %d) (%s : %s) (hne : %s ≠ 1) :\n orderOf %s = %d" % (T, T, T, p, g, T, g, g, p),
261
+ "by\n haveI : Fact (Nat.Prime %d) := ⟨by norm_num⟩\n exact orderOf_eq_prime (pow_card %s %s) hne" % (p, "hG", g), "In a group of prime order p, every non-identity element has order p.", 0.6)
262
+ return informal, [lem, main]
263
+
264
+ # ---------------------------------------------------------------- hom
265
+
266
+ def hom(rng, difficulty):
267
+ G, H = rng.choice([("G", "H"), ("A", "B"), ("G", "K"), ("X", "Y")])
268
+ x, y = rng.choice(NAMES2)
269
+ kinds = {1: ["prod", "pow", "inv", "normal"], 2: ["inj", "comp", "inj", "comp"], 3: ["injcomp", "inj", "cardinj", "range"]}[difficulty]
270
+ kind = rng.choice(kinds)
271
+ pre = "{%s %s : Type*} [Group %s] [Group %s] (f : %s →* %s)" % (G, H, G, H, G, H)
272
+ if kind == "prod":
273
+ informal = "Let \\(f : G \\to H\\) be a group homomorphism and \\(%s, %s\\) in its kernel. Then \\(%s %s^{-1}\\) lies in the kernel." % (x, y, x, y)
274
+ return informal, [Theorem("kernel_mul_inv", "%s {%s %s : %s}\n (hx : %s ∈ f.ker) (hy : %s ∈ f.ker) : %s * %s⁻¹ ∈ f.ker" % (pre, x, y, G, x, y, x, y), "by\n exact mul_mem hx (inv_mem hy)",
275
+ "The kernel is closed under x y⁻¹.")]
276
+ if kind == "pow":
277
+ n = rng.randrange(2, 12)
278
+ informal = "Let \\(f : G \\to H\\) be a group homomorphism and \\(%s\\) an element of \\(G\\) with \\(f(%s) = e\\). Then \\(f(%s^{%d}) = e\\)." % (x, x, x, n)
279
+ return informal, [Theorem("image_of_power", "%s (%s : %s)\n (hx : f %s = 1) : f (%s ^ %d) = 1" % (pre, x, G, x, x, n), "by\n rw [map_pow, hx, one_pow]", "Powers of kernel elements are in the kernel.")]
280
+ if kind == "inv":
281
+ informal = "Let \\(f : G \\to H\\) be a group homomorphism and \\(%s, %s \\in G\\). Then \\(f(%s) = f(%s)\\) if and only if \\(%s^{-1} %s\\) lies in the kernel of \\(f\\)." % (x, y, x, y, x, y)
282
+ return informal, [Theorem("eq_iff_mem_ker", "%s (%s %s : %s) :\n f %s = f %s ↔ %s⁻¹ * %s ∈ f.ker" % (pre, x, y, G, x, y, x, y),
283
+ "by\n rw [MonoidHom.mem_ker, map_mul, map_inv, inv_mul_eq_one]", "Two elements have the same image exactly when x⁻¹ y is in the kernel.")]
284
+ if kind == "conj":
285
+ n = rng.randrange(1, 6)
286
+ informal = "Let \\(f : G \\to H\\) be a group homomorphism, \\(%s \\in G\\) with \\(f(%s) = e\\) and \\(%s \\in G\\). Then \\(f(%s %s^{%d} %s^{-1}) = e\\)." % (x, x, y, y, x, n, y)
287
+ return informal, [Theorem("conj_in_kernel", "%s (%s %s : %s)\n (hx : f %s = 1) : f (%s * %s ^ %d * %s⁻¹) = 1" % (pre, x, y, G, x, y, x, n, y),
288
+ "by\n rw [map_mul, map_mul, map_pow, map_inv, hx, one_pow, mul_one, mul_inv_cancel]", "The kernel is normal.")]
289
+ if kind == "normal":
290
+ informal = "Let \\(f : G \\to H\\) be a group homomorphism and \\(%s, %s \\in G\\) with \\(f(%s) = e\\). Then \\(%s %s %s^{-1} %s^{-1}\\) lies in the kernel of \\(f\\)." % (x, y, x, y, x, y, x)
291
+ return informal, [Theorem("commutator_in_kernel", "%s (%s %s : %s)\n (hx : f %s = 1) : %s * %s * %s⁻¹ * %s⁻¹ ∈ f.ker" % (pre, x, y, G, x, y, x, y, x),
292
+ "by\n exact mul_mem (f.normal_ker.conj_mem _ hx %s) (inv_mem hx)" % y, "Commutators with a kernel element lie in the kernel.")]
293
+ if kind == "inj":
294
+ informal = "Let \\(f : G \\to H\\) be a group homomorphism such that \\(f(%s) = e\\) implies \\(%s = e\\) for every \\(%s \\in G\\). Then \\(f\\) is injective." % (x, x, x)
295
+ return informal, [Theorem("injective_of_trivial_kernel", "%s\n (h : ∀ %s : %s, f %s = 1 → %s = 1) : Function.Injective f" % (pre, x, G, x, x),
296
+ "by\n intro a b hab\n have h1 : f (a⁻¹ * b) = 1 := by rw [map_mul, map_inv, hab, inv_mul_cancel]\n exact inv_mul_eq_one.mp (h _ h1)",
297
+ "A homomorphism with trivial kernel is injective.")]
298
+ if kind == "comp":
299
+ K = "Z"
300
+ informal = "Let \\(f : G \\to H\\) and \\(g : H \\to K\\) be group homomorphisms. Then every element of the kernel of \\(f\\) lies in the kernel of \\(g \\circ f\\)."
301
+ return informal, [Theorem("ker_le_ker_comp", "{%s %s %s : Type*} [Group %s] [Group %s] [Group %s] (f : %s →* %s) (g : %s →* %s) :\n f.ker ≤ (g.comp f).ker" % (G, H, K, G, H, K, G, H, H, K),
302
+ "by\n intro %s hx\n rw [MonoidHom.mem_ker] at hx ⊢\n rw [MonoidHom.comp_apply, hx, map_one]" % x, "The kernel of f lies in the kernel of g after f.")]
303
+ if kind == "injcomp":
304
+ K = "Z"
305
+ informal = "Let \\(f : G \\to H\\) and \\(g : H \\to K\\) be group homomorphisms with \\(g\\) injective. Then \\(g \\circ f\\) and \\(f\\) have the same kernel."
306
+ lem = Theorem("ker_le_ker_comp", "{%s %s %s : Type*} [Group %s] [Group %s] [Group %s] (f : %s →* %s) (g : %s →* %s) :\n f.ker ≤ (g.comp f).ker" % (G, H, K, G, H, K, G, H, H, K),
307
+ "by\n intro %s hx\n rw [MonoidHom.mem_ker] at hx ⊢\n rw [MonoidHom.comp_apply, hx, map_one]" % x, "The kernel of f lies in the kernel of g after f.", 0.3)
308
+ main = Theorem("ker_comp_eq", "{%s %s %s : Type*} [Group %s] [Group %s] [Group %s] (f : %s →* %s) (g : %s →* %s)\n (hg : Function.Injective g) : (g.comp f).ker = f.ker" % (G, H, K, G, H, K, G, H, H, K),
309
+ "by\n apply le_antisymm\n · intro %s hx\n rw [MonoidHom.mem_ker, MonoidHom.comp_apply] at hx\n rw [MonoidHom.mem_ker]\n exact hg (by rw [hx, map_one])\n · exact ker_le_ker_comp f g" % x,
310
+ "If g is injective the kernels agree.", 0.7)
311
+ return informal + " Show that \\(\\ker f \\subseteq \\ker(g \\circ f)\\) and then the equality.", [lem, main]
312
+ if kind == "cardinj":
313
+ informal = "Let \\(f : G \\to H\\) be a group homomorphism whose kernel has exactly one element. Then \\(f\\) is injective."
314
+ return informal, [Theorem("injective_of_card_ker", "%s\n (h : Nat.card f.ker = 1) : Function.Injective f" % pre, "by\n exact (MonoidHom.ker_eq_bot_iff f).mp (Subgroup.card_eq_one.mp h)",
315
+ "A homomorphism whose kernel has one element is injective.")]
316
+ # range: an injective hom from G into H gives |G| dividing |H|
317
+ informal = "Let \\(f : G \\to H\\) be an injective group homomorphism of groups. Then \\(|G|\\) divides \\(|H|\\) (cardinalities are in \\(\\mathbb{N}\\), with 0 for an infinite group)."
318
+ return informal, [Theorem("card_dvd_of_injective", "%s\n (hf : Function.Injective f) : Nat.card %s ∣ Nat.card %s" % (pre, G, H),
319
+ "by\n have h1 : Nat.card %s = Nat.card f.range := Nat.card_congr (MonoidHom.ofInjective hf).toEquiv\n rw [h1]\n exact Subgroup.card_subgroup_dvd_card f.range" % G,
320
+ "Lagrange for an injective homomorphism.")]
321
+
322
+ FAM = {"involution": involution, "inverse": inverse, "subgroup": subgroup, "hom": hom}
323
+ TITLES = {"involution": "Commutativity from a group law", "inverse": "Inverses and cancellation", "subgroup": "Subgroups and their orders", "hom": "Kernels of group homomorphisms"}
324
+
325
+ def generate(seed, difficulty, family=None):
326
+ family = family or sorted(FAMILIES)[seed % len(FAMILIES)]
327
+ rng = rng_for(ENV + "/" + family, seed, difficulty)
328
+ informal, theorems = FAM[family](rng, difficulty)
329
+ return Task(env=ENV, family=family, seed=seed, difficulty=difficulty, kind="prove",
330
+ title=TITLES[family], informal="Prove the following statement.\n\n" + informal, theorems=theorems)
envs/inequalities/__init__.py ADDED
File without changes
envs/inequalities/env.toml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ name = "inequalities"
2
+ title = "Inequalities over the reals"
3
+ msc = "26"
4
+ kind = "prove"
5
+ summary = "Prove real inequalities: AM-GM, Cauchy-Schwarz, absolute values and monotone functions, with hints, case splits and lemma reuse."
6
+ skill = "Real inequalities with nlinarith hints"
7
+ good_for = ["nlinarith with hints", "abs_le and case splits", "field_simp then positivity", "monotonicity lemmas"]
8
+ families = ["abs_ineq", "amgm", "cauchy", "monotone"]
envs/inequalities/gen.py ADDED
@@ -0,0 +1,305 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Inequalities over the reals (MSC 26: real functions; 26D05, 26D07, 26D15 inequalities).
2
+
3
+ Families:
4
+ amgm AM-GM in two or three variables (squares, field_simp then positivity, a cross-lemma step);
5
+ cauchy Cauchy-Schwarz small cases, including the bound u x + v y <= w when x^2 + y^2 <= 1;
6
+ abs_ineq absolute-value inequalities (abs_le, case splits on abs_cases, a product bound);
7
+ monotone inequalities between values of increasing functions (exp, arctan, sinh, odd powers, sqrt, log).
8
+ Second code path: every numeric constant and every inequality is rechecked in Python with exact
9
+ fractions (or a float grid for transcendental functions) before the task is returned.
10
+ """
11
+ import math
12
+ from fractions import Fraction as F
13
+ from arena.core import Task, Theorem, rng_for
14
+
15
+ ENV = "inequalities"
16
+ FAMILIES = ["abs_ineq", "amgm", "cauchy", "monotone"]
17
+
18
+
19
+ def mono(c, body):
20
+ return body if c == 1 else "%d * %s" % (c, body)
21
+
22
+
23
+ def tmono(c, body):
24
+ return body if c == 1 else "%d%s" % (c, body)
25
+
26
+
27
+ def sgn_term(c, body, first=False, tex=False):
28
+ """' + c * body' / ' - |c| * body' (or without sign when first)."""
29
+ mag = abs(c)
30
+ b = (body if mag == 1 else ("%d%s" % (mag, body) if tex else "%d * %s" % (mag, body)))
31
+ if first: return ("-" if c < 0 else "") + b
32
+ return (" - " if c < 0 else " + ") + b
33
+
34
+
35
+ def shift(var, c):
36
+ """Lean text of var + c (c an integer)."""
37
+ if c == 0: return var
38
+ return "%s + %d" % (var, c) if c > 0 else "%s - %d" % (var, -c)
39
+
40
+
41
+ def tshift(var, c):
42
+ return shift(var, c)
43
+
44
+
45
+ # ---------------------------------------------------------------- amgm
46
+ def amgm(rng, difficulty):
47
+ if difficulty == 1:
48
+ if rng.random() < 0.5:
49
+ p, q = rng.randrange(1, 10), rng.randrange(1, 10)
50
+ K = 4 * p * q
51
+ for a in range(-4, 5):
52
+ for b in range(-4, 5): assert K * a * b <= (p * a + q * b) ** 2
53
+ lhs = "%s * a * b" % K
54
+ pa, qb = mono(p, "a"), mono(q, "b")
55
+ informal = "Prove that for all real numbers \\(a\\) and \\(b\\), \\[%d\\,ab \\le (%s + %s)^2.\\]" % (K, tmono(p, "a"), tmono(q, "b"))
56
+ stmt = "(a b : ℝ) :\n %s ≤ (%s + %s) ^ 2" % (lhs, pa, qb)
57
+ proof = "by\n nlinarith [sq_nonneg (%s - %s)]" % (pa, qb)
58
+ return informal, [Theorem("two_var_amgm", stmt, proof, "A square-completion bound for two real numbers.")]
59
+ p, q = rng.randrange(1, 7), rng.randrange(1, 7); s = rng.randrange(1, 41)
60
+ for a in range(-6, 7):
61
+ for b in range(-6, 7):
62
+ if p * a + q * b == s: assert p * q * a * b <= F(s * s, 4)
63
+ pa, qb = mono(p, "a"), mono(q, "b")
64
+ informal = ("Let \\(a\\) and \\(b\\) be real numbers with \\(%s + %s = %d\\). Prove that \\[%s \\le \\frac{%d^2}{4}.\\]"
65
+ % (tmono(p, "a"), tmono(q, "b"), s, tmono(p * q, "ab"), s))
66
+ stmt = "(a b : ℝ) (h : %s + %s = %d) :\n %s ≤ %d ^ 2 / 4" % (pa, qb, s, mono(p * q, "a * b"), s)
67
+ proof = ("by\n have h2 : (%s + %s) ^ 2 = %d ^ 2 := by rw [h]\n nlinarith [sq_nonneg (%s - %s), h2]" % (pa, qb, s, pa, qb))
68
+ return informal, [Theorem("amgm_constraint", stmt, proof, "The product is at most a quarter of the squared sum.")]
69
+ if difficulty == 2:
70
+ m, u, v = rng.randrange(1, 5), rng.randrange(1, 6), rng.randrange(1, 6)
71
+ k1, k2, T = m * u * u, m * v * v, 2 * m * u * v
72
+ for a in (F(1, 3), F(2), F(7, 5), F(5)):
73
+ for b in (F(1, 2), F(3), F(11, 7), F(1)):
74
+ assert k1 * (a / b) + k2 * (b / a) - T == m * (u * a - v * b) ** 2 / (a * b) >= 0
75
+ if rng.random() < 0.5:
76
+ informal = ("Let \\(a\\) and \\(b\\) be positive real numbers. Prove that \\[%d \\le %s\\frac{a}{b} + %s\\frac{b}{a}.\\]" % (T, tmono(k1, ""), tmono(k2, "")))
77
+ stmt = "(a b : ℝ) (ha : 0 < a) (hb : 0 < b) :\n %d ≤ %s + %s" % (T, mono(k1, "(a / b)"), mono(k2, "(b / a)"))
78
+ key = "%s + %s - %d = %d * (%s - %s) ^ 2 / (a * b)" % (mono(k1, "(a / b)"), mono(k2, "(b / a)"), T, m, mono(u, "a"), mono(v, "b"))
79
+ proof = ("by\n have ha' := ha.ne'\n have hb' := hb.ne'\n have key : %s := by\n field_simp\n ring\n"
80
+ " have h : 0 ≤ %d * (%s - %s) ^ 2 / (a * b) := by positivity\n linarith" % (key, m, mono(u, "a"), mono(v, "b")))
81
+ return informal, [Theorem("amgm_ratio", stmt, proof, "A weighted sum of a ratio and its reciprocal is bounded below.")]
82
+ informal = "Let \\(x\\) be a positive real number. Prove that \\[%d \\le %s + \\frac{%d}{x}.\\]" % (T, tmono(k1, "x"), k2)
83
+ stmt = "(x : ℝ) (hx : 0 < x) :\n %d ≤ %s + %d / x" % (T, mono(k1, "x"), k2)
84
+ key = "%s + %d / x - %d = %d * (%s - %d) ^ 2 / x" % (mono(k1, "x"), k2, T, m, mono(u, "x"), v)
85
+ proof = ("by\n have hx' := hx.ne'\n have key : %s := by\n field_simp\n ring\n"
86
+ " have h : 0 ≤ %d * (%s - %d) ^ 2 / x := by positivity\n linarith" % (key, m, mono(u, "x"), v))
87
+ return informal, [Theorem("amgm_linear_plus_inverse", stmt, proof, "The sum of a linear term and an inverse term is bounded below.")]
88
+ p, q, r = rng.randrange(1, 8), rng.randrange(1, 8), rng.randrange(1, 8)
89
+ P = p * q * r
90
+ for a in (F(1), F(2, 3), F(5), F(0)):
91
+ for b in (F(3, 2), F(1, 7), F(4)):
92
+ for c in (F(2), F(9, 4), F(0)):
93
+ assert 27 * P * a * b * c <= (p * a + q * b + r * c) ** 3
94
+ pa, qb, rc = mono(p, "a"), mono(q, "b"), mono(r, "c")
95
+ informal = ("Prove that \\(27xyz \\le (x+y+z)^3\\) for all non-negative real numbers \\(x, y, z\\). "
96
+ "Then prove that for all non-negative real numbers \\(a, b, c\\), \\[%d\\,abc \\le (%s + %s + %s)^3.\\]" % (27 * P, tmono(p, "a"), tmono(q, "b"), tmono(r, "c")))
97
+ hints = ", ".join("mul_nonneg h%s (sq_nonneg (%s - %s))" % (v, w, z) for v, w, z in
98
+ [("x", "y", "z"), ("y", "z", "x"), ("z", "x", "y"), ("x", "x", "y"), ("x", "x", "z"), ("y", "y", "x"), ("y", "y", "z"), ("z", "z", "x"), ("z", "z", "y")])
99
+ lemma = Theorem("amgm_three", "(x y z : ℝ) (hx : 0 ≤ x) (hy : 0 ≤ y) (hz : 0 ≤ z) :\n 27 * x * y * z ≤ (x + y + z) ^ 3",
100
+ "by\n nlinarith [%s]" % hints, "The three-variable AM-GM inequality in cubic form.")
101
+ main = Theorem("amgm_three_scaled", "(a b c : ℝ) (ha : 0 ≤ a) (hb : 0 ≤ b) (hc : 0 ≤ c) :\n %d * a * b * c ≤ (%s + %s + %s) ^ 3" % (27 * P, pa, qb, rc),
102
+ "by\n have h := amgm_three (%s) (%s) (%s) (by linarith) (by linarith) (by linarith)\n nlinarith [h]" % (pa, qb, rc),
103
+ "The scaled three-variable inequality.", weight=2.0)
104
+ return informal, [lemma, main]
105
+
106
+
107
+ # ---------------------------------------------------------------- cauchy
108
+ TRIPLES2 = [(3, 4, 5), (5, 12, 13), (8, 15, 17), (7, 24, 25), (20, 21, 29), (6, 8, 10), (9, 12, 15), (12, 16, 20), (15, 8, 17), (12, 5, 13)]
109
+ TRIPLES3 = [(1, 2, 2, 3), (2, 3, 6, 7), (1, 4, 8, 9), (4, 4, 7, 9), (2, 6, 9, 11), (6, 6, 7, 11), (3, 4, 12, 13), (2, 10, 11, 15), (1, 12, 12, 17), (4, 8, 8, 12), (2, 2, 1, 3), (6, 2, 3, 7)]
110
+
111
+
112
+ def cauchy(rng, difficulty):
113
+ if difficulty == 1:
114
+ if rng.random() < 0.5:
115
+ p, q = rng.randrange(1, 10), rng.randrange(1, 10); P = p * q
116
+ for a, b, c, d in [(1, 2, 3, 4), (-2, 5, 1, -1), (3, -3, 2, 7)]:
117
+ assert (p * a * c + q * b * d) ** 2 <= (p * a * a + q * b * b) * (p * c * c + q * d * d)
118
+ informal = ("Prove that for all real numbers \\(a, b, c, d\\), \\[(%s + %s)^2 \\le (%s + %s)(%s + %s).\\]"
119
+ % (tmono(p, "ac"), tmono(q, "bd"), tmono(p, "a^2"), tmono(q, "b^2"), tmono(p, "c^2"), tmono(q, "d^2")))
120
+ stmt = "(a b c d : ℝ) :\n (%s + %s) ^ 2 ≤ (%s + %s) * (%s + %s)" % (mono(p, "a * c"), mono(q, "b * d"), mono(p, "a ^ 2"), mono(q, "b ^ 2"), mono(p, "c ^ 2"), mono(q, "d ^ 2"))
121
+ proof = "by\n nlinarith [mul_nonneg (show (0 : ℝ) ≤ %d by norm_num) (sq_nonneg (a * d - b * c))]" % P
122
+ return informal, [Theorem("weighted_cauchy", stmt, proof, "Cauchy-Schwarz with positive weights for two pairs.")]
123
+ p, q = rng.randrange(1, 13), rng.randrange(1, 13); S = p * p + q * q
124
+ for x, y in [(F(1), F(2)), (F(-3), F(5, 2)), (F(0), F(7))]: assert (p * x + q * y) ** 2 <= S * (x * x + y * y)
125
+ informal = "Prove that for all real numbers \\(x\\) and \\(y\\), \\[(%s + %s)^2 \\le %d\\,(x^2 + y^2).\\]" % (tmono(p, "x"), tmono(q, "y"), S)
126
+ stmt = "(x y : ℝ) :\n (%s + %s) ^ 2 ≤ %d * (x ^ 2 + y ^ 2)" % (mono(p, "x"), mono(q, "y"), S)
127
+ proof = "by\n nlinarith [sq_nonneg (%s - %s)]" % (mono(q, "x"), mono(p, "y"))
128
+ return informal, [Theorem("cauchy_two", stmt, proof, "A two-term Cauchy-Schwarz bound.")]
129
+ if difficulty == 2:
130
+ u, v, w = rng.choice(TRIPLES2)
131
+ if rng.random() < 0.5: u, v = v, u
132
+ sv = rng.choice([1, -1]); s = rng.randrange(1, 6); B = w * s
133
+ for k in range(0, 360):
134
+ x, y = F(s * math.cos(k * math.pi / 180)).limit_denominator(1000), F(s * math.sin(k * math.pi / 180)).limit_denominator(1000)
135
+ if x * x + y * y <= s * s: assert u * x + sv * v * y <= B
136
+ form = sgn_term(u, "x", True) + sgn_term(sv * v, "y")
137
+ tform = sgn_term(u, "x", True, True) + sgn_term(sv * v, "y", False, True)
138
+ informal = ("Let \\(x\\) and \\(y\\) be real numbers with \\(x^2 + y^2 \\le %d\\). Prove that \\(%s \\le %d\\)." % (s * s, tform, B))
139
+ stmt = "(x y : ℝ) (h : x ^ 2 + y ^ 2 ≤ %d) :\n %s ≤ %d" % (s * s, form, B)
140
+ proof = ("by\n have h1 : (%s) ^ 2 ≤ %d ^ 2 := by\n nlinarith [sq_nonneg (%s - %s)]\n by_contra hc\n push_neg at hc\n nlinarith [h1, hc]"
141
+ % (form, B, mono(v, "x"), ("(%d) * y" % (sv * u)) if sv * u != 1 else "y"))
142
+ return informal, [Theorem("cauchy_bound_circle", stmt, proof, "A linear form is bounded on a disc by the Cauchy-Schwarz inequality.")]
143
+ u, v, w, t = rng.choice(TRIPLES3)
144
+ cs = [u, v, w]; rng.shuffle(cs)
145
+ cs = [c * rng.choice([1, -1]) for c in cs]
146
+ s = rng.randrange(1, 5); B = t * s
147
+ assert sum(c * c for c in cs) == t * t
148
+ # exact check on the boundary points in the direction of the coefficient vector and a few others
149
+ for x, y, z in [(F(c * s, t) for c in cs), (F(s, 3), F(-s, 3), F(s, 3)), (F(0), F(s), F(0))]:
150
+ if x * x + y * y + z * z <= s * s: assert cs[0] * x + cs[1] * y + cs[2] * z <= B
151
+ form = sgn_term(cs[0], "x", True) + sgn_term(cs[1], "y") + sgn_term(cs[2], "z")
152
+ tform = sgn_term(cs[0], "x", True, True) + sgn_term(cs[1], "y", False, True) + sgn_term(cs[2], "z", False, True)
153
+ informal = ("Prove that for all real numbers \\(u, v, w, x, y, z\\), \\[(ux + vy + wz)^2 \\le (u^2 + v^2 + w^2)(x^2 + y^2 + z^2).\\] "
154
+ "Then let \\(x, y, z\\) be real numbers with \\(x^2 + y^2 + z^2 \\le %d\\) and prove that \\(%s \\le %d\\)." % (s * s, tform, B))
155
+ lemma = Theorem("cauchy_three", "(u v w x y z : ℝ) :\n (u * x + v * y + w * z) ^ 2 ≤ (u ^ 2 + v ^ 2 + w ^ 2) * (x ^ 2 + y ^ 2 + z ^ 2)",
156
+ "by\n nlinarith [sq_nonneg (u * y - v * x), sq_nonneg (u * z - w * x), sq_nonneg (v * z - w * y)]",
157
+ "Cauchy-Schwarz for three-term sums.")
158
+ inst = " ".join("(%d)" % c if c < 0 else "%d" % c for c in cs)
159
+ main = Theorem("cauchy_bound_ball", "(x y z : ℝ) (h : x ^ 2 + y ^ 2 + z ^ 2 ≤ %d) :\n %s ≤ %d" % (s * s, form, B),
160
+ "by\n have h1 := cauchy_three %s x y z\n by_contra hc\n push_neg at hc\n nlinarith [h1, hc]" % inst,
161
+ "A linear form is bounded on a ball.", weight=2.0)
162
+ return informal, [lemma, main]
163
+
164
+
165
+ # ---------------------------------------------------------------- abs_ineq
166
+ def abs_ineq(rng, difficulty):
167
+ if difficulty == 1:
168
+ p, q = rng.randrange(1, 10), rng.randrange(1, 10)
169
+ a, b = rng.randrange(-9, 10), rng.randrange(-9, 10); r, s = rng.randrange(1, 10), rng.randrange(1, 10)
170
+ K = p * a - q * b; bound = p * r + q * s
171
+ for x in (a - r, a + r, a):
172
+ for y in (b - s, b + s, b): assert abs(p * x - q * y - K) <= bound
173
+ expr = sgn_term(p, "x", True) + sgn_term(-q, "y") + ((" + %d" % -K if -K > 0 else " - %d" % K) if K != 0 else "")
174
+ tex = expr.replace(" * ", "")
175
+ informal = ("Let \\(x\\) and \\(y\\) be real numbers with \\(|%s| \\le %d\\) and \\(|%s| \\le %d\\). Prove that \\(|%s| \\le %d\\)."
176
+ % (shift("x", -a), r, shift("y", -b), s, tex, bound))
177
+ stmt = "(x y : ℝ) (hx : |%s| ≤ %d) (hy : |%s| ≤ %d) :\n |%s| ≤ %d" % (shift("x", -a), r, shift("y", -b), s, expr, bound)
178
+ proof = "by\n rw [abs_le] at hx hy ⊢\n obtain ⟨h1, h2⟩ := hx\n obtain ⟨h3, h4⟩ := hy\n constructor <;> linarith"
179
+ return informal, [Theorem("abs_linear_bound", stmt, proof, "An error bound for a linear combination.")]
180
+ if difficulty == 2 and rng.random() < 0.5:
181
+ p = rng.randrange(1, 7); a = rng.randrange(1, 10); gap = rng.randrange(1, 13); b = a + gap
182
+ for x in range(-20, 30): assert p * gap <= p * abs(x - a) + p * abs(x - b)
183
+ K = p * gap
184
+ informal = "Prove that for every real number \\(x\\), \\[%d \\le %s|x - %d| + %s|x - %d|.\\]" % (K, tmono(p, ""), a, tmono(p, ""), b)
185
+ stmt = "(x : ℝ) :\n %d ≤ %s + %s" % (K, mono(p, "|x - %d|" % a), mono(p, "|x - %d|" % b))
186
+ proof = ("by\n rcases abs_cases (x - %d) with ⟨h1, _⟩ | ⟨h1, _⟩ <;> rcases abs_cases (x - %d) with ⟨h2, _⟩ | ⟨h2, _⟩ <;> linarith" % (a, b))
187
+ return informal, [Theorem("abs_two_points", stmt, proof, "The sum of two distances is at least p times the gap.")]
188
+ if difficulty == 2:
189
+ a = rng.choice([c for c in range(-7, 8) if c != 0]); r = rng.randrange(1, 6); A = abs(a)
190
+ bound = r * (r + 2 * A)
191
+ for k in range(-20, 21):
192
+ x = F(a) + F(k, 20) * r
193
+ assert abs(x * x - a * a) <= bound
194
+ informal = "Let \\(x\\) be a real number with \\(|%s| \\le %d\\). Prove that \\(|x^2 - %s^2| \\le %d\\)." % (shift("x", -a), r, ("(%d)" % a) if a < 0 else a, bound)
195
+ ap = "(%d)" % a if a < 0 else "%d" % a
196
+ stmt = "(x : ℝ) (h : |%s| ≤ %d) :\n |x ^ 2 - %s ^ 2| ≤ %d * (%d + 2 * %d)" % (shift("x", -a), r, ap, r, r, A)
197
+ informal = informal.replace("\\le %d\\)." % bound, "\\le %d(%d + %d)\\)." % (r, r, 2 * A))
198
+ proof = ("by\n have h1 : |%s| ≤ %d + 2 * %d := by\n rw [abs_le] at h ⊢\n constructor <;> linarith [h.1, h.2]\n"
199
+ " have h2 : |x ^ 2 - %s ^ 2| = |%s| * |%s| := by\n rw [← abs_mul]\n congr 1\n ring\n"
200
+ " rw [h2]\n exact mul_le_mul h h1 (abs_nonneg _) (by norm_num)" % (shift("x", a), r, A, ap, shift("x", -a), shift("x", a)))
201
+ return informal, [Theorem("abs_square_bound", stmt, proof, "A bound on a difference of squares near a point.")]
202
+ pts = sorted(rng.randrange(1, 10) for _ in range(4)); a, b, c, e = pts
203
+ K = (e - a) + (c - b)
204
+ for x in range(-5, 20): assert K <= abs(x - a) + abs(x - b) + abs(x - c) + abs(x - e)
205
+ informal = ("Prove that for all real numbers \\(a \\le c\\) and \\(x\\), \\(c - a \\le |x - a| + |x - c|\\). "
206
+ "Then prove that for every real \\(x\\), \\[%d \\le |x - %d| + |x - %d| + |x - %d| + |x - %d|.\\]" % (K, a, b, c, e))
207
+ lemma = Theorem("pair_abs_bound", "(x a c : ℝ) (h : a ≤ c) :\n c - a ≤ |x - a| + |x - c|",
208
+ "by\n rcases abs_cases (x - a) with ⟨h1, _⟩ | ⟨h1, _⟩ <;> rcases abs_cases (x - c) with ⟨h2, _⟩ | ⟨h2, _⟩ <;> linarith",
209
+ "The sum of the distances to two points is at least their gap.")
210
+ main = Theorem("four_points_abs", "(x : ℝ) :\n %d ≤ |x - %d| + |x - %d| + |x - %d| + |x - %d|" % (K, a, b, c, e),
211
+ "by\n have h1 := pair_abs_bound x %d %d (by norm_num)\n have h2 := pair_abs_bound x %d %d (by norm_num)\n linarith" % (a, e, b, c),
212
+ "The sum of four distances is bounded below.", weight=2.0)
213
+ return informal, [lemma, main]
214
+
215
+
216
+ # ---------------------------------------------------------------- monotone
217
+ # name: (lean template, tex template, python function, proof of T(x) <= T(y) from h [and hx])
218
+ UNCOND = {
219
+ "exp": ("Real.exp %s", "e^{%s}", math.exp, "Real.exp_le_exp.2 h"),
220
+ "cube": ("%s ^ 3", "%s^3", lambda t: t ** 3, "(Odd.strictMono_pow (by decide : Odd 3)).monotone h"),
221
+ "quint": ("%s ^ 5", "%s^5", lambda t: t ** 5, "(Odd.strictMono_pow (by decide : Odd 5)).monotone h"),
222
+ "arctan": ("Real.arctan %s", "\\arctan %s", math.atan, "Real.arctan_strictMono.monotone h"),
223
+ "sinh": ("Real.sinh %s", "\\sinh %s", math.sinh, "Real.sinh_strictMono.monotone h"),
224
+ }
225
+ COND = { # need 0 < x
226
+ "sqrt": ("Real.sqrt %s", "\\sqrt{%s}", math.sqrt, "Real.sqrt_le_sqrt h"),
227
+ "log": ("Real.log %s", "\\ln %s", math.log, "Real.log_le_log hx h"),
228
+ "sq": ("%s ^ 2", "%s^2", lambda t: t * t, "pow_le_pow_left₀ hx.le h 2"),
229
+ }
230
+ LOG1SQ = ("Real.log (1 + %s ^ 2)", "\\ln(1 + %s^2)", lambda t: math.log(1 + t * t))
231
+
232
+
233
+ def mono_expr(terms, c0, var, tex=False):
234
+ """terms: list of (coef, template) ; c0 coefficient of the linear term (0 for none)."""
235
+ parts = []
236
+ for c, t in terms:
237
+ parts.append((c, t % var))
238
+ if c0: parts.append((c0, var))
239
+ out = ""
240
+ for i, (c, body) in enumerate(parts):
241
+ if tex: out += ("" if i == 0 else " + ") + (body if c == 1 else "%d\\,%s" % (c, body))
242
+ else: out += ("" if i == 0 else " + ") + (body if c == 1 else "%d * %s" % (c, body))
243
+ return out
244
+
245
+
246
+ def monotone(rng, difficulty):
247
+ names = sorted(UNCOND)
248
+ if difficulty == 1:
249
+ n1 = rng.choice(names); c1 = rng.randrange(1, 10); c0 = rng.randrange(0, 10)
250
+ tm = [(c1, UNCOND[n1][0])]; tt = [(c1, UNCOND[n1][1])]
251
+ f = lambda t: c1 * UNCOND[n1][2](t) + c0 * t
252
+ for x, y in [(-1.5, -1.0), (-0.3, 0.2), (0.5, 2.0), (1.0, 1.0)]: assert f(x) <= f(y) + 1e-12
253
+ informal = "Prove that for all real numbers \\(x \\le y\\), \\[%s \\le %s.\\]" % (mono_expr(tt, c0, "x", True), mono_expr(tt, c0, "y", True))
254
+ stmt = "(x y : ℝ) (h : x ≤ y) :\n %s ≤ %s" % (mono_expr(tm, c0, "x"), mono_expr(tm, c0, "y"))
255
+ have = " have h1 : %s ≤ %s := %s" % (UNCOND[n1][0] % "x", UNCOND[n1][0] % "y", UNCOND[n1][3])
256
+ return informal, [Theorem("monotone_sum", stmt, "by\n%s\n linarith" % have, "The function is non-decreasing.")]
257
+ if difficulty == 2:
258
+ k = rng.choice([2, 3]); chosen = rng.sample(names, k)
259
+ cs = [rng.randrange(1, 7) for _ in chosen]; c0 = rng.choice([0, 0, rng.randrange(1, 6)])
260
+ tm = [(c, UNCOND[n][0]) for c, n in zip(cs, chosen)]; tt = [(c, UNCOND[n][1]) for c, n in zip(cs, chosen)]
261
+ f = lambda t: sum(c * UNCOND[n][2](t) for c, n in zip(cs, chosen)) + c0 * t
262
+ for x, y in [(-1.5, -1.0), (-0.3, 0.2), (0.5, 2.0), (-2.0, 2.0)]: assert f(x) <= f(y) + 1e-12
263
+ informal = "Prove that the function \\(f(x) = %s\\) is monotone on the real numbers: \\(x \\le y\\) implies \\(f(x) \\le f(y)\\)." % mono_expr(tt, c0, "x", True)
264
+ stmt = ": Monotone (fun x : ℝ => %s)" % mono_expr(tm, c0, "x")
265
+ haves = "\n".join(" have h%d : %s ≤ %s := %s" % (i + 1, UNCOND[n][0] % "x", UNCOND[n][0] % "y", UNCOND[n][3]) for i, n in enumerate(chosen))
266
+ proof = "by\n intro x y h\n%s\n show %s ≤ %s\n linarith" % (haves, mono_expr(tm, c0, "x"), mono_expr(tm, c0, "y"))
267
+ return informal, [Theorem("monotone_function", stmt, proof, "The function is monotone.")]
268
+ cn = rng.sample(sorted(COND), rng.choice([1, 2])); un = rng.sample(names, rng.choice([1, 2]))
269
+ c_log = rng.randrange(1, 6)
270
+ items = [(rng.randrange(1, 6), "u", n) for n in un] + [(rng.randrange(1, 6), "c", n) for n in cn]
271
+ rng.shuffle(items)
272
+ items.append((c_log, "l", "log1sq"))
273
+ tm = []; tt = []
274
+ for c, kind, n in items:
275
+ tpl = LOG1SQ if kind == "l" else (UNCOND if kind == "u" else COND)[n]
276
+ tm.append((c, tpl[0])); tt.append((c, tpl[1]))
277
+ def pyf(t):
278
+ s = 0.0
279
+ for c, kind, n in items:
280
+ fn = LOG1SQ[2] if kind == "l" else (UNCOND if kind == "u" else COND)[n][2]
281
+ s += c * fn(t)
282
+ return s
283
+ for x, y in [(0.1, 0.5), (0.5, 0.5), (0.3, 4.0), (1.0, 9.0)]: assert pyf(x) <= pyf(y) + 1e-12
284
+ informal = ("Prove that \\(0 \\le \\ln(1 + y^2) - \\ln(1 + x^2)\\) for real numbers \\(0 < x \\le y\\). Then prove that for such \\(x, y\\), \\[0 \\le \\left(%s\\right) - \\left(%s\\right).\\]"
285
+ % (mono_expr(tt, 0, "y", True), mono_expr(tt, 0, "x", True)))
286
+ lemma = Theorem("log_one_add_sq_mono", "(x y : ℝ) (hx : 0 < x) (h : x ≤ y) :\n 0 ≤ Real.log (1 + y ^ 2) - Real.log (1 + x ^ 2)",
287
+ "by\n have hy : 0 < y := lt_of_lt_of_le hx h\n have h3 : Real.log (1 + x ^ 2) ≤ Real.log (1 + y ^ 2) := by\n apply Real.log_le_log (by positivity)\n nlinarith [mul_pos hx hy, mul_nonneg (sub_nonneg.2 h) hx.le]\n linarith",
288
+ "The logarithm of one plus a square is increasing on the positive reals.")
289
+ haves = []
290
+ for i, (c, kind, n) in enumerate(items):
291
+ if kind == "l":
292
+ haves.append(" have h%d := log_one_add_sq_mono x y hx h" % (i + 1)); continue
293
+ tpl, pr = (UNCOND if kind == "u" else COND)[n][0], (UNCOND if kind == "u" else COND)[n][3]
294
+ haves.append(" have h%d : %s ≤ %s := %s" % (i + 1, tpl % "x", tpl % "y", pr))
295
+ main = Theorem("monotone_combination", "(x y : ℝ) (hx : 0 < x) (h : x ≤ y) :\n 0 ≤ (%s) - (%s)" % (mono_expr(tm, 0, "y"), mono_expr(tm, 0, "x")),
296
+ "by\n%s\n linarith" % "\n".join(haves), "The combination is non-decreasing on the positive reals.", weight=2.0)
297
+ return informal, [lemma, main]
298
+
299
+
300
+ def generate(seed, difficulty, family=None):
301
+ family = family or sorted(FAMILIES)[seed % len(FAMILIES)]
302
+ rng = rng_for(ENV + "/" + family, seed, difficulty)
303
+ informal, theorems = {"amgm": amgm, "cauchy": cauchy, "abs_ineq": abs_ineq, "monotone": monotone}[family](rng, difficulty)
304
+ return Task(env=ENV, family=family, seed=seed, difficulty=difficulty, kind="prove",
305
+ title="Prove an inequality over the reals", informal=informal, theorems=theorems)
envs/linear_algebra/__init__.py ADDED
File without changes
envs/linear_algebra/env.toml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ name = "linear-algebra"
2
+ title = "Proofs about matrices and vector spaces"
3
+ msc = "15"
4
+ kind = "prove"
5
+ summary = "Prove facts about 2x2 matrices, matrix powers, linear independence of explicit vectors, and kernels, ranges and projections of linear maps."
6
+ skill = "Matrix computation and linear map API"
7
+ good_for = ["Matrix.det_fin_two and trace identities", "induction on matrix powers", "LinearMap.ker and range"]
8
+ families = ["det_trace", "independence", "linear_map", "matrix_pow"]
envs/linear_algebra/gen.py ADDED
@@ -0,0 +1,322 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Linear algebra (MSC 15: linear and multilinear algebra, matrix theory).
2
+
3
+ Families: det_trace (determinant, trace and Cayley-Hamilton for 2x2 integer matrices),
4
+ matrix_pow (closed forms for powers of 2x2 matrices by induction), independence (linear
5
+ independence or dependence of explicit vectors in Fin 2 -> Q and Fin 3 -> Q), linear_map
6
+ (kernel, range and idempotent maps on vector spaces).
7
+ Second code path: every numeric claim is re-checked in Python with exact integer or Fraction
8
+ arithmetic (matrix products, determinants, Gaussian elimination) before the task is returned;
9
+ the Lean reference proofs are compiled in the self-test.
10
+ """
11
+ from fractions import Fraction as F
12
+ from arena.core import Task, Theorem, rng_for
13
+
14
+ ENV = "linear_algebra"
15
+ FAMILIES = ["det_trace", "independence", "linear_map", "matrix_pow"]
16
+ M2 = "Matrix (Fin 2) (Fin 2) ℤ"
17
+
18
+ def mm(A, B): return [[sum(A[i][k] * B[k][j] for k in range(2)) for j in range(2)] for i in range(2)]
19
+ def det2(A): return A[0][0] * A[1][1] - A[0][1] * A[1][0]
20
+ def tr2(A): return A[0][0] + A[1][1]
21
+ def mat(A): return "!![%s]" % "; ".join(", ".join(str(x) for x in row) for row in A)
22
+ def tex(A): return "\\begin{pmatrix} %s \\end{pmatrix}" % " \\\\ ".join(" & ".join(str(x) for x in row) for row in A)
23
+ def rmat(rng, lo, hi): return [[rng.randrange(lo, hi + 1) for _ in range(2)] for _ in range(2)]
24
+ def zn(x): return "(%d : ℤ)" % x
25
+ def num(x): return "(%d : ℤ)" % x if x < 0 else str(x)
26
+
27
+ FIN2 = "rw [Matrix.one_fin_two, Matrix.mul_fin_two]\n ext i j\n fin_cases i <;> fin_cases j <;> simp <;> ring"
28
+
29
+ # ---------------------------------------------------------------- det_trace
30
+
31
+ CAYLEY = Theorem("cayley_hamilton_two", "(A : %s) :\n A ^ 2 = Matrix.trace A • A - Matrix.det A • (1 : %s)" % (M2, M2),
32
+ "by\n rw [Matrix.eta_fin_two A, Matrix.one_fin_two, pow_two, Matrix.mul_fin_two, Matrix.trace_fin_two, Matrix.det_fin_two]\n ext i j\n fin_cases i <;> fin_cases j <;> simp <;> ring",
33
+ "Cayley-Hamilton for 2x2 integer matrices.", 0.4)
34
+
35
+ def det_trace(rng, difficulty):
36
+ kind = rng.choice({1: ["detprod", "adjugate"], 2: ["charpoly", "cayley", "detprodx"], 3: ["cayley3", "trace_sq"]}[difficulty])
37
+ if kind in ("detprod", "detprod3"):
38
+ k = 2 if kind == "detprod" else 3
39
+ Ms = [rmat(rng, -3, 4) for _ in range(k)]
40
+ P = Ms[0]
41
+ for X in Ms[1:]: P = mm(P, X)
42
+ v = 1
43
+ for X in Ms: v *= det2(X)
44
+ assert det2(P) == v and all(det2(mm(X, Y)) == det2(X) * det2(Y) for X in Ms for Y in Ms)
45
+ if abs(v) < 2 and difficulty > 1: return det_trace(rng, difficulty)
46
+ prod = " * ".join(mat(X) for X in Ms)
47
+ rw = ", ".join(["Matrix.det_mul"] * (k - 1) + ["Matrix.det_fin_two_of"] * k)
48
+ informal = "Compute the determinant of the product %s of integer matrices. Show that it equals %d." % (" ".join("\\(%s\\)" % tex(X) for X in Ms), v)
49
+ return informal, [Theorem("det_of_product", ": Matrix.det (%s : %s) = %s" % (prod, M2, num(v)), "by\n rw [%s]\n norm_num" % rw, "The determinant of the product is the product of the determinants.")]
50
+ if kind == "detprodx":
51
+ p, q, r, s_ = [rng.randrange(-3, 4) for _ in range(4)]; u, v, w = [rng.randrange(-3, 4) for _ in range(3)]
52
+ A = lambda x: [[x + p, q], [r, x + s_]]; B = lambda x: [[x, u], [v, x + w]]
53
+ pa = [p * s_ - q * r, p + s_, 1]; pb = [-u * v, w, 1]
54
+ prod = [sum(pa[i] * pb[k - i] for i in range(3) if 0 <= k - i < 3) for k in range(5)]
55
+ for x in range(-4, 5):
56
+ assert det2(mm(A(x), B(x))) == sum(c * x ** i for i, c in enumerate(prod))
57
+ if prod[0] == 0 and prod[1] == 0: return det_trace(rng, difficulty)
58
+ def e(c): return "x + %d" % c if c >= 0 else "x - %d" % -c
59
+ La = "!![%s, %d; %d, %s]" % (e(p), q, r, e(s_)); Lb = "!![x, %d; %d, %s]" % (u, v, e(w))
60
+ poly = " + ".join("%d * x ^ %d" % (c, i) if i > 1 else ("%d * x" % c if i == 1 else "%d" % c) for i, c in reversed(list(enumerate(prod))) if c)
61
+ poly = poly.replace("+ -", "- ").replace("1 * x", "x") if False else poly
62
+ def poly_str(cs, times, pw):
63
+ out = ""
64
+ for i in range(len(cs) - 1, -1, -1):
65
+ c = cs[i]
66
+ if not c: continue
67
+ mag = abs(c); body = ("%d" % mag) if i == 0 else (("x" if i == 1 else pw % i) if mag == 1 else "%d%sx%s" % (mag, times, "" if i == 1 else pw % i if False else (pw % i)[1:]) if False else (("%d%s" % (mag, times) + ("x" if i == 1 else pw % i))))
68
+ out += (("-" if c < 0 else "") + body) if not out else (" - " if c < 0 else " + ") + body
69
+ return out
70
+ stmt = "(x : ℤ) :\n Matrix.det (%s * %s : %s) = %s" % (La, Lb, M2, poly_str(prod, " * ", "x ^ %d"))
71
+ informal = "For every integer \\(x\\), the determinant of \\[\\begin{pmatrix} x%+d & %d \\\\ %d & x%+d \\end{pmatrix}\\begin{pmatrix} x & %d \\\\ %d & x%+d \\end{pmatrix}\\] equals \\(%s\\)." % (
72
+ p, q, r, s_, u, v, w, poly_str(prod, "", "x^%d"))
73
+ return informal, [Theorem("det_of_polynomial_product", stmt, "by\n rw [Matrix.det_mul, Matrix.det_fin_two_of, Matrix.det_fin_two_of]\n ring", "The determinant of a product of matrices with a variable entry.")]
74
+ if kind == "adjugate":
75
+ p, q, r, s = [rng.randrange(-3, 5) for _ in range(4)]
76
+ A = lambda x: [[x + p, q], [r, x + s]]; Adj = lambda x: [[x + s, -q], [-r, x + p]]
77
+ for x in range(-4, 5):
78
+ P = mm(A(x), Adj(x)); d = x * x + (p + s) * x + (p * s - q * r)
79
+ assert P == [[d, 0], [0, d]]
80
+ def ent(top, a, b): return "x + %d" % top if top >= 0 else "x - %d" % -top
81
+ def e(c): return "x + %d" % c if c >= 0 else "x - %d" % -c
82
+ L = "!![%s, %d; %d, %s]" % (e(p), q, r, e(s)); R = "!![%s, %d; %d, %s]" % (e(s), -q, -r, e(p))
83
+ poly = "x ^ 2 + %d * x + %d" % (p + s, p * s - q * r)
84
+ stmt = "(x : ℤ) :\n %s * %s = (%s) • (1 : %s)" % (L, R, poly, M2)
85
+ proof = "by\n " + FIN2
86
+ informal = "For every integer \\(x\\), \\[\\begin{pmatrix} x%+d & %d \\\\ %d & x%+d \\end{pmatrix}\\begin{pmatrix} x%+d & %d \\\\ %d & x%+d \\end{pmatrix} = (x^2 %+d x %+d) \\begin{pmatrix} 1 & 0 \\\\ 0 & 1 \\end{pmatrix}.\\]" % (p, q, r, s, s, -q, -r, p, p + s, p * s - q * r)
87
+ return informal, [Theorem("adjugate_product", stmt, proof, "A matrix times its adjugate is its determinant times the identity.")]
88
+ if kind == "charpoly":
89
+ A = rmat(rng, -3, 4)
90
+ T, D = tr2(A), det2(A)
91
+ for x in range(-5, 6): assert det2([[x - A[0][0], -A[0][1]], [-A[1][0], x - A[1][1]]]) == x * x - T * x + D
92
+ poly = "x ^ 2 - %s * x + %s" % (num(T), num(D))
93
+ stmt = "(x : ℤ) :\n Matrix.det (x • (1 : %s) - %s) = %s" % (M2, mat(A), poly)
94
+ informal = "For every integer \\(x\\), the determinant of \\(x I - %s\\), where \\(I\\) is the \\(2 \\times 2\\) identity matrix, equals \\(x^2 - (%d)x + (%d)\\)." % ("\\(%s\\)" % tex(A) if False else tex(A), T, D)
95
+ informal = "For every integer \\(x\\), \\[\\det\\left(x I - %s\\right) = x^2 - (%d)\\,x + (%d),\\] where \\(I\\) is the \\(2 \\times 2\\) identity matrix." % (tex(A), T, D)
96
+ return informal, [Theorem("char_poly_value", stmt, "by\n rw [Matrix.one_fin_two, Matrix.det_fin_two]\n simp\n ring", "The characteristic polynomial of a 2x2 matrix is x^2 - tr x + det.")]
97
+ # Cayley-Hamilton based
98
+ t, d = rng.randrange(-3, 4), rng.randrange(-4, 5)
99
+ # second path: A^2 - tr A + det I = 0 on random integer matrices
100
+ for _ in range(20):
101
+ B = rmat(rng, -5, 5); B2 = mm(B, B)
102
+ for i in range(2):
103
+ for j in range(2): assert B2[i][j] - tr2(B) * B[i][j] + det2(B) * (1 if i == j else 0) == 0
104
+ B3 = mm(B2, B)
105
+ for i in range(2):
106
+ for j in range(2): assert B3[i][j] == (tr2(B) ** 2 - det2(B)) * B[i][j] - tr2(B) * det2(B) * (1 if i == j else 0)
107
+ assert tr2(B2) == tr2(B) ** 2 - 2 * det2(B)
108
+ hyps = "(ht : Matrix.trace A = %s) (hd : Matrix.det A = %s)" % (zn(t), zn(d))
109
+ words = "Let \\(A\\) be a \\(2 \\times 2\\) integer matrix with trace %d and determinant %d. " % (t, d)
110
+ if kind == "cayley":
111
+ stmt = "(A : %s) %s :\n A ^ 2 = %s • A - %s • (1 : %s)" % (M2, hyps, zn(t), zn(d), M2)
112
+ proof = ("by\n have key : A ^ 2 = Matrix.trace A • A - Matrix.det A • (1 : %s) := by\n rw [Matrix.eta_fin_two A, Matrix.one_fin_two, pow_two, Matrix.mul_fin_two, Matrix.trace_fin_two, Matrix.det_fin_two]\n"
113
+ " ext i j\n fin_cases i <;> fin_cases j <;> simp <;> ring\n rw [key, ht, hd]") % M2
114
+ return words + "Then \\(A^2 = %d A - %d I\\), where \\(I\\) is the identity matrix." % (t, d), [Theorem("square_of_matrix", stmt, proof, "A^2 = tr(A) A - det(A) I with the given trace and determinant.")]
115
+ if kind == "cayley3":
116
+ stmt = "(A : %s) %s :\n A ^ 3 = %s • A - %s • (1 : %s)" % (M2, hyps, zn(t * t - d), zn(t * d), M2)
117
+ proof = ("by\n have h2 := cayley_hamilton_two A\n rw [ht, hd] at h2\n calc A ^ 3 = A * A ^ 2 := by rw [pow_succ']\n _ = A * (%s • A - %s • (1 : %s)) := by rw [h2]\n"
118
+ " _ = %s • (A * A) - %s • A := by simp only [mul_sub, mul_smul_comm, mul_one]\n _ = %s • (%s • A - %s • (1 : %s)) - %s • A := by rw [← pow_two, h2]\n"
119
+ " _ = %s • A - %s • (1 : %s) := by module") % (zn(t), zn(d), M2, zn(t), zn(d), zn(t), zn(t), zn(d), M2, zn(d), zn(t * t - d), zn(t * d), M2)
120
+ main = Theorem("cube_of_matrix", stmt, proof, "A^3 in terms of the trace and determinant.", 0.6)
121
+ return words + "Then \\(A^3 = %d A - %d I\\), where \\(I\\) is the identity matrix. You may first prove \\(A^2 = (\\operatorname{tr} A) A - (\\det A) I\\) for every \\(2 \\times 2\\) integer matrix." % (t * t - d, t * d), [CAYLEY, main]
122
+ stmt = "(A : %s) %s :\n Matrix.trace (A ^ 2) = %s" % (M2, hyps, num(t * t - 2 * d))
123
+ proof = "by\n rw [cayley_hamilton_two A, Matrix.trace_sub, Matrix.trace_smul, Matrix.trace_smul, Matrix.trace_one, ht, hd]\n norm_num"
124
+ main = Theorem("trace_of_square", stmt, proof, "The trace of A^2 from the trace and determinant of A.", 0.6)
125
+ return words + "Then the trace of \\(A^2\\) is %d. You may first prove \\(A^2 = (\\operatorname{tr} A) A - (\\det A) I\\) for every \\(2 \\times 2\\) integer matrix." % (t * t - 2 * d), [CAYLEY, main]
126
+
127
+ # ---------------------------------------------------------------- matrix_pow
128
+
129
+ def matrix_pow(rng, difficulty):
130
+ kind = rng.choice({1: ["shear", "shear", "lower"], 2: ["diag", "jordan", "shear2"], 3: ["affine", "shearprod", "affine"]}[difficulty])
131
+ ind = "by\n induction n with\n | zero =>\n ext i j\n fin_cases i <;> fin_cases j <;> simp\n | succ j ih =>\n rw [pow_succ, ih, Matrix.mul_fin_two]\n ext i j\n fin_cases i <;> fin_cases j <;> simp <;> ring"
132
+ def check(A, form, extra=lambda n: n):
133
+ P = [[1, 0], [0, 1]]
134
+ for n in range(7):
135
+ assert P == form(n), (A, n, P, form(n))
136
+ P = mm(P, A)
137
+ if kind == "shear":
138
+ k = rng.choice([1, 2, 3, 4, 5, 7, -1, -2, -3])
139
+ check([[1, k], [0, 1]], lambda n: [[1, n * k], [0, 1]])
140
+ stmt = "(n : ℕ) :\n (!![1, %s; 0, 1] : %s) ^ n = !![1, (n : ℤ) * %s; 0, 1]" % (k, M2, num(k))
141
+ informal = "For every natural number \\(n\\), \\[\\begin{pmatrix} 1 & %d \\\\ 0 & 1 \\end{pmatrix}^n = \\begin{pmatrix} 1 & %dn \\\\ 0 & 1 \\end{pmatrix}.\\]" % (k, k)
142
+ return informal, [Theorem("shear_power", stmt, ind, "Powers of a shear matrix.")]
143
+ if kind == "lower":
144
+ k = rng.choice([1, 2, 3, 4, 5, 6, -1, -2, -4])
145
+ check([[1, 0], [k, 1]], lambda n: [[1, 0], [n * k, 1]])
146
+ stmt = "(n : ℕ) :\n (!![1, 0; %s, 1] : %s) ^ n = !![1, 0; (n : ℤ) * %s, 1]" % (k, M2, num(k))
147
+ informal = "For every natural number \\(n\\), \\[\\begin{pmatrix} 1 & 0 \\\\ %d & 1 \\end{pmatrix}^n = \\begin{pmatrix} 1 & 0 \\\\ %dn & 1 \\end{pmatrix}.\\]" % (k, k)
148
+ return informal, [Theorem("lower_shear_power", stmt, ind, "Powers of a lower shear matrix.")]
149
+ if kind == "diag":
150
+ p, q = rng.sample([2, 3, 4, 5, -2, -3, 6, 7], 2)
151
+ check([[p, 0], [0, q]], lambda n: [[p ** n, 0], [0, q ** n]])
152
+ stmt = "(n : ℕ) :\n (!![%s, 0; 0, %s] : %s) ^ n = !![%s ^ n, 0; 0, %s ^ n]" % (num(p), num(q), M2, num(p), num(q))
153
+ informal = "For every natural number \\(n\\), \\[\\begin{pmatrix} %d & 0 \\\\ 0 & %d \\end{pmatrix}^n = \\begin{pmatrix} (%d)^n & 0 \\\\ 0 & (%d)^n \\end{pmatrix}.\\]" % (p, q, p, q)
154
+ return informal, [Theorem("diagonal_power", stmt, ind, "Powers of a diagonal matrix.")]
155
+ if kind == "jordan":
156
+ p = rng.choice([2, 3, 4, 5, -2, -3, 6])
157
+ check([[p, 1], [0, p]], lambda n: [[p ** n, n * p ** (n - 1) if n else 0], [0, p ** n]])
158
+ stmt = "(n : ℕ) :\n (!![%s, 1; 0, %s] : %s) ^ (n + 1) = !![%s ^ (n + 1), ((n : ℤ) + 1) * %s ^ n; 0, %s ^ (n + 1)]" % (num(p), num(p), M2, num(p), num(p), num(p))
159
+ proof = "by\n induction n with\n | zero =>\n ext i j\n fin_cases i <;> fin_cases j <;> simp\n | succ j ih =>\n rw [pow_succ, ih, Matrix.mul_fin_two]\n ext i j\n fin_cases i <;> fin_cases j <;> simp [pow_succ] <;> ring"
160
+ informal = "For every natural number \\(n\\), \\[\\begin{pmatrix} %d & 1 \\\\ 0 & %d \\end{pmatrix}^{n+1} = \\begin{pmatrix} (%d)^{n+1} & (n+1)(%d)^n \\\\ 0 & (%d)^{n+1} \\end{pmatrix}.\\]" % (p, p, p, p, p)
161
+ return informal, [Theorem("jordan_power", stmt, proof, "Powers of a 2x2 Jordan block.")]
162
+ if kind == "shear2":
163
+ k, l = rng.sample([1, 2, 3, 4, 5, -1, -2], 2)
164
+ check([[1, k], [l * 0, 1]], lambda n: [[1, n * k], [0, 1]])
165
+ a = rng.choice([2, 3, 4, 5]); b = rng.choice([1, 2, 3, 4, 5, 6])
166
+ # (diag(1,1) shear)^n times a scalar: (a * S)^n = a^n * S^n
167
+ stmt = "(n : ℕ) :\n (!![%d, %d; 0, %d] : %s) ^ n = !![(%d : ℤ) ^ n, (n : ℤ) * %d * %d ^ (n - 1); 0, (%d : ℤ) ^ n]" % (a, a * k, a, M2, a, a * k, a, a) if False else None
168
+ # an exact variant: lower triangular with equal diagonal: !![a, 0; 1, a]^(n+1)
169
+ check([[a, 0], [1, a]], lambda n: [[a ** n, 0], [n * a ** (n - 1) if n else 0, a ** n]])
170
+ stmt = "(n : ℕ) :\n (!![%d, 0; 1, %d] : %s) ^ (n + 1) = !![(%d : ℤ) ^ (n + 1), 0; ((n : ℤ) + 1) * %d ^ n, (%d : ℤ) ^ (n + 1)]" % (a, a, M2, a, a, a)
171
+ proof = "by\n induction n with\n | zero =>\n ext i j\n fin_cases i <;> fin_cases j <;> simp\n | succ j ih =>\n rw [pow_succ, ih, Matrix.mul_fin_two]\n ext i j\n fin_cases i <;> fin_cases j <;> simp [pow_succ] <;> ring"
172
+ informal = "For every natural number \\(n\\), \\[\\begin{pmatrix} %d & 0 \\\\ 1 & %d \\end{pmatrix}^{n+1} = \\begin{pmatrix} %d^{n+1} & 0 \\\\ (n+1)\\,%d^{n} & %d^{n+1} \\end{pmatrix}.\\]" % (a, a, a, a, a)
173
+ return informal, [Theorem("lower_jordan_power", stmt, proof, "Powers of a lower 2x2 Jordan block.")]
174
+ if kind == "affine":
175
+ a = rng.choice([2, 3, 4, 5, -2, -3]); b = rng.choice([1, 2, 3, 4, 5, 6, -1, -2])
176
+ check([[a, b], [0, 1]], lambda n: [[a ** n, b * sum(a ** i for i in range(n))], [0, 1]])
177
+ stmt = "(n : ℕ) :\n (!![%s, %s; 0, 1] : %s) ^ n = !![%s ^ n, %s * ∑ i ∈ Finset.range n, %s ^ i; 0, 1]" % (num(a), num(b), M2, num(a), num(b), num(a))
178
+ proof = "by\n induction n with\n | zero =>\n ext i j\n fin_cases i <;> fin_cases j <;> simp\n | succ j ih =>\n rw [pow_succ, ih, Matrix.mul_fin_two]\n ext i j\n fin_cases i <;> fin_cases j <;> simp [Finset.sum_range_succ, pow_succ] <;> ring"
179
+ informal = "For every natural number \\(n\\), \\[\\begin{pmatrix} %d & %d \\\\ 0 & 1 \\end{pmatrix}^n = \\begin{pmatrix} (%d)^n & %d \\sum_{i=0}^{n-1} (%d)^i \\\\ 0 & 1 \\end{pmatrix}.\\] The sum is empty when \\(n = 0\\)." % (a, b, a, b, a)
180
+ return informal, [Theorem("affine_power", stmt, proof, "Powers of an affine map matrix, with a geometric sum.")]
181
+ k, l = rng.sample([1, 2, 3, 4, 5, 6, -1, -2, -3], 2)
182
+ for n in range(5):
183
+ for m in range(5): assert mm([[1, n * k], [0, 1]], [[1, m * l], [0, 1]]) == [[1, n * k + m * l], [0, 1]]
184
+ lem = Theorem("shear_power", "(k : ℤ) (n : ℕ) :\n (!![1, k; 0, 1] : %s) ^ n = !![1, (n : ℤ) * k; 0, 1]" % M2, ind, "Powers of a shear matrix.", 0.4)
185
+ main = Theorem("shear_product", "(n m : ℕ) :\n (!![1, %s; 0, 1] : %s) ^ n * (!![1, %s; 0, 1] : %s) ^ m = !![1, (n : ℤ) * %s + (m : ℤ) * %s; 0, 1]" % (num(k), M2, num(l), M2, num(k), num(l)),
186
+ "by\n rw [shear_power, shear_power, Matrix.mul_fin_two]\n ext i j\n fin_cases i <;> fin_cases j <;> simp <;> ring", "A product of powers of two shears.", 0.6)
187
+ informal = ("For every integer \\(k\\) and natural number \\(n\\), \\[\\begin{pmatrix} 1 & k \\\\ 0 & 1 \\end{pmatrix}^n = \\begin{pmatrix} 1 & nk \\\\ 0 & 1 \\end{pmatrix}.\\] "
188
+ "Deduce that for all natural numbers \\(n, m\\), \\[\\begin{pmatrix} 1 & %d \\\\ 0 & 1 \\end{pmatrix}^n \\begin{pmatrix} 1 & %d \\\\ 0 & 1 \\end{pmatrix}^m = \\begin{pmatrix} 1 & %dn + %dm \\\\ 0 & 1 \\end{pmatrix}.\\]" % (k, l, k, l))
189
+ return informal, [lem, main]
190
+
191
+ # ---------------------------------------------------------------- independence
192
+
193
+ def det3(M):
194
+ return (M[0][0] * (M[1][1] * M[2][2] - M[1][2] * M[2][1]) - M[0][1] * (M[1][0] * M[2][2] - M[1][2] * M[2][0]) + M[0][2] * (M[1][0] * M[2][1] - M[1][1] * M[2][0]))
195
+
196
+ def rank_frac(rows):
197
+ A = [[F(x) for x in r] for r in rows]; rank = 0
198
+ for c in range(len(A[0])):
199
+ piv = next((r for r in range(rank, len(A)) if A[r][c] != 0), None)
200
+ if piv is None: continue
201
+ A[rank], A[piv] = A[piv], A[rank]
202
+ for r in range(len(A)):
203
+ if r != rank and A[r][c] != 0:
204
+ f = A[r][c] / A[rank][c]; A[r] = [x - f * y for x, y in zip(A[r], A[rank])]
205
+ rank += 1
206
+ return rank
207
+
208
+ def vec(v, n): return "(![%s] : Fin %d → ℚ)" % (", ".join(str(x) for x in v), n)
209
+ def vecs(vs, n): return "![%s, %s]" % (vec(vs[0], n), ", ".join("![%s]" % ", ".join(str(x) for x in v) for v in vs[1:]))
210
+ def tv(v): return "\\begin{pmatrix} %s \\end{pmatrix}" % " \\\\ ".join(str(x) for x in v)
211
+
212
+ def independence(rng, difficulty):
213
+ n = 2 if difficulty < 3 else 3
214
+ dependent = rng.random() < (0.35 if difficulty == 1 else 0.5)
215
+ r = 4 if difficulty == 1 else 6
216
+ while True:
217
+ vs = [[rng.randrange(-r, r + 1) for _ in range(n)] for _ in range(n)]
218
+ if any(all(x == 0 for x in v) for v in vs): continue
219
+ if dependent:
220
+ coef = [rng.choice([-3, -2, -1, 1, 2, 3]) for _ in range(n - 1)]
221
+ vs[-1] = [sum(c * vs[i][j] for i, c in enumerate(coef)) for j in range(n)]
222
+ if all(x == 0 for x in vs[-1]) or rank_frac(vs) != n - 1: continue
223
+ break
224
+ if rank_frac(vs) == n and (det3(vs) if n == 3 else det2(vs)) != 0: break
225
+ assert (rank_frac(vs) == n) == (not dependent)
226
+ S = vecs(vs, n)
227
+ names = "two" if n == 2 else "three"
228
+ informal = "In \\(\\mathbb{Q}^%d\\) consider the vectors %s. " % (n, ", ".join("\\(%s\\)" % tv(v) for v in vs))
229
+ if not dependent:
230
+ informal += "Show that they are linearly independent over \\(\\mathbb{Q}\\)."
231
+ if n == 2:
232
+ proof = ("by\n rw [LinearIndependent.pair_iff]\n intro s t h\n have h0 := congr_fun h 0\n have h1 := congr_fun h 1\n simp at h0 h1\n constructor <;> linarith")
233
+ else:
234
+ proof = ("by\n rw [Fintype.linearIndependent_iff]\n intro g hg\n have h0 := congr_fun hg 0\n have h1 := congr_fun hg 1\n have h2 := congr_fun hg 2\n"
235
+ " simp [Fin.sum_univ_three] at h0 h1 h2\n intro i\n fin_cases i <;> simp <;> linarith")
236
+ return informal, [Theorem("vectors_independent", ": LinearIndependent ℚ %s" % S, proof, "The given vectors are linearly independent over the rationals.")]
237
+ informal += "Show that they are not linearly independent over \\(\\mathbb{Q}\\)."
238
+ coefs = coef + [-1]
239
+ gl = "![%s]" % ", ".join("(%d : ℚ)" % c for c in coefs)
240
+ sumfn = "Fin.sum_univ_two" if n == 2 else "Fin.sum_univ_three"
241
+ proof = ("by\n rw [Fintype.not_linearIndependent_iff]\n refine ⟨%s, ?_, %d, by simp⟩\n ext i\n fin_cases i <;> simp [%s] <;> norm_num") % (gl, n - 1, sumfn)
242
+ return informal, [Theorem("vectors_dependent", ": ¬ LinearIndependent ℚ %s" % S, proof, "The given vectors are linearly dependent over the rationals.")]
243
+
244
+ # ---------------------------------------------------------------- linear_map
245
+
246
+ HP = {
247
+ "pt": ("(hp : ∀ x, {p} ({p} x) = {p} x)", "{p}({p}(x)) = {p}(x) for every vector x", "have hp' : ∀ x, {p} ({p} x) = {p} x := hp"),
248
+ "comp": ("(hp : {p} ∘ₗ {p} = {p})", "{p} \\circ {p} = {p}", "have hp' : ∀ x, {p} ({p} x) = {p} x := fun x => LinearMap.congr_fun hp x"),
249
+ "mul": ("(hp : {p} * {p} = {p})", "{p}^2 = {p}", "have hp' : ∀ x, {p} ({p} x) = {p} x := fun x => LinearMap.congr_fun hp x"),
250
+ }
251
+
252
+ def linear_map(rng, difficulty):
253
+ Fd, Ftex = rng.choice([("ℚ", "\\mathbb{Q}"), ("ℝ", "\\mathbb{R}")])
254
+ V, W = "V", "W"; p = rng.choice(["p", "e", "q"]); x, y = rng.choice([("x", "y"), ("u", "v"), ("a", "b")])
255
+ kind = rng.choice({1: ["kercomb", "projsub", "kercomb"], 2: ["kersmul", "rangecomp", "kercomp", "kerid"], 3: ["iscompl", "iscompl", "kerid", "idem"]}[difficulty])
256
+ sp = "{%s %s : Type*} [AddCommGroup %s] [Module %s %s] [AddCommGroup %s] [Module %s %s]" % (V, W, V, Fd, V, W, Fd, W)
257
+ sv = "{%s : Type*} [AddCommGroup %s] [Module %s %s]" % (V, V, Fd, V)
258
+ hpl, hpt, hpf = HP[rng.choice((["comp", "mul"] if kind == "idem" else ["pt", "comp", "mul"]) if difficulty > 1 else ["pt"])]
259
+ if difficulty == 3 and kind in ("kerid", "idem"):
260
+ pass
261
+ key = None
262
+ for k in HP:
263
+ if HP[k][0] == hpl: key = k
264
+ hpl, hpt, hpf = (s.replace("{p}", p) for s in (hpl, hpt, hpf))
265
+ if kind == "kercomb":
266
+ a, b = rng.sample([2, 3, 4, 5, -1, -2, -3, 7], 2)
267
+ stmt = "%s (f : %s →ₗ[%s] %s) {%s %s : %s}\n (hx : f %s = 0) (hy : f %s = 0) : f ((%d : %s) • %s + (%d : %s) • %s) = 0" % (sp, V, Fd, W, x, y, V, x, y, a, Fd, x, b, Fd, y)
268
+ informal = "Let \\(f : V \\to W\\) be a linear map of vector spaces over \\(%s\\) and \\(%s, %s \\in V\\) with \\(f(%s) = 0\\) and \\(f(%s) = 0\\). Then \\(f(%d%s + %d%s) = 0\\)." % (Ftex, x, y, x, y, a, x, b, y)
269
+ return informal, [Theorem("kernel_combination", stmt, "by\n rw [map_add, map_smul, map_smul, hx, hy]\n simp", "The kernel is closed under linear combinations.")]
270
+ if kind == "projsub":
271
+ stmt = "%s (%s : %s →ₗ[%s] %s) (hp : ∀ x, %s (%s x) = %s x) (%s : %s) :\n %s - %s %s ∈ LinearMap.ker %s" % (sv, p, V, Fd, V, p, p, p, x, V, x, p, x, p)
272
+ informal = "Let \\(%s : V \\to V\\) be a linear map over \\(%s\\) with \\(%s(%s(v)) = %s(v)\\) for every \\(v\\). Then \\(%s - %s(%s)\\) lies in the kernel of \\(%s\\) for every \\(%s \\in V\\)." % (p, Ftex, p, "v", "v", x, p, x, p, x)
273
+ return informal, [Theorem("sub_proj_mem_ker", stmt, "by\n rw [LinearMap.mem_ker, map_sub, hp, sub_self]", "x - p x lies in the kernel of an idempotent map p.")]
274
+ if kind == "kersmul":
275
+ c = rng.choice([2, 3, 4, 5, 7, -1, -2, -3])
276
+ stmt = "%s (f : %s →ₗ[%s] %s) :\n LinearMap.ker ((%d : %s) • f) = LinearMap.ker f" % (sp, V, Fd, W, c, Fd)
277
+ informal = "Let \\(f : V \\to W\\) be a linear map of vector spaces over \\(%s\\). Then the kernel of \\(%df\\) equals the kernel of \\(f\\)." % (Ftex, c)
278
+ proof = "by\n ext %s\n simp only [LinearMap.mem_ker, LinearMap.smul_apply, smul_eq_zero]\n constructor\n · rintro (h | h)\n · norm_num at h\n · exact h\n · intro h\n exact Or.inr h" % x
279
+ return informal, [Theorem("ker_smul_eq", stmt, proof, "A nonzero scalar multiple has the same kernel.")]
280
+ if kind in ("rangecomp", "kercomp"):
281
+ U = "U"
282
+ pre = "{%s %s %s : Type*} [AddCommGroup %s] [Module %s %s] [AddCommGroup %s] [Module %s %s] [AddCommGroup %s] [Module %s %s]" % (V, W, U, V, Fd, V, W, Fd, W, U, Fd, U)
283
+ if kind == "rangecomp":
284
+ stmt = "%s (f : %s →ₗ[%s] %s) (g : %s →ₗ[%s] %s) :\n LinearMap.range (g ∘ₗ f) ≤ LinearMap.range g" % (pre, V, Fd, W, W, Fd, U)
285
+ informal = "Let \\(f : V \\to W\\) and \\(g : W \\to U\\) be linear maps over \\(%s\\). Then the range of \\(g \\circ f\\) is contained in the range of \\(g\\)." % Ftex
286
+ proof = "by\n rintro z ⟨%s, rfl⟩\n exact ⟨f %s, rfl⟩" % (x, x)
287
+ return informal, [Theorem("range_comp_le", stmt, proof, "range (g ∘ f) ≤ range g.")]
288
+ stmt = "%s (f : %s →ₗ[%s] %s) (g : %s →ₗ[%s] %s) :\n LinearMap.ker f ≤ LinearMap.ker (g ∘ₗ f)" % (pre, V, Fd, W, W, Fd, U)
289
+ informal = "Let \\(f : V \\to W\\) and \\(g : W \\to U\\) be linear maps over \\(%s\\). Then the kernel of \\(f\\) is contained in the kernel of \\(g \\circ f\\)." % Ftex
290
+ proof = "by\n intro %s hx\n rw [LinearMap.mem_ker] at hx ⊢\n rw [LinearMap.comp_apply, hx, map_zero]" % x
291
+ return informal, [Theorem("ker_le_comp", stmt, proof, "ker f ≤ ker (g ∘ f).")]
292
+ if kind == "idem":
293
+ stmt = "%s (%s : %s →ₗ[%s] %s) %s :\n (LinearMap.id - %s) ∘ₗ (LinearMap.id - %s) = LinearMap.id - %s ∧ %s ∘ₗ (LinearMap.id - %s) = 0" % (sv, p, V, Fd, V, hpl, p, p, p, p, p)
294
+ informal = "Let \\(%s : V \\to V\\) be a linear map over \\(%s\\) with \\(%s\\). Then \\(\\mathrm{id} - %s\\) is also idempotent, and \\(%s \\circ (\\mathrm{id} - %s) = 0\\)." % (p, Ftex, hpt, p, p, p)
295
+ proof = "by\n %s\n refine ⟨?_, ?_⟩ <;> ext %s <;> simp [hp']" % (hpf, x)
296
+ return informal, [Theorem("complement_idempotent", stmt, proof, "If p is idempotent then so is id - p, and p kills its image.")]
297
+ if kind == "kerid":
298
+ stmt = "%s (%s : %s →ₗ[%s] %s) %s :\n LinearMap.ker (LinearMap.id - %s) = LinearMap.range %s" % (sv, p, V, Fd, V, hpl, p, p)
299
+ informal = "Let \\(%s : V \\to V\\) be a linear map over \\(%s\\) with \\(%s\\). Then the kernel of \\(\\mathrm{id} - %s\\) equals the range of \\(%s\\)." % (p, Ftex, hpt, p, p)
300
+ proof = ("by\n %s\n ext %s\n constructor\n · intro h\n rw [LinearMap.mem_ker, LinearMap.sub_apply, LinearMap.id_apply, sub_eq_zero] at h\n exact ⟨%s, h.symm⟩\n"
301
+ " · rintro ⟨%s, rfl⟩\n rw [LinearMap.mem_ker, LinearMap.sub_apply, LinearMap.id_apply, hp', sub_self]") % (hpf, x, x, y)
302
+ return informal, [Theorem("ker_id_sub", stmt, proof, "For idempotent p, the kernel of id - p is the range of p.")]
303
+ # iscompl
304
+ stmt0 = "%s (%s : %s →ₗ[%s] %s) %s" % (sv, p, V, Fd, V, hpl)
305
+ lem = Theorem("disjoint_ker_range", stmt0 + " :\n Disjoint (LinearMap.ker %s) (LinearMap.range %s)" % (p, p),
306
+ "by\n %s\n rw [Submodule.disjoint_def]\n rintro %s h1 ⟨%s, rfl⟩\n rw [LinearMap.mem_ker, hp'] at h1\n rw [h1]" % (hpf, x, y), "The kernel and the range of an idempotent map meet only in 0.", 0.4)
307
+ main = Theorem("ker_range_isCompl", stmt0 + " :\n IsCompl (LinearMap.ker %s) (LinearMap.range %s)" % (p, p),
308
+ ("by\n %s\n refine ⟨disjoint_ker_range %s hp, ?_⟩\n rw [codisjoint_iff, eq_top_iff]\n intro %s _\n rw [Submodule.mem_sup]\n"
309
+ " exact ⟨%s - %s %s, by rw [LinearMap.mem_ker, map_sub, hp', sub_self], %s %s, LinearMap.mem_range_self %s %s, by abel⟩") % (hpf, p, x, x, p, x, p, x, p, x),
310
+ "The kernel and the range of an idempotent map are complements.", 0.6)
311
+ informal = "Let \\(%s : V \\to V\\) be a linear map over \\(%s\\) with \\(%s\\). Show that \\(\\ker %s\\) and \\(\\operatorname{range} %s\\) are complementary subspaces: their intersection is \\(\\{0\\}\\) and together they span \\(V\\)." % (p, Ftex, hpt, p, p)
312
+ return informal, [lem, main]
313
+
314
+ FAM = {"det_trace": det_trace, "matrix_pow": matrix_pow, "independence": independence, "linear_map": linear_map}
315
+ TITLES = {"det_trace": "Determinant and trace of 2x2 matrices", "matrix_pow": "Powers of 2x2 matrices", "independence": "Linear independence of explicit vectors", "linear_map": "Kernels, ranges and projections"}
316
+
317
+ def generate(seed, difficulty, family=None):
318
+ family = family or sorted(FAMILIES)[seed % len(FAMILIES)]
319
+ rng = rng_for(ENV + "/" + family, seed, difficulty)
320
+ informal, theorems = FAM[family](rng, difficulty)
321
+ return Task(env=ENV, family=family, seed=seed, difficulty=difficulty, kind="prove",
322
+ title=TITLES[family], informal="Prove the following statement.\n\n" + informal, theorems=theorems)
envs/logic_and_sets/__init__.py ADDED
File without changes
envs/logic_and_sets/env.toml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ name = "logic-and-sets"
2
+ title = "Logic and set algebra"
3
+ msc = "03"
4
+ kind = "prove"
5
+ summary = "Prove set identities and image statements, Finset cardinality facts and equivalence relations."
6
+ skill = "Set algebra, cardinality, relations"
7
+ good_for = ["ext and tauto", "Finset.card lemmas", "equivalence relations"]
8
+ families = ["finset_card", "relations", "set_identities"]
envs/logic_and_sets/gen.py ADDED
@@ -0,0 +1,355 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Logic and set algebra (MSC 03: mathematical logic and foundations; 03B, 03E).
2
+
3
+ Families: predicate-logic equivalences; set identities over `Set α` proved by extensionality (algebra at
4
+ difficulties 1 and 3, images and preimages at 2 and sometimes 3);
5
+ cardinality facts on `Finset ℕ`; equivalence relations on integers and pairs.
6
+ Second code path: every set identity is checked on a truth table (membership of one element in
7
+ each variable set) in Python before it is returned, including the rows allowed by a hypothesis.
8
+ """
9
+ import itertools
10
+ from arena.core import Task, Theorem, rng_for
11
+
12
+ ENV = "logic_and_sets"
13
+ # `quantifiers` is retired: aesop closes every task in it, so it teaches nothing. The generator stays for tests.
14
+ FAMILIES = ["finset_card", "relations", "set_identities"]
15
+
16
+ # ---------------------------------------------------------------- quantifiers
17
+ # Each item: (needs_nonempty, uses_prop, statement body, tex, proof). Placeholders: %(P)s %(Q)s %(R)s %(c)s.
18
+ Q1 = [
19
+ (False, False, "(¬ ∀ x, %(P)s x) ↔ ∃ x, ¬ %(P)s x", "\\neg \\forall x\\, %(P)s(x) \\iff \\exists x\\, \\neg %(P)s(x)",
20
+ "by\n constructor\n · intro h\n by_contra h'\n apply h\n intro x\n by_contra hx\n exact h' ⟨x, hx⟩\n · rintro ⟨x, hx⟩ h\n exact hx (h x)"),
21
+ (False, False, "(¬ ∃ x, %(P)s x) ↔ ∀ x, ¬ %(P)s x", "\\neg \\exists x\\, %(P)s(x) \\iff \\forall x\\, \\neg %(P)s(x)",
22
+ "by\n constructor\n · intro h x hx\n exact h ⟨x, hx⟩\n · rintro h ⟨x, hx⟩\n exact h x hx"),
23
+ (False, False, "(∀ x, %(P)s x ∧ %(Q)s x) ↔ (∀ x, %(P)s x) ∧ ∀ x, %(Q)s x", "\\forall x\\, (%(P)s(x) \\wedge %(Q)s(x)) \\iff (\\forall x\\, %(P)s(x)) \\wedge (\\forall x\\, %(Q)s(x))",
24
+ "⟨fun h => ⟨fun x => (h x).1, fun x => (h x).2⟩, fun h x => ⟨h.1 x, h.2 x⟩⟩"),
25
+ (False, False, "(∃ x, %(P)s x ∨ %(Q)s x) ↔ (∃ x, %(P)s x) ∨ ∃ x, %(Q)s x", "\\exists x\\, (%(P)s(x) \\vee %(Q)s(x)) \\iff (\\exists x\\, %(P)s(x)) \\vee (\\exists x\\, %(Q)s(x))",
26
+ "by\n constructor\n · rintro ⟨x, hx | hx⟩\n · exact Or.inl ⟨x, hx⟩\n · exact Or.inr ⟨x, hx⟩\n · rintro (⟨x, hx⟩ | ⟨x, hx⟩)\n · exact ⟨x, Or.inl hx⟩\n · exact ⟨x, Or.inr hx⟩"),
27
+ ]
28
+ Q2 = [
29
+ (True, True, "(∃ x, %(P)s x → %(c)s) ↔ ((∀ x, %(P)s x) → %(c)s)", "\\exists x\\, (%(P)s(x) \\to %(c)s) \\iff ((\\forall x\\, %(P)s(x)) \\to %(c)s)",
30
+ "by\n constructor\n · rintro ⟨x, hx⟩ h\n exact hx (h x)\n · intro h\n by_cases hall : ∀ x, %(P)s x\n · exact ⟨Classical.arbitrary _, fun _ => h hall⟩\n · push_neg at hall\n obtain ⟨x, hx⟩ := hall\n exact ⟨x, fun hp => absurd hp hx⟩"),
31
+ (False, False, "(¬ ∀ x, %(P)s x → %(Q)s x) ↔ ∃ x, %(P)s x ∧ ¬ %(Q)s x", "\\neg \\forall x\\, (%(P)s(x) \\to %(Q)s(x)) \\iff \\exists x\\, (%(P)s(x) \\wedge \\neg %(Q)s(x))",
32
+ "by\n constructor\n · intro h\n by_contra h'\n apply h\n intro x hp\n by_contra hq\n exact h' ⟨x, hp, hq⟩\n · rintro ⟨x, hp, hq⟩ h\n exact hq (h x hp)"),
33
+ (False, True, "(∀ x, %(P)s x ∨ %(c)s) ↔ (∀ x, %(P)s x) ∨ %(c)s", "\\forall x\\, (%(P)s(x) \\vee %(c)s) \\iff (\\forall x\\, %(P)s(x)) \\vee %(c)s",
34
+ "by\n constructor\n · intro h\n by_cases hc : %(c)s\n · exact Or.inr hc\n · exact Or.inl fun x => (h x).resolve_right hc\n · rintro (h | h) x\n · exact Or.inl (h x)\n · exact Or.inr h"),
35
+ (False, True, "(∀ x, %(P)s x → %(c)s) ↔ ((∃ x, %(P)s x) → %(c)s)", "\\forall x\\, (%(P)s(x) \\to %(c)s) \\iff ((\\exists x\\, %(P)s(x)) \\to %(c)s)",
36
+ "⟨fun h ⟨x, hx⟩ => h x hx, fun h x hx => h ⟨x, hx⟩⟩"),
37
+ (False, False, "(∀ x, (%(P)s x ↔ %(Q)s x)) → ((∃ x, %(P)s x) ↔ ∃ x, %(Q)s x)", "(\\forall x\\, (%(P)s(x) \\iff %(Q)s(x))) \\to ((\\exists x\\, %(P)s(x)) \\iff (\\exists x\\, %(Q)s(x)))",
38
+ "by\n intro h\n constructor\n · rintro ⟨x, hx⟩\n exact ⟨x, (h x).1 hx⟩\n · rintro ⟨x, hx⟩\n exact ⟨x, (h x).2 hx⟩"),
39
+ ]
40
+ Q3 = [
41
+ (True, False, "∃ x, %(P)s x → ∀ y, %(P)s y", "\\exists x\\, (%(P)s(x) \\to \\forall y\\, %(P)s(y))",
42
+ "by\n by_cases h : ∀ y, %(P)s y\n · exact ⟨Classical.arbitrary _, fun _ => h⟩\n · push_neg at h\n obtain ⟨x, hx⟩ := h\n exact ⟨x, fun hp => absurd hp hx⟩"),
43
+ (False, False, "¬ ∃ x, ∀ y, (%(R)s x y ↔ ¬ %(R)s y y)", "\\neg \\exists x\\, \\forall y\\, (%(R)s(x, y) \\iff \\neg %(R)s(y, y))",
44
+ "by\n rintro ⟨x, hx⟩\n have h := hx x\n tauto"),
45
+ (False, False, "(¬ ∃ x, ∀ y, %(R)s x y) ↔ ∀ x, ∃ y, ¬ %(R)s x y", "\\neg \\exists x\\, \\forall y\\, %(R)s(x, y) \\iff \\forall x\\, \\exists y\\, \\neg %(R)s(x, y)",
46
+ "by\n constructor\n · intro h x\n by_contra h'\n apply h\n refine ⟨x, fun y => ?_⟩\n by_contra hy\n exact h' ⟨y, hy⟩\n · rintro h ⟨x, hx⟩\n obtain ⟨y, hy⟩ := h x\n exact hy (hx y)"),
47
+ (False, False, "(∃ x, %(P)s x ∧ ∀ y, %(P)s y → %(R)s x y) → ∀ y, %(P)s y → ∃ x, %(P)s x ∧ %(R)s x y", "(\\exists x\\, (%(P)s(x) \\wedge \\forall y\\, (%(P)s(y) \\to %(R)s(x, y)))) \\to \\forall y\\, (%(P)s(y) \\to \\exists x\\, (%(P)s(x) \\wedge %(R)s(x, y)))",
48
+ "by\n rintro ⟨x, hx, h⟩ y hy\n exact ⟨x, hx, h y hy⟩"),
49
+ (False, False, "((∀ x, %(P)s x → %(Q)s x) ∧ ∃ x, %(P)s x ∧ %(R)s x x) → ∃ x, %(Q)s x ∧ %(R)s x x", "((\\forall x\\, (%(P)s(x) \\to %(Q)s(x))) \\wedge \\exists x\\, (%(P)s(x) \\wedge %(R)s(x, x))) \\to \\exists x\\, (%(Q)s(x) \\wedge %(R)s(x, x))",
50
+ "by\n rintro ⟨h, x, hp, hr⟩\n exact ⟨x, h x hp, hr⟩"),
51
+ (True, False, "(∃ x, ∀ y, %(R)s x y) ∨ (∀ x, ∃ y, ¬ %(R)s x y)", "(\\exists x\\, \\forall y\\, %(R)s(x, y)) \\vee (\\forall x\\, \\exists y\\, \\neg %(R)s(x, y))",
52
+ "by\n by_cases h : ∃ x, ∀ y, %(R)s x y\n · exact Or.inl h\n · right\n intro x\n by_contra h'\n apply h\n refine ⟨x, fun y => ?_⟩\n by_contra hy\n exact h' ⟨y, hy⟩"),
53
+ ]
54
+
55
+ def quantifiers(rng, difficulty):
56
+ pool = {1: Q1, 2: Q2, 3: Q3}[difficulty]
57
+ nonempty, useprop, body, tex, proof = rng.choice(pool)
58
+ P, Q = rng.sample(["P", "Q", "S", "T"], 2)
59
+ R = rng.choice(["R", "r", "E", "L"])
60
+ c = rng.choice(["p", "q", "r2"]) if useprop else ""
61
+ sub = {"P": P, "Q": Q, "R": R, "c": c}
62
+ uses_R = "%(R)s" in body; uses_Q = "%(Q)s" in body
63
+ binders = ["{α : Type*}"] + (["[Nonempty α]"] if nonempty else [])
64
+ binders.append("(%s : α → Prop)" % P if not uses_Q else "(%s %s : α → Prop)" % (P, Q))
65
+ if uses_R: binders[-1] = (binders[-1] + " (%s : α → α → Prop)" % R) if "%(P)s" in body else "(%s : α → α → Prop)" % R
66
+ if useprop: binders.append("(%s : Prop)" % c)
67
+ stmt = " ".join(binders) + " :\n " + body % sub
68
+ words = []
69
+ if "%(P)s" in body: words.append("\\(%s\\)%s" % (P, " and \\(%s\\)" % Q if uses_Q else ""))
70
+ pred_names = [P] + ([Q] if uses_Q else []) if "%(P)s" in body else []
71
+ info = "Let \\(\\alpha\\) be a type" + (" (nonempty)" if nonempty else "")
72
+ parts = []
73
+ if pred_names: parts.append(" and ".join("\\(%s\\)" % n for n in pred_names) + (" predicates" if len(pred_names) > 1 else " a predicate") + " on \\(\\alpha\\)")
74
+ if uses_R: parts.append("\\(%s\\) a binary relation on \\(\\alpha\\)" % R)
75
+ if useprop: parts.append("\\(%s\\) a proposition" % c)
76
+ info += ", " + ", ".join(parts) + ". Prove \\[%s.\\]" % (tex % sub)
77
+ thm = "pred_logic"
78
+ return info, [Theorem(thm, stmt, proof % sub, "The stated statement of predicate logic.")]
79
+
80
+ # ---------------------------------------------------------------- set identities
81
+ SIMP = "simp only [Set.mem_union, Set.mem_inter_iff, Set.mem_diff, Set.mem_compl_iff]"
82
+
83
+ # Laws: (lhs, rhs) over metavariables a, b, c.
84
+ V = lambda n: ("v", n)
85
+ LAWS = [
86
+ (("c", ("u", V("a"), V("b"))), ("i", ("c", V("a")), ("c", V("b")))),
87
+ (("c", ("i", V("a"), V("b"))), ("u", ("c", V("a")), ("c", V("b")))),
88
+ (("i", V("a"), ("u", V("b"), V("c"))), ("u", ("i", V("a"), V("b")), ("i", V("a"), V("c")))),
89
+ (("u", V("a"), ("i", V("b"), V("c"))), ("i", ("u", V("a"), V("b")), ("u", V("a"), V("c")))),
90
+ (("d", V("a"), ("u", V("b"), V("c"))), ("i", ("d", V("a"), V("b")), ("d", V("a"), V("c")))),
91
+ (("d", V("a"), ("i", V("b"), V("c"))), ("u", ("d", V("a"), V("b")), ("d", V("a"), V("c")))),
92
+ (("d", ("u", V("a"), V("b")), V("c")), ("u", ("d", V("a"), V("c")), ("d", V("b"), V("c")))),
93
+ (("d", V("a"), ("d", V("b"), V("c"))), ("u", ("d", V("a"), V("b")), ("i", V("a"), V("c")))),
94
+ (("d", V("a"), V("b")), ("i", V("a"), ("c", V("b")))),
95
+ (("c", ("d", V("a"), V("b"))), ("u", ("c", V("a")), V("b"))),
96
+ (("u", V("a"), ("i", V("a"), V("b"))), V("a")),
97
+ (("u", ("d", V("a"), V("b")), ("d", V("b"), V("a"))), ("d", ("u", V("a"), V("b")), ("i", V("a"), V("b")))),
98
+ (("i", ("d", V("a"), V("b")), ("d", V("a"), V("c"))), ("d", V("a"), ("u", V("b"), V("c")))),
99
+ ]
100
+
101
+ def subst(e, m):
102
+ if e[0] == "v": return m[e[1]]
103
+ return (e[0],) + tuple(subst(x, m) for x in e[1:])
104
+
105
+ def ev(e, env):
106
+ if e[0] == "v": return env[e[1]]
107
+ if e[0] == "c": return not ev(e[1], env)
108
+ a, b = ev(e[1], env), ev(e[2], env)
109
+ return {"u": a or b, "i": a and b, "d": a and not b}[e[0]]
110
+
111
+ def lean(e, top=False):
112
+ if e[0] == "v": return e[1]
113
+ if e[0] == "c":
114
+ return "%sᶜ" % (lean(e[1]) if e[1][0] in ("v", "c") else "(%s)" % lean(e[1], True))
115
+ s = "%s %s %s" % (lean(e[1]), {"u": "∪", "i": "∩", "d": "\\"}[e[0]], lean(e[2]))
116
+ return s if top else "(%s)" % s
117
+
118
+ def tex(e, top=False):
119
+ if e[0] == "v": return e[1]
120
+ if e[0] == "c":
121
+ return "%s^{c}" % (tex(e[1]) if e[1][0] in ("v", "c") else "(%s)" % tex(e[1], True))
122
+ s = "%s %s %s" % (tex(e[1]), {"u": "\\cup", "i": "\\cap", "d": "\\setminus"}[e[0]], tex(e[2]))
123
+ return s if top else "(%s)" % s
124
+
125
+ def degenerate(e):
126
+ if e[0] == "v": return False
127
+ if e[0] == "c": return e[1][0] == "c" or degenerate(e[1])
128
+ return e[1] == e[2] or degenerate(e[1]) or degenerate(e[2])
129
+
130
+ def count_vars(e, acc=None):
131
+ acc = {} if acc is None else acc
132
+ if e[0] == "v": acc[e[1]] = acc.get(e[1], 0) + 1
133
+ else:
134
+ for x in e[1:]: count_vars(x, acc)
135
+ return acc
136
+
137
+ def vars_of(e): return {e[1]} if e[0] == "v" else set().union(*[vars_of(x) for x in e[1:]])
138
+ def size(e): return 1 if e[0] == "v" else 1 + sum(size(x) for x in e[1:])
139
+
140
+ def rand_expr(rng, depth, names):
141
+ if depth == 0 or (depth < 3 and rng.random() < 0.3): return ("v", rng.choice(names))
142
+ op = rng.choice(["u", "i", "d", "u", "i", "c"])
143
+ if op == "c": return ("c", rand_expr(rng, depth - 1, names))
144
+ return (op, rand_expr(rng, depth - 1, names), rand_expr(rng, depth - 1, names))
145
+
146
+ def simple_expr(rng, names):
147
+ k = rng.random()
148
+ if k < 0.45: return ("v", rng.choice(names))
149
+ if k < 0.6: return ("c", ("v", rng.choice(names)))
150
+ a, b = rng.sample(names, 2)
151
+ return (rng.choice(["u", "i", "d"]), ("v", a), ("v", b))
152
+
153
+
154
+ # Image and preimage statements: (needs_inj, binder over sets, statement, tex, proof). Placeholders: %(A)s %(B)s %(f)s.
155
+ IMG2 = [
156
+ (False, "A B", "%(f)s '' %(A)s \\ %(f)s '' %(B)s ⊆ %(f)s '' (%(A)s \\ %(B)s)", "%(f)s(%(A)s) \\setminus %(f)s(%(B)s) \\subseteq %(f)s(%(A)s \\setminus %(B)s)",
157
+ "by\n rintro y ⟨⟨x, hx, rfl⟩, hy⟩\n exact ⟨x, ⟨hx, fun hb => hy ⟨x, hb, rfl⟩⟩, rfl⟩", "image"),
158
+ (False, "B", "%(f)s '' (%(f)s ⁻¹' %(B)s) = %(B)s ∩ Set.range %(f)s", "%(f)s(%(f)s^{-1}(%(B)s)) = %(B)s \\cap \\operatorname{range} %(f)s",
159
+ "by\n ext y\n constructor\n · rintro ⟨x, hx, rfl⟩\n exact ⟨hx, x, rfl⟩\n · rintro ⟨hy, x, rfl⟩\n exact ⟨x, hy, rfl⟩", "preimage"),
160
+ (True, "A", "%(f)s ⁻¹' (%(f)s '' %(A)s) = %(A)s", "%(f)s^{-1}(%(f)s(%(A)s)) = %(A)s",
161
+ "by\n ext x\n constructor\n · rintro ⟨y, hy, hxy⟩\n exact (hf hxy) ▸ hy\n · intro hx\n exact ⟨x, hx, rfl⟩", "preimage"),
162
+ ]
163
+ IMG3 = [
164
+ (True, "A B", "%(f)s '' (%(A)s ∩ %(B)s) = %(f)s '' %(A)s ∩ %(f)s '' %(B)s", "%(f)s(%(A)s \\cap %(B)s) = %(f)s(%(A)s) \\cap %(f)s(%(B)s)",
165
+ "by\n ext y\n constructor\n · rintro ⟨x, ⟨ha, hb⟩, rfl⟩\n exact ⟨⟨x, ha, rfl⟩, ⟨x, hb, rfl⟩⟩\n · rintro ⟨⟨x, ha, rfl⟩, ⟨x', hb, hx⟩⟩\n have hxx : x' = x := hf hx\n subst hxx\n exact ⟨x', ⟨ha, hb⟩, rfl⟩", "image"),
166
+ (True, "A B", "%(f)s '' (%(A)s \\ %(B)s) = %(f)s '' %(A)s \\ %(f)s '' %(B)s", "%(f)s(%(A)s \\setminus %(B)s) = %(f)s(%(A)s) \\setminus %(f)s(%(B)s)",
167
+ "by\n ext y\n constructor\n · rintro ⟨x, ⟨ha, hb⟩, rfl⟩\n exact ⟨⟨x, ha, rfl⟩, fun ⟨x', hb', hx⟩ => hb ((hf hx) ▸ hb')⟩\n · rintro ⟨⟨x, ha, rfl⟩, hy⟩\n exact ⟨x, ⟨ha, fun hb => hy ⟨x, hb, rfl⟩⟩, rfl⟩", "image"),
168
+ (True, "A B", "%(f)s ⁻¹' (%(f)s '' %(A)s) ∩ %(B)s = %(A)s ∩ %(B)s", "%(f)s^{-1}(%(f)s(%(A)s)) \\cap %(B)s = %(A)s \\cap %(B)s",
169
+ "by\n ext x\n constructor\n · rintro ⟨⟨y, hy, hxy⟩, hb⟩\n exact ⟨(hf hxy) ▸ hy, hb⟩\n · rintro ⟨ha, hb⟩\n exact ⟨⟨x, ha, rfl⟩, hb⟩", "preimage"),
170
+ ]
171
+
172
+ def image_statements(rng, difficulty):
173
+ needs_inj, sets, body, tx, proof, _ = rng.choice(IMG2 if difficulty == 2 else IMG3)
174
+ f = rng.choice(["f", "g", "h"]); A, B = rng.sample(["A", "B", "C", "S", "T"], 2)
175
+ sub = {"f": f, "A": A, "B": B}
176
+ names = [{"A": A, "B": B}[c] for c in sets.split()]
177
+ stype = {"A": "α", "B": "β"}
178
+ # sets live in α, except the lone preimage-of-B statement which lives in β
179
+ ssort = "β" if (sets == "B") else "α"
180
+ binder = "{α β : Type*} (%s : α → β) (%s : Set %s)" % (f, " ".join(names), ssort)
181
+ if needs_inj: binder += " (hf : Function.Injective %s)" % f
182
+ stmt = "%s :\n %s" % (binder, body % sub)
183
+ if sets == "B": # sets named B in the statement; rename B to the chosen name for the second letter
184
+ pass
185
+ info = "Let \\(%s : \\alpha \\to \\beta\\) be a function%s and let \\(%s\\) be subsets of \\(%s\\). Write \\(%s(X)\\) for the image and \\(%s^{-1}(X)\\) for the preimage of a set \\(X\\). Prove \\[%s.\\]" % (
186
+ f, " that is injective" if needs_inj else "", ", ".join(names), "\\beta" if ssort == "β" else "\\alpha", f, f, tx % sub)
187
+ return info, [Theorem("image_identity", stmt, proof.replace("hf", "hf"), "The stated statement about images and preimages.")]
188
+
189
+ def set_identities(rng, difficulty):
190
+ if difficulty == 2 or (difficulty == 3 and rng.random() < 0.5):
191
+ return image_statements(rng, difficulty)
192
+ return set_algebra(rng, difficulty)
193
+
194
+ def set_algebra(rng, difficulty):
195
+ names = rng.sample(["A", "B", "C", "S", "T", "U", "X", "Y", "Z"], 3)
196
+ rows = list(itertools.product([False, True], repeat=3))
197
+ envs = [dict(zip(names, r)) for r in rows]
198
+ hyp = None
199
+ if difficulty < 3:
200
+ while True:
201
+ l, r = rng.choice(LAWS)
202
+ if difficulty == 1:
203
+ m = dict(zip("abc", rng.sample(names, 3)))
204
+ m = {k: ("v", v) for k, v in m.items()}
205
+ else:
206
+ m = {k: simple_expr(rng, names) for k in "abc"}
207
+ e1, e2 = subst(l, m), subst(r, m)
208
+ if lean(e1) == lean(e2) or degenerate(e1) or degenerate(e2): continue
209
+ if difficulty == 2 and size(e1) + size(e2) < 12: continue
210
+ if difficulty == 2 and rng.random() < 0.7 and len(vars_of(e1) | vars_of(e2)) < 3: continue
211
+ break
212
+ if rng.random() < 0.5: e1, e2 = e2, e1
213
+ allowed = envs
214
+ else:
215
+ a, b = rng.sample(names, 2)
216
+ if rng.random() < 0.5:
217
+ hyp = ("sub", a, b, "(h : %s ⊆ %s)" % (a, b), "%s \\subseteq %s" % (a, b), lambda env, a=a, b=b: (not env[a]) or env[b])
218
+ else:
219
+ hyp = ("dis", a, b, "(h : %s ∩ %s = ∅)" % (a, b), "%s \\cap %s = \\emptyset" % (a, b), lambda env, a=a, b=b: not (env[a] and env[b]))
220
+ allowed = [e for e in envs if hyp[5](e)]
221
+ for _ in range(200000):
222
+ e1 = rand_expr(rng, 3, names); e2 = rand_expr(rng, 3, names)
223
+ if lean(e1) == lean(e2) or degenerate(e1) or degenerate(e2) or not (4 <= size(e1) <= 8 and 4 <= size(e2) <= 8): continue
224
+ if len(vars_of(e1) | vars_of(e2)) < 3: continue
225
+ if max(count_vars(e1).values()) > 2 or max(count_vars(e2).values()) > 2: continue
226
+ if not all(ev(e1, e) == ev(e2, e) for e in allowed): continue
227
+ if all(ev(e1, e) == ev(e2, e) for e in envs): continue
228
+ if len({ev(e1, e) for e in allowed}) < 2 or len({ev(e2, e) for e in allowed}) < 2: continue
229
+ break
230
+ else: raise RuntimeError("no identity found")
231
+ assert all(ev(e1, e) == ev(e2, e) for e in allowed)
232
+ binder = "{α : Type*} (%s : Set α)" % " ".join(names) + ((" " + hyp[3]) if hyp else "")
233
+ stmt = "%s :\n %s = %s" % (binder, lean(e1, True), lean(e2, True))
234
+ if hyp is None:
235
+ proof = "by\n ext x\n %s\n all_goals tauto" % SIMP; extra = ""
236
+ elif hyp[0] == "sub":
237
+ proof = "by\n ext x\n have hx : x ∈ %s → x ∈ %s := @h x\n %s\n all_goals tauto" % (hyp[1], hyp[2], SIMP)
238
+ extra = " Assume that \\(%s\\)." % hyp[4]
239
+ else:
240
+ proof = ("by\n ext x\n have hx : x ∈ %s → x ∈ %s → False := fun ha hb => by\n have hm : x ∈ %s ∩ %s := ⟨ha, hb⟩\n simp [h] at hm\n %s\n tauto" % (hyp[1], hyp[2], hyp[1], hyp[2], SIMP)).replace("\n tauto", "\n all_goals tauto")
241
+ extra = " Assume that \\(%s\\)." % hyp[4]
242
+ info = "Let \\(%s\\) be subsets of a type \\(\\alpha\\).%s Prove the set identity \\[%s = %s.\\]" % (", ".join(names), extra, tex(e1, True), tex(e2, True))
243
+ return info, [Theorem("set_identity", stmt, proof, "The stated identity between sets.")]
244
+
245
+ # ---------------------------------------------------------------- finset cardinalities
246
+ INJ = "have hinj : Function.Injective (fun x : ℕ => %d * x + %d) := by\n intro x y h\n simp only at h\n omega\n "
247
+
248
+ def finset_card(rng, difficulty):
249
+ a = rng.randrange(2, 10); b = rng.randrange(0, 10)
250
+ f = "(fun x : ℕ => %d * x + %d)" % (a, b); ftex = "x \\mapsto %dx + %d" % (a, b)
251
+ inj = INJ % (a, b)
252
+ if difficulty == 1:
253
+ if rng.random() < 0.5:
254
+ stmt = "(s : Finset ℕ) :\n (s.image %s).card = s.card" % f
255
+ proof = "by\n " + inj + "exact Finset.card_image_of_injective s hinj"
256
+ info = "Let \\(f(x) = %dx + %d\\) on the natural numbers and let \\(s\\) be a finite set of natural numbers. Prove that the image \\(f(s)\\) has the same number of elements as \\(s\\)." % (a, b)
257
+ else:
258
+ stmt = "(s t : Finset ℕ) :\n ((s.image %s) ×ˢ t).card = s.card * t.card" % f
259
+ proof = "by\n " + inj + "rw [Finset.card_product, Finset.card_image_of_injective s hinj]"
260
+ info = "Let \\(f(x) = %dx + %d\\) on the natural numbers and let \\(s, t\\) be finite sets of natural numbers. Prove that the product \\(f(s) \\times t\\) has \\(|s| \\cdot |t|\\) elements." % (a, b)
261
+ return info, [Theorem("card_fact", stmt, proof, "A cardinality fact about finite sets.")]
262
+ if difficulty == 2:
263
+ if rng.random() < 0.5:
264
+ stmt = "(s t : Finset ℕ) :\n ((s ∪ t).image %s).card + ((s ∩ t).image %s).card = s.card + t.card" % (f, f)
265
+ proof = ("by\n " + inj + "rw [Finset.image_union, Finset.image_inter _ _ hinj, Finset.card_union_add_card_inter,\n Finset.card_image_of_injective s hinj, Finset.card_image_of_injective t hinj]")
266
+ info = "Let \\(f(x) = %dx + %d\\) on the natural numbers and let \\(s, t\\) be finite sets of natural numbers. Prove that \\[|f(s \\cup t)| + |f(s \\cap t)| = |s| + |t|.\\]" % (a, b)
267
+ else:
268
+ stmt = "(s t : Finset ℕ) :\n ((s \\ t).image %s).card + (s ∩ t).card = s.card" % f
269
+ proof = ("by\n " + inj + "rw [Finset.card_image_of_injective _ hinj]\n have h := Finset.card_sdiff_add_card_inter s t\n omega")
270
+ info = "Let \\(f(x) = %dx + %d\\) on the natural numbers and let \\(s, t\\) be finite sets of natural numbers. Prove that \\[|f(s \\setminus t)| + |s \\cap t| = |s|.\\]" % (a, b)
271
+ return info, [Theorem("card_fact", stmt, proof, "A cardinality fact about finite sets.")]
272
+ if rng.random() < 0.5:
273
+ stmt = "(s t : Finset ℕ) (h : Disjoint s t) :\n ((s ∪ t).image %s).card = s.card + t.card" % f
274
+ proof = "by\n " + inj + "rw [Finset.card_image_of_injective _ hinj, Finset.card_union_of_disjoint h]"
275
+ info = "Let \\(f(x) = %dx + %d\\) on the natural numbers and let \\(s, t\\) be disjoint finite sets of natural numbers. Prove that \\(|f(s \\cup t)| = |s| + |t|\\)." % (a, b)
276
+ return info, [Theorem("card_fact", stmt, proof, "A cardinality fact about finite sets.")]
277
+ lemma = Theorem("incl_excl", "(s t u : Finset ℕ) :\n (s ∪ t ∪ u).card + (s ∩ t).card + (s ∩ u).card + (t ∩ u).card = s.card + t.card + u.card + (s ∩ t ∩ u).card",
278
+ "by\n have h1 := Finset.card_union_add_card_inter (s ∪ t) u\n have h2 := Finset.card_union_add_card_inter s t\n have h3 := Finset.card_union_add_card_inter (s ∩ u) (t ∩ u)\n"
279
+ " have e1 : (s ∪ t) ∩ u = s ∩ u ∪ t ∩ u := Finset.union_inter_distrib_right s t u\n have e2 : s ∩ u ∩ (t ∩ u) = s ∩ t ∩ u := by\n ext x\n simp only [Finset.mem_inter]\n tauto\n rw [e1] at h1\n rw [e2] at h3\n omega",
280
+ "Inclusion and exclusion for three finite sets.")
281
+ main = Theorem("card_union_three", "(s t u : Finset ℕ) :\n (s ∪ t ∪ u).card = s.card + t.card + u.card - (s ∩ t).card - (s ∩ u).card - (t ∩ u).card + (s ∩ t ∩ u).card",
282
+ "by\n have h := incl_excl s t u\n have h7 : (s ∩ t ∩ u).card ≤ (s ∪ t ∪ u).card :=\n Finset.card_le_card (fun x hx => by\n simp only [Finset.mem_inter, Finset.mem_union] at hx ⊢\n tauto)\n omega",
283
+ "The size of a union of three finite sets, in terms of the sizes of the intersections.", weight=2.0)
284
+ info = ("Let \\(s, t, u\\) be finite sets of natural numbers. First prove the identity \\[|s \\cup t \\cup u| + |s \\cap t| + |s \\cap u| + |t \\cap u| = |s| + |t| + |u| + |s \\cap t \\cap u|.\\] "
285
+ "Then use it to prove the following, where subtraction is truncated subtraction on the natural numbers: \\[|s \\cup t \\cup u| = |s| + |t| + |u| - |s \\cap t| - |s \\cap u| - |t \\cap u| + |s \\cap t \\cap u|.\\]")
286
+ return info, [lemma, main]
287
+
288
+ # ---------------------------------------------------------------- relations
289
+ def relations(rng, difficulty):
290
+ if difficulty == 1:
291
+ m = rng.randrange(2, 13)
292
+ if rng.random() < 0.5:
293
+ rel = "fun x y : ℤ => %d ∣ x - y" % m; tx = "x \\sim y \\iff %d \\mid x - y" % m
294
+ else:
295
+ rel = "fun x y : ℤ => x %% %d = y %% %d" % (m, m); tx = "x \\sim y \\iff x \\bmod %d = y \\bmod %d" % (m, m)
296
+ proof = "⟨fun x => by omega, fun {x y} h => by omega, fun {x y z} h1 h2 => by omega⟩"
297
+ info = "On the integers define \\(%s\\). Prove that \\(\\sim\\) is an equivalence relation." % tx
298
+ return info, [Theorem("rel_equiv", ":\n Equivalence (%s)" % rel, proof, "The relation is reflexive, symmetric and transitive.")]
299
+ if difficulty == 2:
300
+ if rng.random() < 0.5:
301
+ a = rng.randrange(2, 8)
302
+ rel = "fun p q : ℕ × ℕ => p.1 + %d * q.2 = q.1 + %d * p.2" % (a, a)
303
+ tx = "(x_1, y_1) \\sim (x_2, y_2) \\iff x_1 + %d y_2 = x_2 + %d y_1" % (a, a)
304
+ proof = "⟨fun p => by omega, fun {p q} h => by omega, fun {p q r} h1 h2 => by omega⟩"
305
+ info = "On pairs of natural numbers define \\(%s\\). Prove that \\(\\sim\\) is an equivalence relation." % tx
306
+ else:
307
+ m = rng.randrange(2, 13); k = rng.choice([2, 3, 4])
308
+ rel = "fun x y : ℤ => %d ∣ x ^ %d - y ^ %d" % (m, k, k)
309
+ tx = "x \\sim y \\iff %d \\mid x^{%d} - y^{%d}" % (m, k, k)
310
+ proof = ("⟨fun x => by simp, fun {x y} h => (dvd_sub_comm).mp h, fun {x y z} h1 h2 => by\n have h := dvd_add h1 h2\n rwa [sub_add_sub_cancel] at h⟩")
311
+ info = "On the integers define \\(%s\\). Prove that \\(\\sim\\) is an equivalence relation." % tx
312
+ return info, [Theorem("rel_equiv", ":\n Equivalence (%s)" % rel, proof, "The relation is reflexive, symmetric and transitive.")]
313
+ n = rng.choice(["m", "n", "q"])
314
+ form = rng.choice(["dvd", "modeq"]); second = rng.choice(["mul", "pow"])
315
+ if form == "dvd":
316
+ rel = "fun x y : ℤ => %s ∣ x - y" % n; tx = "x \\sim y \\iff %s \\mid x - y" % n
317
+ p1 = ("⟨fun x => by simp, fun {x y} h => (dvd_sub_comm).mp h, fun {x y z} h1 h2 => by\n have h := dvd_add h1 h2\n rwa [sub_add_sub_cancel] at h⟩")
318
+ hyp = lambda a, b: "%s ∣ %s - %s" % (n, a, b)
319
+ add_p = "by\n have h := dvd_add h1 h2\n have e : (a + c) - (b + d) = (a - b) + (c - d) := by ring\n rw [e]\n exact h"
320
+ base = lambda lhs, rhs: "%s ∣ %s - %s" % (n, ("(%s)" % lhs) if "+" in lhs else lhs, ("(%s)" % rhs) if "+" in rhs else rhs)
321
+ tex_h = lambda a, b: "%s \\mid %s - %s" % (n, ("(%s)" % a) if "+" in a else a, ("(%s)" % b) if "+" in b else b)
322
+ else:
323
+ rel = "fun x y : ℤ => x ≡ y [ZMOD %s]" % n; tx = "x \\sim y \\iff x \\equiv y \\pmod{%s}" % n
324
+ p1 = "Int.ModEq.refl, fun {x y} h => h.symm, fun {x y z} h1 h2 => h1.trans h2"
325
+ p1 = "⟨%s⟩" % p1.replace("Int.ModEq.refl,", "fun x => Int.ModEq.refl x,")
326
+ hyp = lambda a, b: "%s ≡ %s [ZMOD %s]" % (a, b, n)
327
+ add_p = "h1.add h2"
328
+ base = lambda lhs, rhs: "%s ≡ %s [ZMOD %s]" % (lhs, rhs, n)
329
+ tex_h = lambda a, b: "%s \\equiv %s \\pmod{%s}" % (a, b, n)
330
+ t1 = Theorem("rel_equiv", "(%s : ℤ) :\n Equivalence (%s)" % (n, rel), p1, "The relation is reflexive, symmetric and transitive.")
331
+ t2 = Theorem("rel_add", "(%s a b c d : ℤ) (h1 : %s) (h2 : %s) :\n %s" % (n, hyp("a", "b"), hyp("c", "d"), base("a + c", "b + d")), add_p, "The relation is compatible with addition.")
332
+ if second == "mul":
333
+ if form == "dvd":
334
+ pm = "by\n have e : a * c - b * d = a * (c - d) + (a - b) * d := by ring\n rw [e]\n exact dvd_add (dvd_mul_of_dvd_right h2 a) (dvd_mul_of_dvd_left h1 d)"
335
+ else: pm = "h1.mul h2"
336
+ t3 = Theorem("rel_mul", "(%s a b c d : ℤ) (h1 : %s) (h2 : %s) :\n %s" % (n, hyp("a", "b"), hyp("c", "d"), base("a * c", "b * d")), pm, "The relation is compatible with multiplication.", weight=2.0)
337
+ what = "\\(a c \\sim b d\\)"; tx3 = "multiplication: if \\(%s\\) and \\(%s\\) then \\(%s\\)" % (tex_h("a", "b"), tex_h("c", "d"), tex_h("ac", "bd"))
338
+ else:
339
+ if form == "dvd":
340
+ pm = "by\n exact h.trans (sub_dvd_pow_sub_pow a b k)"
341
+ else: pm = "h.pow k"
342
+ t3 = Theorem("rel_pow", "(%s a b : ℤ) (k : ℕ) (h : %s) :\n %s" % (n, hyp("a", "b"), base("a ^ k", "b ^ k")), pm, "The relation is compatible with taking powers.", weight=2.0)
343
+ tx3 = "powers: if \\(%s\\) then \\(%s\\) for every natural number \\(k\\)" % (tex_h("a", "b"), tex_h("a^k", "b^k"))
344
+ info = ("For an integer \\(%s\\), define a relation on the integers by \\(%s\\). Prove three things: (1) \\(\\sim\\) is an equivalence relation; (2) \\(\\sim\\) is compatible with addition: if \\(%s\\) and \\(%s\\) then \\(%s\\); (3) \\(\\sim\\) is compatible with %s."
345
+ % (n, tx, tex_h("a", "b"), tex_h("c", "d"), tex_h("a+c", "b+d"), tx3))
346
+ return info, [t1, t2, t3]
347
+
348
+ def generate(seed, difficulty, family=None):
349
+ family = family or sorted(FAMILIES)[seed % len(FAMILIES)]
350
+ rng = rng_for(ENV + "/" + family, seed, difficulty)
351
+ info, thms = {"quantifiers": quantifiers, "set_identities": set_identities, "finset_card": finset_card, "relations": relations}[family](rng, difficulty)
352
+ titles = {"quantifiers": "Prove a statement of predicate logic", "set_identities": "Prove an identity between sets",
353
+ "finset_card": "Prove a cardinality fact about finite sets", "relations": "Prove properties of a relation"}
354
+ return Task(env=ENV, family=family, seed=seed, difficulty=difficulty, kind="prove", title=titles[family],
355
+ informal="Prove the following.\n\n" + info, theorems=thms)
envs/modular_arithmetic/__init__.py ADDED
File without changes
envs/modular_arithmetic/env.toml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ name = "modular-arithmetic"
2
+ title = "Divisibility, congruences and parity"
3
+ msc = "11"
4
+ kind = "prove"
5
+ summary = "Prove facts about residues, divisibility, congruences and coprimality for natural numbers and integers, by case analysis on residues."
6
+ skill = "Residue arithmetic and divisibility"
7
+ good_for = ["case analysis on residues", "Int.ModEq and Nat.ModEq", "ZMod and decide", "coprimality and gcd"]
8
+ families = ["congruence_chain", "divisibility", "gcd_coprime", "power_residues"]
envs/modular_arithmetic/gen.py ADDED
@@ -0,0 +1,229 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Divisibility, congruences, parity and coprimality (MSC 11: number theory, 11A07 congruences, 11A05 gcd).
2
+
3
+ Families:
4
+ power_residues residues of u*n^k + w (one variable) or non-attained residues of u*a^k + v*b^k + w;
5
+ divisibility m | a*n^p + b*n over the integers (Fermat-style p-th powers), proved in ZMod;
6
+ congruence_chain from x = r (mod m) derive a congruence for a polynomial in x (Int.ModEq);
7
+ gcd_coprime coprimality of two linear forms and their gcd.
8
+ Second code path: every residue set, every divisibility claim, every congruence value and every gcd
9
+ claim is recomputed by brute force in Python before the task is returned.
10
+ """
11
+ from math import gcd
12
+ from arena.core import Task, Theorem, rng_for
13
+
14
+ ENV = "modular_arithmetic"
15
+ FAMILIES = ["congruence_chain", "divisibility", "gcd_coprime", "power_residues"]
16
+
17
+ PRIMES_FOR = {2: [2], 3: [2, 3], 5: [2, 3, 5], 7: [2, 3, 7]} # primes q with n^p = n (mod q)
18
+
19
+
20
+ def poly(terms, tex=False):
21
+ """terms: list of (coef, lean monomial, tex monomial); '' means the constant term."""
22
+ out = ""
23
+ for i, (c, lm, tm) in enumerate(terms):
24
+ m = tm if tex else lm
25
+ mag = abs(c)
26
+ if m == "": body = "%d" % mag
27
+ elif mag == 1: body = m
28
+ elif tex: body = "%d%s" % (mag, m)
29
+ else: body = "%d * %s" % (mag, m)
30
+ if i == 0: out += ("-" if c < 0 else "") + body
31
+ else: out += (" - " if c < 0 else " + ") + body
32
+ return out
33
+
34
+
35
+ def ml(proof, c):
36
+ """ModEq proof of c * (...) from a proof of (...), skipping the factor 1."""
37
+ return proof if c == 1 else "(%s).mul_left %d" % (proof, c)
38
+
39
+
40
+ def mono(c, body):
41
+ return body if c == 1 else "%d * %s" % (c, body)
42
+
43
+
44
+ def paren(c):
45
+ return "(%d)" % c if c < 0 else "%d" % c
46
+
47
+
48
+ # ---------------------------------------------------------------- power_residues
49
+ def power_residues(rng, difficulty):
50
+ if difficulty < 3:
51
+ while True:
52
+ m = rng.choice([3, 4, 5, 7, 8, 9] if difficulty == 1 else [5, 7, 9, 11, 13, 16])
53
+ k = 2 if difficulty == 1 else rng.choice([3, 4])
54
+ u = rng.randrange(1, m); w = rng.randrange(0, m)
55
+ res = sorted({(u * x ** k + w) % m for x in range(m)})
56
+ free = {(u * x + w) % m for x in range(m)} # residues if n^k were an arbitrary number
57
+ if 2 <= len(res) and len(res) < len(free): break
58
+ # second path: the residues over a long range of n agree with the residues over one period
59
+ assert sorted({(u * n ** k + w) % m for n in range(5 * m + 3)}) == res
60
+ expr = poly([(u, "n ^ %d" % k, "n^%d" % k)] + ([(w, "", "")] if w else []))
61
+ texexpr = poly([(u, "n ^ %d" % k, "n^%d" % k)] + ([(w, "", "")] if w else []), tex=True)
62
+ cases = " ∨ ".join("(%s) %% %d = %d" % (expr, m, r) for r in res)
63
+ tex = ", ".join("%d" % r for r in res)
64
+ informal = ("Prove that for every natural number \\(n\\), the remainder of \\(%s\\) on division by \\(%d\\) is one of \\(%s\\)."
65
+ % (texexpr, m, tex))
66
+ stmt = "(n : ℕ) :\n %s" % cases
67
+ proof = ("by\n have key : (%s) %% %d = (%s) %% %d :=\n (%s).add_right %d\n"
68
+ " have h := Nat.mod_lt n (show 0 < %d by norm_num)\n rw [key]\n generalize n %% %d = r at h ⊢\n interval_cases r <;> decide"
69
+ % (expr, m, mono(u, "(n %% %d) ^ %d" % (m, k)) + " + %d" % w, m, ml("((Nat.mod_modEq n %d).symm.pow %d)" % (m, k), u), w, m, m))
70
+ return informal, [Theorem("residues_of_power", stmt, proof, "The remainder of the expression is one of the listed values.")]
71
+ while True:
72
+ m = rng.choice([4, 5, 7, 8, 9]); k = rng.choice([2, 3])
73
+ u = rng.randrange(1, 4); v = rng.randrange(1, 4); w = rng.randrange(0, m)
74
+ got = {(u * a ** k + v * b ** k + w) % m for a in range(m) for b in range(m)}
75
+ free = {(u * x + v * y + w) % m for x in range(m) for y in range(m)} # if the powers were arbitrary numbers
76
+ missing = [r for r in range(m) if r not in got and r in free]
77
+ if missing: break
78
+ r = rng.choice(missing)
79
+ for a in range(2 * m + 2):
80
+ for b in range(2 * m + 2): assert (u * a ** k + v * b ** k + w) % m != r
81
+ expr = poly([(u, "a ^ %d" % k, "a^%d" % k), (v, "b ^ %d" % k, "b^%d" % k)] + ([(w, "", "")] if w else []))
82
+ texexpr = poly([(u, "a^%d" % k, "a^%d" % k), (v, "b^%d" % k, "b^%d" % k)] + ([(w, "", "")] if w else []), tex=True)
83
+ informal = "Prove that for all natural numbers \\(a\\) and \\(b\\), the number \\(%s\\) never leaves remainder \\(%d\\) on division by \\(%d\\)." % (texexpr, r, m)
84
+ stmt = "(a b : ℕ) :\n (%s) %% %d ≠ %d" % (expr, m, r)
85
+ sub = "%s + %s + %d" % (mono(u, "(a %% %d) ^ %d" % (m, k)), mono(v, "(b %% %d) ^ %d" % (m, k)), w)
86
+ proof = ("by\n have key : (%s) %% %d = (%s) %% %d :=\n"
87
+ " ((%s).add (%s)).add_right %d\n"
88
+ " have ha := Nat.mod_lt a (show 0 < %d by norm_num)\n have hb := Nat.mod_lt b (show 0 < %d by norm_num)\n rw [key]\n"
89
+ " generalize a %% %d = x at ha ⊢\n generalize b %% %d = y at hb ⊢\n interval_cases x <;> interval_cases y <;> decide"
90
+ % (expr, m, sub, m, ml("((Nat.mod_modEq a %d).symm.pow %d)" % (m, k), u), ml("((Nat.mod_modEq b %d).symm.pow %d)" % (m, k), v), w, m, m, m, m))
91
+ return informal, [Theorem("residue_never_attained", stmt, proof, "The expression never leaves the stated remainder.")]
92
+
93
+
94
+ # ---------------------------------------------------------------- divisibility
95
+ def zmod_proof(M, expr):
96
+ return ("by\n have h : ((%s : ℤ) : ZMod %d) = 0 := by\n push_cast\n generalize (n : ZMod %d) = x\n revert x\n decide +kernel\n"
97
+ " exact (ZMod.intCast_zmod_eq_zero_iff_dvd _ _).1 h" % (expr, M, M))
98
+
99
+
100
+ def divisibility(rng, difficulty):
101
+ if difficulty == 1:
102
+ p = rng.choice([3, 5, 7]); ps = PRIMES_FOR[p]
103
+ sub = [q for q in ps if rng.random() < 0.6] or [rng.choice(ps)]
104
+ M = 1
105
+ for q in sub: M *= q
106
+ else:
107
+ p = rng.choice([3, 5, 7] if difficulty == 2 else [5, 7]); ps = PRIMES_FOR[p]
108
+ M = 1
109
+ for q in ps: M *= q
110
+ while True:
111
+ a = rng.randrange(1, 41); t = rng.randrange(-3, 4); b = M * t - a
112
+ if b != 0 and gcd(a, M) == 1: break
113
+ for n in range(-60, 61): assert (a * n ** p + b * n) % M == 0
114
+ terms = [(a, "n ^ %d" % p, "n^%d" % p), (b, "n", "n")]
115
+ expr = poly(terms); texexpr = poly(terms, tex=True)
116
+ informal = "Prove that for every integer \\(n\\), the number \\(%d\\) divides \\(%s\\)." % (M, texexpr)
117
+ if difficulty < 3:
118
+ stmt = "(n : ℤ) :\n (%d : ℤ) ∣ %s" % (M, expr)
119
+ return informal, [Theorem("dvd_poly", stmt, zmod_proof(M, expr), "The integer divides the polynomial value.")]
120
+ ths = []
121
+ for q in ps:
122
+ ths.append(Theorem("dvd_by_%d" % q, "(n : ℤ) :\n (%d : ℤ) ∣ %s" % (q, expr), zmod_proof(q, expr),
123
+ "The prime %d divides the polynomial value." % q))
124
+ haves = "\n".join(" have h%d := dvd_by_%d n" % (q, q) for q in ps)
125
+ main = Theorem("dvd_poly", "(n : ℤ) :\n (%d : ℤ) ∣ %s" % (M, expr), "by\n%s\n generalize %s = e at %s ⊢\n omega" % (haves, expr, " ".join("h%d" % q for q in ps)),
126
+ "The product of the primes divides the polynomial value.", weight=float(len(ps)))
127
+ return informal + " Prove it first for each prime factor of \\(%d\\), then combine." % M, ths + [main]
128
+
129
+
130
+ # ---------------------------------------------------------------- congruence_chain
131
+ def congruence_chain(rng, difficulty):
132
+ m = rng.randrange(5, 14)
133
+ if difficulty == 1:
134
+ r = rng.randrange(0, m); u, v, w = rng.randrange(1, 8), rng.randrange(1, 8), rng.randrange(1, 8)
135
+ val = (u * r * r + v * r + w) % m
136
+ for x in range(-3 * m, 3 * m):
137
+ if x % m == r: assert (u * x * x + v * x + w - val) % m == 0
138
+ terms = [(u, "x ^ 2", "x^2"), (v, "x", "x"), (w, "", "")]
139
+ expr = poly(terms); tex = poly(terms, tex=True)
140
+ informal = "Let \\(x\\) be an integer with \\(x \\equiv %d \\pmod{%d}\\). Prove that \\(%s \\equiv %d \\pmod{%d}\\)." % (r, m, tex, val, m)
141
+ stmt = "(x : ℤ) (h : x ≡ %d [ZMOD %d]) :\n %s ≡ %d [ZMOD %d]" % (r, m, expr, val, m)
142
+ proof = ("by\n have h1 := ((%s).add (%s)).add_right %d\n refine h1.trans ?_\n norm_num [Int.ModEq]" % (ml("h.pow 2", u), ml("h", v), w))
143
+ return informal, [Theorem("congr_poly", stmt, proof, "The polynomial is congruent to the stated residue.")]
144
+ if difficulty == 2:
145
+ r, s = rng.randrange(0, m), rng.randrange(0, m)
146
+ u, v, w = rng.randrange(1, 8), rng.randrange(1, 8), rng.randrange(1, 8)
147
+ val = (u * r * s + v * s * s + w * r) % m
148
+ for x in range(-2 * m, 2 * m, 3):
149
+ for y in range(-2 * m, 2 * m, 5):
150
+ if x % m == r and y % m == s: assert (u * x * y + v * y * y + w * x - val) % m == 0
151
+ terms = [(u, "x * y", "xy"), (v, "y ^ 2", "y^2"), (w, "x", "x")]
152
+ expr = mono(u, "(x * y)") + " + " + mono(v, "y ^ 2") + " + " + mono(w, "x"); tex = poly(terms, tex=True)
153
+ informal = "Let \\(x\\) and \\(y\\) be integers with \\(x \\equiv %d \\pmod{%d}\\) and \\(y \\equiv %d \\pmod{%d}\\). Prove that \\(%s \\equiv %d \\pmod{%d}\\)." % (r, m, s, m, tex, val, m)
154
+ stmt = "(x y : ℤ) (hx : x ≡ %d [ZMOD %d]) (hy : y ≡ %d [ZMOD %d]) :\n %s ≡ %d [ZMOD %d]" % (r, m, s, m, expr, val, m)
155
+ proof = ("by\n have h1 := ((%s).add (%s)).add (%s)\n refine h1.trans ?_\n norm_num [Int.ModEq]" % (ml("hx.mul hy", u), ml("hy.pow 2", v), ml("hx", w)))
156
+ return informal, [Theorem("congr_poly2", stmt, proof, "The expression is congruent to the stated residue.")]
157
+ m = rng.randrange(7, 14)
158
+ r, s = rng.randrange(2, m), rng.randrange(2, m)
159
+ e, f = rng.randrange(8, 40), rng.randrange(8, 40); w = rng.randrange(1, 9)
160
+ ve, vf = pow(r, e, m), pow(s, f, m)
161
+ val = (ve * vf + w) % m
162
+ for x in (r, r + m, r - 2 * m):
163
+ for y in (s, s + 3 * m, s - m): assert (x ** e * y ** f + w - val) % m == 0
164
+ informal = ("Let \\(x\\) and \\(y\\) be integers with \\(x \\equiv %d \\pmod{%d}\\) and \\(y \\equiv %d \\pmod{%d}\\). "
165
+ "Prove that \\(x^{%d} \\equiv %d \\pmod{%d}\\), and then that \\(x^{%d} y^{%d} + %d \\equiv %d \\pmod{%d}\\)."
166
+ % (r, m, s, m, e, ve, m, e, f, w, val, m))
167
+ lemma = Theorem("congr_pow", "(x : ℤ) (h : x ≡ %d [ZMOD %d]) :\n x ^ %d ≡ %d [ZMOD %d]" % (r, m, e, ve, m),
168
+ "by\n refine (h.pow %d).trans ?_\n norm_num [Int.ModEq]" % e, "A large power of x has the stated residue.")
169
+ main = Theorem("congr_product", "(x y : ℤ) (hx : x ≡ %d [ZMOD %d]) (hy : y ≡ %d [ZMOD %d]) :\n x ^ %d * y ^ %d + %d ≡ %d [ZMOD %d]" % (r, m, s, m, e, f, w, val, m),
170
+ "by\n have h1 := congr_pow x hx\n have h2 : y ^ %d ≡ %d [ZMOD %d] := by\n refine (hy.pow %d).trans ?_\n norm_num [Int.ModEq]\n"
171
+ " refine ((h1.mul h2).add_right %d).trans ?_\n norm_num [Int.ModEq]" % (f, vf, m, f, w),
172
+ "The combined expression has the stated residue.", weight=2.0)
173
+ return informal, [lemma, main]
174
+
175
+
176
+ # ---------------------------------------------------------------- gcd_coprime
177
+ def linear_pair(rng, want_prime_det):
178
+ while True:
179
+ a, b, c = rng.randrange(1, 10), rng.randrange(1, 10), rng.randrange(1, 10)
180
+ if want_prime_det:
181
+ d = rng.randrange(1, 10)
182
+ D = abs(a * d - b * c)
183
+ if D in (2, 3, 5, 7, 11, 13): return a, b, c, d, a * d - b * c
184
+ else:
185
+ s = rng.choice([1, -1])
186
+ if (b * c + s) % a == 0 and (b * c + s) // a >= 1:
187
+ d = (b * c + s) // a
188
+ return a, b, c, d, a * d - b * c
189
+
190
+
191
+ def gcd_coprime(rng, difficulty):
192
+ a, b, c, d, det = linear_pair(rng, difficulty == 3)
193
+ A = poly([(a, "n", "n"), (b, "", "")]); B = poly([(c, "n", "n"), (d, "", "")])
194
+ tA = poly([(a, "n", "n"), (b, "", "")], tex=True); tB = poly([(c, "n", "n"), (d, "", "")], tex=True)
195
+ if difficulty < 3:
196
+ assert abs(det) == 1 and all(gcd(a * n + b, c * n + d) == 1 for n in range(300))
197
+ s = det
198
+ wit = "⟨%s, %s, by ring⟩" % (paren(-s * c), paren(s * a))
199
+ if difficulty == 1:
200
+ informal = "Prove that for every integer \\(n\\), the integers \\(%s\\) and \\(%s\\) are coprime, in the sense that \\(u(%s) + v(%s) = 1\\) for some integers \\(u, v\\)." % (tA, tB, tA, tB)
201
+ stmt = "(n : ℤ) :\n IsCoprime (%s) (%s)" % (A, B)
202
+ return informal, [Theorem("coprime_int", stmt, "by\n exact %s" % wit, "The two linear forms are coprime.")]
203
+ informal = "Prove that for every natural number \\(n\\), the numbers \\(%s\\) and \\(%s\\) are coprime." % (tA, tB)
204
+ stmt = "(n : ℕ) :\n Nat.Coprime (%s) (%s)" % (A, B)
205
+ proof = "by\n rw [← Nat.isCoprime_iff_coprime]\n push_cast\n exact %s" % wit
206
+ return informal, [Theorem("coprime_nat", stmt, proof, "The two linear forms are coprime.")]
207
+ D = abs(det)
208
+ assert all(D % gcd(a * n + b, c * n + d) == 0 for n in range(300))
209
+ g = "Nat.gcd (%s) (%s)" % (A, B)
210
+ if a * d > b * c: first = "Dvd.dvd.mul_left h2 %d" % a; second = "Dvd.dvd.mul_left h1 %d" % c; e = "%d * (%s) - %d * (%s) = %d" % (a, B, c, A, D)
211
+ else: first = "Dvd.dvd.mul_left h1 %d" % c; second = "Dvd.dvd.mul_left h2 %d" % a; e = "%d * (%s) - %d * (%s) = %d" % (c, A, a, B, D)
212
+ informal = ("Let \\(n\\) be a natural number and \\(g = \\gcd(%s, %s)\\). Prove that \\(g\\) divides \\(%d\\), "
213
+ "and conclude that \\(g = 1\\) or \\(g = %d\\)." % (tA, tB, D, D))
214
+ lemma = Theorem("gcd_dvd_det", "(n : ℕ) :\n %s ∣ %d" % (g, D),
215
+ "by\n have h1 : %s ∣ %s := Nat.gcd_dvd_left _ _\n have h2 : %s ∣ %s := Nat.gcd_dvd_right _ _\n"
216
+ " have h3 := Nat.dvd_sub (%s) (%s)\n have e : %s := by omega\n rw [e] at h3\n exact h3" % (g, A, g, B, first, second, e),
217
+ "The gcd divides the determinant.")
218
+ main = Theorem("gcd_one_or_prime", "(n : ℕ) :\n %s = 1 ∨ %s = %d" % (g, g, D),
219
+ "by\n exact (Nat.dvd_prime (by norm_num)).1 (gcd_dvd_det n)", "The gcd is 1 or the prime determinant.", weight=2.0)
220
+ return informal, [lemma, main]
221
+
222
+
223
+ def generate(seed, difficulty, family=None):
224
+ family = family or sorted(FAMILIES)[seed % len(FAMILIES)]
225
+ rng = rng_for(ENV + "/" + family, seed, difficulty)
226
+ informal, theorems = {"power_residues": power_residues, "divisibility": divisibility,
227
+ "congruence_chain": congruence_chain, "gcd_coprime": gcd_coprime}[family](rng, difficulty)
228
+ return Task(env=ENV, family=family, seed=seed, difficulty=difficulty, kind="prove",
229
+ title="Prove a fact about divisibility and residues", informal=informal, theorems=theorems)
envs/real_analysis/__init__.py ADDED
File without changes
envs/real_analysis/env.toml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ name = "real-analysis"
2
+ title = "Real analysis with epsilon and delta"
3
+ msc = "26"
4
+ kind = "prove"
5
+ summary = "Prove limits of explicit sequences, epsilon-delta continuity, bounds on recursive sequences and uniform bounds, from the definitions."
6
+ skill = "Epsilon-delta arguments and induction on real sequences"
7
+ good_for = ["choosing N and delta", "abs and inequality estimates", "induction on recursive sequences", "geometric sums"]
8
+ families = ["continuity", "limit_sequence", "sequence_bounds", "uniform_bounds"]