AFTD Auto-Formalizing Theoretical Domains

op874_distance_parity_succ_ne

theoremverified

Consecutive natural numbers have opposite parity.

Statement

theorem op874_distance_parity_succ_ne (n : ℕ) : decide ((n+1)%2=0) ≠ decide (n%2=0)
Source
Parity alternates between consecutive natural distances.
Verified
22 Nov 2026
Axioms
Quot.soundpropext
Used by 1
  • op874_distance_partial_bitsIf each nonroot vertex descends in distance to an allowed successor and both specified successors have odd distance, parity gives the…

The proof, explained

We argue by cases on the parity of $n$. In each case, linear integer arithmetic determines the parity of $n + 1$, showing that exactly one of $n$ and $n + 1$ is even. Consequently, their boolean decision values are distinct, completing the proof.

  1. It suffices to consider the cases where $n$ is even and where $n$ is odd.

    We perform a case split on whether $n$ is divisible by $2$ ($n \% 2 = 0$).

    line 2

      by_cases h : n % 2 = 0
  2. If $n$ is even, the parities of $n + 1$ and $n$ are distinct.

    Assuming $n \% 2 = 0$, Presburger arithmetic (`omega`) deduces that $(n + 1) \% 2 \neq 0$. Rewriting with these two facts evaluates $\text{decide}((n + 1) \% 2 = 0)$ to `false` and $\text{decide}(n \% 2 = 0)$ to `true`, which are distinct boolean values.

    lines 3–4

      · have h' : (n+1)%2 ≠ 0 := by omega
        simp [h, h']
  3. If $n$ is odd, the parities of $n + 1$ and $n$ are distinct.

    Assuming $n \% 2 \neq 0$, Presburger arithmetic (`omega`) deduces that $(n + 1) \% 2 = 0$. Rewriting with these two facts evaluates $\text{decide}((n + 1) \% 2 = 0)$ to `true` and $\text{decide}(n \% 2 = 0)$ to `false`, which are distinct boolean values.

    lines 5–6

      · have h' : (n+1)%2 = 0 := by omega
        simp [h, h']

Written by a model (gemini-3.8-flash) from the Lean proof and the goal states Lean reported at each step. Lean verified the proof; this explanation is a reading aid and is not itself machine-checked.

Lean source view module on GitHub

theorem op874_distance_parity_succ_ne (n : ℕ) : decide ((n+1)%2=0) ≠ decide (n%2=0) := by  by_cases h : n % 2 = 0  · have h' : (n+1)%2 ≠ 0 := by omega    simp [h, h']  · have h' : (n+1)%2 = 0 := by omega    simp [h, h']
See it in the graphDiscuss this resultChallenge it