AFTD Auto-Formalizing Theoretical Domains

op309_cyclic_matching_domination_period_three

theoremverified

For a Boolean matching pattern on a cyclic sequence, if each position has a neighboring boundary position with exactly one matching edge adjacent to it, then the matching pattern is three-periodic and the cycle length is divisible by three.

Statement

theorem op309_cyclic_matching_domination_period_three
    (n : ℕ) [NeZero n] (m : ZMod n → Bool)
    (hmatch : ∀ i, m i = true → m (i + 1) = false)
    (hdom : ∀ i, m (i - 2) ≠ m i ∨ m i ≠ m (i + 2)) :
    (∀ i, m (i + 3) = m i) ∧ 3 ∣ n
Source
Combinatorial cycle lemma for the OP-309 two-colors-per-perfect-matching obstruction; checked by SAT for lengths 1 through 100 in experiment 33558.
Verified
19 Nov 2026
Axioms
Classical.choiceQuot.soundpropext

The proof, explained

The proof first establishes that the matching pattern m is 3-periodic: a true position forces both its adjacent neighbors to be false by the matching condition, and the domination condition then forces the positions at distance 3 forward and backward to be true. To show that 3 divides the cycle length n, we argue by contradiction: if 3 does not divide n, then 3 is invertible in ZMod n because 3 is prime. Repeatedly applying the period-3 symmetry for the inverse multiplier shows that m must actually be 1-periodic, meaning m is constant. However, a constant pattern cannot contain any true position without violating the matching condition, and an identically false pattern contradicts the domination condition at position 0.

  1. If m(i) is true, then m(i + 3) must also be true.

    Since m(i) is true, the matching assumption hmatch implies that its left neighbor m(i - 1) and right neighbor m(i + 1) are both false. Applying the domination condition hdom at position i + 1 requires that at least one of m((i + 1) - 2) = m(i - 1) or m((i + 1) + 2) = m(i + 3) differs from m(i + 1). Because m(i - 1) and m(i + 1) are both false, the difference must occur at m(i + 3), forcing m(i + 3) to be true.

    lines 8–23

      have forward : ∀ i, m i = true → m (i + 3) = true := by
        intro i hi
        have hp : m (i - 1) = false := by
          cases h : m (i - 1) with
          | false => rfl
          | true =>
            have hh := hmatch (i - 1) h
            have hid : (i - 1) + 1 = i := by ring
            rw [hid, hi] at hh
            contradiction
        have hn : m (i + 1) = false := hmatch i hi
        have hh := hdom (i + 1)
        have hid1 : (i + 1) - 2 = i - 1 := by ring
        have hid2 : (i + 1) + 2 = i + 3 := by ring
        rw [hid1, hid2, hp, hn] at hh
        cases h : m (i + 3) <;> simp_all
  2. If m(i) is true, then m(i - 3) must also be true.

    Symmetrically, if m(i) is true, its immediate neighbors m(i - 1) and m(i + 1) are both false. Evaluating the domination condition at position i - 1 shows that m((i - 1) - 2) = m(i - 3) or m((i - 1) + 2) = m(i + 1) must differ from m(i - 1). Since m(i + 1) = m(i - 1) = false, m(i - 3) must differ from false, meaning m(i - 3) is true.

    lines 24–39

      have backward : ∀ i, m i = true → m (i - 3) = true := by
        intro i hi
        have hp : m (i - 1) = false := by
          cases h : m (i - 1) with
          | false => rfl
          | true =>
            have hh := hmatch (i - 1) h
            have hid : (i - 1) + 1 = i := by ring
            rw [hid, hi] at hh
            contradiction
        have hn : m (i + 1) = false := hmatch i hi
        have hh := hdom (i - 1)
        have hid1 : (i - 1) - 2 = i - 3 := by ring
        have hid2 : (i - 1) + 2 = i + 1 := by ring
        rw [hid1, hid2, hp, hn] at hh
        cases h : m (i - 3) <;> simp_all
  3. The matching pattern m is 3-periodic: m(i + 3) = m(i) for all i.

    We consider whether m(i) is false or true. If m(i) is true, the forward implication immediately yields m(i + 3) = true. If m(i) is false, m(i + 3) cannot be true, because if it were, the backward implication applied at i + 3 would give m(i) = true, a contradiction. Hence m(i + 3) must also be false, establishing m(i + 3) = m(i) in all cases.

    lines 40–50

      intro i
      cases hi : m i with
      | false =>
        cases hj : m (i + 3) with
        | false => rfl
        | true =>
          have h := backward (i + 3) hj
          have hid : (i + 3) - 3 = i := by ring
          rw [hid, hi] at h
          contradiction
      | true => exact forward i hi
  4. The pattern m is 3-periodic, proving the first conjunct of the theorem.

    The lemma op309_cycle_boundary_period proved above directly establishes the first conjunct, m(i + 3) = m(i) for all i.

    lines 57–60

    uses op309_cycle_boundary_period

      have period : ∀ i, m (i + 3) = m i :=
        op309_cycle_boundary_period n m hmatch hdom
      constructor
      · exact period
  5. Assuming 3 does not divide n, 3 is an invertible element in ZMod n with a natural number inverse witness k.

    We proceed by contradiction, assuming 3 does not divide n. Since 3 is prime, it is coprime to n by Nat.prime_three.coprime_iff_not_dvd. By ZMod.isUnit_iff_coprime, 3 is a unit in ZMod n. Taking k to be the representative integer value of its inverse unit u⁻¹, we obtain (k : ZMod n) * 3 = 1 via ZMod.natCast_zmod_val.

    lines 61–69

    uses Nat.prime_three.coprime_iff_not_dvd, ZMod.isUnit_iff_coprime, ZMod.natCast_zmod_val

      · by_contra hdiv
        have hcop : Nat.Coprime 3 n := (Nat.prime_three.coprime_iff_not_dvd).2 hdiv
        have hu : IsUnit (3 : ZMod n) := (ZMod.isUnit_iff_coprime 3 n).2 hcop
        obtain ⟨u, hu⟩ := hu
        let k : ℕ := (↑u⁻¹ : ZMod n).val
        have hk : (k : ZMod n) * 3 = 1 := by
          dsimp [k]
          rw [ZMod.natCast_zmod_val, ← hu]
          simp
  6. The pattern m has period 1: m(i + 1) = m(i) for all i.

    By induction on j, repeatedly shifting by 3 preserves the value of m, so m(i + j * 3) = m(i) for all natural numbers j. Specializing this identity to j = k, and using k * 3 = 1 in ZMod n, we conclude that shifting by 1 also preserves m, so m(i + 1) = m(i).

    lines 70–79

        have hiter (i : ZMod n) : ∀ j : ℕ, m (i + (j : ZMod n) * 3) = m i := by
          intro j
          induction j with
          | zero => simp
          | succ j ih =>
            have hid : i + ((Nat.succ j : ℕ) : ZMod n) * 3 =
                (i + (j : ZMod n) * 3) + 3 := by push_cast; ring
            rw [hid, period, ih]
        have hstep (i : ZMod n) : m (i + 1) = m i := by
          simpa [hk] using hiter i k
  7. The pattern m is identically false: m(i) = false for all i.

    If m(i) were true at any position i, then by hmatch its successor m(i + 1) would be false. But we just established m(i + 1) = m(i) = true, which is impossible. Thus m(i) must be false everywhere.

    lines 80–88

        have hzero : ∀ i, m i = false := by
          intro i
          cases hi : m i with
          | false => rfl
          | true =>
            have hnext := hmatch i hi
            have heq := hstep i
            rw [hnext, hi] at heq
            contradiction
  8. A contradiction is obtained with the domination condition, concluding that 3 divides n.

    Evaluating the domination condition hdom at position 0 asserts that m(-2) ≠ m(0) or m(0) ≠ m(2). Since m is identically false, both sides of both disjunctions evaluate to false, resulting in false ≠ false ∨ false ≠ false, a contradiction. Hence 3 must divide n.

    lines 89–90

        have hh := hdom 0
        simp [hzero] at hh
op309_cycle_boundary_period
Under the matching and domination hypotheses on a cyclic sequence of length n, the matching pattern m is 3-periodic, satisfying m(i + 3) = m(i) for all i.
Nat.prime_three.coprime_iff_not_dvd
An integer n is coprime to 3 if and only if 3 does not divide n.
ZMod.isUnit_iff_coprime
An integer representative modulo n is a unit in ZMod n if and only if it is coprime to n.
ZMod.natCast_zmod_val
The natural cast of the representative value of an element a in ZMod n back to ZMod n equals a itself.

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

set_option maxRecDepth 8192theorem op309_cycle_boundary_period    (n : ℕ) [NeZero n] (m : ZMod n → Bool)    (hmatch : ∀ i, m i = true → m (i + 1) = false)    (hdom : ∀ i, m (i - 2) ≠ m i ∨ m i ≠ m (i + 2)) :    ∀ i, m (i + 3) = m i := by  have forward : ∀ i, m i = true → m (i + 3) = true := by    intro i hi    have hp : m (i - 1) = false := by      cases h : m (i - 1) with      | false => rfl      | true =>        have hh := hmatch (i - 1) h        have hid : (i - 1) + 1 = i := by ring        rw [hid, hi] at hh        contradiction    have hn : m (i + 1) = false := hmatch i hi    have hh := hdom (i + 1)    have hid1 : (i + 1) - 2 = i - 1 := by ring    have hid2 : (i + 1) + 2 = i + 3 := by ring    rw [hid1, hid2, hp, hn] at hh    cases h : m (i + 3) <;> simp_all  have backward : ∀ i, m i = true → m (i - 3) = true := by    intro i hi    have hp : m (i - 1) = false := by      cases h : m (i - 1) with      | false => rfl      | true =>        have hh := hmatch (i - 1) h        have hid : (i - 1) + 1 = i := by ring        rw [hid, hi] at hh        contradiction    have hn : m (i + 1) = false := hmatch i hi    have hh := hdom (i - 1)    have hid1 : (i - 1) - 2 = i - 3 := by ring    have hid2 : (i - 1) + 2 = i + 1 := by ring    rw [hid1, hid2, hp, hn] at hh    cases h : m (i - 3) <;> simp_all  intro i  cases hi : m i with  | false =>    cases hj : m (i + 3) with    | false => rfl    | true =>      have h := backward (i + 3) hj      have hid : (i + 3) - 3 = i := by ring      rw [hid, hi] at h      contradiction  | true => exact forward i hitheorem op309_cyclic_matching_domination_period_three    (n : ℕ) [NeZero n] (m : ZMod n → Bool)    (hmatch : ∀ i, m i = true → m (i + 1) = false)    (hdom : ∀ i, m (i - 2) ≠ m i ∨ m i ≠ m (i + 2)) :    (∀ i, m (i + 3) = m i) ∧ 3 ∣ n := by  have period : ∀ i, m (i + 3) = m i :=    op309_cycle_boundary_period n m hmatch hdom  constructor  · exact period  · by_contra hdiv    have hcop : Nat.Coprime 3 n := (Nat.prime_three.coprime_iff_not_dvd).2 hdiv    have hu : IsUnit (3 : ZMod n) := (ZMod.isUnit_iff_coprime 3 n).2 hcop    obtain ⟨u, hu⟩ := hu    let k : ℕ := (↑u⁻¹ : ZMod n).val    have hk : (k : ZMod n) * 3 = 1 := by      dsimp [k]      rw [ZMod.natCast_zmod_val, ← hu]      simp    have hiter (i : ZMod n) : ∀ j : ℕ, m (i + (j : ZMod n) * 3) = m i := by      intro j      induction j with      | zero => simp      | succ j ih =>        have hid : i + ((Nat.succ j : ℕ) : ZMod n) * 3 =            (i + (j : ZMod n) * 3) + 3 := by push_cast; ring        rw [hid, period, ih]    have hstep (i : ZMod n) : m (i + 1) = m i := by      simpa [hk] using hiter i k    have hzero : ∀ i, m i = false := by      intro i      cases hi : m i with      | false => rfl      | true =>        have hnext := hmatch i hi        have heq := hstep i        rw [hnext, hi] at heq        contradiction    have hh := hdom 0    simp [hzero] at hh
See it in the graphDiscuss this resultChallenge it