/- Copyright 2026 The Formal Conjectures Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -/ import FormalConjecturesUtil import FormalConjectures.OEIS.«105033»

Conjectures associated with A102371

The sequence $a(n)$ is defined by the recurrence relation $a(1)=1$, and for $n>1$, $a(n) = a(n-1) \operatorname{XOR} (a(n-1) + n)$. The conjecture asks if $a(n) = 2^n - 1 - \operatorname{A105033}(n-1)$ for $n \ge 1$.

References:

namespace OeisA102371open Natopen Int

The primary defining sequence a. $a(n)$ is defined by the recurrence relation $a(1)=1$, and for $n>1$, $a(n) = a(n-1) \operatorname{XOR} (a(n-1) + n)$, where $\operatorname{XOR}$ is the bitwise exclusive-or operator (^^^).

def a : | 0 => 0 | 1 => 1 | (n' + 2) => let anMinus1 := a (n' + 1) anMinus1 ^^^ (anMinus1 + (n' + 2))

Term theorems verifying the first few values of the sequence against the official OEIS b-file

@[category test, AMS 11] theorem a_1 : a 1 = 1 := a 1 = 1 All goals completed! 🐙@[category test, AMS 11] theorem a_2 : a 2 = 2 := a 2 = 2 All goals completed! 🐙@[category test, AMS 11] theorem a_3 : a 3 = 7 := a 3 = 7 All goals completed! 🐙@[category test, AMS 11] theorem a_4 : a 4 = 12 := a 4 = 12 All goals completed! 🐙@[category test, AMS 11] theorem a_5 : a 5 = 29 := a 5 = 29 All goals completed! 🐙

Do we have $a(n) = 2^n - 1 - \operatorname{A105033}(n-1)$ for $n \ge 1$?

Note: The OEIS comment suggests $n-1$ which means this applies at least for $n \ge 1$, as we assume $\operatorname{A105033}(\mathbb{N})$ is defined on $\mathbb{N}$. We include the case $n=1$ which relies on $A105033(0)$, which is 0.

@[category research solved, AMS 11, formal_proof using lean4 at "https://github.com/KitaKen1/oeis-a102371/blob/d80fba9/lean/OeisA102371FC.lean#L490-L497"] theorem conjecture : answer(True) n : , 0 < n a n = 2^n - 1 - OeisA105033.a (n - 1) := True (n : ), 0 < n OeisA102371.a n = 2 ^ n - 1 - OeisA105033.a (n - 1) All goals completed! 🐙end OeisA102371