lean-refactor-arena / benchmark_data.jsonl
mikeljl's picture
Switch to real putnam_small benchmark + statement-match guard
f946490
{"name": "putnam_1964_a4", "proof_length": 1769, "header": "import Mathlib\nimport Aesop\n\nset_option maxHeartbeats 0\n\nopen Set Function\n\n\n", "signature": "theorem putnam_1964_a4\n(u : β„• β†’ β„€)\n(boundedu : βˆƒ B T : β„€, βˆ€ n : β„•, B ≀ u n ∧ u n ≀ T)\n(hu : βˆ€ n β‰₯ 4, u n = ((u (n - 1) + u (n - 2) + u (n - 3) * u (n - 4)) : ℝ) / (u (n - 1) * u (n - 2) + u (n - 3) + u (n - 4)) ∧ (u (n - 1) * u (n - 2) + u (n - 3) + u (n - 4)) β‰  0)\n: (βˆƒ N c : β„•, c > 0 ∧ βˆ€ n β‰₯ N, u (n + c) = u n)", "src": "theorem putnam_1964_a4\n(u : β„• β†’ β„€)\n(boundedu : βˆƒ B T : β„€, βˆ€ n : β„•, B ≀ u n ∧ u n ≀ T)\n(hu : βˆ€ n β‰₯ 4, u n = ((u (n - 1) + u (n - 2) + u (n - 3) * u (n - 4)) : ℝ) / (u (n - 1) * u (n - 2) + u (n - 3) + u (n - 4)) ∧ (u (n - 1) * u (n - 2) + u (n - 3) + u (n - 4)) β‰  0)\n: (βˆƒ N c : β„•, c > 0 ∧ βˆ€ n β‰₯ N, u (n + c) = u n) := by \n have h_main : βˆƒ (i j : β„•), i < j ∧ (u i = u j ∧ u (i + 1) = u (j + 1) ∧ u (i + 2) = u (j + 2) ∧ u (i + 3) = u (j + 3)) := by\n obtain ⟨B, T, hB⟩ := boundedu\n have h₁ : βˆƒ (i j : β„•), i < j ∧ (u i = u j ∧ u (i + 1) = u (j + 1) ∧ u (i + 2) = u (j + 2) ∧ u (i + 3) = u (j + 3)) := by\n \n classical\n \n let f : β„• β†’ (β„€ Γ— β„€ Γ— β„€ Γ— β„€) := fun n => (u n, u (n + 1), u (n + 2), u (n + 3))\n have hβ‚‚ : Set.Finite (Set.range f) := by\n have h₃ : Set.range f βŠ† Set.Icc (B, B, B, B) (T, T, T, T) := by\n intro x hx\n rcases hx with ⟨n, rfl⟩\n have hβ‚„ := hB n\n have hβ‚… := hB (n + 1)\n have h₆ := hB (n + 2)\n have h₇ := hB (n + 3)\n simp only [Set.mem_Icc, Prod.le_def] at hβ‚„ hβ‚… h₆ h₇ ⊒\n constructor <;>\n (try constructor) <;>\n (try constructor) <;>\n (try constructor) <;>\n (try simp_all [f]) <;>\n (try nlinarith)\n \n have hβ‚„ : Set.Finite (Set.Icc (B, B, B, B) (T, T, T, T)) := by\n apply Set.Finite.subset (Set.finite_mem_finset (Finset.Icc (B, B, B, B) (T, T, T, T)))\n intro x hx\n simp_all [Set.mem_Icc]\n <;>\n (try aesop)\n exact Set.Finite.subset hβ‚„ h₃\n \n have h₃ : βˆƒ (i j : β„•), i < j ∧ f i = f j := by\n by_contra! hβ‚„\n have hβ‚… : Function.Injective f := by\n intro i j h₆\n by_cases h₇ : i = j\n Β· exact h₇\n Β· have hβ‚ˆ : i < j ∨ j < i := by omega\n cases hβ‚ˆ with\n | inl hβ‚ˆ =>\n have h₉ := hβ‚„ i j hβ‚ˆ\n simp_all\n | inr hβ‚ˆ =>\n have h₉ := hβ‚„ j i hβ‚ˆ\n simp_all\n have h₆ : Set.Infinite (Set.range f) := Set.infinite_range_of_injective hβ‚…\n exact Set.not_infinite.mpr hβ‚‚ h₆\n \n obtain ⟨i, j, hβ‚„, hβ‚…βŸ© := h₃\n refine' ⟨i, j, hβ‚„, _⟩\n simp [f] at hβ‚… ⊒\n <;>\n (try simp_all [Prod.ext_iff]) <;>\n (try omega) <;>\n (try aesop)\n exact h₁\n \n have h_periodic : βˆƒ N c : β„•, c > 0 ∧ βˆ€ n β‰₯ N, u (n + c) = u n := by\n obtain ⟨i, j, hij, h_eq⟩ := h_main\n have h₁ : βˆ€ m : β„•, u (i + m) = u (j + m) := by\n intro m\n have hβ‚‚ : βˆ€ m : β„•, u (i + m) = u (j + m) := by\n intro m\n induction m using Nat.strong_induction_on with\n | h m ih =>\n match m with\n | 0 =>\n have h₃ := h_eq.1\n simp at h₃ ⊒\n <;> simp_all [add_assoc]\n | 1 =>\n have h₃ := h_eq.2.1\n simp at h₃ ⊒\n <;> simp_all [add_assoc]\n <;> ring_nf at *\n <;> omega\n | 2 =>\n have h₃ := h_eq.2.2.1\n simp at h₃ ⊒\n <;> simp_all [add_assoc]\n <;> ring_nf at *\n <;> omega\n | 3 =>\n have h₃ := h_eq.2.2.2\n simp at h₃ ⊒\n <;> simp_all [add_assoc]\n <;> ring_nf at *\n <;> omega\n | m + 4 =>\n have h₃ : i + (m + 4) β‰₯ 4 := by\n have hβ‚„ : i β‰₯ 0 := by linarith\n omega\n have hβ‚„ : u (i + (m + 4)) = ((u (i + (m + 4) - 1) + u (i + (m + 4) - 2) + u (i + (m + 4) - 3) * u (i + (m + 4) - 4)) : ℝ) / (u (i + (m + 4) - 1) * u (i + (m + 4) - 2) + u (i + (m + 4) - 3) + u (i + (m + 4) - 4)) := by\n have hβ‚… := hu (i + (m + 4)) (by omega)\n have h₆ := hβ‚….1\n norm_cast at h₆ ⊒\n <;> simp_all [add_assoc]\n <;> ring_nf at *\n <;> norm_num at *\n <;> linarith\n have hβ‚… : u (j + (m + 4)) = ((u (j + (m + 4) - 1) + u (j + (m + 4) - 2) + u (j + (m + 4) - 3) * u (j + (m + 4) - 4)) : ℝ) / (u (j + (m + 4) - 1) * u (j + (m + 4) - 2) + u (j + (m + 4) - 3) + u (j + (m + 4) - 4)) := by\n have h₆ := hu (j + (m + 4)) (by\n have h₇ : j β‰₯ i + 1 := by omega\n omega\n )\n have h₇ := h₆.1\n norm_cast at h₇ ⊒\n <;> simp_all [add_assoc]\n <;> ring_nf at *\n <;> norm_num at *\n <;> linarith\n have h₆ : (i + (m + 4) - 1 : β„•) = i + (m + 3) := by\n omega\n have h₇ : (i + (m + 4) - 2 : β„•) = i + (m + 2) := by\n omega\n have hβ‚ˆ : (i + (m + 4) - 3 : β„•) = i + (m + 1) := by\n omega\n have h₉ : (i + (m + 4) - 4 : β„•) = i + m := by\n omega\n have h₁₀ : (j + (m + 4) - 1 : β„•) = j + (m + 3) := by\n omega\n have h₁₁ : (j + (m + 4) - 2 : β„•) = j + (m + 2) := by\n omega\n have h₁₂ : (j + (m + 4) - 3 : β„•) = j + (m + 1) := by\n omega\n have h₁₃ : (j + (m + 4) - 4 : β„•) = j + m := by\n omega\n have h₁₄ : u (i + (m + 3)) = u (j + (m + 3)) := by\n have h₁₅ := ih (m + 3) (by omega)\n simp [add_assoc] at h₁₅ ⊒\n <;> omega\n have h₁₅ : u (i + (m + 2)) = u (j + (m + 2)) := by\n have h₁₆ := ih (m + 2) (by omega)\n simp [add_assoc] at h₁₆ ⊒\n <;> omega\n have h₁₆ : u (i + (m + 1)) = u (j + (m + 1)) := by\n have h₁₇ := ih (m + 1) (by omega)\n simp [add_assoc] at h₁₇ ⊒\n <;> omega\n have h₁₇ : u (i + m) = u (j + m) := by\n have hβ‚β‚ˆ := ih m (by omega)\n simp [add_assoc] at hβ‚β‚ˆ ⊒\n <;> omega\n have hβ‚β‚ˆ : (u (i + (m + 4)) : ℝ) = (u (j + (m + 4)) : ℝ) := by\n rw [hβ‚„, hβ‚…]\n simp [h₆, h₇, hβ‚ˆ, h₉, h₁₀, h₁₁, h₁₂, h₁₃] at *\n norm_cast at *\n <;>\n (try simp_all [h₁₄, h₁₅, h₁₆, h₁₇]) <;>\n (try ring_nf at *) <;>\n (try field_simp at *) <;>\n (try norm_cast at *) <;>\n (try linarith)\n norm_cast at hβ‚β‚ˆ ⊒\n <;>\n (try simp_all) <;>\n (try linarith)\n exact hβ‚‚ m\n have hβ‚‚ : βˆƒ N c : β„•, c > 0 ∧ βˆ€ n β‰₯ N, u (n + c) = u n := by\n use i, (j - i)\n have h₃ : j - i > 0 := by\n omega\n constructor\n Β· exact h₃\n Β· intro n hn\n have hβ‚„ : u (n + (j - i)) = u n := by\n have hβ‚… : u (i + (n - i)) = u (j + (n - i)) := by\n have h₆ := h₁ (n - i)\n simp [add_assoc] at h₆ ⊒\n <;> omega\n have h₆ : i + (n - i) = n := by\n omega\n have h₇ : j + (n - i) = n + (j - i) := by\n omega\n rw [h₆] at hβ‚…\n rw [h₇] at hβ‚…\n linarith\n exact hβ‚„\n exact hβ‚‚\n \n exact h_periodic"}
{"name": "putnam_1995_a3", "proof_length": 4085, "header": "import Mathlib\nimport Aesop\n\nset_option maxHeartbeats 0\n\nopen Filter Topology Real\n\n\n", "signature": "theorem putnam_1995_a3\n(relation : (Fin 9 β†’ β„€) β†’ (Fin 9 β†’ β„€) β†’ Prop)\n(digits_to_num : (Fin 9 β†’ β„€) β†’ β„€)\n(hdigits_to_num : digits_to_num = fun dig => βˆ‘ i : Fin 9, (dig i) * 10^i.1)\n(hrelation : βˆ€ d e : (Fin 9 β†’ β„€), relation d e ↔ (βˆ€ i : Fin 9, d i < 10 ∧ d i β‰₯ 0 ∧ e i < 10 ∧ e i β‰₯ 0) ∧ (βˆ€ i : Fin 9, 7 ∣ (digits_to_num (fun j : Fin 9 => if j = i then e j else d j))))\n: βˆ€ d e f : (Fin 9 β†’ β„€), ((relation d e) ∧ (relation e f)) β†’ (βˆ€ i : Fin 9, 7 ∣ d i - f i)", "src": "theorem putnam_1995_a3\n(relation : (Fin 9 β†’ β„€) β†’ (Fin 9 β†’ β„€) β†’ Prop)\n(digits_to_num : (Fin 9 β†’ β„€) β†’ β„€)\n(hdigits_to_num : digits_to_num = fun dig => βˆ‘ i : Fin 9, (dig i) * 10^i.1)\n(hrelation : βˆ€ d e : (Fin 9 β†’ β„€), relation d e ↔ (βˆ€ i : Fin 9, d i < 10 ∧ d i β‰₯ 0 ∧ e i < 10 ∧ e i β‰₯ 0) ∧ (βˆ€ i : Fin 9, 7 ∣ (digits_to_num (fun j : Fin 9 => if j = i then e j else d j))))\n: βˆ€ d e f : (Fin 9 β†’ β„€), ((relation d e) ∧ (relation e f)) β†’ (βˆ€ i : Fin 9, 7 ∣ d i - f i) := by \n have h_main : βˆ€ (d e f : (Fin 9 β†’ β„€)), ((relation d e) ∧ (relation e f)) β†’ (βˆ€ i : Fin 9, 7 ∣ d i - f i) := by\n intro d e f h\n have h₁ : relation d e := h.1\n have hβ‚‚ : relation e f := h.2\n have h₃ : βˆ€ (i : Fin 9), 7 ∣ (digits_to_num (fun j : Fin 9 => if j = i then e j else d j)) := by\n have hβ‚„ : (βˆ€ i : Fin 9, 7 ∣ (digits_to_num (fun j : Fin 9 => if j = i then e j else d j))) := (hrelation d e).mp h₁ |>.2\n exact hβ‚„\n have hβ‚„ : βˆ€ (i : Fin 9), 7 ∣ (digits_to_num (fun j : Fin 9 => if j = i then f j else e j)) := by\n have hβ‚… : (βˆ€ i : Fin 9, 7 ∣ (digits_to_num (fun j : Fin 9 => if j = i then f j else e j))) := (hrelation e f).mp hβ‚‚ |>.2\n exact hβ‚…\n \n have hβ‚… : βˆ€ (i : Fin 9), 7 ∣ (e i - d i) * (10 : β„€) ^ (i : β„•) + digits_to_num d := by\n intro i\n have h₆ : 7 ∣ (digits_to_num (fun j : Fin 9 => if j = i then e j else d j)) := h₃ i\n have h₇ : (digits_to_num (fun j : Fin 9 => if j = i then e j else d j)) = digits_to_num d + (e i - d i) * (10 : β„€) ^ (i : β„•) := by\n calc\n (digits_to_num (fun j : Fin 9 => if j = i then e j else d j)) = βˆ‘ j : Fin 9, (if j = i then e j else d j) * (10 : β„€) ^ (j : β„•) := by\n simp [hdigits_to_num]\n <;>\n rfl\n _ = βˆ‘ j : Fin 9, (if j = i then e j else d j) * (10 : β„€) ^ (j : β„•) := rfl\n _ = (βˆ‘ j : Fin 9, d j * (10 : β„€) ^ (j : β„•)) + (e i - d i) * (10 : β„€) ^ (i : β„•) := by\n calc\n (βˆ‘ j : Fin 9, (if j = i then e j else d j) * (10 : β„€) ^ (j : β„•)) = βˆ‘ j : Fin 9, (d j * (10 : β„€) ^ (j : β„•) + (if j = i then (e j - d j) else 0) * (10 : β„€) ^ (j : β„•)) := by\n apply Finset.sum_congr rfl\n intro j _\n by_cases h : j = i\n Β· simp [h]\n <;> ring\n Β· simp [h]\n <;> ring\n _ = (βˆ‘ j : Fin 9, d j * (10 : β„€) ^ (j : β„•)) + βˆ‘ j : Fin 9, (if j = i then (e j - d j) else 0) * (10 : β„€) ^ (j : β„•) := by\n rw [Finset.sum_add_distrib]\n _ = (βˆ‘ j : Fin 9, d j * (10 : β„€) ^ (j : β„•)) + (e i - d i) * (10 : β„€) ^ (i : β„•) := by\n have hβ‚ˆ : βˆ‘ j : Fin 9, (if j = i then (e j - d j) else 0) * (10 : β„€) ^ (j : β„•) = (e i - d i) * (10 : β„€) ^ (i : β„•) := by\n calc\n _ = βˆ‘ j : Fin 9, (if j = i then (e j - d j) else 0) * (10 : β„€) ^ (j : β„•) := rfl\n _ = (if i = i then (e i - d i) else 0) * (10 : β„€) ^ (i : β„•) := by\n \n simp [Finset.sum_ite_eq', Finset.mem_univ, i.is_lt]\n _ = (e i - d i) * (10 : β„€) ^ (i : β„•) := by simp\n rw [hβ‚ˆ]\n <;> simp [hdigits_to_num]\n <;>\n rfl\n _ = digits_to_num d + (e i - d i) * (10 : β„€) ^ (i : β„•) := by\n simp [hdigits_to_num]\n <;>\n rfl\n have hβ‚ˆ : 7 ∣ digits_to_num d + (e i - d i) * (10 : β„€) ^ (i : β„•) := by\n rw [h₇] at h₆\n exact h₆\n \n have h₉ : 7 ∣ (e i - d i) * (10 : β„€) ^ (i : β„•) + digits_to_num d := by\n \n have h₁₀ : (e i - d i) * (10 : β„€) ^ (i : β„•) + digits_to_num d = digits_to_num d + (e i - d i) * (10 : β„€) ^ (i : β„•) := by ring\n rw [h₁₀]\n exact hβ‚ˆ\n exact h₉\n \n have h₆ : βˆ€ (i : Fin 9), 7 ∣ (f i - e i) * (10 : β„€) ^ (i : β„•) + digits_to_num e := by\n intro i\n have h₇ : 7 ∣ (digits_to_num (fun j : Fin 9 => if j = i then f j else e j)) := hβ‚„ i\n have hβ‚ˆ : (digits_to_num (fun j : Fin 9 => if j = i then f j else e j)) = digits_to_num e + (f i - e i) * (10 : β„€) ^ (i : β„•) := by\n calc\n (digits_to_num (fun j : Fin 9 => if j = i then f j else e j)) = βˆ‘ j : Fin 9, (if j = i then f j else e j) * (10 : β„€) ^ (j : β„•) := by\n simp [hdigits_to_num]\n <;>\n rfl\n _ = βˆ‘ j : Fin 9, (if j = i then f j else e j) * (10 : β„€) ^ (j : β„•) := rfl\n _ = (βˆ‘ j : Fin 9, e j * (10 : β„€) ^ (j : β„•)) + (f i - e i) * (10 : β„€) ^ (i : β„•) := by\n calc\n (βˆ‘ j : Fin 9, (if j = i then f j else e j) * (10 : β„€) ^ (j : β„•)) = βˆ‘ j : Fin 9, (e j * (10 : β„€) ^ (j : β„•) + (if j = i then (f j - e j) else 0) * (10 : β„€) ^ (j : β„•)) := by\n apply Finset.sum_congr rfl\n intro j _\n by_cases h : j = i\n Β· simp [h]\n <;> ring\n Β· simp [h]\n <;> ring\n _ = (βˆ‘ j : Fin 9, e j * (10 : β„€) ^ (j : β„•)) + βˆ‘ j : Fin 9, (if j = i then (f j - e j) else 0) * (10 : β„€) ^ (j : β„•) := by\n rw [Finset.sum_add_distrib]\n _ = (βˆ‘ j : Fin 9, e j * (10 : β„€) ^ (j : β„•)) + (f i - e i) * (10 : β„€) ^ (i : β„•) := by\n have h₉ : βˆ‘ j : Fin 9, (if j = i then (f j - e j) else 0) * (10 : β„€) ^ (j : β„•) = (f i - e i) * (10 : β„€) ^ (i : β„•) := by\n calc\n _ = βˆ‘ j : Fin 9, (if j = i then (f j - e j) else 0) * (10 : β„€) ^ (j : β„•) := rfl\n _ = (if i = i then (f i - e i) else 0) * (10 : β„€) ^ (i : β„•) := by\n \n simp [Finset.sum_ite_eq', Finset.mem_univ, i.is_lt]\n _ = (f i - e i) * (10 : β„€) ^ (i : β„•) := by simp\n rw [h₉]\n <;> simp [hdigits_to_num]\n <;>\n rfl\n _ = digits_to_num e + (f i - e i) * (10 : β„€) ^ (i : β„•) := by\n simp [hdigits_to_num]\n <;>\n rfl\n have h₉ : 7 ∣ digits_to_num e + (f i - e i) * (10 : β„€) ^ (i : β„•) := by\n rw [hβ‚ˆ] at h₇\n exact h₇\n \n have h₁₀ : 7 ∣ (f i - e i) * (10 : β„€) ^ (i : β„•) + digits_to_num e := by\n \n have h₁₁ : (f i - e i) * (10 : β„€) ^ (i : β„•) + digits_to_num e = digits_to_num e + (f i - e i) * (10 : β„€) ^ (i : β„•) := by ring\n rw [h₁₁]\n exact h₉\n exact h₁₀\n \n have h₇ : 7 ∣ digits_to_num e + digits_to_num d := by\n have hβ‚ˆ : digits_to_num e = digits_to_num d + βˆ‘ i : Fin 9, (e i - d i) * (10 : β„€) ^ (i : β„•) := by\n calc\n digits_to_num e = βˆ‘ i : Fin 9, e i * (10 : β„€) ^ (i : β„•) := by simp [hdigits_to_num]\n _ = βˆ‘ i : Fin 9, (d i + (e i - d i)) * (10 : β„€) ^ (i : β„•) := by\n apply Finset.sum_congr rfl\n intro i _\n ring\n _ = βˆ‘ i : Fin 9, (d i * (10 : β„€) ^ (i : β„•) + (e i - d i) * (10 : β„€) ^ (i : β„•)) := by\n apply Finset.sum_congr rfl\n intro i _\n ring\n _ = (βˆ‘ i : Fin 9, d i * (10 : β„€) ^ (i : β„•)) + βˆ‘ i : Fin 9, (e i - d i) * (10 : β„€) ^ (i : β„•) := by\n rw [Finset.sum_add_distrib]\n _ = digits_to_num d + βˆ‘ i : Fin 9, (e i - d i) * (10 : β„€) ^ (i : β„•) := by\n simp [hdigits_to_num]\n <;>\n rfl\n have h₉ : βˆ€ i : Fin 9, 7 ∣ (e i - d i) * (10 : β„€) ^ (i : β„•) + digits_to_num d := hβ‚…\n have h₁₀ : 7 ∣ βˆ‘ i : Fin 9, ((e i - d i) * (10 : β„€) ^ (i : β„•) + digits_to_num d) := by\n apply Finset.dvd_sum\n intro i _\n exact h₉ i\n have h₁₁ : βˆ‘ i : Fin 9, ((e i - d i) * (10 : β„€) ^ (i : β„•) + digits_to_num d) = βˆ‘ i : Fin 9, (e i - d i) * (10 : β„€) ^ (i : β„•) + 9 * digits_to_num d := by\n calc\n βˆ‘ i : Fin 9, ((e i - d i) * (10 : β„€) ^ (i : β„•) + digits_to_num d) = βˆ‘ i : Fin 9, (e i - d i) * (10 : β„€) ^ (i : β„•) + βˆ‘ i : Fin 9, digits_to_num d := by\n rw [Finset.sum_add_distrib]\n _ = βˆ‘ i : Fin 9, (e i - d i) * (10 : β„€) ^ (i : β„•) + 9 * digits_to_num d := by\n simp [Finset.sum_const, Finset.card_fin]\n <;> ring\n <;> norm_num\n have h₁₂ : 7 ∣ βˆ‘ i : Fin 9, (e i - d i) * (10 : β„€) ^ (i : β„•) + 9 * digits_to_num d := by\n rw [h₁₁] at h₁₀\n exact h₁₀\n have h₁₃ : 7 ∣ digits_to_num e + digits_to_num d := by\n have h₁₄ : digits_to_num e + digits_to_num d = 2 * digits_to_num d + βˆ‘ i : Fin 9, (e i - d i) * (10 : β„€) ^ (i : β„•) := by\n linarith\n rw [h₁₄]\n have h₁₅ : 7 ∣ 2 * digits_to_num d + βˆ‘ i : Fin 9, (e i - d i) * (10 : β„€) ^ (i : β„•) := by\n have h₁₆ : 7 ∣ βˆ‘ i : Fin 9, (e i - d i) * (10 : β„€) ^ (i : β„•) + 9 * digits_to_num d := h₁₂\n have h₁₇ : 7 ∣ 2 * digits_to_num d + βˆ‘ i : Fin 9, (e i - d i) * (10 : β„€) ^ (i : β„•) := by\n \n have hβ‚β‚ˆ : (βˆ‘ i : Fin 9, (e i - d i) * (10 : β„€) ^ (i : β„•) + 9 * digits_to_num d) = (βˆ‘ i : Fin 9, (e i - d i) * (10 : β„€) ^ (i : β„•)) + 9 * digits_to_num d := by ring\n rw [hβ‚β‚ˆ] at h₁₆\n \n \n \n \n \n \n have h₁₉ : 7 ∣ (βˆ‘ i : Fin 9, (e i - d i) * (10 : β„€) ^ (i : β„•)) + 2 * digits_to_num d := by\n \n \n \n have hβ‚‚β‚€ : 7 ∣ (βˆ‘ i : Fin 9, (e i - d i) * (10 : β„€) ^ (i : β„•)) + 9 * digits_to_num d := h₁₆\n have h₂₁ : 7 ∣ 7 * digits_to_num d := by\n use digits_to_num d\n <;> ring\n have hβ‚‚β‚‚ : 7 ∣ (βˆ‘ i : Fin 9, (e i - d i) * (10 : β„€) ^ (i : β„•)) + 2 * digits_to_num d := by\n \n have h₂₃ : (βˆ‘ i : Fin 9, (e i - d i) * (10 : β„€) ^ (i : β„•)) + 2 * digits_to_num d = ((βˆ‘ i : Fin 9, (e i - d i) * (10 : β„€) ^ (i : β„•)) + 9 * digits_to_num d) - 7 * digits_to_num d := by ring\n rw [h₂₃]\n exact dvd_sub hβ‚‚β‚€ h₂₁\n exact hβ‚‚β‚‚\n \n have hβ‚‚β‚€ : 7 ∣ 2 * digits_to_num d + βˆ‘ i : Fin 9, (e i - d i) * (10 : β„€) ^ (i : β„•) := by\n \n have h₂₁ : 2 * digits_to_num d + βˆ‘ i : Fin 9, (e i - d i) * (10 : β„€) ^ (i : β„•) = (βˆ‘ i : Fin 9, (e i - d i) * (10 : β„€) ^ (i : β„•)) + 2 * digits_to_num d := by ring\n rw [h₂₁]\n exact h₁₉\n exact hβ‚‚β‚€\n exact h₁₇\n exact h₁₅\n exact h₁₃\n \n have hβ‚ˆ : βˆ€ (i : Fin 9), 7 ∣ (f i - d i) * (10 : β„€) ^ (i : β„•) := by\n intro i\n have h₉ : 7 ∣ (f i - e i) * (10 : β„€) ^ (i : β„•) + digits_to_num e := h₆ i\n have h₁₀ : 7 ∣ (e i - d i) * (10 : β„€) ^ (i : β„•) + digits_to_num d := hβ‚… i\n have h₁₁ : 7 ∣ digits_to_num e + digits_to_num d := h₇\n \n have h₁₂ : 7 ∣ (f i - e i) * (10 : β„€) ^ (i : β„•) - digits_to_num d := by\n \n \n have h₁₃ : 7 ∣ (f i - e i) * (10 : β„€) ^ (i : β„•) + digits_to_num e := h₆ i\n have h₁₄ : 7 ∣ digits_to_num e + digits_to_num d := h₇\n \n have h₁₅ : 7 ∣ ((f i - e i) * (10 : β„€) ^ (i : β„•) + digits_to_num e) - (digits_to_num e + digits_to_num d) := by\n exact dvd_sub h₁₃ h₁₄\n \n have h₁₆ : ((f i - e i) * (10 : β„€) ^ (i : β„•) + digits_to_num e) - (digits_to_num e + digits_to_num d) = (f i - e i) * (10 : β„€) ^ (i : β„•) - digits_to_num d := by\n ring\n rw [h₁₆] at h₁₅\n exact h₁₅\n \n have h₁₃ : 7 ∣ (f i - d i) * (10 : β„€) ^ (i : β„•) := by\n have h₁₄ : 7 ∣ (f i - e i) * (10 : β„€) ^ (i : β„•) - digits_to_num d := h₁₂\n have h₁₅ : 7 ∣ (e i - d i) * (10 : β„€) ^ (i : β„•) + digits_to_num d := hβ‚… i\n \n have h₁₆ : 7 ∣ ((f i - e i) * (10 : β„€) ^ (i : β„•) - digits_to_num d) + ((e i - d i) * (10 : β„€) ^ (i : β„•) + digits_to_num d) := by\n exact dvd_add h₁₄ h₁₅\n \n have h₁₇ : ((f i - e i) * (10 : β„€) ^ (i : β„•) - digits_to_num d) + ((e i - d i) * (10 : β„€) ^ (i : β„•) + digits_to_num d) = (f i - d i) * (10 : β„€) ^ (i : β„•) := by\n ring\n rw [h₁₇] at h₁₆\n exact h₁₆\n exact h₁₃\n \n have h₉ : βˆ€ (i : Fin 9), 7 ∣ d i - f i := by\n intro i\n have h₁₀ : 7 ∣ (f i - d i) * (10 : β„€) ^ (i : β„•) := hβ‚ˆ i\n have h₁₁ : 7 ∣ (f i - d i) := by\n \n have h₁₂ : (7 : β„€) ∣ (f i - d i) * (10 : β„€) ^ (i : β„•) := h₁₀\n \n have h₁₃ : (7 : β„•).Prime := by decide\n have h₁₄ : Β¬(7 : β„€) ∣ (10 : β„€) ^ (i : β„•) := by\n \n intro h\n have h₁₅ : (7 : β„•) ∣ (10 : β„•) ^ (i : β„•) := by\n norm_cast at h ⊒\n <;> simpa [Int.coe_nat_dvd_left] using h\n have h₁₆ : (7 : β„•) ∣ 10 := by\n \n exact Nat.Prime.dvd_of_dvd_pow h₁₃ h₁₅\n norm_num at h₁₆\n <;> contradiction\n \n have h₁₅ : (7 : β„€) ∣ (f i - d i) := by\n \n have h₁₆ : (7 : β„€) ∣ (f i - d i) * (10 : β„€) ^ (i : β„•) := h₁₂\n have h₁₇ : Β¬(7 : β„€) ∣ (10 : β„€) ^ (i : β„•) := h₁₄\n \n have hβ‚β‚ˆ : (7 : β„€) ∣ (f i - d i) := by\n \n have h₁₉ : (7 : β„€) ∣ (f i - d i) * (10 : β„€) ^ (i : β„•) := h₁₂\n have hβ‚‚β‚€ : (7 : β„•).Prime := by decide\n have h₂₁ : (7 : β„€) ∣ (f i - d i) ∨ (7 : β„€) ∣ (10 : β„€) ^ (i : β„•) := by\n \n have hβ‚‚β‚‚ : (7 : β„€) ∣ (f i - d i) * (10 : β„€) ^ (i : β„•) := h₁₂\n have h₂₃ : (7 : β„€) ∣ (f i - d i) ∨ (7 : β„€) ∣ (10 : β„€) ^ (i : β„•) := by\n \n apply (Int.prime_iff_natAbs_prime.mpr (by decide)).dvd_mul.mp\n exact hβ‚‚β‚‚\n exact h₂₃\n cases h₂₁ with\n | inl h₂₁ =>\n exact h₂₁\n | inr h₂₁ =>\n exfalso\n exact h₁₄ h₂₁\n exact hβ‚β‚ˆ\n exact h₁₅\n \n have h₁₂ : 7 ∣ d i - f i := by\n have h₁₃ : 7 ∣ (f i - d i) := h₁₁\n have h₁₄ : 7 ∣ -(f i - d i) := by\n exact dvd_neg.mpr h₁₃\n have h₁₅ : -(f i - d i) = d i - f i := by ring\n rw [h₁₅] at h₁₄\n exact h₁₄\n exact h₁₂\n \n intro i\n have h₁₀ : 7 ∣ d i - f i := h₉ i\n exact h₁₀\n exact h_main"}
{"name": "putnam_1988_a2", "proof_length": 2161, "header": "import Mathlib\nimport Aesop\n\nset_option maxHeartbeats 0\n\nopen Set\n\n\n\n", "signature": "theorem putnam_1988_a2\n (f : ℝ β†’ ℝ)\n (hf : f = fun x ↦ Real.exp (x ^ 2)) :\n ((True) : Prop ) ↔\n (βˆƒ a b : ℝ,\n a < b ∧\n βˆƒ g : ℝ β†’ ℝ,\n (βˆƒ x ∈ Ioo a b, g x β‰  0) ∧\n DifferentiableOn ℝ g (Ioo a b) ∧\n βˆ€ x ∈ Ioo a b, deriv (fun y ↦ f y * g y) x = (deriv f x) * (deriv g x))", "src": "theorem putnam_1988_a2\n (f : ℝ β†’ ℝ)\n (hf : f = fun x ↦ Real.exp (x ^ 2)) :\n ((True) : Prop ) ↔\n (βˆƒ a b : ℝ,\n a < b ∧\n βˆƒ g : ℝ β†’ ℝ,\n (βˆƒ x ∈ Ioo a b, g x β‰  0) ∧\n DifferentiableOn ℝ g (Ioo a b) ∧\n βˆ€ x ∈ Ioo a b, deriv (fun y ↦ f y * g y) x = (deriv f x) * (deriv g x)) :=\n by \n have h_main : (βˆƒ (a b : ℝ), a < b ∧ βˆƒ (g : ℝ β†’ ℝ), (βˆƒ x ∈ Set.Ioo a b, g x β‰  0) ∧ DifferentiableOn ℝ g (Set.Ioo a b) ∧ βˆ€ x ∈ Set.Ioo a b, deriv (fun y ↦ f y * g y) x = (deriv f x) * (deriv g x)) := by\n use 1, 2\n constructor\n Β· norm_num\n Β· \n use fun x => Real.exp x * Real.sqrt (2 * x - 1)\n constructor\n Β· \n use 3 / 2\n constructor\n Β· \n norm_num [Set.mem_Ioo]\n Β· \n have h₁ : Real.exp (3 / 2 : ℝ) > 0 := Real.exp_pos _\n have hβ‚‚ : Real.sqrt (2 * (3 / 2 : ℝ) - 1) > 0 := by\n apply Real.sqrt_pos_of_pos\n norm_num\n have h₃ : Real.exp (3 / 2 : ℝ) * Real.sqrt (2 * (3 / 2 : ℝ) - 1) > 0 := by positivity\n intro hβ‚„\n linarith\n Β· constructor\n Β· \n have h₁ : DifferentiableOn ℝ (fun x : ℝ => Real.exp x * Real.sqrt (2 * x - 1)) (Set.Ioo 1 2) := by\n apply DifferentiableOn.mul\n Β· exact DifferentiableOn.exp (differentiableOn_id)\n Β· apply DifferentiableOn.sqrt\n Β· \n have hβ‚‚ : DifferentiableOn ℝ (fun x : ℝ => (2 : ℝ) * x - 1) (Set.Ioo 1 2) := by\n apply DifferentiableOn.sub\n Β· apply DifferentiableOn.const_mul\n exact differentiableOn_id\n Β· exact differentiableOn_const _\n exact hβ‚‚\n Β· \n intro x hx\n have h₃ : 1 < x := hx.1\n have hβ‚„ : x < 2 := hx.2\n have hβ‚… : (2 : ℝ) * x - 1 > 0 := by linarith\n linarith\n exact h₁\n Β· \n intro x hx\n have h₁ : x ∈ Set.Ioo 1 2 := hx\n have hβ‚‚ : 1 < x := h₁.1\n have h₃ : x < 2 := h₁.2\n have hβ‚„ : (2 : ℝ) * x - 1 > 0 := by linarith\n have hβ‚… : Real.sqrt (2 * x - 1) > 0 := Real.sqrt_pos.mpr hβ‚„\n have h₆ : HasDerivAt (fun x : ℝ => Real.exp x * Real.sqrt (2 * x - 1)) (Real.exp x * Real.sqrt (2 * x - 1) + Real.exp x / Real.sqrt (2 * x - 1)) x := by\n \n have h₇ : HasDerivAt (fun x : ℝ => Real.exp x) (Real.exp x) x := Real.hasDerivAt_exp x\n have hβ‚ˆ : HasDerivAt (fun x : ℝ => Real.sqrt (2 * x - 1)) (1 / Real.sqrt (2 * x - 1)) x := by\n have h₉ : HasDerivAt (fun x : ℝ => (2 : ℝ) * x - 1) 2 x := by\n simpa using (hasDerivAt_id x).const_mul 2 |>.sub_const 1\n have h₁₀ : HasDerivAt (fun x : ℝ => Real.sqrt (2 * x - 1)) (1 / Real.sqrt (2 * x - 1)) x := by\n convert HasDerivAt.sqrt h₉ (by positivity) using 1 <;>\n field_simp [hβ‚„.ne'] <;>\n ring_nf <;>\n field_simp [hβ‚„.ne'] <;>\n ring\n exact h₁₀\n have h₁₁ : HasDerivAt (fun x : ℝ => Real.exp x * Real.sqrt (2 * x - 1)) (Real.exp x * Real.sqrt (2 * x - 1) + Real.exp x / Real.sqrt (2 * x - 1)) x := by\n convert h₇.mul hβ‚ˆ using 1 <;>\n field_simp [hβ‚„.ne'] <;>\n ring_nf <;>\n field_simp [hβ‚„.ne'] <;>\n ring\n exact h₁₁\n have h₇ : deriv (fun x : ℝ => Real.exp x * Real.sqrt (2 * x - 1)) x = Real.exp x * Real.sqrt (2 * x - 1) + Real.exp x / Real.sqrt (2 * x - 1) := by\n apply HasDerivAt.deriv\n exact h₆\n \n have hβ‚ˆ : f = fun x => Real.exp (x ^ 2) := hf\n have h₉ : deriv f x = 2 * x * Real.exp (x ^ 2) := by\n rw [hβ‚ˆ]\n \n have h₁₀ : HasDerivAt (fun x : ℝ => Real.exp (x ^ 2)) (2 * x * Real.exp (x ^ 2)) x := by\n have h₁₁ : HasDerivAt (fun x : ℝ => x ^ 2) (2 * x) x := by\n simpa using (hasDerivAt_pow 2 x)\n have h₁₂ : HasDerivAt (fun x : ℝ => Real.exp (x ^ 2)) (Real.exp (x ^ 2) * (2 * x)) x := by\n apply HasDerivAt.exp\n exact h₁₁\n convert h₁₂ using 1 <;> ring\n have h₁₃ : deriv (fun x : ℝ => Real.exp (x ^ 2)) x = 2 * x * Real.exp (x ^ 2) := by\n apply HasDerivAt.deriv\n exact h₁₀\n exact h₁₃\n have h₁₀ : deriv (fun y : ℝ => f y * (Real.exp y * Real.sqrt (2 * y - 1))) x = (deriv f x) * (deriv (fun y : ℝ => Real.exp y * Real.sqrt (2 * y - 1)) x) := by\n \n have h₁₁ : deriv (fun y : ℝ => f y * (Real.exp y * Real.sqrt (2 * y - 1))) x = deriv f x * (Real.exp x * Real.sqrt (2 * x - 1)) + f x * (Real.exp x * Real.sqrt (2 * x - 1) + Real.exp x / Real.sqrt (2 * x - 1)) := by\n \n have h₁₂ : HasDerivAt (fun y : ℝ => f y * (Real.exp y * Real.sqrt (2 * y - 1))) (deriv f x * (Real.exp x * Real.sqrt (2 * x - 1)) + f x * (Real.exp x * Real.sqrt (2 * x - 1) + Real.exp x / Real.sqrt (2 * x - 1))) x := by\n have h₁₃ : HasDerivAt f (deriv f x) x := by\n have h₁₄ : DifferentiableAt ℝ f x := by\n rw [hβ‚ˆ]\n apply DifferentiableAt.exp\n apply DifferentiableAt.pow\n exact differentiableAt_id\n exact h₁₄.hasDerivAt\n have h₁₄ : HasDerivAt (fun y : ℝ => Real.exp y * Real.sqrt (2 * y - 1)) (Real.exp x * Real.sqrt (2 * x - 1) + Real.exp x / Real.sqrt (2 * x - 1)) x := by\n convert h₆ using 1\n have h₁₅ : HasDerivAt (fun y : ℝ => f y * (Real.exp y * Real.sqrt (2 * y - 1))) (deriv f x * (Real.exp x * Real.sqrt (2 * x - 1)) + f x * (Real.exp x * Real.sqrt (2 * x - 1) + Real.exp x / Real.sqrt (2 * x - 1))) x := by\n convert h₁₃.mul h₁₄ using 1 <;>\n simp [h₉, hβ‚ˆ, mul_assoc]\n <;>\n ring_nf\n <;>\n field_simp [hβ‚„.ne']\n <;>\n ring\n exact h₁₅\n have h₁₆ : deriv (fun y : ℝ => f y * (Real.exp y * Real.sqrt (2 * y - 1))) x = deriv f x * (Real.exp x * Real.sqrt (2 * x - 1)) + f x * (Real.exp x * Real.sqrt (2 * x - 1) + Real.exp x / Real.sqrt (2 * x - 1)) := by\n apply HasDerivAt.deriv\n exact h₁₂\n exact h₁₆\n have h₁₇ : deriv f x * (Real.exp x * Real.sqrt (2 * x - 1)) + f x * (Real.exp x * Real.sqrt (2 * x - 1) + Real.exp x / Real.sqrt (2 * x - 1)) = (deriv f x) * (deriv (fun y : ℝ => Real.exp y * Real.sqrt (2 * y - 1)) x) := by\n \n have hβ‚β‚ˆ : deriv f x = 2 * x * Real.exp (x ^ 2) := h₉\n have h₁₉ : f x = Real.exp (x ^ 2) := by\n rw [hβ‚ˆ]\n <;> simp\n have hβ‚‚β‚€ : deriv (fun y : ℝ => Real.exp y * Real.sqrt (2 * y - 1)) x = Real.exp x * Real.sqrt (2 * x - 1) + Real.exp x / Real.sqrt (2 * x - 1) := h₇\n have h₂₁ : 2 * x * (Real.exp x * Real.sqrt (2 * x - 1)) + (Real.exp x * Real.sqrt (2 * x - 1) + Real.exp x / Real.sqrt (2 * x - 1)) = 2 * x * (Real.exp x * Real.sqrt (2 * x - 1) + Real.exp x / Real.sqrt (2 * x - 1)) := by\n \n have hβ‚‚β‚‚ : Real.exp x > 0 := Real.exp_pos x\n have h₂₃ : Real.sqrt (2 * x - 1) > 0 := Real.sqrt_pos.mpr (by linarith)\n field_simp [h₂₃.ne', hβ‚‚β‚‚.ne']\n <;>\n nlinarith [Real.sq_sqrt (show 0 ≀ 2 * x - 1 by linarith)]\n calc\n deriv f x * (Real.exp x * Real.sqrt (2 * x - 1)) + f x * (Real.exp x * Real.sqrt (2 * x - 1) + Real.exp x / Real.sqrt (2 * x - 1)) = (2 * x * Real.exp (x ^ 2)) * (Real.exp x * Real.sqrt (2 * x - 1)) + Real.exp (x ^ 2) * (Real.exp x * Real.sqrt (2 * x - 1) + Real.exp x / Real.sqrt (2 * x - 1)) := by\n rw [hβ‚β‚ˆ, h₁₉]\n _ = Real.exp (x ^ 2) * (2 * x * (Real.exp x * Real.sqrt (2 * x - 1)) + (Real.exp x * Real.sqrt (2 * x - 1) + Real.exp x / Real.sqrt (2 * x - 1))) := by\n ring_nf\n <;>\n field_simp [Real.exp_ne_zero]\n <;>\n ring_nf\n _ = Real.exp (x ^ 2) * (2 * x * (Real.exp x * Real.sqrt (2 * x - 1) + Real.exp x / Real.sqrt (2 * x - 1))) := by\n rw [h₂₁]\n <;>\n ring_nf\n _ = (2 * x * Real.exp (x ^ 2)) * (Real.exp x * Real.sqrt (2 * x - 1) + Real.exp x / Real.sqrt (2 * x - 1)) := by\n ring_nf\n _ = (deriv f x) * (deriv (fun y : ℝ => Real.exp y * Real.sqrt (2 * y - 1)) x) := by\n rw [hβ‚β‚ˆ, hβ‚‚β‚€]\n <;>\n ring_nf\n <;>\n field_simp [Real.exp_ne_zero]\n <;>\n ring_nf\n rw [h₁₁]\n rw [h₁₇]\n \n have h₁₁ : deriv (fun y : ℝ => f y * (Real.exp y * Real.sqrt (2 * y - 1))) x = (deriv f x) * (deriv (fun y : ℝ => Real.exp y * Real.sqrt (2 * y - 1)) x) := h₁₀\n simpa [hβ‚ˆ] using h₁₁\n \n have h_final : ((True) : Prop ) ↔ (βˆƒ a b : ℝ, a < b ∧ βˆƒ g : ℝ β†’ ℝ, (βˆƒ x ∈ Set.Ioo a b, g x β‰  0) ∧ DifferentiableOn ℝ g (Set.Ioo a b) ∧ βˆ€ x ∈ Set.Ioo a b, deriv (fun y ↦ f y * g y) x = (deriv f x) * (deriv g x)) := by\n constructor\n Β· intro _\n exact h_main\n Β· intro h\n trivial\n \n exact h_final"}
{"name": "putnam_2001_b1", "proof_length": 3178, "header": "import Mathlib\nimport Aesop\n\nset_option maxHeartbeats 0\n\nopen Topology Filter Polynomial Set\n\n\n", "signature": "theorem putnam_2001_b1\n (n : β„•)\n (hn : n > 0) (hn' : Even n)\n (nums : Fin n β†’ Fin n β†’ β„€)\n (colors : Fin n β†’ Fin n β†’ Fin 2)\n (hnums : βˆ€ k l, nums k l = k * n + l + 1)\n (hcolorsrows : βˆ€ k, (βˆ‘ l, (if (colors k l = 0) then 1 else 0)) = n / 2)\n (hcolorscols : βˆ€ l, (βˆ‘ k, (if (colors k l = 0) then 1 else 0)) = n / 2) :\n (βˆ‘ k, βˆ‘ l, (if (colors k l = 0) then (nums k l) else 0)) = (βˆ‘ k, βˆ‘ l, (if (colors k l = 1) then (nums k l) else 0))", "src": "theorem putnam_2001_b1\n (n : β„•)\n (hn : n > 0) (hn' : Even n)\n (nums : Fin n β†’ Fin n β†’ β„€)\n (colors : Fin n β†’ Fin n β†’ Fin 2)\n (hnums : βˆ€ k l, nums k l = k * n + l + 1)\n (hcolorsrows : βˆ€ k, (βˆ‘ l, (if (colors k l = 0) then 1 else 0)) = n / 2)\n (hcolorscols : βˆ€ l, (βˆ‘ k, (if (colors k l = 0) then 1 else 0)) = n / 2) :\n (βˆ‘ k, βˆ‘ l, (if (colors k l = 0) then (nums k l) else 0)) = (βˆ‘ k, βˆ‘ l, (if (colors k l = 1) then (nums k l) else 0)) := by \n have hrow_sum_zero : βˆ€ (k : Fin n), (βˆ‘ l : Fin n, (2 * (if colors k l = 0 then (1 : β„€) else 0) - 1)) = 0 := by\n intro k\n have h1 : (βˆ‘ l : Fin n, (if colors k l = 0 then (1 : β„€) else 0)) = n / 2 := by\n norm_cast at hcolorsrows ⊒\n simpa using hcolorsrows k\n have h2 : (βˆ‘ l : Fin n, (2 * (if colors k l = 0 then (1 : β„€) else 0) - 1)) = 0 := by\n calc\n (βˆ‘ l : Fin n, (2 * (if colors k l = 0 then (1 : β„€) else 0) - 1)) = (βˆ‘ l : Fin n, (2 * (if colors k l = 0 then (1 : β„€) else 0))) - βˆ‘ l : Fin n, (1 : β„€) := by\n rw [Finset.sum_sub_distrib]\n _ = 2 * (βˆ‘ l : Fin n, (if colors k l = 0 then (1 : β„€) else 0)) - βˆ‘ l : Fin n, (1 : β„€) := by\n rw [Finset.mul_sum]\n _ = 2 * (n / 2 : β„€) - n := by\n rw [h1]\n simp [Finset.sum_const, Finset.card_fin]\n <;> norm_cast\n <;> simp [nsmul_eq_mul]\n <;> ring_nf\n <;> simp_all [Nat.cast_inj]\n <;> omega\n _ = 0 := by\n have h3 : (n : β„€) % 2 = 0 := by\n have h4 : Even n := hn'\n rw [even_iff_two_dvd] at h4\n obtain ⟨m, hm⟩ := h4\n norm_cast at hm ⊒\n omega\n have h4 : (n : β„€) / 2 * 2 = n := by\n have h5 : (n : β„€) % 2 = 0 := h3\n have h6 : (n : β„€) = 2 * ((n : β„€) / 2) := by\n omega\n linarith\n ring_nf at *\n <;> omega\n exact h2\n \n have hcol_sum_zero : βˆ€ (l : Fin n), (βˆ‘ k : Fin n, (2 * (if colors k l = 0 then (1 : β„€) else 0) - 1)) = 0 := by\n intro l\n have h1 : (βˆ‘ k : Fin n, (if colors k l = 0 then (1 : β„€) else 0)) = n / 2 := by\n norm_cast at hcolorscols ⊒\n simpa using hcolorscols l\n have h2 : (βˆ‘ k : Fin n, (2 * (if colors k l = 0 then (1 : β„€) else 0) - 1)) = 0 := by\n calc\n (βˆ‘ k : Fin n, (2 * (if colors k l = 0 then (1 : β„€) else 0) - 1)) = (βˆ‘ k : Fin n, (2 * (if colors k l = 0 then (1 : β„€) else 0))) - βˆ‘ k : Fin n, (1 : β„€) := by\n rw [Finset.sum_sub_distrib]\n _ = 2 * (βˆ‘ k : Fin n, (if colors k l = 0 then (1 : β„€) else 0)) - βˆ‘ k : Fin n, (1 : β„€) := by\n rw [Finset.mul_sum]\n _ = 2 * (n / 2 : β„€) - n := by\n rw [h1]\n simp [Finset.sum_const, Finset.card_fin]\n <;> norm_cast\n <;> simp [nsmul_eq_mul]\n <;> ring_nf\n <;> simp_all [Nat.cast_inj]\n <;> omega\n _ = 0 := by\n have h3 : (n : β„€) % 2 = 0 := by\n have h4 : Even n := hn'\n rw [even_iff_two_dvd] at h4\n obtain ⟨m, hm⟩ := h4\n norm_cast at hm ⊒\n omega\n have h4 : (n : β„€) / 2 * 2 = n := by\n have h5 : (n : β„€) % 2 = 0 := h3\n have h6 : (n : β„€) = 2 * ((n : β„€) / 2) := by\n omega\n linarith\n ring_nf at *\n <;> omega\n exact h2\n \n have hsum_diff : (βˆ‘ k : Fin n, βˆ‘ l : Fin n, (if colors k l = 0 then (nums k l : β„€) else 0)) - (βˆ‘ k : Fin n, βˆ‘ l : Fin n, (if colors k l = 1 then (nums k l : β„€) else 0)) = βˆ‘ k : Fin n, βˆ‘ l : Fin n, (2 * (if colors k l = 0 then (1 : β„€) else 0) - 1) * (nums k l : β„€) := by\n have h₁ : (βˆ‘ k : Fin n, βˆ‘ l : Fin n, (if colors k l = 0 then (nums k l : β„€) else 0)) - (βˆ‘ k : Fin n, βˆ‘ l : Fin n, (if colors k l = 1 then (nums k l : β„€) else 0)) = βˆ‘ k : Fin n, βˆ‘ l : Fin n, ((if colors k l = 0 then (nums k l : β„€) else 0) - (if colors k l = 1 then (nums k l : β„€) else 0)) := by\n simp [Finset.sum_sub_distrib, Finset.sum_add_distrib]\n <;>\n simp_all [Finset.sum_sub_distrib]\n <;>\n rfl\n have hβ‚‚ : βˆ€ (k : Fin n) (l : Fin n), ((if colors k l = 0 then (nums k l : β„€) else 0) - (if colors k l = 1 then (nums k l : β„€) else 0)) = (2 * (if colors k l = 0 then (1 : β„€) else 0) - 1) * (nums k l : β„€) := by\n intro k l\n have h₃ : colors k l = 0 ∨ colors k l = 1 := by\n have hβ‚„ : colors k l = 0 ∨ colors k l = 1 := by\n have hβ‚… : colors k l = 0 ∨ colors k l = 1 := by\n have : colors k l = 0 ∨ colors k l = 1 := by\n have h₆ : (colors k l : β„•) < 2 := by\n have : (colors k l : β„•) < 2 := by\n simp [Fin.is_lt]\n exact this\n omega\n exact this\n exact hβ‚…\n exact hβ‚„\n rcases h₃ with (h₃ | h₃)\n Β· \n simp [h₃]\n <;>\n (try norm_num) <;>\n (try ring_nf) <;>\n (try simp_all)\n <;>\n (try omega)\n Β· \n simp [h₃]\n <;>\n (try norm_num) <;>\n (try ring_nf) <;>\n (try simp_all)\n <;>\n (try omega)\n calc\n (βˆ‘ k : Fin n, βˆ‘ l : Fin n, (if colors k l = 0 then (nums k l : β„€) else 0)) - (βˆ‘ k : Fin n, βˆ‘ l : Fin n, (if colors k l = 1 then (nums k l : β„€) else 0)) = βˆ‘ k : Fin n, βˆ‘ l : Fin n, ((if colors k l = 0 then (nums k l : β„€) else 0) - (if colors k l = 1 then (nums k l : β„€) else 0)) := by rw [h₁]\n _ = βˆ‘ k : Fin n, βˆ‘ l : Fin n, (2 * (if colors k l = 0 then (1 : β„€) else 0) - 1) * (nums k l : β„€) := by\n apply Finset.sum_congr rfl\n intro k _\n apply Finset.sum_congr rfl\n intro l _\n rw [hβ‚‚ k l]\n \n have hsum_split_zero : (βˆ‘ k : Fin n, βˆ‘ l : Fin n, (2 * (if colors k l = 0 then (1 : β„€) else 0) - 1) * (nums k l : β„€)) = 0 := by\n have h₁ : (βˆ‘ k : Fin n, βˆ‘ l : Fin n, (2 * (if colors k l = 0 then (1 : β„€) else 0) - 1) * (nums k l : β„€)) = βˆ‘ k : Fin n, βˆ‘ l : Fin n, (2 * (if colors k l = 0 then (1 : β„€) else 0) - 1) * ((k : β„€) * n + (l : β„€) + 1) := by\n apply Finset.sum_congr rfl\n intro k _\n apply Finset.sum_congr rfl\n intro l _\n rw [hnums]\n <;> simp [Fin.val_mk]\n <;> norm_cast\n <;> ring_nf\n rw [h₁]\n have hβ‚‚ : (βˆ‘ k : Fin n, βˆ‘ l : Fin n, (2 * (if colors k l = 0 then (1 : β„€) else 0) - 1) * ((k : β„€) * n + (l : β„€) + 1)) = (βˆ‘ k : Fin n, βˆ‘ l : Fin n, (2 * (if colors k l = 0 then (1 : β„€) else 0) - 1) * ((k : β„€) * n)) + (βˆ‘ k : Fin n, βˆ‘ l : Fin n, (2 * (if colors k l = 0 then (1 : β„€) else 0) - 1) * ((l : β„€) + 1)) := by\n calc\n (βˆ‘ k : Fin n, βˆ‘ l : Fin n, (2 * (if colors k l = 0 then (1 : β„€) else 0) - 1) * ((k : β„€) * n + (l : β„€) + 1)) = βˆ‘ k : Fin n, βˆ‘ l : Fin n, ((2 * (if colors k l = 0 then (1 : β„€) else 0) - 1) * ((k : β„€) * n) + (2 * (if colors k l = 0 then (1 : β„€) else 0) - 1) * ((l : β„€) + 1)) := by\n apply Finset.sum_congr rfl\n intro k _\n apply Finset.sum_congr rfl\n intro l _\n ring_nf\n _ = (βˆ‘ k : Fin n, βˆ‘ l : Fin n, (2 * (if colors k l = 0 then (1 : β„€) else 0) - 1) * ((k : β„€) * n)) + (βˆ‘ k : Fin n, βˆ‘ l : Fin n, (2 * (if colors k l = 0 then (1 : β„€) else 0) - 1) * ((l : β„€) + 1)) := by\n simp [Finset.sum_add_distrib]\n rw [hβ‚‚]\n have h₃ : (βˆ‘ k : Fin n, βˆ‘ l : Fin n, (2 * (if colors k l = 0 then (1 : β„€) else 0) - 1) * ((k : β„€) * n)) = 0 := by\n have hβ‚„ : βˆ€ (k : Fin n), (βˆ‘ l : Fin n, (2 * (if colors k l = 0 then (1 : β„€) else 0) - 1) * ((k : β„€) * n)) = 0 := by\n intro k\n have hβ‚… : (βˆ‘ l : Fin n, (2 * (if colors k l = 0 then (1 : β„€) else 0) - 1)) = 0 := hrow_sum_zero k\n calc\n (βˆ‘ l : Fin n, (2 * (if colors k l = 0 then (1 : β„€) else 0) - 1) * ((k : β„€) * n)) = βˆ‘ l : Fin n, ((k : β„€) * n) * (2 * (if colors k l = 0 then (1 : β„€) else 0) - 1) := by\n apply Finset.sum_congr rfl\n intro l _\n ring_nf\n _ = ((k : β„€) * n) * βˆ‘ l : Fin n, (2 * (if colors k l = 0 then (1 : β„€) else 0) - 1) := by\n rw [Finset.mul_sum]\n _ = ((k : β„€) * n) * 0 := by rw [hβ‚…]\n _ = 0 := by ring\n calc\n (βˆ‘ k : Fin n, βˆ‘ l : Fin n, (2 * (if colors k l = 0 then (1 : β„€) else 0) - 1) * ((k : β„€) * n)) = βˆ‘ k : Fin n, (βˆ‘ l : Fin n, (2 * (if colors k l = 0 then (1 : β„€) else 0) - 1) * ((k : β„€) * n)) := by simp [Finset.sum_sigma']\n _ = βˆ‘ k : Fin n, 0 := by\n apply Finset.sum_congr rfl\n intro k _\n rw [hβ‚„ k]\n _ = 0 := by simp\n have hβ‚„ : (βˆ‘ k : Fin n, βˆ‘ l : Fin n, (2 * (if colors k l = 0 then (1 : β„€) else 0) - 1) * ((l : β„€) + 1)) = 0 := by\n have hβ‚… : βˆ€ (l : Fin n), (βˆ‘ k : Fin n, (2 * (if colors k l = 0 then (1 : β„€) else 0) - 1)) = 0 := by\n intro l\n exact hcol_sum_zero l\n calc\n (βˆ‘ k : Fin n, βˆ‘ l : Fin n, (2 * (if colors k l = 0 then (1 : β„€) else 0) - 1) * ((l : β„€) + 1)) = βˆ‘ l : Fin n, βˆ‘ k : Fin n, (2 * (if colors k l = 0 then (1 : β„€) else 0) - 1) * ((l : β„€) + 1) := by\n rw [Finset.sum_comm]\n _ = βˆ‘ l : Fin n, ((l : β„€) + 1) * (βˆ‘ k : Fin n, (2 * (if colors k l = 0 then (1 : β„€) else 0) - 1)) := by\n apply Finset.sum_congr rfl\n intro l _\n calc\n (βˆ‘ k : Fin n, (2 * (if colors k l = 0 then (1 : β„€) else 0) - 1) * ((l : β„€) + 1)) = βˆ‘ k : Fin n, ((l : β„€) + 1) * (2 * (if colors k l = 0 then (1 : β„€) else 0) - 1) := by\n apply Finset.sum_congr rfl\n intro k _\n ring_nf\n _ = ((l : β„€) + 1) * βˆ‘ k : Fin n, (2 * (if colors k l = 0 then (1 : β„€) else 0) - 1) := by\n rw [Finset.mul_sum]\n _ = βˆ‘ l : Fin n, ((l : β„€) + 1) * 0 := by\n apply Finset.sum_congr rfl\n intro l _\n rw [hβ‚… l]\n _ = βˆ‘ l : Fin n, 0 := by\n apply Finset.sum_congr rfl\n intro l _\n ring_nf\n _ = 0 := by simp\n rw [h₃, hβ‚„]\n <;> simp\n \n have hfinal : (βˆ‘ k, βˆ‘ l, (if (colors k l = 0) then (nums k l) else 0)) = (βˆ‘ k, βˆ‘ l, (if (colors k l = 1) then (nums k l) else 0)) := by\n have h₁ : (βˆ‘ k : Fin n, βˆ‘ l : Fin n, (if colors k l = 0 then (nums k l : β„€) else 0)) - (βˆ‘ k : Fin n, βˆ‘ l : Fin n, (if colors k l = 1 then (nums k l : β„€) else 0)) = 0 := by\n rw [hsum_diff]\n rw [hsum_split_zero]\n have hβ‚‚ : (βˆ‘ k : Fin n, βˆ‘ l : Fin n, (if colors k l = 0 then (nums k l : β„€) else 0)) = (βˆ‘ k : Fin n, βˆ‘ l : Fin n, (if colors k l = 1 then (nums k l : β„€) else 0)) := by\n linarith\n simpa using hβ‚‚\n \n exact hfinal"}
{"name": "putnam_1964_b2", "proof_length": 1754, "header": "import Mathlib\nimport Aesop\n\nset_option maxHeartbeats 0\n\nopen Set Function Filter Topology\n\n\n", "signature": "theorem putnam_1964_b2\n(S : Type*) [Fintype S] [Nonempty S]\n(P : Finset (Set S))\n(hPP : βˆ€ T ∈ P, βˆ€ U ∈ P, T ∩ U β‰  βˆ…)\n(hPS : Β¬βˆƒ T : Set S, T βˆ‰ P ∧ (βˆ€ U ∈ P, T ∩ U β‰  βˆ…))\n: (P.card = 2 ^ (Fintype.card S - 1))", "src": "theorem putnam_1964_b2\n(S : Type*) [Fintype S] [Nonempty S]\n(P : Finset (Set S))\n(hPP : βˆ€ T ∈ P, βˆ€ U ∈ P, T ∩ U β‰  βˆ…)\n(hPS : Β¬βˆƒ T : Set S, T βˆ‰ P ∧ (βˆ€ U ∈ P, T ∩ U β‰  βˆ…))\n: (P.card = 2 ^ (Fintype.card S - 1)) := by \n have h_no_empty : βˆ€ (T : Set S), T ∈ P β†’ T.Nonempty := by\n intro T hT\n have h₁ : T ∩ T β‰  βˆ… := hPP T hT T hT\n have hβ‚‚ : T ∩ T = T := by simp [Set.ext_iff]\n rw [hβ‚‚] at h₁\n exact Set.nonempty_iff_ne_empty.mpr h₁\n \n have h_subset_or_compl : βˆ€ (A : Set S), A ∈ P ∨ Aᢜ ∈ P := by\n intro A\n by_contra! h\n have h₁ : A βˆ‰ P := h.1\n have hβ‚‚ : Aᢜ βˆ‰ P := h.2\n \n have h₃ : βˆƒ (U : Set S), U ∈ P ∧ A ∩ U = βˆ… := by\n have hβ‚„ : Β¬(A βˆ‰ P ∧ βˆ€ (U : Set S), U ∈ P β†’ A ∩ U β‰  βˆ…) := by\n intro hβ‚…\n have h₆ : βˆƒ (T : Set S), T βˆ‰ P ∧ (βˆ€ U ∈ P, T ∩ U β‰  βˆ…) := by\n refine' ⟨A, _⟩\n constructor\n Β· exact hβ‚….1\n Β· intro U hU\n have h₇ := hβ‚….2 U hU\n have hβ‚ˆ : A ∩ U β‰  βˆ… := h₇\n have h₉ : A ∩ U = U ∩ A := by\n ext x\n simp [Set.mem_inter_iff]\n <;> tauto\n have h₁₀ : U ∩ A β‰  βˆ… := by\n intro h₁₁\n apply hβ‚ˆ\n simp_all [Set.ext_iff]\n <;> aesop\n simpa [Set.inter_comm] using h₁₀\n exact hPS h₆\n by_cases hβ‚… : A βˆ‰ P\n Β· have h₆ : Β¬(βˆ€ (U : Set S), U ∈ P β†’ A ∩ U β‰  βˆ…) := by\n intro h₇\n exact hβ‚„ ⟨hβ‚…, hβ‚‡βŸ©\n push_neg at h₆\n obtain ⟨U, hU, hβ‚ˆβŸ© := h₆\n refine' ⟨U, hU, _⟩\n have h₉ : A ∩ U = βˆ… := by\n by_contra h₁₀\n have h₁₁ : A ∩ U β‰  βˆ… := h₁₀\n simp_all [Set.ext_iff]\n <;> aesop\n exact h₉\n Β· exfalso\n simp_all\n \n have hβ‚„ : βˆƒ (V : Set S), V ∈ P ∧ Aᢜ ∩ V = βˆ… := by\n have hβ‚… : Β¬(Aᢜ βˆ‰ P ∧ βˆ€ (U : Set S), U ∈ P β†’ Aᢜ ∩ U β‰  βˆ…) := by\n intro h₆\n have h₇ : βˆƒ (T : Set S), T βˆ‰ P ∧ (βˆ€ U ∈ P, T ∩ U β‰  βˆ…) := by\n refine' ⟨Aᢜ, _⟩\n constructor\n Β· exact h₆.1\n Β· intro U hU\n have hβ‚ˆ := h₆.2 U hU\n have h₉ : Aᢜ ∩ U β‰  βˆ… := hβ‚ˆ\n have h₁₀ : Aᢜ ∩ U = U ∩ Aᢜ := by\n ext x\n simp [Set.mem_inter_iff]\n <;> tauto\n have h₁₁ : U ∩ Aᢜ β‰  βˆ… := by\n intro h₁₂\n apply h₉\n simp_all [Set.ext_iff]\n <;> aesop\n simpa [Set.inter_comm] using h₁₁\n exact hPS h₇\n by_cases h₆ : Aᢜ βˆ‰ P\n Β· have h₇ : Β¬(βˆ€ (U : Set S), U ∈ P β†’ Aᢜ ∩ U β‰  βˆ…) := by\n intro hβ‚ˆ\n exact hβ‚… ⟨h₆, hβ‚ˆβŸ©\n push_neg at h₇\n obtain ⟨V, hV, hβ‚ˆβŸ© := h₇\n refine' ⟨V, hV, _⟩\n have h₉ : Aᢜ ∩ V = βˆ… := by\n by_contra h₁₀\n have h₁₁ : Aᢜ ∩ V β‰  βˆ… := h₁₀\n simp_all [Set.ext_iff]\n <;> aesop\n exact h₉\n Β· exfalso\n simp_all\n \n obtain ⟨U, hU, hU'⟩ := h₃\n obtain ⟨V, hV, hV'⟩ := hβ‚„\n \n have hβ‚… : U βŠ† Aᢜ := by\n intro x hx\n by_contra h₆\n have h₇ : x ∈ A := by simp_all [Set.mem_compl_iff]\n have hβ‚ˆ : x ∈ A ∩ U := Set.mem_inter h₇ hx\n rw [hU'] at hβ‚ˆ\n simp at hβ‚ˆ\n <;> aesop\n have h₆ : V βŠ† A := by\n intro x hx\n by_contra h₇\n have hβ‚ˆ : x ∈ Aᢜ := by simp_all [Set.mem_compl_iff]\n have h₉ : x ∈ Aᢜ ∩ V := Set.mem_inter hβ‚ˆ hx\n rw [hV'] at h₉\n simp at h₉\n <;> aesop\n \n have h₇ : U ∩ V = βˆ… := by\n apply Set.eq_empty_of_forall_not_mem\n intro x hx\n have hβ‚ˆ : x ∈ U := Set.mem_of_mem_inter_left hx\n have h₉ : x ∈ V := Set.mem_of_mem_inter_right hx\n have h₁₀ : x ∈ Aᢜ := hβ‚… hβ‚ˆ\n have h₁₁ : x ∈ A := h₆ h₉\n simp_all [Set.mem_compl_iff]\n <;> aesop\n \n have hβ‚ˆ : U ∩ V β‰  βˆ… := hPP U hU V hV\n simp_all [Set.ext_iff]\n <;> aesop\n \n have h_not_both : βˆ€ (A : Set S), A ∈ P β†’ Aᢜ βˆ‰ P := by\n intro A hA\n by_contra h\n have h₁ : Aᢜ ∈ P := h\n have hβ‚‚ : A ∩ Aᢜ = βˆ… := by\n ext x\n simp [Set.mem_inter_iff]\n <;> tauto\n have h₃ : A ∩ Aᢜ β‰  βˆ… := hPP A hA Aᢜ h₁\n rw [hβ‚‚] at h₃\n contradiction\n \n have h_card : P.card = 2 ^ (Fintype.card S - 1) := by\n classical\n \n let Q : Finset (Set S) := (Finset.univ : Finset (Set S)) \\ P\n \n have h₁ : P.card = Q.card := by\n \n have hβ‚‚ : βˆ€ (A : Set S), A ∈ P β†’ Aᢜ ∈ Q := by\n intro A hA\n have h₃ : Aᢜ ∈ (Finset.univ : Finset (Set S)) := Finset.mem_univ _\n have hβ‚„ : Aᢜ βˆ‰ P := h_not_both A hA\n simp only [Q, Finset.mem_sdiff] at *\n tauto\n have h₃ : βˆ€ (A : Set S), A ∈ Q β†’ Aᢜ ∈ P := by\n intro A hA\n have hβ‚„ : A ∈ (Finset.univ : Finset (Set S)) := by\n simp only [Q, Finset.mem_sdiff] at hA\n tauto\n have hβ‚… : A βˆ‰ P := by\n simp only [Q, Finset.mem_sdiff] at hA\n tauto\n have h₆ : A ∈ (Finset.univ : Finset (Set S)) := by tauto\n have h₇ : A ∈ P ∨ Aᢜ ∈ P := h_subset_or_compl A\n cases h₇ with\n | inl hβ‚ˆ =>\n exfalso\n tauto\n | inr hβ‚ˆ =>\n exact hβ‚ˆ\n \n have hβ‚„ : P.card = Q.card := by\n \n have hβ‚… : P.card = Q.card := by\n \n have h₆ : βˆ€ (A : Set S), A ∈ P β†’ Aᢜ ∈ Q := hβ‚‚\n have h₇ : βˆ€ (A : Set S), A ∈ Q β†’ Aᢜ ∈ P := h₃\n \n have hβ‚ˆ : P.card = Q.card := by\n \n apply Finset.card_bij' (fun A _ => Aᢜ) (fun A _ => Aᢜ)\n <;> simp_all [Set.ext_iff]\n <;>\n (try\n {\n aesop\n })\n <;>\n (try\n {\n tauto\n })\n <;>\n (try\n {\n intros\n <;>\n simp_all [Set.ext_iff]\n <;>\n tauto\n })\n <;>\n (try\n {\n intros\n <;>\n simp_all [Set.ext_iff]\n <;>\n tauto\n })\n exact hβ‚ˆ\n exact hβ‚…\n exact hβ‚„\n \n have hβ‚‚ : P.card + Q.card = 2 ^ Fintype.card S := by\n have h₃ : P.card + Q.card = (Finset.univ : Finset (Set S)).card := by\n have hβ‚„ : Disjoint P Q := by\n rw [Finset.disjoint_left]\n intro A hA hA'\n simp only [Q, Finset.mem_sdiff] at hA'\n tauto\n have hβ‚… : P βˆͺ Q = (Finset.univ : Finset (Set S)) := by\n apply Finset.ext\n intro A\n simp only [Q, Finset.mem_union, Finset.mem_sdiff, Finset.mem_univ, true_and]\n <;>\n by_cases h₆ : A ∈ P <;> simp_all [h_subset_or_compl]\n <;>\n (try tauto)\n <;>\n (try\n {\n have h₇ := h_subset_or_compl A\n cases h₇ with\n | inl hβ‚ˆ => tauto\n | inr hβ‚ˆ =>\n have h₉ : Aᢜ ∈ P := hβ‚ˆ\n have h₁₀ : A ∈ P ∨ Aᢜ ∈ P := by tauto\n tauto\n })\n have h₆ : P.card + Q.card = (P βˆͺ Q).card := by\n rw [← Finset.card_union_add_card_inter P Q]\n have h₇ : P ∩ Q = βˆ… := Finset.disjoint_iff_inter_eq_empty.mp hβ‚„\n rw [h₇]\n simp\n rw [hβ‚…] at h₆\n exact h₆\n have hβ‚„ : (Finset.univ : Finset (Set S)).card = 2 ^ Fintype.card S := by\n simp [Fintype.card_fun]\n <;>\n simp_all [Fintype.card_fun]\n <;>\n ring_nf\n <;>\n simp_all [Fintype.card_fun]\n <;>\n norm_num\n <;>\n aesop\n linarith\n \n have h₃ : P.card * 2 = 2 ^ Fintype.card S := by\n have hβ‚„ : P.card + Q.card = 2 ^ Fintype.card S := hβ‚‚\n have hβ‚… : P.card = Q.card := h₁\n linarith\n \n have hβ‚„ : Fintype.card S β‰₯ 1 := by\n have hβ‚… : Nonempty S := inferInstance\n have h₆ : 0 < Fintype.card S := by\n apply Fintype.card_pos_iff.mpr\n exact ⟨Classical.choice hβ‚…βŸ©\n omega\n have hβ‚… : P.card = 2 ^ (Fintype.card S - 1) := by\n have h₆ : P.card * 2 = 2 ^ Fintype.card S := h₃\n have h₇ : Fintype.card S β‰₯ 1 := hβ‚„\n have hβ‚ˆ : 2 ^ (Fintype.card S - 1) * 2 = 2 ^ Fintype.card S := by\n have h₉ : Fintype.card S - 1 + 1 = Fintype.card S := by\n have h₁₀ : Fintype.card S β‰₯ 1 := hβ‚„\n omega\n calc\n 2 ^ (Fintype.card S - 1) * 2 = 2 ^ (Fintype.card S - 1) * 2 ^ 1 := by norm_num\n _ = 2 ^ ((Fintype.card S - 1) + 1) := by\n rw [← pow_add]\n _ = 2 ^ Fintype.card S := by\n rw [h₉]\n <;> simp [add_comm]\n have h₉ : P.card = 2 ^ (Fintype.card S - 1) := by\n have h₁₀ : P.card * 2 = 2 ^ Fintype.card S := h₃\n have h₁₁ : 2 ^ (Fintype.card S - 1) * 2 = 2 ^ Fintype.card S := hβ‚ˆ\n have h₁₂ : P.card = 2 ^ (Fintype.card S - 1) := by\n nlinarith\n exact h₁₂\n exact h₉\n exact hβ‚…\n \n exact h_card"}
{"name": "putnam_2007_a1", "proof_length": 5463, "header": "import Mathlib\nimport Aesop\n\nset_option maxHeartbeats 0\n\n\n\n\n", "signature": "theorem putnam_2007_a1\n (P : (ℝ β†’ ℝ) β†’ Prop)\n (P_def : βˆ€ f, P f ↔ βˆƒ x y, f x = y ∧ f y = x ∧ deriv f x * deriv f y = 1)\n (Ξ± : ℝ) :\n P (fun t ↦ Ξ± * t ^ 2 + Ξ± * t + 1 / 24) ↔ Ξ± ∈ (({2 / 3, 3 / 2, (13 + √601) / 12, (13 - √601) / 12}) : Set ℝ )", "src": "theorem putnam_2007_a1\n (P : (ℝ β†’ ℝ) β†’ Prop)\n (P_def : βˆ€ f, P f ↔ βˆƒ x y, f x = y ∧ f y = x ∧ deriv f x * deriv f y = 1)\n (Ξ± : ℝ) :\n P (fun t ↦ Ξ± * t ^ 2 + Ξ± * t + 1 / 24) ↔ Ξ± ∈ (({2 / 3, 3 / 2, (13 + √601) / 12, (13 - √601) / 12}) : Set ℝ ) :=\n by \n have h_main : P (fun t : ℝ => Ξ± * t ^ 2 + Ξ± * t + 1 / 24) ↔ Ξ± = 2 / 3 ∨ Ξ± = 3 / 2 ∨ Ξ± = (13 + Real.sqrt 601) / 12 ∨ Ξ± = (13 - Real.sqrt 601) / 12 := by\n have h₁ : P (fun t : ℝ => Ξ± * t ^ 2 + Ξ± * t + 1 / 24) ↔ βˆƒ (x y : ℝ), (Ξ± * x ^ 2 + Ξ± * x + 1 / 24 : ℝ) = y ∧ (Ξ± * y ^ 2 + Ξ± * y + 1 / 24 : ℝ) = x ∧ (2 * Ξ± * x + Ξ±) * (2 * Ξ± * y + Ξ±) = 1 := by\n have hβ‚‚ : P (fun t : ℝ => Ξ± * t ^ 2 + Ξ± * t + 1 / 24) ↔ βˆƒ x y, (fun t : ℝ => Ξ± * t ^ 2 + Ξ± * t + 1 / 24) x = y ∧ (fun t : ℝ => Ξ± * t ^ 2 + Ξ± * t + 1 / 24) y = x ∧ deriv (fun t : ℝ => Ξ± * t ^ 2 + Ξ± * t + 1 / 24) x * deriv (fun t : ℝ => Ξ± * t ^ 2 + Ξ± * t + 1 / 24) y = 1 := by\n rw [P_def]\n <;> simp\n rw [hβ‚‚]\n have h₃ : βˆ€ (x : ℝ), deriv (fun t : ℝ => Ξ± * t ^ 2 + Ξ± * t + 1 / 24) x = 2 * Ξ± * x + Ξ± := by\n intro x\n \n have hβ‚„ : deriv (fun t : ℝ => Ξ± * t ^ 2 + Ξ± * t + 1 / 24) x = deriv (fun t : ℝ => Ξ± * t ^ 2 + Ξ± * t + 1 / 24) x := rfl\n rw [hβ‚„]\n \n have hβ‚… : HasDerivAt (fun t : ℝ => Ξ± * t ^ 2 + Ξ± * t + 1 / 24) (2 * Ξ± * x + Ξ±) x := by\n \n have h₆ : HasDerivAt (fun t : ℝ => Ξ± * t ^ 2) (2 * Ξ± * x) x := by\n \n have h₇ : HasDerivAt (fun t : ℝ => t ^ 2) (2 * x) x := by\n simpa using (hasDerivAt_pow 2 x)\n have hβ‚ˆ : HasDerivAt (fun t : ℝ => Ξ± * t ^ 2) (Ξ± * (2 * x)) x := by\n convert HasDerivAt.const_mul Ξ± h₇ using 1 <;> ring\n convert hβ‚ˆ using 1 <;> ring\n have h₉ : HasDerivAt (fun t : ℝ => Ξ± * t) Ξ± x := by\n \n have h₁₀ : HasDerivAt (fun t : ℝ => t) 1 x := by\n simpa using hasDerivAt_id x\n have h₁₁ : HasDerivAt (fun t : ℝ => Ξ± * t) (Ξ± * 1) x := by\n convert HasDerivAt.const_mul Ξ± h₁₀ using 1 <;> ring\n convert h₁₁ using 1 <;> ring\n have h₁₂ : HasDerivAt (fun t : ℝ => (1 : ℝ) / 24) 0 x := by\n \n simpa using hasDerivAt_const x (1 / 24 : ℝ)\n \n have h₁₃ : HasDerivAt (fun t : ℝ => Ξ± * t ^ 2 + Ξ± * t + 1 / 24) (2 * Ξ± * x + Ξ±) x := by\n convert h₆.add h₉ |>.add h₁₂ using 1 <;> ring\n exact h₁₃\n \n have h₁₄ : deriv (fun t : ℝ => Ξ± * t ^ 2 + Ξ± * t + 1 / 24) x = 2 * Ξ± * x + Ξ± := by\n apply HasDerivAt.deriv\n exact hβ‚…\n rw [h₁₄]\n \n constructor\n Β· intro h\n obtain ⟨x, y, h₁₅, h₁₆, hβ‚β‚‡βŸ© := h\n refine' ⟨x, y, _, _, _⟩ <;>\n (try simp_all [h₃]) <;>\n (try ring_nf at * <;> simp_all) <;>\n (try nlinarith)\n Β· intro h\n obtain ⟨x, y, h₁₅, h₁₆, hβ‚β‚‡βŸ© := h\n refine' ⟨x, y, _, _, _⟩ <;>\n (try simp_all [h₃]) <;>\n (try ring_nf at * <;> simp_all) <;>\n (try nlinarith)\n rw [h₁]\n constructor\n Β· \n intro h\n have hβ‚‚ : βˆƒ (x y : ℝ), (Ξ± * x ^ 2 + Ξ± * x + 1 / 24 : ℝ) = y ∧ (Ξ± * y ^ 2 + Ξ± * y + 1 / 24 : ℝ) = x ∧ (2 * Ξ± * x + Ξ±) * (2 * Ξ± * y + Ξ±) = 1 := h\n obtain ⟨x, y, h₃, hβ‚„, hβ‚…βŸ© := hβ‚‚\n have h₆ : (x - y) * (Ξ± * (x + y + 1) + 1) = 0 := by\n have h₇ : Ξ± * x ^ 2 + Ξ± * x + 1 / 24 = y := h₃\n have hβ‚ˆ : Ξ± * y ^ 2 + Ξ± * y + 1 / 24 = x := hβ‚„\n have h₉ : Ξ± * (x ^ 2 - y ^ 2) + Ξ± * (x - y) = (y - x) := by\n linarith\n have h₁₀ : Ξ± * (x - y) * (x + y) + Ξ± * (x - y) = -(x - y) := by\n linarith\n have h₁₁ : (x - y) * (Ξ± * (x + y) + Ξ± + 1) = 0 := by\n linarith\n have h₁₂ : (x - y) * (Ξ± * (x + y + 1) + 1) = 0 := by\n linarith\n exact h₁₂\n by_cases h₇ : x = y\n Β· \n have hβ‚ˆ : Ξ± * x ^ 2 + Ξ± * x + 1 / 24 = x := by\n linarith\n have h₉ : (2 * Ξ± * x + Ξ±) * (2 * Ξ± * x + Ξ±) = 1 := by\n have h₁₀ : (2 * Ξ± * x + Ξ±) * (2 * Ξ± * y + Ξ±) = 1 := hβ‚…\n have h₁₁ : (2 * Ξ± * x + Ξ±) * (2 * Ξ± * x + Ξ±) = 1 := by\n simpa [h₇] using h₁₀\n exact h₁₁\n have h₁₀ : (2 * Ξ± * x + Ξ±) = 1 ∨ (2 * Ξ± * x + Ξ±) = -1 := by\n have h₁₁ : (2 * Ξ± * x + Ξ±) ^ 2 = 1 := by\n nlinarith\n have h₁₂ : (2 * Ξ± * x + Ξ±) = 1 ∨ (2 * Ξ± * x + Ξ±) = -1 := by\n apply or_iff_not_imp_left.mpr\n intro h₁₃\n apply eq_of_sub_eq_zero\n apply mul_left_cancelβ‚€ (sub_ne_zero.mpr h₁₃)\n nlinarith\n exact h₁₂\n cases h₁₀ with\n | inl h₁₀ =>\n \n have h₁₁ : 2 * Ξ± * x + Ξ± = 1 := h₁₀\n have h₁₂ : Ξ± β‰  0 := by\n by_contra h₁₃\n rw [h₁₃] at h₁₁\n norm_num at h₁₁\n <;> linarith\n have h₁₃ : x = (1 - Ξ±) / (2 * Ξ±) := by\n have h₁₄ : 2 * Ξ± * x + Ξ± = 1 := h₁₁\n field_simp at h₁₄ ⊒\n nlinarith\n have h₁₄ : Ξ± * x ^ 2 + (Ξ± - 1) * x + 1 / 24 = 0 := by\n have h₁₅ : Ξ± * x ^ 2 + Ξ± * x + 1 / 24 = x := hβ‚ˆ\n linarith\n rw [h₁₃] at h₁₄\n have h₁₅ : Ξ± * ((1 - Ξ±) / (2 * Ξ±)) ^ 2 + (Ξ± - 1) * ((1 - Ξ±) / (2 * Ξ±)) + 1 / 24 = 0 := h₁₄\n have h₁₆ : 6 * Ξ± ^ 2 - 13 * Ξ± + 6 = 0 := by\n field_simp at h₁₅\n ring_nf at h₁₅ ⊒\n nlinarith [sq_pos_of_ne_zero h₁₂]\n have h₁₇ : Ξ± = 2 / 3 ∨ Ξ± = 3 / 2 := by\n have hβ‚β‚ˆ : (Ξ± - 2 / 3) * (Ξ± - 3 / 2) = 0 := by\n nlinarith\n have h₁₉ : Ξ± - 2 / 3 = 0 ∨ Ξ± - 3 / 2 = 0 := by\n apply eq_zero_or_eq_zero_of_mul_eq_zero hβ‚β‚ˆ\n cases h₁₉ with\n | inl h₁₉ =>\n have hβ‚‚β‚€ : Ξ± = 2 / 3 := by linarith\n exact Or.inl hβ‚‚β‚€\n | inr h₁₉ =>\n have hβ‚‚β‚€ : Ξ± = 3 / 2 := by linarith\n exact Or.inr hβ‚‚β‚€\n cases h₁₇ with\n | inl h₁₇ =>\n exact Or.inl h₁₇\n | inr h₁₇ =>\n exact Or.inr (Or.inl h₁₇)\n | inr h₁₀ =>\n \n have h₁₁ : 2 * Ξ± * x + Ξ± = -1 := h₁₀\n have h₁₂ : Ξ± β‰  0 := by\n by_contra h₁₃\n rw [h₁₃] at h₁₁\n norm_num at h₁₁\n <;> linarith\n have h₁₃ : x = (-1 - Ξ±) / (2 * Ξ±) := by\n have h₁₄ : 2 * Ξ± * x + Ξ± = -1 := h₁₁\n field_simp at h₁₄ ⊒\n nlinarith\n have h₁₄ : Ξ± * x ^ 2 + (Ξ± - 1) * x + 1 / 24 = 0 := by\n have h₁₅ : Ξ± * x ^ 2 + Ξ± * x + 1 / 24 = x := hβ‚ˆ\n linarith\n rw [h₁₃] at h₁₄\n have h₁₅ : Ξ± * ((-1 - Ξ±) / (2 * Ξ±)) ^ 2 + (Ξ± - 1) * ((-1 - Ξ±) / (2 * Ξ±)) + 1 / 24 = 0 := h₁₄\n have h₁₆ : 6 * Ξ± ^ 2 - 13 * Ξ± - 18 = 0 := by\n field_simp at h₁₅\n ring_nf at h₁₅ ⊒\n nlinarith [sq_pos_of_ne_zero h₁₂]\n have h₁₇ : Ξ± = (13 + Real.sqrt 601) / 12 ∨ Ξ± = (13 - Real.sqrt 601) / 12 := by\n have hβ‚β‚ˆ : Ξ± = (13 + Real.sqrt 601) / 12 ∨ Ξ± = (13 - Real.sqrt 601) / 12 := by\n have h₁₉ : Ξ± = (13 + Real.sqrt 601) / 12 ∨ Ξ± = (13 - Real.sqrt 601) / 12 := by\n have hβ‚‚β‚€ : (Ξ± - (13 + Real.sqrt 601) / 12) * (Ξ± - (13 - Real.sqrt 601) / 12) = 0 := by\n have h₂₁ : Real.sqrt 601 β‰₯ 0 := Real.sqrt_nonneg _\n nlinarith [Real.sq_sqrt (show 0 ≀ 601 by norm_num)]\n have hβ‚‚β‚‚ : Ξ± - (13 + Real.sqrt 601) / 12 = 0 ∨ Ξ± - (13 - Real.sqrt 601) / 12 = 0 := by\n apply eq_zero_or_eq_zero_of_mul_eq_zero hβ‚‚β‚€\n cases hβ‚‚β‚‚ with\n | inl hβ‚‚β‚‚ =>\n have h₂₃ : Ξ± = (13 + Real.sqrt 601) / 12 := by linarith\n exact Or.inl h₂₃\n | inr hβ‚‚β‚‚ =>\n have h₂₃ : Ξ± = (13 - Real.sqrt 601) / 12 := by linarith\n exact Or.inr h₂₃\n exact h₁₉\n exact hβ‚β‚ˆ\n cases h₁₇ with\n | inl h₁₇ =>\n exact Or.inr (Or.inr (Or.inl h₁₇))\n | inr h₁₇ =>\n exact Or.inr (Or.inr (Or.inr h₁₇))\n Β· \n have hβ‚ˆ : Ξ± * (x + y + 1) + 1 = 0 := by\n apply mul_left_cancelβ‚€ (sub_ne_zero.mpr h₇)\n nlinarith\n have h₉ : (2 * Ξ± * x + Ξ±) + (2 * Ξ± * y + Ξ±) = -2 := by\n have h₁₀ : Ξ± * (x + y + 1) + 1 = 0 := hβ‚ˆ\n have h₁₁ : Ξ± * (x + y + 1) = -1 := by linarith\n have h₁₂ : 2 * Ξ± * (x + y + 1) = -2 := by linarith\n have h₁₃ : 2 * Ξ± * x + 2 * Ξ± * y + 2 * Ξ± = -2 := by linarith\n linarith\n have h₁₀ : (2 * Ξ± * x + Ξ±) * (2 * Ξ± * y + Ξ±) = 1 := hβ‚…\n have h₁₁ : (2 * Ξ± * x + Ξ±) = -1 := by\n have h₁₂ : (2 * Ξ± * x + Ξ±) + (2 * Ξ± * y + Ξ±) = -2 := h₉\n have h₁₃ : (2 * Ξ± * x + Ξ±) * (2 * Ξ± * y + Ξ±) = 1 := h₁₀\n have h₁₄ : (2 * Ξ± * x + Ξ±) = -1 := by\n nlinarith [sq_nonneg ((2 * Ξ± * x + Ξ±) - (2 * Ξ± * y + Ξ±))]\n exact h₁₄\n have h₁₂ : (2 * Ξ± * y + Ξ±) = -1 := by\n have h₁₃ : (2 * Ξ± * x + Ξ±) + (2 * Ξ± * y + Ξ±) = -2 := h₉\n have h₁₄ : (2 * Ξ± * x + Ξ±) = -1 := h₁₁\n linarith\n have h₁₃ : 2 * Ξ± * x + Ξ± = -1 := h₁₁\n have h₁₄ : 2 * Ξ± * y + Ξ± = -1 := h₁₂\n have h₁₅ : x = y := by\n have h₁₆ : 2 * Ξ± * x + Ξ± = 2 * Ξ± * y + Ξ± := by linarith\n have h₁₇ : 2 * Ξ± * x = 2 * Ξ± * y := by linarith\n by_cases hβ‚β‚ˆ : Ξ± = 0\n Β· have h₁₉ : Ξ± = 0 := hβ‚β‚ˆ\n rw [h₁₉] at h₁₃\n norm_num at h₁₃\n <;> linarith\n Β· have h₁₉ : Ξ± β‰  0 := hβ‚β‚ˆ\n have hβ‚‚β‚€ : x = y := by\n apply mul_left_cancelβ‚€ (show (2 : ℝ) * Ξ± β‰  0 by\n intro h₂₁\n apply h₁₉\n linarith)\n linarith\n exact hβ‚‚β‚€\n contradiction\n Β· \n intro h\n have hβ‚‚ : Ξ± = 2 / 3 ∨ Ξ± = 3 / 2 ∨ Ξ± = (13 + Real.sqrt 601) / 12 ∨ Ξ± = (13 - Real.sqrt 601) / 12 := h\n cases hβ‚‚ with\n | inl hβ‚‚ =>\n \n have h₃ : Ξ± = 2 / 3 := hβ‚‚\n have hβ‚„ : βˆƒ (x y : ℝ), (Ξ± * x ^ 2 + Ξ± * x + 1 / 24 : ℝ) = y ∧ (Ξ± * y ^ 2 + Ξ± * y + 1 / 24 : ℝ) = x ∧ (2 * Ξ± * x + Ξ±) * (2 * Ξ± * y + Ξ±) = 1 := by\n use 1 / 4, 1 / 4\n rw [h₃]\n norm_num\n <;>\n (try ring_nf) <;>\n (try norm_num) <;>\n (try linarith)\n exact hβ‚„\n | inr hβ‚‚ =>\n cases hβ‚‚ with\n | inl hβ‚‚ =>\n \n have h₃ : Ξ± = 3 / 2 := hβ‚‚\n have hβ‚„ : βˆƒ (x y : ℝ), (Ξ± * x ^ 2 + Ξ± * x + 1 / 24 : ℝ) = y ∧ (Ξ± * y ^ 2 + Ξ± * y + 1 / 24 : ℝ) = x ∧ (2 * Ξ± * x + Ξ±) * (2 * Ξ± * y + Ξ±) = 1 := by\n use -1 / 6, -1 / 6\n rw [h₃]\n norm_num\n <;>\n (try ring_nf) <;>\n (try norm_num) <;>\n (try linarith)\n exact hβ‚„\n | inr hβ‚‚ =>\n cases hβ‚‚ with\n | inl hβ‚‚ =>\n \n have h₃ : Ξ± = (13 + Real.sqrt 601) / 12 := hβ‚‚\n have hβ‚„ : βˆƒ (x y : ℝ), (Ξ± * x ^ 2 + Ξ± * x + 1 / 24 : ℝ) = y ∧ (Ξ± * y ^ 2 + Ξ± * y + 1 / 24 : ℝ) = x ∧ (2 * Ξ± * x + Ξ±) * (2 * Ξ± * y + Ξ±) = 1 := by\n have hβ‚… : Ξ± β‰  0 := by\n rw [h₃]\n nlinarith [Real.sqrt_nonneg 601, Real.sq_sqrt (show 0 ≀ 601 by norm_num)]\n use (-1 - Ξ±) / (2 * Ξ±), (-1 - Ξ±) / (2 * Ξ±)\n constructor\n Β· \n have h₆ : (Ξ± : ℝ) * ((-1 - Ξ±) / (2 * Ξ±)) ^ 2 + Ξ± * ((-1 - Ξ±) / (2 * Ξ±)) + 1 / 24 = (-1 - Ξ±) / (2 * Ξ±) := by\n have h₇ : Ξ± β‰  0 := hβ‚…\n have hβ‚ˆ : 6 * Ξ± ^ 2 - 13 * Ξ± - 18 = 0 := by\n rw [h₃]\n nlinarith [Real.sq_sqrt (show (0 : ℝ) ≀ 601 by norm_num)]\n have h₉ : (3 + 2 * Ξ± - Ξ± ^ 2) / (4 * Ξ±) + 1 / 24 = 0 := by\n have h₁₀ : 6 * Ξ± ^ 2 = 13 * Ξ± + 18 := by linarith\n field_simp [h₇]\n nlinarith\n have h₁₀ : (Ξ± : ℝ) * ((-1 - Ξ±) / (2 * Ξ±)) ^ 2 + (Ξ± - 1) * ((-1 - Ξ±) / (2 * Ξ±)) + 1 / 24 = 0 := by\n have h₁₁ : (Ξ± : ℝ) * ((-1 - Ξ±) / (2 * Ξ±)) ^ 2 + (Ξ± - 1) * ((-1 - Ξ±) / (2 * Ξ±)) + 1 / 24 = (3 + 2 * Ξ± - Ξ± ^ 2) / (4 * Ξ±) + 1 / 24 := by\n field_simp [h₇]\n <;> ring_nf\n <;> field_simp [h₇]\n <;> ring_nf\n rw [h₁₁]\n linarith\n have h₁₁ : (Ξ± : ℝ) * ((-1 - Ξ±) / (2 * Ξ±)) ^ 2 + Ξ± * ((-1 - Ξ±) / (2 * Ξ±)) + 1 / 24 = (-1 - Ξ±) / (2 * Ξ±) := by\n have h₁₂ : (Ξ± : ℝ) * ((-1 - Ξ±) / (2 * Ξ±)) ^ 2 + (Ξ± - 1) * ((-1 - Ξ±) / (2 * Ξ±)) + 1 / 24 = 0 := h₁₀\n have h₁₃ : (Ξ± : ℝ) * ((-1 - Ξ±) / (2 * Ξ±)) ^ 2 + Ξ± * ((-1 - Ξ±) / (2 * Ξ±)) + 1 / 24 = (-1 - Ξ±) / (2 * Ξ±) := by\n linarith\n exact h₁₃\n exact h₁₁\n exact h₆\n Β· constructor\n Β· \n have h₆ : (Ξ± : ℝ) * ((-1 - Ξ±) / (2 * Ξ±)) ^ 2 + Ξ± * ((-1 - Ξ±) / (2 * Ξ±)) + 1 / 24 = (-1 - Ξ±) / (2 * Ξ±) := by\n have h₇ : Ξ± β‰  0 := hβ‚…\n have hβ‚ˆ : 6 * Ξ± ^ 2 - 13 * Ξ± - 18 = 0 := by\n rw [h₃]\n nlinarith [Real.sq_sqrt (show 0 ≀ 601 by norm_num)]\n have h₉ : (3 + 2 * Ξ± - Ξ± ^ 2) / (4 * Ξ±) + 1 / 24 = 0 := by\n have h₁₀ : 6 * Ξ± ^ 2 = 13 * Ξ± + 18 := by linarith\n field_simp [h₇]\n nlinarith\n have h₁₀ : (Ξ± : ℝ) * ((-1 - Ξ±) / (2 * Ξ±)) ^ 2 + (Ξ± - 1) * ((-1 - Ξ±) / (2 * Ξ±)) + 1 / 24 = 0 := by\n have h₁₁ : (Ξ± : ℝ) * ((-1 - Ξ±) / (2 * Ξ±)) ^ 2 + (Ξ± - 1) * ((-1 - Ξ±) / (2 * Ξ±)) + 1 / 24 = (3 + 2 * Ξ± - Ξ± ^ 2) / (4 * Ξ±) + 1 / 24 := by\n field_simp [h₇]\n <;> ring_nf\n <;> field_simp [h₇]\n <;> ring_nf\n rw [h₁₁]\n linarith\n have h₁₁ : (Ξ± : ℝ) * ((-1 - Ξ±) / (2 * Ξ±)) ^ 2 + Ξ± * ((-1 - Ξ±) / (2 * Ξ±)) + 1 / 24 = (-1 - Ξ±) / (2 * Ξ±) := by\n have h₁₂ : (Ξ± : ℝ) * ((-1 - Ξ±) / (2 * Ξ±)) ^ 2 + (Ξ± - 1) * ((-1 - Ξ±) / (2 * Ξ±)) + 1 / 24 = 0 := h₁₀\n have h₁₃ : (Ξ± : ℝ) * ((-1 - Ξ±) / (2 * Ξ±)) ^ 2 + Ξ± * ((-1 - Ξ±) / (2 * Ξ±)) + 1 / 24 = (-1 - Ξ±) / (2 * Ξ±) := by\n linarith\n exact h₁₃\n exact h₁₁\n linarith\n Β· \n have h₆ : (2 * Ξ± * ((-1 - Ξ±) / (2 * Ξ±)) + Ξ±) * (2 * Ξ± * ((-1 - Ξ±) / (2 * Ξ±)) + Ξ±) = 1 := by\n have h₇ : Ξ± β‰  0 := hβ‚…\n field_simp [h₇]\n <;> ring_nf\n <;> nlinarith [Real.sqrt_nonneg 601, Real.sq_sqrt (show 0 ≀ 601 by norm_num)]\n exact h₆\n exact hβ‚„\n | inr hβ‚‚ =>\n \n have h₃ : Ξ± = (13 - Real.sqrt 601) / 12 := hβ‚‚\n have hβ‚„ : βˆƒ (x y : ℝ), (Ξ± * x ^ 2 + Ξ± * x + 1 / 24 : ℝ) = y ∧ (Ξ± * y ^ 2 + Ξ± * y + 1 / 24 : ℝ) = x ∧ (2 * Ξ± * x + Ξ±) * (2 * Ξ± * y + Ξ±) = 1 := by\n have hβ‚… : Ξ± β‰  0 := by\n rw [h₃]\n nlinarith [Real.sqrt_nonneg 601, Real.sq_sqrt (show 0 ≀ 601 by norm_num)]\n use (-1 - Ξ±) / (2 * Ξ±), (-1 - Ξ±) / (2 * Ξ±)\n constructor\n Β· \n have h₆ : (Ξ± : ℝ) * ((-1 - Ξ±) / (2 * Ξ±)) ^ 2 + Ξ± * ((-1 - Ξ±) / (2 * Ξ±)) + 1 / 24 = (-1 - Ξ±) / (2 * Ξ±) := by\n have h₇ : Ξ± β‰  0 := hβ‚…\n have hβ‚ˆ : 6 * Ξ± ^ 2 - 13 * Ξ± - 18 = 0 := by\n rw [h₃]\n nlinarith [Real.sq_sqrt (show (0 : ℝ) ≀ 601 by norm_num)]\n have h₉ : (3 + 2 * Ξ± - Ξ± ^ 2) / (4 * Ξ±) + 1 / 24 = 0 := by\n have h₁₀ : 6 * Ξ± ^ 2 = 13 * Ξ± + 18 := by linarith\n field_simp [h₇]\n nlinarith\n have h₁₀ : (Ξ± : ℝ) * ((-1 - Ξ±) / (2 * Ξ±)) ^ 2 + (Ξ± - 1) * ((-1 - Ξ±) / (2 * Ξ±)) + 1 / 24 = 0 := by\n have h₁₁ : (Ξ± : ℝ) * ((-1 - Ξ±) / (2 * Ξ±)) ^ 2 + (Ξ± - 1) * ((-1 - Ξ±) / (2 * Ξ±)) + 1 / 24 = (3 + 2 * Ξ± - Ξ± ^ 2) / (4 * Ξ±) + 1 / 24 := by\n field_simp [h₇]\n <;> ring_nf\n <;> field_simp [h₇]\n <;> ring_nf\n rw [h₁₁]\n linarith\n have h₁₁ : (Ξ± : ℝ) * ((-1 - Ξ±) / (2 * Ξ±)) ^ 2 + Ξ± * ((-1 - Ξ±) / (2 * Ξ±)) + 1 / 24 = (-1 - Ξ±) / (2 * Ξ±) := by\n have h₁₂ : (Ξ± : ℝ) * ((-1 - Ξ±) / (2 * Ξ±)) ^ 2 + (Ξ± - 1) * ((-1 - Ξ±) / (2 * Ξ±)) + 1 / 24 = 0 := h₁₀\n have h₁₃ : (Ξ± : ℝ) * ((-1 - Ξ±) / (2 * Ξ±)) ^ 2 + Ξ± * ((-1 - Ξ±) / (2 * Ξ±)) + 1 / 24 = (-1 - Ξ±) / (2 * Ξ±) := by\n linarith\n exact h₁₃\n exact h₁₁\n exact h₆\n Β· constructor\n Β· \n have h₆ : (Ξ± : ℝ) * ((-1 - Ξ±) / (2 * Ξ±)) ^ 2 + Ξ± * ((-1 - Ξ±) / (2 * Ξ±)) + 1 / 24 = (-1 - Ξ±) / (2 * Ξ±) := by\n have h₇ : Ξ± β‰  0 := hβ‚…\n have hβ‚ˆ : 6 * Ξ± ^ 2 - 13 * Ξ± - 18 = 0 := by\n rw [h₃]\n nlinarith [Real.sq_sqrt (show 0 ≀ 601 by norm_num)]\n have h₉ : (3 + 2 * Ξ± - Ξ± ^ 2) / (4 * Ξ±) + 1 / 24 = 0 := by\n have h₁₀ : 6 * Ξ± ^ 2 = 13 * Ξ± + 18 := by linarith\n field_simp [h₇]\n nlinarith\n have h₁₀ : (Ξ± : ℝ) * ((-1 - Ξ±) / (2 * Ξ±)) ^ 2 + (Ξ± - 1) * ((-1 - Ξ±) / (2 * Ξ±)) + 1 / 24 = 0 := by\n have h₁₁ : (Ξ± : ℝ) * ((-1 - Ξ±) / (2 * Ξ±)) ^ 2 + (Ξ± - 1) * ((-1 - Ξ±) / (2 * Ξ±)) + 1 / 24 = (3 + 2 * Ξ± - Ξ± ^ 2) / (4 * Ξ±) + 1 / 24 := by\n field_simp [h₇]\n <;> ring_nf\n <;> field_simp [h₇]\n <;> ring_nf\n rw [h₁₁]\n linarith\n have h₁₁ : (Ξ± : ℝ) * ((-1 - Ξ±) / (2 * Ξ±)) ^ 2 + Ξ± * ((-1 - Ξ±) / (2 * Ξ±)) + 1 / 24 = (-1 - Ξ±) / (2 * Ξ±) := by\n have h₁₂ : (Ξ± : ℝ) * ((-1 - Ξ±) / (2 * Ξ±)) ^ 2 + (Ξ± - 1) * ((-1 - Ξ±) / (2 * Ξ±)) + 1 / 24 = 0 := h₁₀\n have h₁₃ : (Ξ± : ℝ) * ((-1 - Ξ±) / (2 * Ξ±)) ^ 2 + Ξ± * ((-1 - Ξ±) / (2 * Ξ±)) + 1 / 24 = (-1 - Ξ±) / (2 * Ξ±) := by\n linarith\n exact h₁₃\n exact h₁₁\n linarith\n Β· \n have h₆ : (2 * Ξ± * ((-1 - Ξ±) / (2 * Ξ±)) + Ξ±) * (2 * Ξ± * ((-1 - Ξ±) / (2 * Ξ±)) + Ξ±) = 1 := by\n have h₇ : Ξ± β‰  0 := hβ‚…\n field_simp [h₇]\n <;> ring_nf\n <;> nlinarith [Real.sqrt_nonneg 601, Real.sq_sqrt (show 0 ≀ 601 by norm_num)]\n exact h₆\n exact hβ‚„\n \n have h_final : (Ξ± = 2 / 3 ∨ Ξ± = 3 / 2 ∨ Ξ± = (13 + Real.sqrt 601) / 12 ∨ Ξ± = (13 - Real.sqrt 601) / 12) ↔ Ξ± ∈ (({2 / 3, 3 / 2, (13 + √601) / 12, (13 - √601) / 12}) : Set ℝ) := by\n constructor\n Β· \n intro h\n simp only [Set.mem_insert_iff, Set.mem_singleton_iff]\n tauto\n Β· \n intro h\n simp only [Set.mem_insert_iff, Set.mem_singleton_iff] at h\n tauto\n \n have h_result : P (fun t ↦ Ξ± * t ^ 2 + Ξ± * t + 1 / 24) ↔ Ξ± ∈ (({2 / 3, 3 / 2, (13 + √601) / 12, (13 - √601) / 12}) : Set ℝ) := by\n rw [h_main]\n rw [h_final]\n <;>\n simp_all\n <;>\n tauto\n \n exact h_result"}
{"name": "putnam_1970_b5", "proof_length": 2134, "header": "import Mathlib\nimport Aesop\n\nset_option maxHeartbeats 0\n\nopen Metric Set EuclideanGeometry Filter Topology\n\n\n", "signature": "theorem putnam_1970_b5\n(ramp : β„€ β†’ (ℝ β†’ ℝ))\n(ramp_def : ramp = fun (n : β„€) => (fun (x : ℝ) => if x ≀ -n then (-n : ℝ) else (if -n < x ∧ x ≀ n then x else (n : ℝ))))\n(F : ℝ β†’ ℝ)\n: Continuous F ↔ (βˆ€ n : β„•, Continuous ((ramp n) ∘ F))", "src": "theorem putnam_1970_b5\n(ramp : β„€ β†’ (ℝ β†’ ℝ))\n(ramp_def : ramp = fun (n : β„€) => (fun (x : ℝ) => if x ≀ -n then (-n : ℝ) else (if -n < x ∧ x ≀ n then x else (n : ℝ))))\n(F : ℝ β†’ ℝ)\n: Continuous F ↔ (βˆ€ n : β„•, Continuous ((ramp n) ∘ F)) := by \n have h_ramp_def : βˆ€ (n : β„€) (x : ℝ), ramp n x = if x ≀ -n then (-n : ℝ) else (if -n < x ∧ x ≀ n then x else (n : ℝ)) := by\n intro n x\n rw [ramp_def]\n <;> simp [n]\n <;> aesop\n \n have h_imp : Continuous F β†’ (βˆ€ n : β„•, Continuous ((ramp n) ∘ F)) := by\n intro hF\n intro n\n have h₁ : Continuous (ramp n) := by\n have hβ‚‚ : Continuous (fun x : ℝ => min (max x (-(n : ℝ))) (n : ℝ)) := by\n continuity\n have h₃ : (ramp n) = (fun x : ℝ => min (max x (-(n : ℝ))) (n : ℝ)) := by\n funext x\n have hβ‚„ : ramp n x = if x ≀ (-(n : ℝ)) then (-(n : ℝ)) else (if (-(n : ℝ) : ℝ) < x ∧ x ≀ (n : ℝ) then x else (n : ℝ)) := by\n have hβ‚… := h_ramp_def (n : β„€) x\n simp [Int.cast_neg, Int.cast_ofNat] at hβ‚… ⊒\n <;>\n (try norm_num at hβ‚… ⊒) <;>\n (try ring_nf at hβ‚… ⊒) <;>\n (try simp_all) <;>\n (try linarith)\n <;>\n (try\n {\n split_ifs at hβ‚… ⊒ <;>\n simp_all [Int.cast_neg, Int.cast_ofNat] <;>\n norm_num at * <;>\n (try linarith)\n })\n rw [hβ‚„]\n split_ifs <;>\n (try {\n simp_all [max_eq_left, max_eq_right, min_eq_left, min_eq_right, le_of_lt]\n <;>\n (try { nlinarith }) <;>\n (try { linarith })\n }) <;>\n (try {\n cases' le_total x (n : ℝ) with h₆ h₆ <;>\n simp_all [max_eq_left, max_eq_right, min_eq_left, min_eq_right, le_of_lt] <;>\n (try { nlinarith }) <;>\n (try { linarith })\n })\n rw [h₃]\n exact hβ‚‚\n \n exact h₁.comp hF\n \n have h_conv : (βˆ€ n : β„•, Continuous ((ramp n) ∘ F)) β†’ Continuous F := by\n intro h\n have h₁ : Continuous F := by\n have hβ‚‚ : βˆ€ (xβ‚€ : ℝ), ContinuousAt F xβ‚€ := by\n intro xβ‚€\n \n have h₃ : βˆ€ (Ξ΅ : ℝ), Ξ΅ > 0 β†’ (βˆƒ (Ξ΄ : ℝ), Ξ΄ > 0 ∧ βˆ€ (x : ℝ), |x - xβ‚€| < Ξ΄ β†’ |F x - F xβ‚€| < Ξ΅) := by\n intro Ξ΅ Ξ΅pos\n \n have hβ‚„ : βˆƒ (n : β„•), (n : ℝ) > |F xβ‚€| + Ξ΅ := by\n obtain ⟨n, hn⟩ := exists_nat_gt (|F xβ‚€| + Ξ΅)\n refine' ⟨n, _⟩\n exact_mod_cast hn\n obtain ⟨n, hn⟩ := hβ‚„\n have hβ‚… : (n : ℝ) > |F xβ‚€| + Ξ΅ := hn\n have h₆ : Continuous ((ramp n) ∘ F) := h n\n have h₇ : ContinuousAt ((ramp n) ∘ F) xβ‚€ := h₆.continuousAt\n \n have hβ‚ˆ : βˆ€ (Ξ΅ : ℝ), Ξ΅ > 0 β†’ (βˆƒ (Ξ΄ : ℝ), Ξ΄ > 0 ∧ βˆ€ (x : ℝ), |x - xβ‚€| < Ξ΄ β†’ |(ramp n ∘ F) x - (ramp n ∘ F) xβ‚€| < Ξ΅) := by\n intro Ξ΅ Ξ΅pos\n have h₉ : ContinuousAt ((ramp n) ∘ F) xβ‚€ := h₇\n exact Metric.continuousAt_iff.mp h₉ Ξ΅ Ξ΅pos\n have h₉ : βˆƒ (Ξ΄ : ℝ), Ξ΄ > 0 ∧ βˆ€ (x : ℝ), |x - xβ‚€| < Ξ΄ β†’ |(ramp n ∘ F) x - (ramp n ∘ F) xβ‚€| < Ξ΅ := hβ‚ˆ Ξ΅ Ξ΅pos\n obtain ⟨δ, Ξ΄pos, hδ⟩ := h₉\n use Ξ΄\n constructor\n Β· exact Ξ΄pos\n Β· intro x hx\n have h₁₀ : |(ramp n ∘ F) x - (ramp n ∘ F) xβ‚€| < Ξ΅ := hΞ΄ x hx\n have h₁₁ : (ramp n ∘ F) x = ramp n (F x) := rfl\n have h₁₂ : (ramp n ∘ F) xβ‚€ = ramp n (F xβ‚€) := rfl\n rw [h₁₁, h₁₂] at h₁₀\n \n have h₁₃ : ramp n (F xβ‚€) = F xβ‚€ := by\n have h₁₄ : (F xβ‚€ : ℝ) ≀ (n : ℝ) := by\n have h₁₅ : |F xβ‚€| + Ξ΅ < (n : ℝ) := by linarith\n have h₁₆ : |F xβ‚€| < (n : ℝ) := by linarith\n have h₁₇ : F xβ‚€ ≀ |F xβ‚€| := by\n cases' abs_cases (F xβ‚€) with hβ‚β‚ˆ hβ‚β‚ˆ <;> linarith\n linarith\n have h₁₅ : (F xβ‚€ : ℝ) > (-(n : ℝ)) := by\n have h₁₆ : |F xβ‚€| + Ξ΅ < (n : ℝ) := by linarith\n have h₁₇ : |F xβ‚€| < (n : ℝ) := by linarith\n have hβ‚β‚ˆ : - (n : ℝ) < F xβ‚€ := by\n cases' abs_cases (F xβ‚€) with h₁₉ h₁₉ <;> linarith\n linarith\n have h₁₆ : (F xβ‚€ : ℝ) > (-(n : ℝ)) ∧ (F xβ‚€ : ℝ) ≀ (n : ℝ) := ⟨h₁₅, hβ‚β‚„βŸ©\n have h₁₇ : ramp n (F xβ‚€) = (F xβ‚€ : ℝ) := by\n have hβ‚β‚ˆ : ramp n (F xβ‚€) = if (F xβ‚€ : ℝ) ≀ (-(n : ℝ)) then (-(n : ℝ)) else (if (-(n : ℝ)) < (F xβ‚€ : ℝ) ∧ (F xβ‚€ : ℝ) ≀ (n : ℝ) then (F xβ‚€ : ℝ) else (n : ℝ)) := by\n rw [h_ramp_def]\n <;> simp [Int.cast_neg, Int.cast_ofNat]\n <;> norm_num\n <;>\n (try\n {\n ring_nf\n <;>\n norm_cast\n })\n <;>\n (try\n {\n simp_all [Int.cast_neg, Int.cast_ofNat]\n <;>\n norm_num\n <;>\n linarith\n })\n rw [hβ‚β‚ˆ]\n have h₁₉ : Β¬((F xβ‚€ : ℝ) ≀ (-(n : ℝ))) := by\n intro hβ‚‚β‚€\n have h₂₁ : (F xβ‚€ : ℝ) ≀ (-(n : ℝ)) := hβ‚‚β‚€\n have hβ‚‚β‚‚ : (-(n : ℝ)) < (F xβ‚€ : ℝ) := by\n have h₂₃ : |F xβ‚€| + Ξ΅ < (n : ℝ) := by linarith\n have hβ‚‚β‚„ : |F xβ‚€| < (n : ℝ) := by linarith\n cases' abs_cases (F xβ‚€) with hβ‚‚β‚… hβ‚‚β‚… <;> linarith\n linarith\n have hβ‚‚β‚€ : (-(n : ℝ)) < (F xβ‚€ : ℝ) ∧ (F xβ‚€ : ℝ) ≀ (n : ℝ) := h₁₆\n split_ifs at * <;> simp_all [h₁₉] <;>\n (try { contradiction }) <;>\n (try { linarith })\n rw [h₁₇]\n have h₁₄ : ramp n (F x) = F x := by\n by_contra h₁₅\n have h₁₆ : ramp n (F x) β‰  F x := h₁₅\n have h₁₇ : ramp n (F x) = (-(n : ℝ)) ∨ ramp n (F x) = (n : ℝ) := by\n have hβ‚β‚ˆ : ramp n (F x) = if (F x : ℝ) ≀ (-(n : ℝ)) then (-(n : ℝ)) else (if (-(n : ℝ)) < (F x : ℝ) ∧ (F x : ℝ) ≀ (n : ℝ) then (F x : ℝ) else (n : ℝ)) := by\n rw [h_ramp_def]\n <;> simp [Int.cast_neg, Int.cast_ofNat]\n <;> norm_num\n <;>\n (try\n {\n ring_nf\n <;>\n norm_cast\n })\n <;>\n (try\n {\n simp_all [Int.cast_neg, Int.cast_ofNat]\n <;>\n norm_num\n <;>\n linarith\n })\n rw [hβ‚β‚ˆ] at *\n split_ifs at * <;>\n (try { simp_all }) <;>\n (try {\n left\n <;>\n linarith\n }) <;>\n (try {\n right\n <;>\n linarith\n }) <;>\n (try {\n exfalso\n apply h₁₆\n <;>\n simp_all\n })\n cases h₁₇ with\n | inl h₁₇ =>\n have hβ‚β‚ˆ : ramp n (F x) = (-(n : ℝ)) := h₁₇\n have h₁₉ : |(ramp n (F x) : ℝ) - (ramp n (F xβ‚€) : ℝ)| < Ξ΅ := by simpa [h₁₃] using h₁₀\n have hβ‚‚β‚€ : |(-(n : ℝ) : ℝ) - (F xβ‚€ : ℝ)| < Ξ΅ := by simpa [hβ‚β‚ˆ, h₁₃] using h₁₉\n have h₂₁ : (n : ℝ) > |F xβ‚€| + Ξ΅ := by exact_mod_cast hn\n have hβ‚‚β‚‚ : |(-(n : ℝ) : ℝ) - (F xβ‚€ : ℝ)| β‰₯ (n : ℝ) - |F xβ‚€| := by\n cases' abs_cases (F xβ‚€) with h₂₃ h₂₃ <;>\n cases' abs_cases (-(n : ℝ) - F xβ‚€) with hβ‚‚β‚„ hβ‚‚β‚„ <;>\n linarith\n have h₂₃ : (n : ℝ) - |F xβ‚€| > Ξ΅ := by linarith\n linarith\n | inr h₁₇ =>\n have hβ‚β‚ˆ : ramp n (F x) = (n : ℝ) := h₁₇\n have h₁₉ : |(ramp n (F x) : ℝ) - (ramp n (F xβ‚€) : ℝ)| < Ξ΅ := by simpa [h₁₃] using h₁₀\n have hβ‚‚β‚€ : |(n : ℝ) - (F xβ‚€ : ℝ)| < Ξ΅ := by simpa [hβ‚β‚ˆ, h₁₃] using h₁₉\n have h₂₁ : (n : ℝ) > |F xβ‚€| + Ξ΅ := by exact_mod_cast hn\n have hβ‚‚β‚‚ : |(n : ℝ) - (F xβ‚€ : ℝ)| β‰₯ (n : ℝ) - |F xβ‚€| := by\n cases' abs_cases (F xβ‚€) with h₂₃ h₂₃ <;>\n cases' abs_cases ((n : ℝ) - F xβ‚€) with hβ‚‚β‚„ hβ‚‚β‚„ <;>\n linarith\n have h₂₃ : (n : ℝ) - |F xβ‚€| > Ξ΅ := by linarith\n linarith\n have h₁₅ : |F x - F xβ‚€| < Ξ΅ := by\n have h₁₆ : ramp n (F x) = F x := h₁₄\n have h₁₇ : ramp n (F xβ‚€) = F xβ‚€ := h₁₃\n have hβ‚β‚ˆ : |(ramp n (F x) : ℝ) - (ramp n (F xβ‚€) : ℝ)| < Ξ΅ := by simpa [h₁₆, h₁₇] using h₁₀\n simpa [h₁₆, h₁₇] using hβ‚β‚ˆ\n exact h₁₅\n <;>\n simp_all [abs_lt]\n <;>\n linarith\n \n have hβ‚„ : ContinuousAt F xβ‚€ := by\n rw [Metric.continuousAt_iff]\n intro Ξ΅ Ξ΅pos\n obtain ⟨δ, Ξ΄pos, hδ⟩ := h₃ Ξ΅ Ξ΅pos\n refine' ⟨δ, Ξ΄pos, _⟩\n intro x hx\n have hβ‚… : |F x - F xβ‚€| < Ξ΅ := hΞ΄ x hx\n exact hβ‚…\n exact hβ‚„\n \n exact continuous_iff_continuousAt.mpr hβ‚‚\n exact h₁\n \n constructor\n Β· intro h\n exact h_imp h\n Β· intro h\n exact h_conv h"}
{"name": "putnam_1968_a1", "proof_length": 1084, "header": "import Mathlib\nimport Aesop\n\nset_option maxHeartbeats 0\n\n\n", "signature": "theorem putnam_1968_a1\n: 22/7 - Real.pi = ∫ x in (0)..1, x^4 * (1 - x)^4 / (1 + x^2)", "src": "theorem putnam_1968_a1\n: 22/7 - Real.pi = ∫ x in (0)..1, x^4 * (1 - x)^4 / (1 + x^2) := by \n have h_main : (∫ x in (0)..1, x^4 * (1 - x)^4 / (1 + x^2)) = 22/7 - Real.pi := by\n have h₁ : (∫ x in (0)..1, x^4 * (1 - x)^4 / (1 + x^2)) = (∫ x in (0)..1, (x^6 - 4*x^5 + 5*x^4 - 4*x^2 + 4 : ℝ) - 4 / (1 + x^2)) := by\n have h₁₁ : βˆ€ (x : ℝ), x^4 * (1 - x)^4 / (1 + x^2) = (x^6 - 4*x^5 + 5*x^4 - 4*x^2 + 4 : ℝ) - 4 / (1 + x^2) := by\n intro x\n have h₁₂ : (1 + x^2 : ℝ) β‰  0 := by nlinarith\n have h₁₃ : x^4 * (1 - x)^4 = (x^6 - 4*x^5 + 5*x^4 - 4*x^2 + 4 : ℝ) * (1 + x^2) - 4 := by\n ring_nf\n <;>\n nlinarith [sq_nonneg (x ^ 2), sq_nonneg (x ^ 3), sq_nonneg (x - 1), sq_nonneg (x + 1)]\n have h₁₄ : x^4 * (1 - x)^4 / (1 + x^2) = ((x^6 - 4*x^5 + 5*x^4 - 4*x^2 + 4 : ℝ) * (1 + x^2) - 4) / (1 + x^2) := by\n rw [h₁₃]\n rw [h₁₄]\n field_simp [h₁₂]\n <;> ring_nf\n <;> field_simp [h₁₂]\n <;> ring_nf\n \n congr\n ext x\n rw [h₁₁ x]\n rw [h₁]\n \n have hβ‚‚ : (∫ x in (0)..1, (x^6 - 4*x^5 + 5*x^4 - 4*x^2 + 4 : ℝ) - 4 / (1 + x^2)) = (∫ x in (0)..1, (x^6 - 4*x^5 + 5*x^4 - 4*x^2 + 4 : ℝ)) - (∫ x in (0)..1, (4 : ℝ) / (1 + x^2)) := by\n apply intervalIntegral.integral_sub\n Β· \n apply Continuous.intervalIntegrable\n continuity\n Β· \n apply Continuous.intervalIntegrable\n \n have h₃ : Continuous (fun x : ℝ => (4 : ℝ) / (1 + x ^ 2)) := by\n apply Continuous.div\n Β· exact continuous_const\n Β· exact Continuous.add continuous_const (continuous_pow 2)\n Β· intro x\n have hβ‚„ : (1 + x ^ 2 : ℝ) β‰  0 := by nlinarith\n exact hβ‚„\n exact h₃\n rw [hβ‚‚]\n \n have h₃ : (∫ x in (0)..1, (x^6 - 4*x^5 + 5*x^4 - 4*x^2 + 4 : ℝ)) = (22 / 7 : ℝ) := by\n norm_num [integral_id, mul_comm]\n <;>\n ring_nf\n <;>\n norm_num\n <;>\n linarith [Real.pi_pos]\n \n have hβ‚„ : (∫ x in (0)..1, (4 : ℝ) / (1 + x^2)) = Real.pi := by\n have h₄₁ : (∫ x in (0)..1, (4 : ℝ) / (1 + x ^ 2)) = 4 * (∫ x in (0)..1, (1 : ℝ) / (1 + x ^ 2)) := by\n \n have hβ‚„β‚‚ : (∫ x in (0)..1, (4 : ℝ) / (1 + x ^ 2)) = (∫ x in (0)..1, 4 * (1 : ℝ) / (1 + x ^ 2)) := by\n congr\n ext x\n <;> ring_nf\n rw [hβ‚„β‚‚]\n have h₄₃ : (∫ x in (0)..1, 4 * (1 : ℝ) / (1 + x ^ 2)) = 4 * (∫ x in (0)..1, (1 : ℝ) / (1 + x ^ 2)) := by\n \n simp [intervalIntegral.integral_comp_mul_left (fun x => (1 : ℝ) / (1 + x ^ 2))]\n <;>\n norm_num\n <;>\n field_simp\n <;>\n ring_nf\n <;>\n norm_num\n <;>\n linarith [Real.pi_pos]\n rw [h₄₃]\n rw [h₄₁]\n have hβ‚„β‚„ : (∫ x in (0)..1, (1 : ℝ) / (1 + x ^ 2)) = Real.pi / 4 := by\n \n have hβ‚„β‚… : (∫ x in (0)..1, (1 : ℝ) / (1 + x ^ 2)) = Real.arctan 1 - Real.arctan 0 := by\n \n rw [integral_one_div_one_add_sq]\n <;>\n norm_num\n rw [hβ‚„β‚…]\n have h₄₆ : Real.arctan 1 = Real.pi / 4 := by\n \n norm_num [Real.arctan_one]\n have h₄₇ : Real.arctan 0 = 0 := by\n \n norm_num [Real.arctan_zero]\n rw [h₄₆, h₄₇]\n <;>\n ring_nf\n <;>\n norm_num\n rw [hβ‚„β‚„]\n <;>\n ring_nf\n <;>\n norm_num\n \n rw [h₃, hβ‚„]\n <;>\n ring_nf\n <;>\n norm_num\n \n have h_final : 22/7 - Real.pi = ∫ x in (0)..1, x^4 * (1 - x)^4 / (1 + x^2) := by\n rw [h_main]\n <;>\n linarith [Real.pi_pos]\n \n exact h_final"}
{"name": "putnam_1991_b1", "proof_length": 3313, "header": "import Mathlib\nimport Aesop\n\nset_option maxHeartbeats 0\n\nopen Filter Topology\n\n\n\n", "signature": "theorem putnam_1991_b1\n (m S : β„€ β†’ β„€)\n (A : β„€)\n (a : β„• β†’ β„€)\n (hm : βˆ€ n, 0 ≀ n β†’ (m n) ^ 2 ≀ n ∧ (βˆ€ m' : β„€, m' ^ 2 ≀ n β†’ m' ≀ m n))\n (hS : βˆ€ n, 0 ≀ n β†’ S n = n - (m n) ^ 2)\n (ha : a 0 = A ∧ (βˆ€ k, a (k + 1) = a k + S (a k)))\n (hA : A > 0) :\n (βˆƒ (K : β„•) (c : β„•), βˆ€ k β‰₯ K, a k = c) ↔ A ∈ (({A : β„€ | βˆƒ x > 0, A = x ^ 2}) : Set β„€ )", "src": "theorem putnam_1991_b1\n (m S : β„€ β†’ β„€)\n (A : β„€)\n (a : β„• β†’ β„€)\n (hm : βˆ€ n, 0 ≀ n β†’ (m n) ^ 2 ≀ n ∧ (βˆ€ m' : β„€, m' ^ 2 ≀ n β†’ m' ≀ m n))\n (hS : βˆ€ n, 0 ≀ n β†’ S n = n - (m n) ^ 2)\n (ha : a 0 = A ∧ (βˆ€ k, a (k + 1) = a k + S (a k)))\n (hA : A > 0) :\n (βˆƒ (K : β„•) (c : β„•), βˆ€ k β‰₯ K, a k = c) ↔ A ∈ (({A : β„€ | βˆƒ x > 0, A = x ^ 2}) : Set β„€ ) := by \n have h_nonneg : βˆ€ (k : β„•), a k β‰₯ 0 := by\n intro k\n induction k with\n | zero =>\n have h₁ : a 0 = A := ha.1\n linarith\n | succ k ih =>\n have h₁ : a (k + 1) = a k + S (a k) := ha.2 k\n rw [h₁]\n have hβ‚‚ : 0 ≀ a k := ih\n have h₃ : S (a k) = a k - (m (a k)) ^ 2 := hS (a k) hβ‚‚\n have hβ‚„ : (m (a k)) ^ 2 ≀ a k := (hm (a k) hβ‚‚).1\n have hβ‚… : S (a k) β‰₯ 0 := by\n rw [h₃]\n linarith\n linarith\n \n have h_nondec : βˆ€ k, a (k + 1) β‰₯ a k := by\n intro k\n have h₁ : a (k + 1) = a k + S (a k) := (ha.2) k\n rw [h₁]\n have hβ‚‚ : 0 ≀ a k := h_nonneg k\n have h₃ : S (a k) = a k - (m (a k)) ^ 2 := hS (a k) hβ‚‚\n have hβ‚„ : (m (a k)) ^ 2 ≀ a k := (hm (a k) hβ‚‚).1\n have hβ‚… : S (a k) β‰₯ 0 := by\n rw [h₃]\n linarith\n linarith\n \n have h_S_pos : βˆ€ (n : β„€), 0 ≀ n β†’ (βˆ€ (t : β„€), n β‰  t ^ 2) β†’ S n β‰₯ 1 := by\n intro n hn hnotsquare\n have h₁ : S n = n - (m n) ^ 2 := hS n hn\n rw [h₁]\n have hβ‚‚ : (m n) ^ 2 ≀ n := (hm n hn).1\n have h₃ : βˆ€ (m' : β„€), m' ^ 2 ≀ n β†’ m' ≀ m n := (hm n hn).2\n \n have hβ‚„ : n - (m n) ^ 2 β‰₯ 1 := by\n by_contra h\n \n have hβ‚… : n - (m n) ^ 2 ≀ 0 := by\n linarith\n \n have h₆ : (m n + 1 : β„€) ^ 2 > n := by\n by_contra h₆\n have h₇ : (m n + 1 : β„€) ^ 2 ≀ n := by linarith\n have hβ‚ˆ : m n + 1 ≀ m n := h₃ (m n + 1) h₇\n linarith\n \n have h₇ : (m n : β„€) ^ 2 ≀ n := hβ‚‚\n have hβ‚ˆ : (m n + 1 : β„€) ^ 2 > n := h₆\n have h₉ : (m n + 1 : β„€) ^ 2 > n := hβ‚ˆ\n \n \n \n \n \n \n \n have h₁₀ : (m n : β„€) ^ 2 = n := by\n nlinarith\n \n have h₁₁ : βˆƒ (t : β„€), n = t ^ 2 := by\n refine' ⟨m n, _⟩\n linarith\n \n obtain ⟨t, ht⟩ := h₁₁\n have h₁₂ : n = t ^ 2 := ht\n have h₁₃ : n β‰  t ^ 2 := hnotsquare t\n contradiction\n \n linarith\n \n have h_no_new_squares : βˆ€ (k : β„•), (βˆ€ (t : β„€), a k β‰  t ^ 2) β†’ (βˆ€ (t : β„€), a (k + 1) β‰  t ^ 2) := by\n intro k hk\n intro t ht\n have h₁ : a (k + 1) = a k + S (a k) := ha.2 k\n have hβ‚‚ : 0 ≀ a k := h_nonneg k\n have h₃ : S (a k) = a k - (m (a k)) ^ 2 := hS (a k) hβ‚‚\n have hβ‚„ : a (k + 1) = a k + (a k - (m (a k)) ^ 2) := by\n rw [h₁, h₃]\n <;> ring\n have hβ‚… : a (k + 1) = 2 * a k - (m (a k)) ^ 2 := by\n linarith\n have h₆ : a (k + 1) = t ^ 2 := ht\n have h₇ : 2 * a k - (m (a k)) ^ 2 = t ^ 2 := by linarith\n have hβ‚ˆ : (m (a k)) ^ 2 ≀ a k := (hm (a k) hβ‚‚).1\n have h₉ : βˆ€ (m' : β„€), m' ^ 2 ≀ a k β†’ m' ≀ m (a k) := (hm (a k) hβ‚‚).2\n have h₁₀ : a k < (m (a k) + 1) ^ 2 := by\n by_contra h\n have h₁₁ : (m (a k) + 1 : β„€) ^ 2 ≀ a k := by linarith\n have h₁₂ : m (a k) + 1 ≀ m (a k) := h₉ (m (a k) + 1) h₁₁\n linarith\n \n \n \n have h₁₁ : m (a k) β‰₯ 0 := by\n by_contra h\n have h₁₂ : m (a k) < 0 := by linarith\n have h₁₃ : (m (a k)) ^ 2 > 0 := by nlinarith\n have h₁₄ : (m (a k) + 1 : β„€) ^ 2 ≀ a k := by\n nlinarith [hβ‚ˆ]\n have h₁₅ : m (a k) + 1 ≀ m (a k) := h₉ (m (a k) + 1) h₁₄\n linarith\n \n \n have h₁₂ : t ^ 2 = 2 * a k - (m (a k)) ^ 2 := by linarith\n have h₁₃ : (m (a k)) ^ 2 < t ^ 2 := by\n have h₁₄ : (m (a k)) ^ 2 < a k := by\n by_contra h₁₄\n have h₁₅ : (m (a k)) ^ 2 β‰₯ a k := by linarith\n have h₁₆ : (m (a k)) ^ 2 ≀ a k := hβ‚ˆ\n have h₁₇ : (m (a k)) ^ 2 = a k := by linarith\n have hβ‚β‚ˆ : βˆƒ (t : β„€), a k = t ^ 2 := by\n refine' ⟨m (a k), _⟩\n linarith\n obtain ⟨t', ht'⟩ := hβ‚β‚ˆ\n have h₁₉ : a k = t' ^ 2 := ht'\n have hβ‚‚β‚€ : a k β‰  t' ^ 2 := hk t'\n contradiction\n nlinarith\n have h₁₄ : t ^ 2 < (m (a k) + 2) ^ 2 := by\n nlinarith [h₁₀]\n \n \n have h₁₅ : t = m (a k) + 1 ∨ t = -(m (a k) + 1) := by\n have h₁₆ : m (a k) β‰₯ 0 := h₁₁\n have h₁₇ : t ^ 2 < (m (a k) + 2) ^ 2 := h₁₄\n have hβ‚β‚ˆ : (m (a k)) ^ 2 < t ^ 2 := h₁₃\n have h₁₉ : t ≀ m (a k) + 1 := by\n nlinarith\n have hβ‚‚β‚€ : t β‰₯ -(m (a k) + 1) := by\n nlinarith\n have h₂₁ : t β‰₯ m (a k) + 1 ∨ t ≀ -(m (a k) + 1) := by\n by_contra! hβ‚‚β‚‚\n have h₂₃ : -(m (a k) + 1) < t := by linarith\n have hβ‚‚β‚„ : t < m (a k) + 1 := by linarith\n have hβ‚‚β‚… : t ^ 2 < (m (a k) + 1) ^ 2 := by\n nlinarith\n nlinarith\n cases h₂₁ with\n | inl h₂₁ =>\n have hβ‚‚β‚‚ : t = m (a k) + 1 := by\n nlinarith\n exact Or.inl hβ‚‚β‚‚\n | inr h₂₁ =>\n have hβ‚‚β‚‚ : t = -(m (a k) + 1) := by\n nlinarith\n exact Or.inr hβ‚‚β‚‚\n \n cases h₁₅ with\n | inl h₁₅ =>\n have h₁₆ : t = m (a k) + 1 := h₁₅\n have h₁₇ : t ^ 2 = (m (a k) + 1) ^ 2 := by\n rw [h₁₆]\n <;> ring_nf\n have hβ‚β‚ˆ : 2 * a k - (m (a k)) ^ 2 = (m (a k) + 1) ^ 2 := by\n linarith\n have h₁₉ : 2 * a k = 2 * (m (a k)) ^ 2 + 2 * m (a k) + 1 := by\n nlinarith\n have hβ‚‚β‚€ : (2 : β„€) * a k % 2 = 1 := by\n have h₂₁ : (2 : β„€) * a k = 2 * (m (a k)) ^ 2 + 2 * m (a k) + 1 := h₁₉\n omega\n have h₂₁ : (2 : β„€) * a k % 2 = 0 := by\n have hβ‚‚β‚‚ : (2 : β„€) * a k % 2 = 0 := by\n have h₂₃ : (2 : β„€) * a k % 2 = 0 := by\n omega\n exact h₂₃\n exact hβ‚‚β‚‚\n omega\n | inr h₁₅ =>\n have h₁₆ : t = -(m (a k) + 1) := h₁₅\n have h₁₇ : t ^ 2 = (m (a k) + 1) ^ 2 := by\n rw [h₁₆]\n <;> ring_nf\n <;> simp [sq]\n <;> linarith\n have hβ‚β‚ˆ : 2 * a k - (m (a k)) ^ 2 = (m (a k) + 1) ^ 2 := by\n linarith\n have h₁₉ : 2 * a k = 2 * (m (a k)) ^ 2 + 2 * m (a k) + 1 := by\n nlinarith\n have hβ‚‚β‚€ : (2 : β„€) * a k % 2 = 1 := by\n have h₂₁ : (2 : β„€) * a k = 2 * (m (a k)) ^ 2 + 2 * m (a k) + 1 := h₁₉\n omega\n have h₂₁ : (2 : β„€) * a k % 2 = 0 := by\n have hβ‚‚β‚‚ : (2 : β„€) * a k % 2 = 0 := by\n have h₂₃ : (2 : β„€) * a k % 2 = 0 := by\n omega\n exact h₂₃\n exact hβ‚‚β‚‚\n omega\n \n have h_strict_increasing : (βˆ€ (t : β„€), A β‰  t ^ 2) β†’ βˆ€ (k : β„•), a (k + 1) > a k := by\n intro hA_not_square k\n have h₁ : βˆ€ (k : β„•), (βˆ€ (t : β„€), a k β‰  t ^ 2) := by\n intro k\n induction k with\n | zero =>\n intro t ht\n have hβ‚‚ : a 0 = A := ha.1\n rw [hβ‚‚] at ht\n exact hA_not_square t ht\n | succ k ih =>\n intro t ht\n have hβ‚‚ : (βˆ€ (t : β„€), a k β‰  t ^ 2) := ih\n have h₃ : (βˆ€ (t : β„€), a (k + 1) β‰  t ^ 2) := h_no_new_squares k hβ‚‚\n exact h₃ t ht\n have hβ‚‚ : (βˆ€ (t : β„€), a k β‰  t ^ 2) := h₁ k\n have h₃ : 0 ≀ a k := h_nonneg k\n have hβ‚„ : S (a k) β‰₯ 1 := h_S_pos (a k) h₃ hβ‚‚\n have hβ‚… : a (k + 1) = a k + S (a k) := ha.2 k\n have h₆ : a (k + 1) > a k := by\n linarith\n exact h₆\n \n have h_imp : (βˆƒ (K : β„•) (c : β„•), βˆ€ k β‰₯ K, a k = c) β†’ A ∈ (({A : β„€ | βˆƒ x > 0, A = x ^ 2}) : Set β„€) := by\n intro h\n by_contra h₁\n \n have hβ‚‚ : βˆ€ (t : β„€), A β‰  t ^ 2 := by\n intro t ht\n have h₃ : A ∈ ({A : β„€ | βˆƒ x > 0, A = x ^ 2} : Set β„€) := by\n refine' ⟨t.natAbs, _⟩\n have hβ‚„ : A = t ^ 2 := ht\n have hβ‚… : (t.natAbs : β„€) > 0 := by\n have h₆ : t β‰  0 := by\n by_contra h₆\n rw [h₆] at hβ‚„\n have h₇ : A = 0 := by\n norm_num at hβ‚„ ⊒\n <;> linarith\n linarith\n have hβ‚ˆ : t.natAbs > 0 := by\n exact Nat.pos_of_ne_zero (by\n intro h₉\n have h₁₀ : t.natAbs = 0 := h₉\n have h₁₁ : t = 0 := by\n simp [Int.natAbs_eq_zero] at h₁₀ ⊒\n <;> omega\n contradiction\n )\n exact_mod_cast hβ‚ˆ\n have h₉ : A = (t.natAbs : β„€) ^ 2 := by\n have h₁₀ : A = t ^ 2 := ht\n have h₁₁ : (t.natAbs : β„€) ^ 2 = t ^ 2 := by\n simp [sq, Int.natAbs_mul]\n <;> cases' le_or_lt 0 t with h₁₂ h₁₂ <;> simp_all [Int.natAbs_of_nonneg, Int.natAbs_of_nonpos, pow_two] <;>\n ring_nf <;> nlinarith\n linarith\n exact ⟨by exact_mod_cast hβ‚…, by linarith⟩\n contradiction\n \n have h₃ : βˆ€ (k : β„•), a (k + 1) > a k := h_strict_increasing hβ‚‚\n \n obtain ⟨K, c, hβ‚„βŸ© := h\n have hβ‚… : a (K + 1) > a K := h₃ K\n have h₆ : a (K + 1) = c := by\n have h₇ : K + 1 β‰₯ K := by linarith\n have hβ‚ˆ : a (K + 1) = c := hβ‚„ (K + 1) h₇\n exact hβ‚ˆ\n have h₇ : a K = c := by\n have hβ‚ˆ : K β‰₯ K := by linarith\n have h₉ : a K = c := hβ‚„ K hβ‚ˆ\n exact h₉\n linarith\n \n have h_conv : A ∈ (({A : β„€ | βˆƒ x > 0, A = x ^ 2}) : Set β„€) β†’ (βˆƒ (K : β„•) (c : β„•), βˆ€ k β‰₯ K, a k = c) := by\n intro h\n obtain ⟨x, hx, hx'⟩ := h\n have h₁ : a 0 = A := ha.1\n have hβ‚‚ : βˆ€ k, a (k + 1) = a k + S (a k) := ha.2\n have h₃ : βˆ€ k, a k = A := by\n intro k\n induction k with\n | zero => simp [h₁]\n | succ k ih =>\n have hβ‚„ : a (k + 1) = a k + S (a k) := hβ‚‚ k\n rw [hβ‚„]\n have hβ‚… : a k = A := ih\n rw [hβ‚…]\n have h₆ : S A = 0 := by\n have h₇ : 0 ≀ A := by linarith\n have hβ‚ˆ : S A = A - (m A) ^ 2 := hS A h₇\n rw [hβ‚ˆ]\n have h₉ : (m A) ^ 2 ≀ A := (hm A h₇).1\n have h₁₀ : βˆ€ (m' : β„€), m' ^ 2 ≀ A β†’ m' ≀ m A := (hm A h₇).2\n have h₁₁ : A = x ^ 2 := by\n norm_cast at hx' ⊒\n <;> simp_all [pow_two]\n <;> nlinarith\n have h₁₂ : (m A : β„€) = x := by\n have h₁₃ : (m A : β„€) β‰₯ 0 := by\n by_contra h₁₄\n have h₁₅ : (m A : β„€) < 0 := by linarith\n have h₁₆ : (m A : β„€) ^ 2 > 0 := by nlinarith\n have h₁₇ : (m A + 1 : β„€) ^ 2 ≀ A := by\n nlinarith [h₉]\n have hβ‚β‚ˆ : m A + 1 ≀ m A := h₁₀ (m A + 1) h₁₇\n linarith\n have h₁₉ : (m A : β„€) ≀ x := by\n have hβ‚‚β‚€ : (m A : β„€) ^ 2 ≀ A := h₉\n have h₂₁ : A = x ^ 2 := by\n norm_cast at hx' ⊒\n <;> simp_all [pow_two]\n <;> nlinarith\n have hβ‚‚β‚‚ : (m A : β„€) ^ 2 ≀ x ^ 2 := by\n linarith\n nlinarith\n have hβ‚‚β‚€ : (m A : β„€) β‰₯ x := by\n by_contra h₂₁\n have hβ‚‚β‚‚ : (m A : β„€) < x := by linarith\n have h₂₃ : (m A + 1 : β„€) ≀ x := by\n linarith\n have hβ‚‚β‚„ : (m A + 1 : β„€) ^ 2 ≀ x ^ 2 := by\n have hβ‚‚β‚… : (m A + 1 : β„€) ≀ x := by linarith\n have h₂₆ : 0 ≀ (m A + 1 : β„€) := by\n nlinarith [h₁₃]\n nlinarith\n have hβ‚‚β‚… : (m A + 1 : β„€) ^ 2 ≀ A := by\n have h₂₆ : A = x ^ 2 := by\n norm_cast at hx' ⊒\n <;> simp_all [pow_two]\n <;> nlinarith\n linarith\n have h₂₆ : m A + 1 ≀ m A := h₁₀ (m A + 1) hβ‚‚β‚…\n linarith\n linarith\n have h₂₁ : (m A : β„€) = x := h₁₂\n have hβ‚‚β‚‚ : (m A : β„€) ^ 2 = x ^ 2 := by\n rw [h₂₁]\n have h₂₃ : A = x ^ 2 := by\n norm_cast at hx' ⊒\n <;> simp_all [pow_two]\n <;> nlinarith\n linarith\n linarith\n refine' ⟨0, Int.toNat A, _⟩\n intro k hk\n have hβ‚„ : a k = A := h₃ k\n have hβ‚… : 0 ≀ A := by linarith\n have h₆ : (A : β„€) = Int.toNat A := by\n rw [Int.toNat_of_nonneg hβ‚…]\n <;> simp\n rw [hβ‚„]\n <;> norm_cast at h₆ ⊒ <;> simp_all\n <;>\n (try omega)\n \n constructor\n Β· \n intro h\n exact h_imp h\n Β· \n intro h\n exact h_conv h"}
{"name": "putnam_2019_a1", "proof_length": 2381, "header": "import Mathlib\nimport Aesop\n\nset_option maxHeartbeats 0\n\nopen Topology Filter\n\n\n\n", "signature": "theorem putnam_2019_a1\n: {n : β„€ | βˆƒ A B C : β„€, A β‰₯ 0 ∧ B β‰₯ 0 ∧ C β‰₯ 0 ∧ A^3 + B^3 + C^3 - 3*A*B*C = n} = (({n : β„€ | n β‰₯ 0 ∧ Β¬Int.ModEq 9 n 3 ∧ Β¬Int.ModEq 9 n 6}) : Set β„€ )", "src": "theorem putnam_2019_a1\n: {n : β„€ | βˆƒ A B C : β„€, A β‰₯ 0 ∧ B β‰₯ 0 ∧ C β‰₯ 0 ∧ A^3 + B^3 + C^3 - 3*A*B*C = n} = (({n : β„€ | n β‰₯ 0 ∧ Β¬Int.ModEq 9 n 3 ∧ Β¬Int.ModEq 9 n 6}) : Set β„€ ) := by \n have h_subset₁ : {n : β„€ | βˆƒ A B C : β„€, A β‰₯ 0 ∧ B β‰₯ 0 ∧ C β‰₯ 0 ∧ A^3 + B^3 + C^3 - 3*A*B*C = n} βŠ† ({n : β„€ | n β‰₯ 0 ∧ Β¬Int.ModEq 9 n 3 ∧ Β¬Int.ModEq 9 n 6} : Set β„€) := by\n intro n hn\n rcases hn with ⟨A, B, C, hA, hB, hC, hn⟩\n have h₁ : n β‰₯ 0 := by\n have h₁ : (A : β„€) β‰₯ 0 := by exact_mod_cast hA\n have hβ‚‚ : (B : β„€) β‰₯ 0 := by exact_mod_cast hB\n have h₃ : (C : β„€) β‰₯ 0 := by exact_mod_cast hC\n have hβ‚„ : (A : β„€)^3 + (B : β„€)^3 + (C : β„€)^3 - 3 * (A : β„€) * (B : β„€) * (C : β„€) β‰₯ 0 := by\n nlinarith [sq_nonneg (A - B), sq_nonneg (B - C), sq_nonneg (C - A),\n mul_nonneg h₁ hβ‚‚, mul_nonneg hβ‚‚ h₃, mul_nonneg h₃ h₁,\n sq_nonneg (A + B + C), sq_nonneg (A + B - C), sq_nonneg (A + C - B),\n sq_nonneg (B + C - A)]\n linarith\n have hβ‚‚ : Β¬Int.ModEq 9 n 3 := by\n have hβ‚‚ : βˆ€ (A B C : β„€), A β‰₯ 0 β†’ B β‰₯ 0 β†’ C β‰₯ 0 β†’ (A^3 + B^3 + C^3 - 3*A*B*C) % 9 β‰  3 := by\n intro A B C hA hB hC\n have h₃ : A % 9 = 0 ∨ A % 9 = 1 ∨ A % 9 = 2 ∨ A % 9 = 3 ∨ A % 9 = 4 ∨ A % 9 = 5 ∨ A % 9 = 6 ∨ A % 9 = 7 ∨ A % 9 = 8 := by\n omega\n have hβ‚„ : B % 9 = 0 ∨ B % 9 = 1 ∨ B % 9 = 2 ∨ B % 9 = 3 ∨ B % 9 = 4 ∨ B % 9 = 5 ∨ B % 9 = 6 ∨ B % 9 = 7 ∨ B % 9 = 8 := by\n omega\n have hβ‚… : C % 9 = 0 ∨ C % 9 = 1 ∨ C % 9 = 2 ∨ C % 9 = 3 ∨ C % 9 = 4 ∨ C % 9 = 5 ∨ C % 9 = 6 ∨ C % 9 = 7 ∨ C % 9 = 8 := by\n omega\n rcases h₃ with (h₃ | h₃ | h₃ | h₃ | h₃ | h₃ | h₃ | h₃ | h₃) <;>\n rcases hβ‚„ with (hβ‚„ | hβ‚„ | hβ‚„ | hβ‚„ | hβ‚„ | hβ‚„ | hβ‚„ | hβ‚„ | hβ‚„) <;>\n rcases hβ‚… with (hβ‚… | hβ‚… | hβ‚… | hβ‚… | hβ‚… | hβ‚… | hβ‚… | hβ‚… | hβ‚…) <;>\n (try omega) <;>\n (try {\n simp [h₃, hβ‚„, hβ‚…, pow_three, Int.mul_emod, Int.add_emod, Int.sub_emod]\n <;> norm_num <;> omega\n })\n have h₃ := hβ‚‚ A B C hA hB hC\n intro hβ‚„\n have hβ‚… : (n : β„€) % 9 = 3 := by\n rw [Int.ModEq] at hβ‚„\n omega\n have h₆ : (A^3 + B^3 + C^3 - 3*A*B*C) % 9 = 3 := by\n omega\n contradiction\n have h₃ : Β¬Int.ModEq 9 n 6 := by\n have hβ‚‚ : βˆ€ (A B C : β„€), A β‰₯ 0 β†’ B β‰₯ 0 β†’ C β‰₯ 0 β†’ (A^3 + B^3 + C^3 - 3*A*B*C) % 9 β‰  6 := by\n intro A B C hA hB hC\n have h₃ : A % 9 = 0 ∨ A % 9 = 1 ∨ A % 9 = 2 ∨ A % 9 = 3 ∨ A % 9 = 4 ∨ A % 9 = 5 ∨ A % 9 = 6 ∨ A % 9 = 7 ∨ A % 9 = 8 := by\n omega\n have hβ‚„ : B % 9 = 0 ∨ B % 9 = 1 ∨ B % 9 = 2 ∨ B % 9 = 3 ∨ B % 9 = 4 ∨ B % 9 = 5 ∨ B % 9 = 6 ∨ B % 9 = 7 ∨ B % 9 = 8 := by\n omega\n have hβ‚… : C % 9 = 0 ∨ C % 9 = 1 ∨ C % 9 = 2 ∨ C % 9 = 3 ∨ C % 9 = 4 ∨ C % 9 = 5 ∨ C % 9 = 6 ∨ C % 9 = 7 ∨ C % 9 = 8 := by\n omega\n rcases h₃ with (h₃ | h₃ | h₃ | h₃ | h₃ | h₃ | h₃ | h₃ | h₃) <;>\n rcases hβ‚„ with (hβ‚„ | hβ‚„ | hβ‚„ | hβ‚„ | hβ‚„ | hβ‚„ | hβ‚„ | hβ‚„ | hβ‚„) <;>\n rcases hβ‚… with (hβ‚… | hβ‚… | hβ‚… | hβ‚… | hβ‚… | hβ‚… | hβ‚… | hβ‚… | hβ‚…) <;>\n (try omega) <;>\n (try {\n simp [h₃, hβ‚„, hβ‚…, pow_three, Int.mul_emod, Int.add_emod, Int.sub_emod]\n <;> norm_num <;> omega\n })\n have h₃ := hβ‚‚ A B C hA hB hC\n intro hβ‚„\n have hβ‚… : (n : β„€) % 9 = 6 := by\n rw [Int.ModEq] at hβ‚„\n omega\n have h₆ : (A^3 + B^3 + C^3 - 3*A*B*C) % 9 = 6 := by\n omega\n contradiction\n exact ⟨h₁, hβ‚‚, hβ‚ƒβŸ©\n \n have h_subsetβ‚‚ : ({n : β„€ | n β‰₯ 0 ∧ Β¬Int.ModEq 9 n 3 ∧ Β¬Int.ModEq 9 n 6} : Set β„€) βŠ† {n : β„€ | βˆƒ A B C : β„€, A β‰₯ 0 ∧ B β‰₯ 0 ∧ C β‰₯ 0 ∧ A^3 + B^3 + C^3 - 3*A*B*C = n} := by\n intro n hn\n have h₁ : n β‰₯ 0 := hn.1\n have hβ‚‚ : Β¬Int.ModEq 9 n 3 := hn.2.1\n have h₃ : Β¬Int.ModEq 9 n 6 := hn.2.2\n \n have hβ‚„ : n % 3 = 0 ∨ n % 3 = 1 ∨ n % 3 = 2 := by\n have hβ‚„ : n % 3 = 0 ∨ n % 3 = 1 ∨ n % 3 = 2 := by omega\n exact hβ‚„\n rcases hβ‚„ with (hβ‚„ | hβ‚„ | hβ‚„)\n Β· \n have hβ‚… : n % 9 β‰  3 := by\n intro hβ‚…\n have h₆ : Int.ModEq 9 n 3 := by\n rw [Int.ModEq]\n omega\n contradiction\n have h₆ : n % 9 β‰  6 := by\n intro h₆\n have h₇ : Int.ModEq 9 n 6 := by\n rw [Int.ModEq]\n omega\n contradiction\n \n have h₇ : n % 9 = 0 := by\n have h₇ : n % 9 = 0 ∨ n % 9 = 3 ∨ n % 9 = 6 := by\n omega\n rcases h₇ with (h₇ | h₇ | h₇)\n Β· exact h₇\n Β· exfalso\n exact hβ‚… h₇\n Β· exfalso\n exact h₆ h₇\n \n have hβ‚ˆ : βˆƒ (k : β„€), n = 9 * k := by\n use n / 9\n have hβ‚ˆ : n % 9 = 0 := h₇\n have h₉ : n = 9 * (n / 9) := by\n omega\n exact h₉\n rcases hβ‚ˆ with ⟨k, hk⟩\n by_cases h₉ : k = 0\n Β· \n use 0, 0, 0\n simp [h₉, hk]\n <;> norm_num\n Β· \n have h₁₀ : k > 0 := by\n by_contra h₁₀\n have h₁₁ : k ≀ 0 := by linarith\n have h₁₂ : n ≀ 0 := by\n have h₁₃ : (9 : β„€) * k ≀ 0 := by nlinarith\n linarith\n have h₁₃ : n β‰₯ 0 := h₁\n have h₁₄ : n = 0 := by linarith\n have h₁₅ : k = 0 := by\n omega\n contradiction\n \n use (k + 1 : β„€), (k : β„€), (k - 1 : β„€)\n have h₁₁ : (k + 1 : β„€) β‰₯ 0 := by linarith\n have h₁₂ : (k : β„€) β‰₯ 0 := by linarith\n have h₁₃ : (k - 1 : β„€) β‰₯ 0 := by\n have h₁₄ : k β‰₯ 1 := by\n by_contra h₁₄\n have h₁₅ : k ≀ 0 := by linarith\n have h₁₆ : n ≀ 0 := by\n have h₁₇ : (9 : β„€) * k ≀ 0 := by nlinarith\n linarith\n have h₁₇ : n β‰₯ 0 := h₁\n have hβ‚β‚ˆ : n = 0 := by linarith\n have h₁₉ : k = 0 := by\n omega\n contradiction\n linarith\n constructor\n Β· exact_mod_cast h₁₁\n constructor\n Β· exact_mod_cast h₁₂\n constructor\n Β· exact_mod_cast h₁₃\n \n have h₁₄ : (k + 1 : β„€)^3 + (k : β„€)^3 + (k - 1 : β„€)^3 - 3 * (k + 1 : β„€) * (k : β„€) * (k - 1 : β„€) = 9 * k := by\n ring_nf\n <;> nlinarith\n rw [hk]\n linarith\n Β· \n \n have hβ‚… : (n - 1) % 3 = 0 := by\n omega\n have h₆ : βˆƒ (m : β„€), n = 3 * m + 1 := by\n use (n - 1) / 3\n have h₆ : (n - 1) % 3 = 0 := hβ‚…\n have h₇ : n - 1 = 3 * ((n - 1) / 3) := by\n omega\n linarith\n rcases h₆ with ⟨m, hm⟩\n have h₇ : m β‰₯ 0 := by\n by_contra h₇\n have hβ‚ˆ : m < 0 := by linarith\n have h₉ : n < 1 := by\n nlinarith\n have h₁₀ : n β‰₯ 0 := h₁\n omega\n use (m + 1 : β„€), (m : β„€), (m : β„€)\n have hβ‚ˆ : (m + 1 : β„€) β‰₯ 0 := by linarith\n have h₉ : (m : β„€) β‰₯ 0 := by linarith\n have h₁₀ : (m : β„€) β‰₯ 0 := by linarith\n constructor\n Β· exact_mod_cast hβ‚ˆ\n constructor\n Β· exact_mod_cast h₉\n constructor\n Β· exact_mod_cast h₁₀\n \n have h₁₁ : (m + 1 : β„€)^3 + (m : β„€)^3 + (m : β„€)^3 - 3 * (m + 1 : β„€) * (m : β„€) * (m : β„€) = 3 * m + 1 := by\n ring_nf\n <;> nlinarith\n rw [hm]\n linarith\n Β· \n \n have hβ‚… : (n - 2) % 3 = 0 := by\n omega\n have h₆ : βˆƒ (m : β„€), n = 3 * m + 2 := by\n use (n - 2) / 3\n have h₆ : (n - 2) % 3 = 0 := hβ‚…\n have h₇ : n - 2 = 3 * ((n - 2) / 3) := by\n omega\n linarith\n rcases h₆ with ⟨m, hm⟩\n have h₇ : m β‰₯ 0 := by\n by_contra h₇\n have hβ‚ˆ : m < 0 := by linarith\n have h₉ : n < 2 := by\n nlinarith\n have h₁₀ : n β‰₯ 0 := h₁\n have h₁₁ : m ≀ -1 := by\n omega\n have h₁₂ : n < 0 := by\n nlinarith\n linarith\n use (m + 1 : β„€), (m + 1 : β„€), (m : β„€)\n have hβ‚ˆ : (m + 1 : β„€) β‰₯ 0 := by linarith\n have h₉ : (m + 1 : β„€) β‰₯ 0 := by linarith\n have h₁₀ : (m : β„€) β‰₯ 0 := by linarith\n constructor\n Β· exact_mod_cast hβ‚ˆ\n constructor\n Β· exact_mod_cast h₉\n constructor\n Β· exact_mod_cast h₁₀\n \n have h₁₁ : (m + 1 : β„€)^3 + (m + 1 : β„€)^3 + (m : β„€)^3 - 3 * (m + 1 : β„€) * (m + 1 : β„€) * (m : β„€) = 3 * m + 2 := by\n ring_nf\n <;> nlinarith\n rw [hm]\n linarith\n \n have h_main : {n : β„€ | βˆƒ A B C : β„€, A β‰₯ 0 ∧ B β‰₯ 0 ∧ C β‰₯ 0 ∧ A^3 + B^3 + C^3 - 3*A*B*C = n} = (({n : β„€ | n β‰₯ 0 ∧ Β¬Int.ModEq 9 n 3 ∧ Β¬Int.ModEq 9 n 6}) : Set β„€ ) := by\n apply Set.Subset.antisymm\n Β· exact h_subset₁\n Β· exact h_subsetβ‚‚\n \n exact h_main"}