{
  "id": "5435",
  "ident": "NS.05435",
  "slug": "oeis-224515",
  "title": "Existence of integers $k$ with $k^2 \\operatorname{XOR} (k+1)^2 = (2n+1)^2$",
  "status": "solved",
  "statement_status": "reviewed",
  "statement_md": "Conjecture: $a(n) \\ge 0$, i.e., for every $n$ there exists $k$ such that $\\sqrt{k^2 \\oplus (k+1)^2} = 2n+1$.\n\nA formal proof has been found with the methods described in\n[arxiv/2605.22763](https://arxiv.org/abs/2605.22763).",
  "subjects": [
    "math.NT",
    "msc:11"
  ],
  "tags": [
    "formal_proof"
  ],
  "collection": "oeis",
  "source_url": null,
  "solved_on_platform": false,
  "needs_answer": false,
  "version": 1,
  "decl_name": "OeisA224515.exists_xor_sq_eq",
  "statement_lean": "theorem exists_xor_sq_eq (n : ℕ) : ∃ k : ℕ, Nat.xor (k ^ 2) ((k + 1) ^ 2) = (2 * n + 1) ^ 2",
  "challenge_source": "/-\nCopyright 2026 The Formal Conjectures Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    https://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n-/\nmodule\n\npublic import FormalConjecturesUtil\n\n/-!\n# Existence of integers $k$ with $k^2 \\operatorname{XOR} (k+1)^2 = (2n+1)^2$\n\na: $a(n) = \\text{least } k \\text{ such that } \\sqrt{k^2 \\operatorname{XOR} (k+1)^2} = 2n+1$,\n$a(n) = -1 \\text{ if there is no such } k$.\nThis is equivalent to finding the smallest $k \\in \\mathbb{N}$\nsuch that $k^2 \\oplus (k+1)^2 = (2n+1)^2$.\nWe use the set infimum ($\\operatorname{sInf}$) to denote the least element\nof the set of natural numbers satisfying the condition.\nSince Mathlib's `sInf` on a subset of `ℕ` gives a result in `ℕ`, this definition\nis only completely faithful to the OEIS when the set is non-empty.\nThe OEIS definition implies that the set of k's is non-empty for all n.\n\n*References:*\n- [A224515](https://oeis.org/A224515)\n- [arxiv/2605.22763](https://arxiv.org/abs/2605.22763) *Advancing Mathematics Research with AI-Driven Formal Proof Search* by George Tsoukalas et al.\n-/\n\n@[expose] public section\n\nnamespace OeisA224515\n\n\nopen Nat Set\n\n/--\na: $a(n) = \\text{least } k \\text{ such that } \\sqrt{k^2 \\operatorname{XOR} (k+1)^2} = 2n+1$,\n$a(n) = -1 \\text{ if there is no such } k$.\nThis is equivalent to finding the smallest $k \\in \\mathbb{N}$\nsuch that $k^2 \\oplus (k+1)^2 = (2n+1)^2$.\nWe use the set infimum ($\\operatorname{sInf}$) to denote the least element\nof the set of natural numbers satisfying the condition.\nSince Mathlib's `sInf` on a subset of `ℕ` gives a result in `ℕ`, this definition\nis only completely faithful to the OEIS when the set is non-empty.\nThe OEIS definition implies that the set of k's is non-empty for all n,\nwhich is legitimate as shown by the theorem `exists_xor_sq_eq` below.\n-/\nnoncomputable def a (n : ℕ) : ℕ :=\n  -- The term (2*n + 1)^2 is the target value.\n  let target_sq : ℕ := (2 * n + 1) ^ 2\n  -- Define the set of candidate k's.\n  sInf { k : ℕ | Nat.xor (k ^ 2) ((k + 1) ^ 2) = target_sq }\n\n\n@[category API, AMS 11]\nlemma A224515_eq (n val : ℕ) (h_in : Nat.xor (val ^ 2) ((val + 1) ^ 2) = (2 * n + 1) ^ 2)\n  (h_min : ∀ k < val, Nat.xor (k ^ 2) ((k + 1) ^ 2) ≠ (2 * n + 1) ^ 2) : a n = val := by\n  unfold a\n  dsimp only\n  refine csInf_eq_of_forall_ge_of_forall_gt_exists_lt ⟨val, h_in⟩ ?_ ?_\n  · intro a ha\n    by_contra h\n    exact h_min a (by omega) ha\n  · intro w hw\n    exact ⟨val, h_in, hw⟩\n\n@[category test, AMS 11]\nlemma a_0 : a 0 = 0 := by\n  apply A224515_eq 0 0 (by decide)\n  intro k hk; omega\n\n@[category test, AMS 11]\nlemma a_1 : a 1 = 4 := by\n  apply A224515_eq 1 4 (by decide)\n  intro k hk; interval_cases k <;> decide\n\n@[category test, AMS 11]\nlemma a_2 : a 2 = 3 := by\n  apply A224515_eq 2 3 (by decide)\n  intro k hk; interval_cases k <;> decide\n\n@[category test, AMS 11]\nlemma a_3 : a 3 = 24 := by\n  apply A224515_eq 3 24 (by decide)\n  intro k hk; interval_cases k <;> decide\n\n@[category test, AMS 11]\nlemma a_4 : a 4 = 23 := by\n  apply A224515_eq 4 23 (by decide)\n  intro k hk; interval_cases k <;> decide\n\n\nset_option linter.style.formal_proof_palomar false in\n/--\nConjecture: $a(n) \\ge 0$, i.e., for every $n$ there exists $k$ such that $\\sqrt{k^2 \\oplus (k+1)^2} = 2n+1$.\n\nA formal proof has been found with the methods described in\n[arxiv/2605.22763](https://arxiv.org/abs/2605.22763).\n-/\n@[category research solved, AMS 11, formal_proof using formal_conjectures at\n\"https://github.com/mo271/formal-conjectures/blob/a32396489dcb8f86c3549b93aa358ac6a10a3a1f/FormalConjectures/OEIS/224515.wip.lean#L268\"]\ntheorem exists_xor_sq_eq (n : ℕ) : ∃ k : ℕ, Nat.xor (k ^ 2) ((k + 1) ^ 2) = (2 * n + 1) ^ 2 := by\n    sorry\n\nend OeisA224515\n",
  "statement_hash": "325b96cd6505bd89a47d31e090525a33ebaaf23b268fe2378f582d4385447b28",
  "toolchain": "leanprover/lean4:v4.33.1",
  "upstream_commit": "f9b3868d5ca994a7bf95039bcec05338c0c21e2f",
  "workspace": "formal-conjectures",
  "field": "math",
  "formalization": "formal",
  "verification": "lean-kernel",
  "license": "Apache-2.0",
  "attribution": "google-deepmind/formal-conjectures contributors",
  "metric_name": null,
  "metric_direction": null,
  "critiques": [],
  "public_partial_proofs": [],
  "research_threads": [],
  "instructions": "Read research_threads first: other people's public repositories and what they already tried. Write Solution.lean starting from challenge_source. Keep every definition identical, prove decl_name with exactly the same type, no sorry in its dependency closure, no new axioms, no native_decide, no metaprogramming. Submit with POST /api/v1/submissions."
}