op874_mixed_boolean_cycle_has_two_crossings
A nonconstant cyclic Boolean word has at least two transitions.
Statement
theorem op874_mixed_boolean_cycle_has_two_crossings
(n : ℕ) [NeZero n] (b : Fin n → Bool)
(hmixed : ∃ i j, b i ≠ b j) :
∃ i j, i ≠ j ∧ b i ≠ b (i+1) ∧ b j ≠ b (j+1)- Source
- Finite mixed-cycle step for OP-874, https://arxiv.org/abs/2610.41950, Section 2.
- Verified
- 29 Nov 2026
- Axioms
Classical.choiceQuot.soundpropext- Built on 2
- TotalPreorderA total preorder: a preorder where
≤is total (complete). This is weaker thanLinearOrder— it does NOT require antisymmetry or… - LinearOrder.toTotalPreorderEvery
LinearOrderis aTotalPreorder.
- TotalPreorderA total preorder: a preorder where
The proof, explained
The proof fixes the initial value $a = b(0)$ and considers the nonempty finite set $S = \{i \mid b(i) \neq a\}$ of indices where the cyclic word differs from $a$. Taking $m = \min S$ and $M = \max S$, the boundary points $m - 1$ and $M + 1$ cannot belong to $S$ without violating the extremality of $m$ or $M$, which forces $b(m - 1) = a$ and $b(M + 1) = a$. Since $b(m) \neq a$ and $b(M) \neq a$, both $m - 1$ and $M$ are transitions ($b(m-1) \neq b(m)$ and $b(M) \neq b(M+1)$). Finally, $m - 1 \neq M$ because $m \le M$ while $m - 1 < m$, yielding two distinct transition points.
Let $a = b(0)$ and $S = \{i \in \operatorname{Fin} n \mid b(i) \neq a\}$; then $S$ is nonempty.
We fix $a = b(0)$ as a reference value and define $S$ as the set of indices where the cyclic word differs from $a$. Because the word is nonconstant, there exist indices $i$ and $j$ such that $b(i) \neq b(j)$. If $b(i) = a$, then $b(j) \neq a$, meaning $j \in S$; otherwise $b(i) \neq a$, meaning $i \in S$. In either case, $S$ has at least one element.
uses
Finset.mem_filter,Finset.mem_univ,true_andclassical let a : Bool := b 0 let S : Finset (Fin n) := Finset.univ.filter (fun i => b i ≠ a) have hS : S.Nonempty := by rcases hmixed with ⟨i, j, hij⟩ by_cases hi : b i = a · refine ⟨j, ?_⟩ simp only [S, Finset.mem_filter, Finset.mem_univ, true_and] intro hja exact hij (by rw [hi, hja]) · exact ⟨i, by simp [S, hi]⟩
$0 \notin S$, and the minimum $m = \min S$ and maximum $M = \max S$ both belong to $S$, with $m \neq 0$.
Since $a = b(0)$, the condition $b(0) \neq a$ is false, so $0 \notin S$. Because $S$ is a nonempty finite set, it admits a minimum $m \in S$ and a maximum $M \in S$. Since $m \in S$ but $0 \notin S$, it follows that $m \neq 0$.
uses
Finset.min'_mem,Finset.max'_memhave h0not : (0 : Fin n) ∉ S := by simp [S, a] let m : Fin n := S.min' hS let M : Fin n := S.max' hS have hm_mem : m ∈ S := Finset.min'_mem S hS have hM_mem : M ∈ S := Finset.max'_mem S hS have hm_ne_zero : m ≠ 0 := by intro hm0 exact h0not (by simpa [hm0] using hm_mem)
For any nonzero index $y \in \operatorname{Fin} n$, the predecessor satisfies $y - 1 < y$.
By definition of the ordering on `Fin n`, the inequality $y - 1 < y$ holds if and only if it holds for their numerical representations in $\mathbb{N}$. When $y \neq 0$, the numerical representative of $y - 1$ is $\operatorname{val}(y) - 1$, which is strictly less than $\operatorname{val}(y)$ because $\operatorname{val}(y) > 0$.
uses
Fin.lt_def,Fin.val_sub_one_of_ne_zero,Fin.pos_iff_ne_zero.mprhave fin_sub_one_lt : ∀ (y : Fin n), y ≠ 0 → y - 1 < y := by intro y hy rw [Fin.lt_def, Fin.val_sub_one_of_ne_zero hy] have hypos : 0 < (y : ℕ) := Fin.pos_iff_ne_zero.mpr hy omega
$m - 1 \notin S$, and therefore $b(m - 1) = a$.
If $m - 1$ were in $S$, the minimality of $m$ would imply $m \le m - 1$. But because $m \neq 0$, the predecessor inequality gives $m - 1 < m$, a contradiction. Thus $m - 1 \notin S$, which means the condition $b(m - 1) \neq a$ fails, so $b(m - 1) = a$.
uses
Finset.min'_le,not_lt_of_gehave hpred_not : m - 1 ∉ S := by intro hcon have hle : m ≤ m - 1 := Finset.min'_le S (m - 1) hcon exact not_lt_of_ge hle (fin_sub_one_lt m hm_ne_zero) have hpred_eq : b (m - 1) = a := by by_contra hne exact hpred_not (by simp [S, hne])
$M + 1 \notin S$, and therefore $b(M + 1) = a$.
Suppose for contradiction that $M + 1 \in S$. Since $0 \notin S$, we have $M + 1 \neq 0$. Applying the predecessor inequality to $M + 1$ yields $M = (M + 1) - 1 < M + 1$. However, since $M$ is the maximum of $S$, we also have $M + 1 \le M$, a contradiction. Hence $M + 1 \notin S$, which implies $b(M + 1) = a$.
uses
add_sub_cancel_right,Finset.le_max',not_lt_of_gehave hMsuc_not : M + 1 ∉ S := by intro hcon have hy_ne_zero : M + 1 ≠ 0 := by intro hzero exact h0not (by simpa [hzero] using hcon) have hM_lt_suc : M < M + 1 := by have hlt : (M + 1) - 1 < M + 1 := fin_sub_one_lt (M + 1) hy_ne_zero simpa [add_sub_cancel_right] using hlt have hle : M + 1 ≤ M := Finset.le_max' S (M + 1) hcon exact not_lt_of_ge hle hM_lt_suc have hMsuc_eq : b (M + 1) = a := by by_contra hne exact hMsuc_not (by simp [S, hne])
The indices $m - 1$ and $M$ are distinct and both are transition points: $b(m - 1) \neq b(m)$ and $b(M) \neq b(M + 1)$.
We choose the two witness indices $i = m - 1$ and $j = M$. To show they are distinct, suppose $m - 1 = M$; then $m \le M = m - 1$ by maximality of $M$ on $m \in S$, contradicting $m - 1 < m$. Next, $(m - 1) + 1 = m$, and since $b(m - 1) = a$ and $b(m) \neq a$, we have $b(m - 1) \neq b((m - 1) + 1)$. Finally, $b(M) \neq a$ while $b(M + 1) = a$, so $b(M) \neq b(M + 1)$. This provides the two required distinct transitions.
uses
Finset.mem_filter.mp,Finset.le_max',not_lt_of_ge,sub_add_cancelhave hmne : b m ≠ a := (Finset.mem_filter.mp hm_mem).2 have hMne : b M ≠ a := (Finset.mem_filter.mp hM_mem).2 refine ⟨m - 1, M, ?_, ?_, ?_⟩ · intro heq have hle : m ≤ M := Finset.le_max' S m hm_mem rw [← heq] at hle exact not_lt_of_ge hle (fin_sub_one_lt m hm_ne_zero) · rw [sub_add_cancel m 1, hpred_eq] exact hmne.symm · rw [hMsuc_eq] exact hMne
Finset.mem_filter- An element $x$ belongs to the filtered finset $\{y \in s \mid p(y)\}$ if and only if $x \in s$ and $p(x)$ holds.
Finset.mem_univ- Every element of a finite type belongs to the universal finset `Finset.univ`.
true_and- For any proposition $p$, the conjunction $\text{True} \wedge p$ is equivalent to $p$.
Finset.min'_mem- The minimum element of a nonempty finite set belongs to that set.
Finset.max'_mem- The maximum element of a nonempty finite set belongs to that set.
Fin.lt_def- An inequality $a < b$ in `Fin n` holds if and only if their underlying natural number values satisfy $\operatorname{val}(a) < \operatorname{val}(b)$.
Fin.val_sub_one_of_ne_zero- For any nonzero $i \in \operatorname{Fin} n$, the underlying natural number value of $i - 1$ is $\operatorname{val}(i) - 1$.
Fin.pos_iff_ne_zero.mpr- An element of `Fin n` has strictly positive natural number value if it is nonzero.
Finset.min'_le- The minimum of a finite set is less than or equal to every element in the set.
not_lt_of_ge- If $a \le b$, then $b$ is not strictly less than $a$.
add_sub_cancel_right- In an additive group, $(a + b) - b = a$.
Finset.le_max'- Every element of a finite set is less than or equal to the maximum of the set.
Finset.mem_filter.mp- If an element belongs to the filtered finset $\{x \in s \mid p(x)\}$, then it satisfies the predicate $p$.
sub_add_cancel- In an additive group, $(a - b) + b = a$.
- The operations $+ 1$ and $- 1$ on `Fin n` are arithmetic modulo $n$. The proof explicitly verifies that $m \neq 0$ and $M + 1 \neq 0$ to ensure that no modular wrap-around occurs when applying the predecessor inequality.
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_mixed_boolean_cycle_has_two_crossings (n : ℕ) [NeZero n] (b : Fin n → Bool) (hmixed : ∃ i j, b i ≠ b j) : ∃ i j, i ≠ j ∧ b i ≠ b (i+1) ∧ b j ≠ b (j+1) := by classical let a : Bool := b 0 let S : Finset (Fin n) := Finset.univ.filter (fun i => b i ≠ a) have hS : S.Nonempty := by rcases hmixed with ⟨i, j, hij⟩ by_cases hi : b i = a · refine ⟨j, ?_⟩ simp only [S, Finset.mem_filter, Finset.mem_univ, true_and] intro hja exact hij (by rw [hi, hja]) · exact ⟨i, by simp [S, hi]⟩ have h0not : (0 : Fin n) ∉ S := by simp [S, a] let m : Fin n := S.min' hS let M : Fin n := S.max' hS have hm_mem : m ∈ S := Finset.min'_mem S hS have hM_mem : M ∈ S := Finset.max'_mem S hS have hm_ne_zero : m ≠ 0 := by intro hm0 exact h0not (by simpa [hm0] using hm_mem) have fin_sub_one_lt : ∀ (y : Fin n), y ≠ 0 → y - 1 < y := by intro y hy rw [Fin.lt_def, Fin.val_sub_one_of_ne_zero hy] have hypos : 0 < (y : ℕ) := Fin.pos_iff_ne_zero.mpr hy omega have hpred_not : m - 1 ∉ S := by intro hcon have hle : m ≤ m - 1 := Finset.min'_le S (m - 1) hcon exact not_lt_of_ge hle (fin_sub_one_lt m hm_ne_zero) have hpred_eq : b (m - 1) = a := by by_contra hne exact hpred_not (by simp [S, hne]) have hMsuc_not : M + 1 ∉ S := by intro hcon have hy_ne_zero : M + 1 ≠ 0 := by intro hzero exact h0not (by simpa [hzero] using hcon) have hM_lt_suc : M < M + 1 := by have hlt : (M + 1) - 1 < M + 1 := fin_sub_one_lt (M + 1) hy_ne_zero simpa [add_sub_cancel_right] using hlt have hle : M + 1 ≤ M := Finset.le_max' S (M + 1) hcon exact not_lt_of_ge hle hM_lt_suc have hMsuc_eq : b (M + 1) = a := by by_contra hne exact hMsuc_not (by simp [S, hne]) have hmne : b m ≠ a := (Finset.mem_filter.mp hm_mem).2 have hMne : b M ≠ a := (Finset.mem_filter.mp hM_mem).2 refine ⟨m - 1, M, ?_, ?_, ?_⟩ · intro heq have hle : m ≤ M := Finset.le_max' S m hm_mem rw [← heq] at hle exact not_lt_of_ge hle (fin_sub_one_lt m hm_ne_zero) · rw [sub_add_cancel m 1, hpred_eq] exact hmne.symm · rw [hMsuc_eq] exact hMne