Skip to content

Instantly share code, notes, and snippets.

@spolu
Created January 4, 2022 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spolu/d4bedc834448c02befce5c8e3c7d3f1c to your computer and use it in GitHub Desktop.
Save spolu/d4bedc834448c02befce5c8e3c7d3f1c to your computer and use it in GitHub Desktop.
AIME 1984 P1 (Human formalization)
/-
Copyright (c) 2021 OpenAI. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kunhao Zheng, Kudzo Ahegbebu, Stanislas Polu, David Renshaw, OpenAI GPT-f
-/
import minif2f_import
open_locale big_operators
open_locale nat
open_locale real
open_locale rat
-- Sum a sequence by grouping adjacent terms.
lemma sum_pairs (n : ℕ) (f : ℕ → ℚ) :
∑ k in (finset.range (2 * n)), f k = ∑ k in (finset.range n), (f (2 * k) + f (2 * k + 1)) :=
begin
induction n with pn hpn,
{ simp only [finset.sum_empty, finset.range_zero, mul_zero] },
{ have hs: (2 * pn.succ) = (2 * pn).succ.succ := rfl,
rw [finset.sum_range_succ, ←hpn, hs, finset.sum_range_succ, finset.sum_range_succ],
ring },
end
theorem aime_1984_p1
(u : ℕ → ℚ)
(h₀ : ∀ n, u (n + 1) = u n + 1)
(h₁ : ∑ k in finset.range 98, u k.succ = 137) :
∑ k in finset.range 49, u (2 * k.succ) = 93 :=
begin
-- We will use sum_pairs and h₀ to rewrite h₁ and the goal in terms of the quantity
-- ∑ k in finset.range 49, u (2 * k + 1).
have h₂ : ∀ k, k ∈ finset.range 49 → u (2 * k + 1 + 1) = u (2 * k + 1) + 1 :=
by { intros k hk, exact h₀ (2 * k + 1) },
have h₃: ∑ (x : ℕ) in finset.range 49, (1:ℚ) = 49 := by simp only [mul_one, nat.cast_bit0, finset.sum_const, nsmul_eq_mul, nat.cast_bit1, finset.card_range, nat.cast_one],
have h98 : 98 = 2 * 49 := by norm_num,
rw [h98, sum_pairs, finset.sum_add_distrib, finset.sum_congr rfl h₂,
finset.sum_add_distrib, h₃, ←add_assoc] at h₁,
have h₄ : ∑ (k : ℕ) in finset.range 49, u (2 * k.succ)
= ∑ (k : ℕ) in finset.range 49, (u (2 * k + 1) + 1) :=
finset.sum_congr rfl h₂,
rw [h₄, finset.sum_add_distrib, h₃],
linarith,
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment