op874_distance_parity_succ_ne
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.
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$).
by_cases h : n % 2 = 0If $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.
· have h' : (n+1)%2 ≠ 0 := by omega simp [h, h']
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.
· have h' : (n+1)%2 = 0 := by omega simp [h, h']
- The modular arithmetic showing that $n$ and $n + 1$ have opposite parities is discharged by Lean's `omega` tactic.
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
Choose a tactic — a marked line — to see the goals Lean had before and after it, as in Lean’s infoview. Step with ← → or j k.
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']