File size: 9,305 Bytes
16a4018 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 | # openai/math challenge `AlgorithmicThinTrees` (family 174)
Prove the following result from OpenAI's [openai/math](https://github.com/openai/math) release in
Lean 4, with a proof the Lean kernel accepts.
Context: this statement belongs to family 174 of the release, *Deterministic construction of strong thin spanning trees*
(Combinatorics). The family as a whole: Resolves the strong thin-tree conjecture constructively. Every finite loopless $k$-edge-connected multigraph on at least two vertices has a spanning tree containing at most a universal $C/k$ fraction of the edges of every cut. Such a tree can be found deterministically in polynomial time, even with binary-encoded parallel-edge multiplicities.
The challenge is `AlgorithmicThinTrees`, also at `/opt/openai-math/challenges/AlgorithmicThinTrees.lean`:
```lean
import Mathlib
namespace OAI
/-! Deterministic polynomial-time construction of strong thin trees. -/
namespace StrongThinTree
structure MultiGraph (n m : ℕ) where
left : Fin m → Fin n
right : Fin m → Fin n
loopless : ∀ e, left e ≠ right e
namespace MultiGraph
def cut {n m : ℕ} (G : MultiGraph n m) (T : Finset (Fin m))
(S : Finset (Fin n)) : Finset (Fin m) :=
T.filter fun e => (G.left e ∈ S ∧ G.right e ∉ S) ∨
(G.right e ∈ S ∧ G.left e ∉ S)
def Connected {n m : ℕ} (G : MultiGraph n m) (T : Finset (Fin m)) : Prop :=
∀ S : Finset (Fin n), S.Nonempty → S ≠ Finset.univ → (G.cut T S).Nonempty
def SpanningTree {n m : ℕ} (G : MultiGraph n m) (T : Finset (Fin m)) : Prop :=
G.Connected T ∧ ∀ e ∈ T, ¬ G.Connected (T.erase e)
def EdgeConnected {n m : ℕ} (G : MultiGraph n m) (k : ℕ) : Prop :=
∀ S : Finset (Fin n), S.Nonempty → S ≠ Finset.univ →
k ≤ (G.cut Finset.univ S).card
end MultiGraph
end StrongThinTree
namespace CurrentKS
def frame : List Bool → List Bool
| [] => [true]
| b :: bs => false :: b :: frame bs
def encodeNat (n : ℕ) : List Bool := frame (Computability.encodeNat n)
inductive StackAction where
| stay
| pop
| push (bit : Bool)
deriving DecidableEq
def StackAction.apply : StackAction → List Bool → List Bool
| .stay, xs => xs
| .pop, xs => xs.tail
| .push b, xs => b :: xs
structure Instruction (k q : ℕ) where
next : Option (Fin q)
actions : Fin k → StackAction
def Instruction.halt (k q : ℕ) : Instruction k q := ⟨none, fun _ => .stay⟩
structure Machine where
stackCount : ℕ
states : ℕ
initial : Fin states
inputStack : Fin stackCount
outputStack : Fin stackCount
table : List (Instruction stackCount states)
structure Config (k q : ℕ) where
state : Option (Fin q)
«stacks» : Fin k → List Bool
def topCode : List Bool → ℕ
| [] => 0
| false :: _ => 1
| true :: _ => 2
def headsCode : (k : ℕ) → (Fin k → List Bool) → ℕ
| 0, _ => 0
| k + 1, s => topCode (s 0) + 3 * headsCode k (fun j => s j.succ)
def Machine.step (M : Machine) (c : Config M.stackCount M.states) :
Config M.stackCount M.states :=
match c.state with
| none => c
| some q =>
let instruction := M.table.getD
(3 ^ M.stackCount * q.val + headsCode M.stackCount c.stacks)
(Instruction.halt M.stackCount M.states)
⟨instruction.next, fun j => (instruction.actions j).apply (c.stacks j)⟩
def Machine.init (M : Machine) (input : List Bool) : Config M.stackCount M.states :=
⟨some M.initial, fun j => if j = M.inputStack then input else []⟩
def Machine.run (M : Machine) (input : List Bool) (fuel : ℕ) :
Config M.stackCount M.states := (M.step^[fuel]) (M.init input)
end CurrentKS
namespace AlgorithmicThinTrees
open StrongThinTree
structure ExplicitInput where
n : ℕ
m : ℕ
k : ℕ
graph : MultiGraph n m
structure BinaryInput where
n : ℕ
p : ℕ
k : ℕ
left : Fin p → Fin n
right : Fin p → Fin n
ordered : ∀ i, left i < right i
distinct : Function.Injective (fun i => (left i, right i))
multiplicity : Fin p → ℕ
abbrev BinaryInput.Edge (x : BinaryInput) := Σ i : Fin x.p, Fin (x.multiplicity i)
noncomputable def BinaryInput.edgeEquiv (x : BinaryInput) :
x.Edge ≃ Fin (Fintype.card x.Edge) := Fintype.equivFin x.Edge
noncomputable def BinaryInput.graph (x : BinaryInput) :
MultiGraph x.n (Fintype.card x.Edge) where
left e := x.left (x.edgeEquiv.symm e).1
right e := x.right (x.edgeEquiv.symm e).1
loopless e := ne_of_lt (x.ordered (x.edgeEquiv.symm e).1)
inductive Input where
| explicit (x : ExplicitInput)
| binary (x : BinaryInput)
def ExplicitInput.encode (x : ExplicitInput) : List Bool :=
CurrentKS.encodeNat x.n ++ CurrentKS.encodeNat x.m ++ CurrentKS.encodeNat x.k ++
(List.ofFn fun i : Fin x.m =>
CurrentKS.encodeNat (x.graph.left i).val ++
CurrentKS.encodeNat (x.graph.right i).val).flatten
def BinaryInput.encode (x : BinaryInput) : List Bool :=
CurrentKS.encodeNat x.n ++ CurrentKS.encodeNat x.p ++ CurrentKS.encodeNat x.k ++
(List.ofFn fun i : Fin x.p =>
CurrentKS.encodeNat (x.left i).val ++ CurrentKS.encodeNat (x.right i).val ++
CurrentKS.encodeNat (x.multiplicity i)).flatten
def Input.encode : Input → List Bool
| .explicit x => false :: x.encode
| .binary x => true :: x.encode
def Input.length (x : Input) : ℕ := x.encode.length
def Input.n : Input → ℕ
| .explicit x => x.n
| .binary x => x.n
def Valid : Input → Prop
| .explicit x => 1 ≤ x.n ∧ 1 ≤ x.k ∧ x.graph.EdgeConnected x.k
| .binary x => 1 ≤ x.n ∧ 1 ≤ x.k ∧ x.graph.EdgeConnected x.k
def ThinTree {n m : ℕ} (C : ℝ) (k : ℕ) (G : MultiGraph n m)
(T : Finset (Fin m)) : Prop :=
G.SpanningTree T ∧ ∀ S : Finset (Fin n), S.Nonempty → S ≠ Finset.univ →
((G.cut T S).card : ℝ) ≤ C / (k : ℝ) * (G.cut Finset.univ S).card
def ExplicitInput.encodeEdges (x : ExplicitInput) (edges : List (Fin x.m)) : List Bool :=
edges.flatMap (fun e => CurrentKS.encodeNat e.val)
def BinaryInput.encodeEdges (x : BinaryInput) (edges : List x.Edge) : List Bool :=
edges.flatMap (fun e => CurrentKS.encodeNat e.1.val ++ CurrentKS.encodeNat e.2.val)
noncomputable def BinaryInput.selected (x : BinaryInput) (edges : List x.Edge) :
Finset (Fin (Fintype.card x.Edge)) := edges.toFinset.map x.edgeEquiv.toEmbedding
def TreeOutput (C : ℝ) : Input → List Bool → Prop
| .explicit x, bits => ∃ edges : List (Fin x.m), edges.Nodup ∧
bits = x.encodeEdges edges ∧ ThinTree C x.k x.graph edges.toFinset
| .binary x, bits => ∃ edges : List x.Edge, edges.Nodup ∧
bits = x.encodeEdges edges ∧ ThinTree C x.k x.graph (x.selected edges)
def GoodOutput (C : ℝ) (x : Input) (bits : List Bool) : Prop :=
TreeOutput C x bits ∧ (x.n = 1 → bits = [])
def AlgorithmicStrongThinTrees : Prop :=
∃ C : ℝ, 0 < C ∧ ∃ M : CurrentKS.Machine, ∃ a degree : ℕ, 0 < a ∧
∀ x : Input, Valid x →
let result := M.run x.encode (a * (x.length + 1) ^ degree)
result.state = none ∧ GoodOutput C x (result.stacks M.outputStack)
end AlgorithmicThinTrees
namespace AlgorithmicThinTrees
theorem algorithmic_strong_thin_trees : AlgorithmicStrongThinTrees := by
sorry
end AlgorithmicThinTrees
end OAI
```
## What to submit
Write `/workspace/Submission.lean`. Start from a copy of the challenge:
```bash
cp /opt/openai-math/challenges/AlgorithmicThinTrees.lean /workspace/Submission.lean
```
then replace every `sorry` with a proof. The file is graded on three things:
- **Same statements.** The theorem `OAI.AlgorithmicThinTrees.algorithmic_strong_thin_trees` must keep exactly the statement shown above: same names,
namespaces, binders and types. Every definition the statements use must stay exactly as written.
Change nothing except the proofs.
- **Standard axioms only.** Proofs may use only `propext`, `Quot.sound` and `Classical.choice`.
`sorry`, `admit`, new `axiom`s and `native_decide` (it introduces an axiom of its own) are rejected.
- **Keep the challenge's declarations as they are.** Put new lemmas and instances *after* the
definitions the statements use, or in a separate `Submission/*.lean` module. A declaration added
before them can change how they elaborate, and then they no longer match the challenge.
- **Kernel-checked.** The proofs are re-checked by the Lean kernel, not just the elaborator.
Long proofs can be split into modules under `/workspace/Submission/` (module names
`Submission.Foo`, `Submission.Foo.Bar`) imported from `Submission.lean`. Only `.lean` files at
those two paths are graded.
## Environment
- Lean `v4.34.1` and Mathlib at commit `d13f23b` are installed and prebuilt; `/workspace` is a
Lake project.
- The sandbox has 4 CPUs and 8 GB of memory; `LEAN_NUM_THREADS=3` keeps `lake build` to three
parallel jobs. Check your work with `cd /workspace && lake build Submission`. Add `#print axioms <name>` to see
which axioms a proof uses.
- There is no internet access. OpenAI's own proofs are not installed.
## Grading
When you finish, `Submission.lean` and `Submission/**.lean` are copied to a fresh machine and
checked with [Comparator](https://github.com/leanprover/comparator), the Lean FRO's proof checker.
The reward is 1 if Comparator accepts the proof and 0 otherwise. A partial proof scores 0.
|