op874_binary_cycle_with_one_flexible_relation
A cyclic collection of two-state constraints is satisfiable if every constraint contains a bijection and at least one excludes at most one pair.
Statement
theorem op874_binary_cycle_with_one_flexible_relation (n : ℕ) [NeZero n] (R : Fin n → Bool → Bool → Prop) (hperm : ∀ i, ∃ f : Bool → Bool, f false ≠ f true ∧ ∀ a, R i a (f a)) (hflex : ∃ i, ∀ a b c d : Bool, (a,b) ≠ (c,d) → R i a b ∨ R i c d) : ∃ phase : Fin n → Bool, ∀ i, R i (phase i) (phase (i+1))
- Source
- Finite phase reduction for OP-874, https://arxiv.org/abs/2610.41950, Section 2.
- Verified
- 29 Nov 2026
- Axioms
Quot.soundpropext- Built on 4
- op874_binary_chainComposition of two-state compatibility relations along a finite path.
- op874_binary_chain_contains_permutationIf each two-state constraint on a finite path contains a bijection, their composition contains a bijection.
- op874_binary_path_close_almost_completeA finite chain of two-state constraints that each contains a bijection can be closed by any constraint excluding at most one pair.
- cFor a group $G$ and an element $s \in G$, the local count $c_G(s)$ is the cardinality of the set of elements $g \in G$ such that…
The proof, explained
To find a satisfying assignment for a cycle of binary relations where every relation contains a bijection and one relation R i0 excludes at most one pair, we cut the cycle at i0 to obtain a path of n - 1 relations. By op874_binary_path_close_almost_complete, there exist endpoint values a, b connected by a valid path configuration such that the flexible relation R i0 b a also holds. Converting this path chain to an explicit state sequence and rotating the cycle back by i0 yields a valid assignment for the entire cycle.
A chain of zero relations with endpoints a = b is realized by a single-element path.
By definition, op874_binary_chain [] a b requires a = b. The constant sequence x : Fin 1 → Bool with x 0 = a starts at a and ends at x (Fin.last 0) = a = b. The step condition holds vacuously because Fin 0 is empty.
uses
op874_binary_chain,List.length_nilinduction rs generalizing a with | nil => simp only [op874_binary_chain, List.length_nil] at h ⊢ subst h exact ⟨fun _ => a, rfl, rfl, by intro k; exact k.elim0⟩
If a list of relations chains a to b, there is an indexed sequence satisfying all step relations from a to b.
For a list R :: rs, the chain hypothesis provides an intermediate state c such that R a c holds and rs chains c to b. By the induction hypothesis, there is a sequence x' from c to b satisfying rs. Prepending a via Fin.cons a x' yields a sequence starting at a, ending at b, satisfying the first step R a (x' 0) = R a c, and satisfying all subsequent steps by the induction hypothesis on x'.
uses
op874_binary_chain,List.length_cons,Fin.cases| cons R rs ih => simp only [op874_binary_chain, List.length_cons] at h ⊢ obtain ⟨c, hR, hchain⟩ := h obtain ⟨x', hx'0, hx'last, hx'step⟩ := ih c hchain refine ⟨Fin.cons a x', by simp, ?_, ?_⟩ · simp [hx'last] · intro k refine Fin.cases ?_ ?_ k · change R a (x' 0) rw [hx'0] exact hR · intro j change rs.get j (x' j.castSucc) (x' j.succ) exact hx'step jA chain on List.ofFn f is realized by a sequence on Fin (m + 1) satisfying f j at each step.
We apply op874_binary_cycle_with_one_flexible_relation_chain_phase to the list List.ofFn f. Casting the domain from Fin ((List.ofFn f).length + 1) to Fin (m + 1) produces a sequence x : Fin (m + 1) → Bool with x 0 = a, x (Fin.last m) = b, and satisfying f j (x j.castSucc) (x j.succ) for all j : Fin m by List.get_ofFn.
uses
op874_binary_cycle_with_one_flexible_relation_chain_phase,Fin.cast,List.get_ofFnobtain ⟨x0, hx0, hxlast, hxstep⟩ := op874_binary_cycle_with_one_flexible_relation_chain_phase (List.ofFn f) a b h let x : Fin (m + 1) → Bool := fun i => x0 (Fin.cast (by simp) i) refine ⟨x, ?_, ?_, ?_⟩ · simpa [x] using hx0 · simpa [x] using hxlast · intro j have hget := hxstep (Fin.cast (by simp) j) simpa [x, List.get_ofFn] using hget
The cycle of size n ≥ 1 decomposes into a flexible relation at i0 and a path rs of m = n - 1 relations, each containing a bijection.
Since n is non-zero, we write n = m + 1. We fix an index i0 where the relation is flexible (excludes at most one pair). The remaining m edges along the cycle are given by edgeIndex j = i0 + j.succ, forming a list rs = List.ofFn (fun j => R (edgeIndex j)). Since every edge relation contains a bijection, every relation in rs also contains a bijection.
uses
Nat.exists_eq_succ_of_ne_zero,NeZero.ne,List.mem_ofFnobtain ⟨m, rfl⟩ := Nat.exists_eq_succ_of_ne_zero (NeZero.ne n) obtain ⟨i0, hflex0⟩ := hflex let edgeIndex : Fin m → Fin (m + 1) := fun j => i0 + j.succ let rs : List (Bool → Bool → Prop) := List.ofFn (fun j : Fin m => R (edgeIndex j)) have hrs_perm : ∀ T ∈ rs, ∃ f : Bool → Bool, f false ≠ f true ∧ ∀ a, T a (f a) := by intro T hT simp only [rs, List.mem_ofFn] at hT obtain ⟨j, hj⟩ := hT rw [← hj] exact hperm (edgeIndex j)
There exist states a, b and a sequence x along the path from a to b such that R i0 b a holds.
Applying op874_binary_path_close_almost_complete to rs and R i0 yields states a, b such that rs chains a to b and R i0 b a holds. Converting this chain to an explicit sequence via op874_binary_cycle_with_one_flexible_relation_ofFn_phase gives x : Fin (m + 1) → Bool starting at a, ending at b, and satisfying each relation R (edgeIndex j) along the path.
uses
op874_binary_path_close_almost_complete,op874_binary_cycle_with_one_flexible_relation_ofFn_phaseobtain ⟨a, b, hchain, hclose⟩ := op874_binary_path_close_almost_complete rs (R i0) hrs_perm hflex0 have hchain' : op874_binary_chain (List.ofFn (fun j : Fin m => R (edgeIndex j))) a b := by simpa [rs] using hchain obtain ⟨x, hx0, hxlast, hxstep⟩ := op874_binary_cycle_with_one_flexible_relation_ofFn_phase (fun j : Fin m => R (edgeIndex j)) a b hchain'
The sequence y defined by prepending b to the first m elements of x satisfies y (k + 1) = x k for all k : Fin (m + 1).
We define y = Fin.cons b (fun j => x j.castSucc). If k is the last element of Fin (m + 1), k + 1 wraps to 0, so y (k + 1) = y 0 = b = x (Fin.last m). If k < m, k = j.castSucc and k + 1 = j.succ, so y (k + 1) = y j.succ = x j.castSucc = x k.
uses
Fin.cons_zero,Fin.val_lt_last,Fin.ext,Fin.val_add_one,Fin.val_succ,Fin.val_castSucclet y : Fin (m + 1) → Bool := Fin.cons b (fun j : Fin m => x j.castSucc) have hy_succ (j : Fin m) : y j.succ = x j.castSucc := by simp [y] have hy_add_one (k : Fin (m + 1)) : y (k + 1) = x k := by by_cases hk : k = Fin.last m · subst hk simp [y, Fin.cons_zero, hxlast] · let j : Fin m := ⟨k.val, Fin.val_lt_last hk⟩ have hk_eq : k = j.castSucc := Fin.ext rfl have hkplus : k + 1 = j.succ := by ext rw [Fin.val_add_one] simp [hk_eq, Fin.val_succ, Fin.val_castSucc] rw [hkplus, hk_eq] simp [y]
The shifted sequence phase(i) = y(i - i0) satisfies phase(i0 + k) = y k and phase(i0 + k + 1) = y (k + 1).
We set phase i = y ((finCycle i0).symm i). Shifting by i0 + k cancels the cyclic shift by i0, giving phase (i0 + k) = y k and phase (i0 + k + 1) = y (k + 1).
uses
add_commlet phase : Fin (m + 1) → Bool := fun i => y ((finCycle i0).symm i) have hphase (k : Fin (m + 1)) : phase (i0 + k) = y k := by have hk : (finCycle i0) k = i0 + k := by simp [finCycle, add_comm] simp only [phase] rw [← hk] simp have hphase_succ (k : Fin (m + 1)) : phase (i0 + k + 1) = y (k + 1) := by have hk : (finCycle i0) (k + 1) = i0 + k + 1 := by simp [finCycle] abel simp only [phase] rw [← hk] simp
The assignment phase satisfies R i (phase i) (phase (i + 1)) for all i.
Any vertex i can be written as i0 + k. If k = 0, then i = i0, and the edge connects phase i0 = b to phase (i0 + 1) = a, which satisfies R i0 b a by construction. If k = j.succ, then i = i0 + j + 1, and the edge connects phase i = y j.succ = x j.castSucc to phase (i + 1) = y (j.succ + 1) = x j.succ, which satisfies R (edgeIndex j) by the path property of x.
uses
Fin.eq_zero_or_eq_succrefine ⟨phase, ?_⟩ intro i let k : Fin (m + 1) := (finCycle i0).symm i have hi : i = i0 + k := by have hk : (finCycle i0) k = i0 + k := by simp [finCycle, add_comm] rw [← hk] simp [k] rcases Fin.eq_zero_or_eq_succ k with hk0 | ⟨j, hk⟩ · have hi0 : i = i0 := by rw [hi, hk0]; simp rw [hi0] have hph0 : phase i0 = b := by simpa [y] using hphase 0 have hph1 : phase (i0 + 1) = a := by simpa using (by rw [hphase_succ, hy_add_one, hx0] : phase (i0 + (0 : Fin (m + 1)) + 1) = a) rw [hph0, hph1] exact hclose · rw [hk] at hi have hi' : i = i0 + j.succ := hi rw [hi', hphase, hphase_succ, hy_succ] rw [hy_add_one] have hstep := hxstep j change R (edgeIndex j) (x j.castSucc) (x j.succ) at hstep exact hstep
op874_binary_chain- A chain of relations connects state a to state b along list rs.
List.length_nil- The empty list has length 0.
List.length_cons- The length of a cons list a :: as is the length of as plus 1.
Fin.cases- An element of Fin (n + 1) is either 0 or succ j for some j : Fin n.
op874_binary_cycle_with_one_flexible_relation_chain_phase- A chain of relations along a list rs from a to b yields an explicit sequence x on Fin (rs.length + 1) starting at a, ending at b, and satisfying each step.
Fin.cast- Converts an element of Fin n to Fin m given a proof that n = m.
List.get_ofFn- The i-th element of List.ofFn f equals f applied to the corresponding index.
Nat.exists_eq_succ_of_ne_zero- Every non-zero natural number is a successor of some natural number.
NeZero.ne- An element with a NeZero typeclass instance is non-zero.
List.mem_ofFn- An element belongs to List.ofFn f if and only if it is in the image of f.
op874_binary_path_close_almost_complete- If every relation in rs contains a bijection and R excludes at most one pair, there exist states a, b chained by rs such that R(b, a) holds.
op874_binary_cycle_with_one_flexible_relation_ofFn_phase- A chain along List.ofFn f from a to b yields an explicit sequence x on Fin (m + 1) satisfying f j on each step.
Fin.cons_zero- Evaluating Fin.cons x p at 0 yields x.
Fin.val_lt_last- If an element of Fin (n + 1) is not the last element, its value as a natural number is strictly less than n.
Fin.ext- Two elements of Fin n are equal if their underlying natural values are equal.
Fin.val_add_one- In Fin (n + 1), adding 1 to the last element wraps to 0; otherwise it increments the natural value by 1.
Fin.val_succ- The numerical value of j.succ is j.val + 1.
Fin.val_castSucc- The numerical value of i.castSucc is equal to i.val.
add_comm- Addition is commutative: a + b = b + a.
Fin.eq_zero_or_eq_succ- Every element of Fin (n + 1) is either 0 or j.succ for some j : Fin n.
- The cycle is formalized using modular arithmetic in Fin n where n = m + 1. The proof uses two helper lemmas to bridge between the inductive list-based definition of relational chains (op874_binary_chain) and explicit sequences indexed by Fin (m + 1).
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.
private theorem op874_binary_cycle_with_one_flexible_relation_chain_phase (rs : List (Bool → Bool → Prop)) (a b : Bool) (h : op874_binary_chain rs a b) : ∃ x : Fin (rs.length + 1) → Bool, x 0 = a ∧ x (Fin.last rs.length) = b ∧ ∀ k : Fin rs.length, (rs.get k) (x k.castSucc) (x k.succ) := by induction rs generalizing a with | nil => simp only [op874_binary_chain, List.length_nil] at h ⊢ subst h exact ⟨fun _ => a, rfl, rfl, by intro k; exact k.elim0⟩ | cons R rs ih => simp only [op874_binary_chain, List.length_cons] at h ⊢ obtain ⟨c, hR, hchain⟩ := h obtain ⟨x', hx'0, hx'last, hx'step⟩ := ih c hchain refine ⟨Fin.cons a x', by simp, ?_, ?_⟩ · simp [hx'last] · intro k refine Fin.cases ?_ ?_ k · change R a (x' 0) rw [hx'0] exact hR · intro j change rs.get j (x' j.castSucc) (x' j.succ) exact hx'step jprivate theorem op874_binary_cycle_with_one_flexible_relation_ofFn_phase {m : ℕ} (f : Fin m → Bool → Bool → Prop) (a b : Bool) (h : op874_binary_chain (List.ofFn f) a b) : ∃ x : Fin (m + 1) → Bool, x 0 = a ∧ x (Fin.last m) = b ∧ ∀ j : Fin m, f j (x j.castSucc) (x j.succ) := by obtain ⟨x0, hx0, hxlast, hxstep⟩ := op874_binary_cycle_with_one_flexible_relation_chain_phase (List.ofFn f) a b h let x : Fin (m + 1) → Bool := fun i => x0 (Fin.cast (by simp) i) refine ⟨x, ?_, ?_, ?_⟩ · simpa [x] using hx0 · simpa [x] using hxlast · intro j have hget := hxstep (Fin.cast (by simp) j) simpa [x, List.get_ofFn] using hgettheorem op874_binary_cycle_with_one_flexible_relation (n : ℕ) [NeZero n] (R : Fin n → Bool → Bool → Prop) (hperm : ∀ i, ∃ f : Bool → Bool, f false ≠ f true ∧ ∀ a, R i a (f a)) (hflex : ∃ i, ∀ a b c d : Bool, (a,b) ≠ (c,d) → R i a b ∨ R i c d) : ∃ phase : Fin n → Bool, ∀ i, R i (phase i) (phase (i+1)) := by obtain ⟨m, rfl⟩ := Nat.exists_eq_succ_of_ne_zero (NeZero.ne n) obtain ⟨i0, hflex0⟩ := hflex let edgeIndex : Fin m → Fin (m + 1) := fun j => i0 + j.succ let rs : List (Bool → Bool → Prop) := List.ofFn (fun j : Fin m => R (edgeIndex j)) have hrs_perm : ∀ T ∈ rs, ∃ f : Bool → Bool, f false ≠ f true ∧ ∀ a, T a (f a) := by intro T hT simp only [rs, List.mem_ofFn] at hT obtain ⟨j, hj⟩ := hT rw [← hj] exact hperm (edgeIndex j) obtain ⟨a, b, hchain, hclose⟩ := op874_binary_path_close_almost_complete rs (R i0) hrs_perm hflex0 have hchain' : op874_binary_chain (List.ofFn (fun j : Fin m => R (edgeIndex j))) a b := by simpa [rs] using hchain obtain ⟨x, hx0, hxlast, hxstep⟩ := op874_binary_cycle_with_one_flexible_relation_ofFn_phase (fun j : Fin m => R (edgeIndex j)) a b hchain' let y : Fin (m + 1) → Bool := Fin.cons b (fun j : Fin m => x j.castSucc) have hy_succ (j : Fin m) : y j.succ = x j.castSucc := by simp [y] have hy_add_one (k : Fin (m + 1)) : y (k + 1) = x k := by by_cases hk : k = Fin.last m · subst hk simp [y, Fin.cons_zero, hxlast] · let j : Fin m := ⟨k.val, Fin.val_lt_last hk⟩ have hk_eq : k = j.castSucc := Fin.ext rfl have hkplus : k + 1 = j.succ := by ext rw [Fin.val_add_one] simp [hk_eq, Fin.val_succ, Fin.val_castSucc] rw [hkplus, hk_eq] simp [y] let phase : Fin (m + 1) → Bool := fun i => y ((finCycle i0).symm i) have hphase (k : Fin (m + 1)) : phase (i0 + k) = y k := by have hk : (finCycle i0) k = i0 + k := by simp [finCycle, add_comm] simp only [phase] rw [← hk] simp have hphase_succ (k : Fin (m + 1)) : phase (i0 + k + 1) = y (k + 1) := by have hk : (finCycle i0) (k + 1) = i0 + k + 1 := by simp [finCycle] abel simp only [phase] rw [← hk] simp refine ⟨phase, ?_⟩ intro i let k : Fin (m + 1) := (finCycle i0).symm i have hi : i = i0 + k := by have hk : (finCycle i0) k = i0 + k := by simp [finCycle, add_comm] rw [← hk] simp [k] rcases Fin.eq_zero_or_eq_succ k with hk0 | ⟨j, hk⟩ · have hi0 : i = i0 := by rw [hi, hk0]; simp rw [hi0] have hph0 : phase i0 = b := by simpa [y] using hphase 0 have hph1 : phase (i0 + 1) = a := by simpa using (by rw [hphase_succ, hy_add_one, hx0] : phase (i0 + (0 : Fin (m + 1)) + 1) = a) rw [hph0, hph1] exact hclose · rw [hk] at hi have hi' : i = i0 + j.succ := hi rw [hi', hphase, hphase_succ, hy_succ] rw [hy_add_one] have hstep := hxstep j change R (edgeIndex j) (x j.castSucc) (x j.succ) at hstep exact hstep