AFTD Auto-Formalizing Theoretical Domains

cycle_power_dyadic_regular_continuation_right_next_paired_pow

theoremverified

Part of the rightward continuation, uniform in the exponent. Let t ≥ 2 and D = 2^(t+1). In a tight, exactly dyadically covered, fully covered integer Boolean class model at exponent t+1 with exactly t+2 active classes at every vertex, suppose that for every root r with p0 - 3·2^t ≤ r ≤ p0: if p0 - r is even, the class rooted at r contains offset 1 and its offsets come in consecutive pairs (2i and 2i+1 both in or both out, i < 2^t); if p0 - r is odd, that class consists of its two endpoints only, and suppose the class rooted at p0+1 consists of its two endpoints only. Then for every 1 ≤ k < t the class rooted at p0+2 contains offset 2^k exactly when it contains offset 2^k + 1.

Statement

theorem cycle_power_dyadic_regular_continuation_right_next_paired_pow (t : ℕ) (ht : 2 ≤ t)
    (x : ℤ → ℕ → Bool)
    (htight : ∀ p, cycle_power_dyadic_class_weight (t+1) (x p) =
      (Finset.range (2^(t+1))).sum (fun a => (x p a).toNat))
    (hexact : ∀ i < t+1, ∀ v : ℤ, (Finset.range (2^i)).sum (fun a =>
      (x (v-(a : ℤ)) a && x (v-(a : ℤ)) (a+2^(t+1)-2^i)).toNat) = 1)
    (hcover : ∀ d : ℕ, 1 ≤ d → d < 2^(t+1) → ∀ v : ℤ,
      ∃ a : ℕ, a < 2^(t+1)-d ∧ x (v-(a : ℤ)) a = true ∧
        x (v-(a : ℤ)) (a+d) = true)
    (hcount : ∀ v : ℤ, (Finset.range (2^(t+1))).sum (fun a =>
      (x (v-(a : ℤ)) a).toNat) = (t+1)+1)
    (p0 : ℤ)
    (hreg : ∀ r : ℤ, p0 - 3*2^t ≤ r → r ≤ p0 →
      ((p0 - r) % 2 = 0 → x r 1 = true ∧ ∀ i < 2^t, x r (2*i) = x r (2*i+1)) ∧
      ((p0 - r) % 2 = 1 → ∀ a, 0 < a → a < 2^(t+1) - 1 → x r a = false))
    (hend1 : ∀ a, 0 < a → a < 2^(t+1) - 1 → x (p0+1) a = false) :
    ∀ k, 1 ≤ k → k < t → x (p0+2) (2^k) = x (p0+2) (2^k+1)
Source
Helper step for the main statement of OP-205 (arXiv:2610.15635, the case k+1 = 2^m, n even, (k+1) not dividing n, left open there); it concerns the integer Boolean class models that optimal (m+1)-layer covers give. Partial result towards the stated cycle_power_dyadic_regular_continuation_right_next_paired: the pairs (2^k, 2^k+1), 1 ≤ k < t, of the class at p0+2 (the class at p0+1 being endpoint-only by cycle_power_dyadic_regular_continuation_right_low_corners and ..._rank_partner).
Verified
29 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 4
  • cycle_power_dyadic_regular_continuation_right_bit_oneFirst part of the rightward continuation, for every exponent t+1 ≥ 3, without the coverage hypothesis. In a tight, exactly dyadically…
  • cycle_power_dyadic_tight_class_parentEquality in the dyadic class weight bound forces all rooted-tree parent implications at every smaller dyadic scale, uniformly in the arc…
  • cycle_power_dyadic_class_weightThe weighted number of pairs in a dyadic arc: the endpoint pair has weight two, and distances 2^m-2^j for 1≤j<m have weight one.
  • 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…
Used by 1

The proof, explained

The theorem proves by contradiction that the class rooted at p0+2 has x(p0+2, 2^k) = x(p0+2, 2^k+1) for all 1 ≤ k < t. The proof relies on two helper results: a dyadic block inequality showing that sums over [2^(i-1), 2^i) are non-increasing under decremented offsets (cpd_next_paired_pow_block), and the uniqueness of owners in exact dyadic covers (cpd_next_paired_pow_two_le). In Case B (2^k out, 2^k+1 in), root p0+2 acts as an owner at scale k+1, contradicting the distance cover at v-1 via lemma hcov. In Case A (2^k in, 2^k+1 out), comparing the exact vertex counts at v and v-1 using the dyadic block inequalities forces root p0+3 to be an owner at scale k+1, which again contradicts the distance cover via hcov.

  1. For any 2 ≤ i ≤ t and vertex v, the dyadic block sum over [2^(i-1), 2^i) of membership bits is at most 1.

    Exact dyadic coverage hexact at scale i gives that the sum of conjunctions (x(v-a, a) && x(v-a, a + 2^(t+1) - 2^i)) over a < 2^i is 1. By tightness (cycle_power_dyadic_tight_class_parent), whenever a ∈ [2^(i-1), 2^i) is active, its shifted partner offset is also active, so the single bit is bounded by the conjunction. Since [2^(i-1), 2^i) ⊆ [0, 2^i), the sum over the block is at most 1.

    lines 12–34

    uses Nat.pow_le_pow_right, Finset.mem_Ico, cycle_power_dyadic_tight_class_parent, Finset.mem_range.mpr, Finset.sum_le_sum_of_subset, Finset.sum_le_sum

      have hD : 2^i ≤ 2^(t+1) := Nat.pow_le_pow_right (by norm_num) (by omega)
      have h4 : 4 ≤ 2^i := by
        calc 4 = 2^2 := by norm_num
          _ ≤ 2^i := Nat.pow_le_pow_right (by norm_num) hi
      have hex := hexact i (by omega) v
      have hut : ∀ a : ℕ, a ∈ Finset.Ico (2^(i-1)) (2^i) → (x (v-(a:ℤ)) a).toNat ≤
          (x (v-(a : ℤ)) a && x (v-(a : ℤ)) (a+2^(t+1)-2^i)).toNat := by
        intro a ha
        rw [Finset.mem_Ico] at ha
        have hp := (cycle_power_dyadic_tight_class_parent (t+1) i (by omega) (by omega)
          (x (v-(a:ℤ))) (htight _) a ha.2).2 ha.1
        cases h : x (v-(a:ℤ)) a
        · simp
        · simp [hp h]
      have hsub : Finset.Ico (2^(i-1)) (2^i) ⊆ Finset.range (2^i) := by
        intro a ha; rw [Finset.mem_Ico] at ha; exact Finset.mem_range.mpr ha.2
      have hS : (Finset.Ico (2^(i-1)) (2^i)).sum (fun a : ℕ =>
          (x (v-(a : ℤ)) a && x (v-(a : ℤ)) (a+2^(t+1)-2^i)).toNat) ≤ 1 := by
        exact (Finset.sum_le_sum_of_subset (f := fun a : ℕ =>
          (x (v-(a : ℤ)) a && x (v-(a : ℤ)) (a+2^(t+1)-2^i)).toNat) hsub).trans hex.le
      have hU : (Finset.Ico (2^(i-1)) (2^i)).sum (fun a : ℕ => (x (v-(a:ℤ)) a).toNat) ≤
          (Finset.Ico (2^(i-1)) (2^i)).sum (fun a : ℕ =>
            (x (v-(a : ℤ)) a && x (v-(a : ℤ)) (a+2^(t+1)-2^i)).toNat) := Finset.sum_le_sum hut
  2. If the covering witness a' for distance 2^(t+1) - 2^i + 1 at vertex v-1 satisfies a'+1 < 2^(i-1), the dyadic block inequality holds because the LHS sum is 0.

    By hcover, there is an active pair at distance 2^(t+1) - 2^i + 1 at vertex v-1, giving a root v - (a'+1) with offsets a' and (a'+1) + 2^(t+1) - 2^i active. When a'+1 < 2^(i-1), tightness at scale i forces offset a'+1 to be active as well, making a'+1 the unique exact-cover witness at scale i. Since a'+1 lies strictly below the interval [2^(i-1), 2^i), the exact-cover sum over [2^(i-1), 2^i) must be 0, forcing the LHS sum to be 0.

    lines 35–55

    uses Nat.lt_or_ge, cycle_power_dyadic_tight_class_parent, Finset.mem_Ico, Finset.mem_insert, Finset.mem_range.mpr, Finset.sum_le_sum_of_subset, Finset.sum_insert

      obtain ⟨a', ha', h1, h2⟩ := hcover (2^(t+1) - 2^i + 1) (by omega) (by omega) (v - 1)
      have ha'lt : a' + 1 < 2^i := by omega
      have hv : v - 1 - (a':ℤ) = v - ((a'+1 : ℕ):ℤ) := by push_cast; ring
      rw [hv] at h1 h2
      rcases Nat.lt_or_ge (a'+1) (2^(i-1)) with hlt | hge
      · have h2' : x (v-((a'+1:ℕ):ℤ)) (a'+1 + 2^(t+1) - 2^i) = true := by
          rw [show a'+1 + 2^(t+1) - 2^i = a' + (2^(t+1) - 2^i + 1) by omega]; exact h2
        have hp := (cycle_power_dyadic_tight_class_parent (t+1) i (by omega) (by omega)
          (x (v-((a'+1:ℕ):ℤ))) (htight _) (a'+1) ha'lt).1 hlt h2'
        have hown : (x (v-((a'+1:ℕ):ℤ)) (a'+1) && x (v-((a'+1:ℕ):ℤ)) (a'+1+2^(t+1)-2^i)).toNat = 1 := by
          rw [hp, h2']; rfl
        have hnot : a'+1 ∉ Finset.Ico (2^(i-1)) (2^i) := by
          rw [Finset.mem_Ico]; omega
        have hins : insert (a'+1) (Finset.Ico (2^(i-1)) (2^i)) ⊆ Finset.range (2^i) := by
          intro b hb; rw [Finset.mem_insert] at hb; rcases hb with rfl | hb
          · exact Finset.mem_range.mpr ha'lt
          · exact hsub hb
        have hle := Finset.sum_le_sum_of_subset (f := fun a : ℕ =>
          (x (v-(a : ℤ)) a && x (v-(a : ℤ)) (a+2^(t+1)-2^i)).toNat) hins
        rw [Finset.sum_insert hnot, hown, hex] at hle
        omega
  3. If a'+1 ≥ 2^(i-1), the dyadic block inequality holds because the RHS sum is at least 1.

    When a'+1 ≥ 2^(i-1), the index a'+1 lies in [2^(i-1), 2^i). At this index, the RHS summand x(v - (a'+1), a') equals 1. Because all terms are non-negative, the RHS sum is at least 1, which bounds the LHS sum of at most 1.

    lines 56–61

    uses Nat.add_sub_cancel, Finset.single_le_sum

      · have hw : (x (v-((a'+1:ℕ):ℤ)) (a'+1-1)).toNat = 1 := by
          rw [Nat.add_sub_cancel, h1]; rfl
        have hmem : a'+1 ∈ Finset.Ico (2^(i-1)) (2^i) := Finset.mem_Ico.mpr ⟨hge, ha'lt⟩
        have h1le := Finset.single_le_sum (f := fun a : ℕ => (x (v-(a:ℤ)) (a-1)).toNat)
            (fun _ _ => Nat.zero_le _) hmem
        omega
  4. A non-negative function taking value 1 at two distinct elements of a finite set has total sum at least 2.

    The two-element set {a, b} is a subset of s. By monotonicity of summation on subsets and the sum of a two-element set, the sum over s is at least f(a) + f(b) = 2.

    lines 65–72

    uses Finset.mem_insert, Finset.sum_le_sum_of_subset, Finset.sum_pair

      have hsub : ({a, b} : Finset ℕ) ⊆ s := by
        intro c hc; simp only [Finset.mem_insert, Finset.mem_singleton] at hc
        rcases hc with rfl | rfl
        · exact ha
        · exact hb
      have := Finset.sum_le_sum_of_subset (f := f) hsub
      rw [Finset.sum_pair hab, hfa, hfb] at this
      exact this
  5. Fix scale k, set parameters J = 2^k and T = 2^t, and observe that class endpoints are active and x(p0+2, 1) = true.

    We fix 1 ≤ k < t, define J = 2^k and T = 2^t, and deduce basic power inequalities. Exact coverage at rank 0 forces the extreme endpoints 0 and 2^(t+1)-1 of every class to be active. The helper lemma cycle_power_dyadic_regular_continuation_right_bit_one shows that x(p0+2, 1) is active.

    lines 91–117

    uses pow_succ, Nat.pow_le_pow_right, cycle_power_dyadic_regular_continuation_right_bit_one

      intro k hk1 hkt
      obtain ⟨T, hT⟩ : ∃ T : ℕ, T = 2^t := ⟨_, rfl⟩
      obtain ⟨J, hJ⟩ : ∃ J : ℕ, J = 2^k := ⟨_, rfl⟩
      have hD : (2:ℕ)^(t+1) = 2*T := by rw [hT, pow_succ]; ring
      have h2J : (2:ℕ)^(k+1) = 2*J := by rw [hJ, pow_succ]; ring
      have hJT : 2*J ≤ T := by
        rw [← h2J, hT]; exact Nat.pow_le_pow_right (by norm_num) (by omega)
      have hJ2 : 2 ≤ J := by
        rw [hJ]
        calc 2 = 2^1 := by norm_num
          _ ≤ 2^k := Nat.pow_le_pow_right (by norm_num) hk1
      have hkk : (2:ℕ)^(k+1-1) = J := by rw [Nat.add_sub_cancel, hJ]
      obtain ⟨J', hJ'⟩ : ∃ J' : ℕ, J = 2 * J' := ⟨2^(k-1), by rw [hJ, ← pow_succ']; congr 1; omega⟩
      have hTz : ((2:ℤ))^t = (T:ℤ) := by rw [hT]; push_cast; rfl
      have hx : ∀ (q q' : ℤ) (a a' : ℕ), q = q' → a = a' → x q a = x q' a' := by
        intro q q' a a' h1 h2; rw [h1, h2]
      have hends : ∀ v : ℤ, x v 0 = true ∧ x v (2^(t+1) - 1) = true := by
        intro v
        have h := hexact 0 (by omega) v
        simp only [pow_zero, Finset.range_one, Finset.sum_singleton, Nat.cast_zero, sub_zero,
          Nat.zero_add] at h
        revert h
        generalize x v 0 = u
        generalize x v (2^(t+1) - 1) = w
        cases u <;> cases w <;> simp
      have hb1 := (cycle_power_dyadic_regular_continuation_right_bit_one t ht x htight hexact hcount
        p0 hreg).2
  6. At vertex p0+3, it is impossible for both x(p0+3, 2^(t+1)-J) and x(p0+2, 2^(t+1)-J+1) to be true.

    Exact dyadic coverage at rank k for vertex p0+3 has sum 1 over a < J. The term at a = 0 corresponds to root p0+3 with endpoints 0 and 2^(t+1)-J, while the term at a = 1 corresponds to root p0+2 with endpoints 1 and 2^(t+1)-J+1. Since both base offsets 0 and 1 are active, if both shifted offsets were active, cpd_next_paired_pow_two_le would force the sum to be at least 2, a contradiction.

    lines 118–137

    uses cpd_next_paired_pow_two_le

      rw [← hJ]
      obtain ⟨v, hv⟩ : ∃ v : ℤ, v = p0 + J + 3 := ⟨_, rfl⟩
      -- rank k at p0+3: the terms of roots p0+3 and p0+2
      have hexk := hexact k (by omega) (p0+3)
      rw [← hJ] at hexk
      have hk0 : (0:ℕ) ∈ Finset.range J := Finset.mem_range.mpr (by omega)
      have hk1' : (1:ℕ) ∈ Finset.range J := Finset.mem_range.mpr (by omega)
      have hrk : ¬ (x (p0+3) (2^(t+1) - J) = true ∧ x (p0+2) (2^(t+1) - J + 1) = true) := by
        rintro ⟨h1, h2⟩
        have := cpd_next_paired_pow_two_le (Finset.range J) (fun a =>
          (x (p0+3-(a : ℤ)) a && x (p0+3-(a : ℤ)) (a+2^(t+1)-J)).toNat) 0 1 hk0 hk1' (by norm_num)
          (by
            show (x (p0+3-((0:ℕ):ℤ)) 0 && x (p0+3-((0:ℕ):ℤ)) (0+2^(t+1)-J)).toNat = 1
            rw [hx _ (p0+3) 0 0 (by simp) rfl, hx _ (p0+3) (0+2^(t+1)-J) (2^(t+1)-J) (by simp) (by omega),
              (hends _).1, h1]; rfl)
          (by
            show (x (p0+3-((1:ℕ):ℤ)) 1 && x (p0+3-((1:ℕ):ℤ)) (1+2^(t+1)-J)).toNat = 1
            rw [hx _ (p0+2) 1 1 (by push_cast; ring) rfl,
              hx _ (p0+2) (1+2^(t+1)-J) (2^(t+1)-J+1) (by push_cast; ring) (by omega), hb1, h2]; rfl)
        omega
  7. If a0 ∈ {J, J+1} is an active exact-cover owner at scale k+1 for vertex v = p0+J+3, it contradicts the distance cover at v-1 (lemma hcov).

    Covering distance 2^(t+1) - 2*J + 1 at v-1 gives a root v - (a'+1) with offsets a' and (a'+1) + 2^(t+1) - 2*J active. Any second owner distinct from a0 contradicts uniqueness at scale k+1. If a'+1 < J, tightness makes a'+1 an owner strictly smaller than a0. If a'+1 ∈ {J, J+1, J+2}, it either activates forbidden pairs or root p0+1, which has no interior offsets. If a'+1 ≥ J+3, the root is in the regular range, where parity constraints either contradict interior emptiness or force pairing that makes a'+1 a distinct second owner.

    lines 138–192

    uses cpd_next_paired_pow_two_le, Nat.lt_or_ge, cycle_power_dyadic_tight_class_parent, Nat.mod_two_eq_zero_or_one

      -- rank k+1 at v
      have hexk1 := hexact (k+1) (by omega) v
      rw [h2J] at hexk1
      -- the cover of distance D - 2J + 1 at v - 1
      have hcov : ∀ a0 : ℕ, (a0 = J ∨ a0 = J+1) →
          (x (v-(a0:ℤ)) a0 && x (v-(a0:ℤ)) (a0+2^(t+1)-2*J)).toNat = 1 →
          ¬ (x (p0+3) (J-1) = true ∧ x (p0+3) (2^(t+1) - J) = true) →
          ¬ (x (p0+2) J = true ∧ x (p0+2) (2^(t+1) - J + 1) = true) → False := by
        intro a0 ha0 hown hFJ hFJ1
        obtain ⟨a', ha', h1, h2⟩ := hcover (2^(t+1) - 2*J + 1) (by omega) (by omega) (v - 1)
        have hv' : v - 1 - (a':ℤ) = v - ((a'+1 : ℕ):ℤ) := by push_cast; ring
        rw [hv'] at h1 h2
        have h2' : x (v-((a'+1:ℕ):ℤ)) (a'+1 + 2^(t+1) - 2*J) = true := by
          rw [show a'+1 + 2^(t+1) - 2*J = a' + (2^(t+1) - 2*J + 1) by omega]; exact h2
        -- a second owner gives a contradiction
        have hsecond : (x (v-((a'+1:ℕ):ℤ)) (a'+1) = true) → a'+1 ≠ a0 → False := by
          intro h3 hne
          have := cpd_next_paired_pow_two_le (Finset.range (2*J)) (fun a =>
            (x (v-(a : ℤ)) a && x (v-(a : ℤ)) (a+2^(t+1)-2*J)).toNat) a0 (a'+1)
            (Finset.mem_range.mpr (by omega)) (Finset.mem_range.mpr (by omega)) (Ne.symm hne) hown
            (by show (x (v-((a'+1:ℕ):ℤ)) (a'+1) && x (v-((a'+1:ℕ):ℤ)) (a'+1+2^(t+1)-2*J)).toNat = 1
                rw [h3, h2']; rfl)
          omega
        rcases Nat.lt_or_ge (a'+1) J with hlt | hge
        · have hp := (cycle_power_dyadic_tight_class_parent (t+1) (k+1) (by omega) (by omega)
            (x (v-((a'+1:ℕ):ℤ))) (htight _) (a'+1) (by omega)).1 (by rw [hkk]; exact hlt)
            (by rw [h2J]; exact h2')
          exact hsecond hp (by omega)
        · rcases Nat.lt_or_ge (a'+1) (J+3) with hlt3 | hge3
          · have hcases : a'+1 = J ∨ a'+1 = J+1 ∨ a'+1 = J+2 := by omega
            rcases hcases with h | h | h
            · apply hFJ
              refine ⟨?_, ?_⟩
              · rw [hx _ (v-((a'+1:ℕ):ℤ)) (J-1) a' (by rw [h, hv]; push_cast; ring) (by omega)]
                exact h1
              · rw [hx _ (v-((a'+1:ℕ):ℤ)) (2^(t+1)-J) (a'+1 + 2^(t+1) - 2*J) (by rw [h, hv]; push_cast; ring)
                  (by omega)]
                exact h2'
            · apply hFJ1
              refine ⟨?_, ?_⟩
              · rw [hx _ (v-((a'+1:ℕ):ℤ)) J a' (by rw [h, hv]; push_cast; ring) (by omega)]
                exact h1
              · rw [hx _ (v-((a'+1:ℕ):ℤ)) (2^(t+1)-J+1) (a'+1 + 2^(t+1) - 2*J) (by rw [h, hv]; push_cast; ring)
                  (by omega)]
                exact h2'
            · have := hend1 a' (by omega) (by omega)
              rw [hx _ (v-((a'+1:ℕ):ℤ)) a' a' (by rw [h, hv]; push_cast; ring) rfl] at this
              rw [this] at h1; exact absurd h1 (by decide)
          · have hr := hreg (v - ((a'+1:ℕ):ℤ)) (by rw [hTz, hv]; push_cast; omega) (by rw [hv]; push_cast; omega)
            rcases Nat.mod_two_eq_zero_or_one (a'+1) with hpar | hpar
            · have := hr.2 (by rw [hv]; push_cast; omega) a' (by omega) (by omega)
              rw [this] at h1; exact absurd h1 (by decide)
            · have hp := (hr.1 (by rw [hv]; push_cast; omega)).2 (a'/2) (by omega)
              rw [hx _ _ (2*(a'/2)) a' rfl (by omega), hx _ _ (2*(a'/2)+1) (a'+1) rfl (by omega), h1] at hp
              exact hsecond hp.symm (by omega)
  8. Case B, where x(p0+2, J) = false and x(p0+2, J+1) = true, is impossible.

    If x(p0+2, J+1) is true, tightness at scale k+1 implies the partner offset 2^(t+1) - J + 1 is also active at p0+2. Then a0 = J+1 is an active owner at vertex v = p0+J+3. The incompatibility of simultaneous partner offsets at p0+3 and p0+2, together with x(p0+2, J) = false, verifies the hypotheses of hcov, yielding a contradiction.

    lines 193–204

    uses cycle_power_dyadic_tight_class_parent

      cases hA : x (p0+2) J <;> cases hB : x (p0+2) (J+1)
      · rfl
      · -- case B: J out, J+1 in
        exfalso
        have hpB := (cycle_power_dyadic_tight_class_parent (t+1) (k+1) (by omega) (by omega)
          (x (p0+2)) (htight _) (J+1) (by omega)).2 (by rw [hkk]; omega) hB
        rw [h2J, hx _ _ (J+1+2^(t+1)-2*J) (2^(t+1)-J+1) rfl (by omega)] at hpB
        refine hcov (J+1) (Or.inr rfl) ?_ ?_ ?_
        · rw [hx _ (p0+2) (J+1) (J+1) (by rw [hv]; push_cast; ring) rfl,
            hx _ (p0+2) (J+1+2^(t+1)-2*J) (2^(t+1)-J+1) (by rw [hv]; push_cast; ring) (by omega), hB, hpB]; rfl
        · rintro ⟨-, h⟩; exact hrk ⟨h, hpB⟩
        · rintro ⟨h, -⟩; rw [hA] at h; exact absurd h (by decide)
  9. In Case A, where x(p0+2, J) = true and x(p0+2, J+1) = false, the vertex counts at v and v-1 agree on the upper range a ≥ J+2.

    For every a ∈ [J+2, 2^(t+1)), the bits x(v-a, a) and x(v-a, a-1) match by interior emptiness at p0+1 and consecutive pairing or emptiness from regularity. We expand the vertex count t+2 at v and v-1: peeling off boundary terms and the identical tail leaves sums over [1, J+1) and [2, J+1) with known endpoint values.

    lines 205–250

    uses Nat.lt_or_ge, Nat.mod_two_eq_zero_or_one, Finset.range_eq_Ico, Finset.sum_eq_sum_Ico_succ_bot, Finset.sum_Ico_consecutive, Finset.sum_Ico_eq_sum_range, Nat.add_sub_cancel, Finset.sum_Ico_succ_top

      · -- case A: J in, J+1 out
        exfalso
        -- count comparison at v and v - 1
        have hM : ∀ a : ℕ, a ∈ Finset.Ico (J+2) (2^(t+1)) →
            (x (v-(a:ℤ)) a).toNat = (x (v-(a:ℤ)) (a-1)).toNat := by
          intro a ha
          rw [Finset.mem_Ico] at ha
          rcases Nat.lt_or_ge a (J+3) with h2 | h3
          · have ha2 : a = J+2 := by omega
            subst ha2
            rw [hx _ (p0+1) (J+2) (J+2) (by rw [hv]; push_cast; ring) rfl,
              hx _ (p0+1) (J+2-1) (J+1) (by rw [hv]; push_cast; ring) (by omega),
              hend1 (J+2) (by omega) (by omega), hend1 (J+1) (by omega) (by omega)]
          · have hr := hreg (v - (a:ℤ)) (by rw [hTz, hv]; omega) (by rw [hv]; omega)
            rcases Nat.mod_two_eq_zero_or_one a with hpar | hpar
            · rw [hr.2 (by rw [hv]; omega) a (by omega) (by omega),
                hr.2 (by rw [hv]; omega) (a-1) (by omega) (by omega)]
            · have hp := (hr.1 (by rw [hv]; omega)).2 ((a-1)/2) (by omega)
              rw [hx _ _ (a-1) (2*((a-1)/2)) rfl (by omega), hp]
              exact congrArg Bool.toNat (hx _ _ _ _ rfl (by omega))
        have hMs := Finset.sum_congr rfl hM
        have hc1 := hcount v
        rw [Finset.range_eq_Ico, Finset.sum_eq_sum_Ico_succ_bot (by omega),
          ← Finset.sum_Ico_consecutive _ (show 0+1 ≤ J+1 by omega) (show J+1 ≤ 2^(t+1) by omega),
          Finset.sum_eq_sum_Ico_succ_bot (show J+1 < 2^(t+1) by omega), hMs] at hc1
        have u0 : (x (v - ((0:ℕ):ℤ)) 0).toNat = 1 := by
          rw [hx _ v 0 0 (by simp) rfl, (hends v).1]; rfl
        have uJ1 : (x (v - ((J+1:ℕ):ℤ)) (J+1)).toNat = 0 := by
          rw [hx _ (p0+2) (J+1) (J+1) (by rw [hv]; push_cast; ring) rfl, hB]; rfl
        rw [u0, uJ1, show (0:ℕ)+1 = 1 from rfl] at hc1
        have hc0 := hcount (v - 1)
        have hre : (Finset.range (2^(t+1))).sum (fun a => (x (v - 1 - (a:ℤ)) a).toNat) =
            (Finset.Ico 1 (2^(t+1)+1)).sum (fun a : ℕ => (x (v - (a:ℤ)) (a-1)).toNat) := by
          rw [Finset.sum_Ico_eq_sum_range, Nat.add_sub_cancel]
          refine Finset.sum_congr rfl fun k _ => ?_
          exact congrArg Bool.toNat (hx _ _ _ _ (by push_cast; ring) (by omega))
        rw [hre, Finset.sum_Ico_succ_top (by omega), Finset.sum_eq_sum_Ico_succ_bot (by omega),
          ← Finset.sum_Ico_consecutive _ (show 1+1 ≤ J+1 by omega) (show J+1 ≤ 2^(t+1) by omega),
          Finset.sum_eq_sum_Ico_succ_bot (show J+1 < 2^(t+1) by omega)] at hc0
        have w1 : (x (v - ((1:ℕ):ℤ)) (1-1)).toNat = 1 := by
          rw [hx _ (v-1) (1-1) 0 (by simp) rfl, (hends _).1]; rfl
        have wJ1 : (x (v - ((J+1:ℕ):ℤ)) (J+1-1)).toNat = 1 := by
          rw [hx _ (p0+2) (J+1-1) J (by rw [hv]; push_cast; ring) (by omega), hA]; rfl
        have wD : (x (v - ((2^(t+1):ℕ):ℤ)) (2^(t+1)-1)).toNat = 1 := by
          rw [(hends _).2]; rfl
        rw [w1, wJ1, wD, show (1:ℕ)+1 = 2 from rfl] at hc0
  10. For all 1 ≤ b ≤ k, the sum over [1, 2^b) at v is bounded by 1 plus the shifted sum over [2, 2^b) at v-1.

    This is proved by induction on b. The base case b = 1 reduces to a single bit being at most 1. The inductive step splits [1, 2^(b+1)) into [1, 2^b) and the dyadic block [2^b, 2^(b+1)), applies the block inequality cpd_next_paired_pow_block on the high block, and adds the inductive hypothesis on the low block.

    lines 251–274

    uses cpd_next_paired_pow_block, Finset.sum_Ico_consecutive

        -- block bound up to 2^k
        have key : ∀ b, 1 ≤ b → b ≤ k →
            (Finset.Ico 1 (2^b)).sum (fun a : ℕ => (x (v-(a:ℤ)) a).toNat) ≤
              1 + (Finset.Ico 2 (2^b)).sum (fun a : ℕ => (x (v-(a:ℤ)) (a-1)).toNat) := by
          intro b hb1 hbk
          induction b with
          | zero => omega
          | succ b ih =>
            rcases Nat.lt_or_ge b 1 with h | h
            · have hb0 : b = 0 := by omega
              subst hb0
              simp only [zero_add, pow_one, Finset.Ico_self, Finset.sum_empty, add_zero]
              rw [Finset.sum_eq_sum_Ico_succ_bot (by norm_num), Finset.Ico_self, Finset.sum_empty]
              cases x (v - ((1:ℕ):ℤ)) 1 <;> simp
            · have h2b : 2 ≤ 2^b := by
                calc 2 = 2^1 := by norm_num
                  _ ≤ 2^b := Nat.pow_le_pow_right (by norm_num) h
              have hbb : 2^b ≤ 2^(b+1) := Nat.pow_le_pow_right (by norm_num) (by omega)
              have hblk := cpd_next_paired_pow_block t x htight hexact hcover v (b+1) (by omega) (by omega)
              rw [Nat.add_sub_cancel] at hblk
              rw [← Finset.sum_Ico_consecutive _ (show 1 ≤ 2^b by omega) hbb,
                ← Finset.sum_Ico_consecutive _ h2b hbb]
              have := ih h (by omega)
              omega
  11. Comparing the count bounds forces x(p0+3, J) = true and x(p0+3, J-1) = false, triggering hcov at a0 = J to eliminate Case A and complete the proof.

    Applying the inductive key inequality at b = k to the count expansions forces x(p0+3, J) = true and x(p0+3, J-1) = false. By tightness at scale k+1, root p0+3 also contains offset 2^(t+1) - J, making a0 = J an active owner at scale k+1. Since x(p0+3, J-1) is false and the rank k incompatibility forbids x(p0+2, 2^(t+1)-J+1), hcov produces a contradiction, completing the proof.

    lines 275–297

    uses Finset.sum_Ico_succ_top, cycle_power_dyadic_tight_class_parent

        have hk := key k hk1 le_rfl
        rw [← hJ] at hk
        rw [Finset.sum_Ico_succ_top (show 1 ≤ J by omega)] at hc1
        rw [Finset.sum_Ico_succ_top (show 2 ≤ J by omega)] at hc0
        rw [show J+1+1 = J+2 by omega] at hc0
        have hu : (x (v - (J:ℤ)) J).toNat = 1 := by
          have := Bool.toNat_le (x (v - (J:ℤ)) J); omega
        have hw : (x (v - (J:ℤ)) (J-1)).toNat = 0 := by omega
        have hv3 : v - (J:ℤ) = p0 + 3 := by rw [hv]; ring
        rw [hv3] at hu hw
        have hu' : x (p0+3) J = true := by
          revert hu; cases x (p0+3) J <;> simp
        have hw' : x (p0+3) (J-1) = false := by
          revert hw; cases x (p0+3) (J-1) <;> simp
        have hpA := (cycle_power_dyadic_tight_class_parent (t+1) (k+1) (by omega) (by omega)
          (x (p0+3)) (htight _) J (by omega)).2 (by rw [hkk]) hu'
        rw [h2J, hx _ _ (J+2^(t+1)-2*J) (2^(t+1)-J) rfl (by omega)] at hpA
        refine hcov J (Or.inl rfl) ?_ ?_ ?_
        · rw [hx _ (p0+3) J J (by rw [hv]; push_cast; ring) rfl,
            hx _ (p0+3) (J+2^(t+1)-2*J) (2^(t+1)-J) (by rw [hv]; push_cast; ring) (by omega), hu', hpA]; rfl
        · rintro ⟨h, -⟩; rw [hw'] at h; exact absurd h (by decide)
        · rintro ⟨-, h⟩; exact hrk ⟨hpA, h⟩
      · rfl
cpd_next_paired_pow_block
In a tight, exactly dyadically covered, fully covered model, the sum of class membership bits over the dyadic block [2^(i-1), 2^i) at vertex v is at most the corresponding decremented-offset sum.
cpd_next_paired_pow_two_le
If a function into ℕ takes the value 1 at two distinct elements of a finite set, its sum over the set is at least 2.
cycle_power_dyadic_regular_continuation_right_bit_one
Under the continuation hypotheses, the class rooted at p0+1 excludes offset 1, while the class rooted at p0+2 contains offset 1.
cycle_power_dyadic_tight_class_parent
In a tight class of exponent m and scale j < m, an offset in [0, 2^(j-1)) is active if its shifted partner is active, and an offset in [2^(j-1), 2^j) implies its shifted partner is active.
Nat.pow_le_pow_right
For a positive base, exponentiation is non-decreasing in the exponent.
Finset.mem_Ico
An element belongs to the half-open interval [a, b) if and only if it is at least a and strictly less than b.
Finset.mem_range.mpr
A natural number strictly less than n belongs to the range of size n.
Finset.sum_le_sum_of_subset
For non-negative terms, the sum over a subset is at most the sum over the superset.
Finset.sum_le_sum
If f(i) ≤ g(i) for all elements in a finite set, then the sum of f over the set is at most the sum of g.
Nat.lt_or_ge
For any two natural numbers n and m, either n < m or n ≥ m.
Finset.mem_insert
An element belongs to the insertion of an element into a set if and only if it equals the inserted element or already belongs to the set.
Finset.sum_insert
Inserting an element not in s into a sum over s adds its value to the sum.
Nat.add_sub_cancel
Adding and then subtracting the same natural number leaves the value unchanged.
Finset.single_le_sum
A single non-negative term in a finite sum is bounded by the total sum.
Finset.sum_pair
The sum of a function over a set of two distinct elements equals the sum of its values at those elements.
pow_succ
The power a^(n+1) equals a^n * a.
Nat.mod_two_eq_zero_or_one
Every natural number is either even (n % 2 = 0) or odd (n % 2 = 1).
Finset.range_eq_Ico
The range of length a equals the half-open interval [0, a).
Finset.sum_eq_sum_Ico_succ_bot
A sum over [a, b) can be split by peeling off its first term at index a when a < b.
Finset.sum_Ico_consecutive
Sums over adjacent intervals [m, n) and [n, k) combine into the sum over [m, k).
Finset.sum_Ico_eq_sum_range
A sum over [m, n) can be re-indexed as a sum over range (n - m) shifted by m.
Finset.sum_Ico_succ_top
A sum over [a, b+1) equals the sum over [a, b) plus the top term at index b.

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

Lean’s trace was cut to the first 400 of 456 tactics.

theorem cpd_next_paired_pow_block (t : ℕ) (x : ℤ → ℕ → Bool)    (htight : ∀ p, cycle_power_dyadic_class_weight (t+1) (x p) =      (Finset.range (2^(t+1))).sum (fun a => (x p a).toNat))    (hexact : ∀ i < t+1, ∀ v : ℤ, (Finset.range (2^i)).sum (fun a =>      (x (v-(a : ℤ)) a && x (v-(a : ℤ)) (a+2^(t+1)-2^i)).toNat) = 1)    (hcover : ∀ d : ℕ, 1 ≤ d → d < 2^(t+1) → ∀ v : ℤ,      ∃ a : ℕ, a < 2^(t+1)-d ∧ x (v-(a : ℤ)) a = true ∧        x (v-(a : ℤ)) (a+d) = true)    (v : ℤ) (i : ℕ) (hi : 2 ≤ i) (hit : i ≤ t) :    (Finset.Ico (2^(i-1)) (2^i)).sum (fun a : ℕ => (x (v-(a:ℤ)) a).toNat) ≤      (Finset.Ico (2^(i-1)) (2^i)).sum (fun a : ℕ => (x (v-(a:ℤ)) (a-1)).toNat) := by  have hD : 2^i ≤ 2^(t+1) := Nat.pow_le_pow_right (by norm_num) (by omega)  have h4 : 4 ≤ 2^i := by    calc 4 = 2^2 := by norm_num      _ ≤ 2^i := Nat.pow_le_pow_right (by norm_num) hi  have hex := hexact i (by omega) v  have hut : ∀ a : ℕ, a ∈ Finset.Ico (2^(i-1)) (2^i) → (x (v-(a:ℤ)) a).toNat ≤      (x (v-(a : ℤ)) a && x (v-(a : ℤ)) (a+2^(t+1)-2^i)).toNat := by    intro a ha    rw [Finset.mem_Ico] at ha    have hp := (cycle_power_dyadic_tight_class_parent (t+1) i (by omega) (by omega)      (x (v-(a:ℤ))) (htight _) a ha.2).2 ha.1    cases h : x (v-(a:ℤ)) a    · simp    · simp [hp h]  have hsub : Finset.Ico (2^(i-1)) (2^i) ⊆ Finset.range (2^i) := by    intro a ha; rw [Finset.mem_Ico] at ha; exact Finset.mem_range.mpr ha.2  have hS : (Finset.Ico (2^(i-1)) (2^i)).sum (fun a : ℕ =>      (x (v-(a : ℤ)) a && x (v-(a : ℤ)) (a+2^(t+1)-2^i)).toNat) ≤ 1 := by    exact (Finset.sum_le_sum_of_subset (f := fun a : ℕ =>      (x (v-(a : ℤ)) a && x (v-(a : ℤ)) (a+2^(t+1)-2^i)).toNat) hsub).trans hex.le  have hU : (Finset.Ico (2^(i-1)) (2^i)).sum (fun a : ℕ => (x (v-(a:ℤ)) a).toNat) ≤      (Finset.Ico (2^(i-1)) (2^i)).sum (fun a : ℕ =>        (x (v-(a : ℤ)) a && x (v-(a : ℤ)) (a+2^(t+1)-2^i)).toNat) := Finset.sum_le_sum hut  obtain ⟨a', ha', h1, h2⟩ := hcover (2^(t+1) - 2^i + 1) (by omega) (by omega) (v - 1)  have ha'lt : a' + 1 < 2^i := by omega  have hv : v - 1 - (a':ℤ) = v - ((a'+1 : ℕ):ℤ) := by push_cast; ring  rw [hv] at h1 h2  rcases Nat.lt_or_ge (a'+1) (2^(i-1)) with hlt | hge  · have h2' : x (v-((a'+1:ℕ):ℤ)) (a'+1 + 2^(t+1) - 2^i) = true := by      rw [show a'+1 + 2^(t+1) - 2^i = a' + (2^(t+1) - 2^i + 1) by omega]; exact h2    have hp := (cycle_power_dyadic_tight_class_parent (t+1) i (by omega) (by omega)      (x (v-((a'+1:ℕ):ℤ))) (htight _) (a'+1) ha'lt).1 hlt h2'    have hown : (x (v-((a'+1:ℕ):ℤ)) (a'+1) && x (v-((a'+1:ℕ):ℤ)) (a'+1+2^(t+1)-2^i)).toNat = 1 := by      rw [hp, h2']; rfl    have hnot : a'+1 ∉ Finset.Ico (2^(i-1)) (2^i) := by      rw [Finset.mem_Ico]; omega    have hins : insert (a'+1) (Finset.Ico (2^(i-1)) (2^i)) ⊆ Finset.range (2^i) := by      intro b hb; rw [Finset.mem_insert] at hb; rcases hb with rfl | hb      · exact Finset.mem_range.mpr ha'lt      · exact hsub hb    have hle := Finset.sum_le_sum_of_subset (f := fun a : ℕ =>      (x (v-(a : ℤ)) a && x (v-(a : ℤ)) (a+2^(t+1)-2^i)).toNat) hins    rw [Finset.sum_insert hnot, hown, hex] at hle    omega  · have hw : (x (v-((a'+1:ℕ):ℤ)) (a'+1-1)).toNat = 1 := by      rw [Nat.add_sub_cancel, h1]; rfl    have hmem : a'+1 ∈ Finset.Ico (2^(i-1)) (2^i) := Finset.mem_Ico.mpr ⟨hge, ha'lt⟩    have h1le := Finset.single_le_sum (f := fun a : ℕ => (x (v-(a:ℤ)) (a-1)).toNat)        (fun _ _ => Nat.zero_le _) hmem    omegatheorem cpd_next_paired_pow_two_le (s : Finset ℕ) (f : ℕ → ℕ) (a b : ℕ) (ha : a ∈ s) (hb : b ∈ s)    (hab : a ≠ b) (hfa : f a = 1) (hfb : f b = 1) : 2 ≤ s.sum f := by  have hsub : ({a, b} : Finset ℕ) ⊆ s := by    intro c hc; simp only [Finset.mem_insert, Finset.mem_singleton] at hc    rcases hc with rfl | rfl    · exact ha    · exact hb  have := Finset.sum_le_sum_of_subset (f := f) hsub  rw [Finset.sum_pair hab, hfa, hfb] at this  exact thistheorem cycle_power_dyadic_regular_continuation_right_next_paired_pow (t : ℕ) (ht : 2 ≤ t)    (x : ℤ → ℕ → Bool)    (htight : ∀ p, cycle_power_dyadic_class_weight (t+1) (x p) =      (Finset.range (2^(t+1))).sum (fun a => (x p a).toNat))    (hexact : ∀ i < t+1, ∀ v : ℤ, (Finset.range (2^i)).sum (fun a =>      (x (v-(a : ℤ)) a && x (v-(a : ℤ)) (a+2^(t+1)-2^i)).toNat) = 1)    (hcover : ∀ d : ℕ, 1 ≤ d → d < 2^(t+1) → ∀ v : ℤ,      ∃ a : ℕ, a < 2^(t+1)-d ∧ x (v-(a : ℤ)) a = true ∧        x (v-(a : ℤ)) (a+d) = true)    (hcount : ∀ v : ℤ, (Finset.range (2^(t+1))).sum (fun a =>      (x (v-(a : ℤ)) a).toNat) = (t+1)+1)    (p0 : ℤ)    (hreg : ∀ r : ℤ, p0 - 3*2^t ≤ r → r ≤ p0 →      ((p0 - r) % 2 = 0 → x r 1 = true ∧ ∀ i < 2^t, x r (2*i) = x r (2*i+1)) ∧      ((p0 - r) % 2 = 1 → ∀ a, 0 < a → a < 2^(t+1) - 1 → x r a = false))    (hend1 : ∀ a, 0 < a → a < 2^(t+1) - 1 → x (p0+1) a = false) :    ∀ k, 1 ≤ k → k < t → x (p0+2) (2^k) = x (p0+2) (2^k+1) := by  intro k hk1 hkt  obtain ⟨T, hT⟩ : ∃ T : ℕ, T = 2^t := ⟨_, rfl⟩  obtain ⟨J, hJ⟩ : ∃ J : ℕ, J = 2^k := ⟨_, rfl⟩  have hD : (2:ℕ)^(t+1) = 2*T := by rw [hT, pow_succ]; ring  have h2J : (2:ℕ)^(k+1) = 2*J := by rw [hJ, pow_succ]; ring  have hJT : 2*J ≤ T := by    rw [← h2J, hT]; exact Nat.pow_le_pow_right (by norm_num) (by omega)  have hJ2 : 2 ≤ J := by    rw [hJ]    calc 2 = 2^1 := by norm_num      _ ≤ 2^k := Nat.pow_le_pow_right (by norm_num) hk1  have hkk : (2:ℕ)^(k+1-1) = J := by rw [Nat.add_sub_cancel, hJ]  obtain ⟨J', hJ'⟩ : ∃ J' : ℕ, J = 2 * J' := ⟨2^(k-1), by rw [hJ, ← pow_succ']; congr 1; omega⟩  have hTz : ((2:ℤ))^t = (T:ℤ) := by rw [hT]; push_cast; rfl  have hx : ∀ (q q' : ℤ) (a a' : ℕ), q = q' → a = a' → x q a = x q' a' := by    intro q q' a a' h1 h2; rw [h1, h2]  have hends : ∀ v : ℤ, x v 0 = true ∧ x v (2^(t+1) - 1) = true := by    intro v    have h := hexact 0 (by omega) v    simp only [pow_zero, Finset.range_one, Finset.sum_singleton, Nat.cast_zero, sub_zero,      Nat.zero_add] at h    revert h    generalize x v 0 = u    generalize x v (2^(t+1) - 1) = w    cases u <;> cases w <;> simp  have hb1 := (cycle_power_dyadic_regular_continuation_right_bit_one t ht x htight hexact hcount    p0 hreg).2  rw [← hJ]  obtain ⟨v, hv⟩ : ∃ v : ℤ, v = p0 + J + 3 := ⟨_, rfl⟩  -- rank k at p0+3: the terms of roots p0+3 and p0+2  have hexk := hexact k (by omega) (p0+3)  rw [← hJ] at hexk  have hk0 : (0:ℕ) ∈ Finset.range J := Finset.mem_range.mpr (by omega)  have hk1' : (1:ℕ) ∈ Finset.range J := Finset.mem_range.mpr (by omega)  have hrk : ¬ (x (p0+3) (2^(t+1) - J) = true ∧ x (p0+2) (2^(t+1) - J + 1) = true) := by    rintro ⟨h1, h2⟩    have := cpd_next_paired_pow_two_le (Finset.range J) (fun a =>      (x (p0+3-(a : ℤ)) a && x (p0+3-(a : ℤ)) (a+2^(t+1)-J)).toNat) 0 1 hk0 hk1' (by norm_num)      (by        show (x (p0+3-((0:ℕ):ℤ)) 0 && x (p0+3-((0:ℕ):ℤ)) (0+2^(t+1)-J)).toNat = 1        rw [hx _ (p0+3) 0 0 (by simp) rfl, hx _ (p0+3) (0+2^(t+1)-J) (2^(t+1)-J) (by simp) (by omega),          (hends _).1, h1]; rfl)      (by        show (x (p0+3-((1:ℕ):ℤ)) 1 && x (p0+3-((1:ℕ):ℤ)) (1+2^(t+1)-J)).toNat = 1        rw [hx _ (p0+2) 1 1 (by push_cast; ring) rfl,          hx _ (p0+2) (1+2^(t+1)-J) (2^(t+1)-J+1) (by push_cast; ring) (by omega), hb1, h2]; rfl)    omega  -- rank k+1 at v  have hexk1 := hexact (k+1) (by omega) v  rw [h2J] at hexk1  -- the cover of distance D - 2J + 1 at v - 1  have hcov : ∀ a0 : ℕ, (a0 = J ∨ a0 = J+1) →      (x (v-(a0:ℤ)) a0 && x (v-(a0:ℤ)) (a0+2^(t+1)-2*J)).toNat = 1 →      ¬ (x (p0+3) (J-1) = true ∧ x (p0+3) (2^(t+1) - J) = true) →      ¬ (x (p0+2) J = true ∧ x (p0+2) (2^(t+1) - J + 1) = true) → False := by    intro a0 ha0 hown hFJ hFJ1    obtain ⟨a', ha', h1, h2⟩ := hcover (2^(t+1) - 2*J + 1) (by omega) (by omega) (v - 1)    have hv' : v - 1 - (a':ℤ) = v - ((a'+1 : ℕ):ℤ) := by push_cast; ring    rw [hv'] at h1 h2    have h2' : x (v-((a'+1:ℕ):ℤ)) (a'+1 + 2^(t+1) - 2*J) = true := by      rw [show a'+1 + 2^(t+1) - 2*J = a' + (2^(t+1) - 2*J + 1) by omega]; exact h2    -- a second owner gives a contradiction    have hsecond : (x (v-((a'+1:ℕ):ℤ)) (a'+1) = true) → a'+1 ≠ a0 → False := by      intro h3 hne      have := cpd_next_paired_pow_two_le (Finset.range (2*J)) (fun a =>        (x (v-(a : ℤ)) a && x (v-(a : ℤ)) (a+2^(t+1)-2*J)).toNat) a0 (a'+1)        (Finset.mem_range.mpr (by omega)) (Finset.mem_range.mpr (by omega)) (Ne.symm hne) hown        (by show (x (v-((a'+1:ℕ):ℤ)) (a'+1) && x (v-((a'+1:ℕ):ℤ)) (a'+1+2^(t+1)-2*J)).toNat = 1            rw [h3, h2']; rfl)      omega    rcases Nat.lt_or_ge (a'+1) J with hlt | hge    · have hp := (cycle_power_dyadic_tight_class_parent (t+1) (k+1) (by omega) (by omega)        (x (v-((a'+1:ℕ):ℤ))) (htight _) (a'+1) (by omega)).1 (by rw [hkk]; exact hlt)        (by rw [h2J]; exact h2')      exact hsecond hp (by omega)    · rcases Nat.lt_or_ge (a'+1) (J+3) with hlt3 | hge3      · have hcases : a'+1 = J ∨ a'+1 = J+1 ∨ a'+1 = J+2 := by omega        rcases hcases with h | h | h        · apply hFJ          refine ⟨?_, ?_⟩          · rw [hx _ (v-((a'+1:ℕ):ℤ)) (J-1) a' (by rw [h, hv]; push_cast; ring) (by omega)]            exact h1          · rw [hx _ (v-((a'+1:ℕ):ℤ)) (2^(t+1)-J) (a'+1 + 2^(t+1) - 2*J) (by rw [h, hv]; push_cast; ring)              (by omega)]            exact h2'        · apply hFJ1          refine ⟨?_, ?_⟩          · rw [hx _ (v-((a'+1:ℕ):ℤ)) J a' (by rw [h, hv]; push_cast; ring) (by omega)]            exact h1          · rw [hx _ (v-((a'+1:ℕ):ℤ)) (2^(t+1)-J+1) (a'+1 + 2^(t+1) - 2*J) (by rw [h, hv]; push_cast; ring)              (by omega)]            exact h2'        · have := hend1 a' (by omega) (by omega)          rw [hx _ (v-((a'+1:ℕ):ℤ)) a' a' (by rw [h, hv]; push_cast; ring) rfl] at this          rw [this] at h1; exact absurd h1 (by decide)      · have hr := hreg (v - ((a'+1:ℕ):ℤ)) (by rw [hTz, hv]; push_cast; omega) (by rw [hv]; push_cast; omega)        rcases Nat.mod_two_eq_zero_or_one (a'+1) with hpar | hpar        · have := hr.2 (by rw [hv]; push_cast; omega) a' (by omega) (by omega)          rw [this] at h1; exact absurd h1 (by decide)        · have hp := (hr.1 (by rw [hv]; push_cast; omega)).2 (a'/2) (by omega)          rw [hx _ _ (2*(a'/2)) a' rfl (by omega), hx _ _ (2*(a'/2)+1) (a'+1) rfl (by omega), h1] at hp          exact hsecond hp.symm (by omega)  cases hA : x (p0+2) J <;> cases hB : x (p0+2) (J+1)  · rfl  · -- case B: J out, J+1 in    exfalso    have hpB := (cycle_power_dyadic_tight_class_parent (t+1) (k+1) (by omega) (by omega)      (x (p0+2)) (htight _) (J+1) (by omega)).2 (by rw [hkk]; omega) hB    rw [h2J, hx _ _ (J+1+2^(t+1)-2*J) (2^(t+1)-J+1) rfl (by omega)] at hpB    refine hcov (J+1) (Or.inr rfl) ?_ ?_ ?_    · rw [hx _ (p0+2) (J+1) (J+1) (by rw [hv]; push_cast; ring) rfl,        hx _ (p0+2) (J+1+2^(t+1)-2*J) (2^(t+1)-J+1) (by rw [hv]; push_cast; ring) (by omega), hB, hpB]; rfl    · rintro ⟨-, h⟩; exact hrk ⟨h, hpB⟩    · rintro ⟨h, -⟩; rw [hA] at h; exact absurd h (by decide)  · -- case A: J in, J+1 out    exfalso    -- count comparison at v and v - 1    have hM : ∀ a : ℕ, a ∈ Finset.Ico (J+2) (2^(t+1)) →        (x (v-(a:ℤ)) a).toNat = (x (v-(a:ℤ)) (a-1)).toNat := by      intro a ha      rw [Finset.mem_Ico] at ha      rcases Nat.lt_or_ge a (J+3) with h2 | h3      · have ha2 : a = J+2 := by omega        subst ha2        rw [hx _ (p0+1) (J+2) (J+2) (by rw [hv]; push_cast; ring) rfl,          hx _ (p0+1) (J+2-1) (J+1) (by rw [hv]; push_cast; ring) (by omega),          hend1 (J+2) (by omega) (by omega), hend1 (J+1) (by omega) (by omega)]      · have hr := hreg (v - (a:ℤ)) (by rw [hTz, hv]; omega) (by rw [hv]; omega)        rcases Nat.mod_two_eq_zero_or_one a with hpar | hpar        · rw [hr.2 (by rw [hv]; omega) a (by omega) (by omega),            hr.2 (by rw [hv]; omega) (a-1) (by omega) (by omega)]        · have hp := (hr.1 (by rw [hv]; omega)).2 ((a-1)/2) (by omega)          rw [hx _ _ (a-1) (2*((a-1)/2)) rfl (by omega), hp]          exact congrArg Bool.toNat (hx _ _ _ _ rfl (by omega))    have hMs := Finset.sum_congr rfl hM    have hc1 := hcount v    rw [Finset.range_eq_Ico, Finset.sum_eq_sum_Ico_succ_bot (by omega),      ← Finset.sum_Ico_consecutive _ (show 0+1 ≤ J+1 by omega) (show J+1 ≤ 2^(t+1) by omega),      Finset.sum_eq_sum_Ico_succ_bot (show J+1 < 2^(t+1) by omega), hMs] at hc1    have u0 : (x (v - ((0:ℕ):ℤ)) 0).toNat = 1 := by      rw [hx _ v 0 0 (by simp) rfl, (hends v).1]; rfl    have uJ1 : (x (v - ((J+1:ℕ):ℤ)) (J+1)).toNat = 0 := by      rw [hx _ (p0+2) (J+1) (J+1) (by rw [hv]; push_cast; ring) rfl, hB]; rfl    rw [u0, uJ1, show (0:ℕ)+1 = 1 from rfl] at hc1    have hc0 := hcount (v - 1)    have hre : (Finset.range (2^(t+1))).sum (fun a => (x (v - 1 - (a:ℤ)) a).toNat) =        (Finset.Ico 1 (2^(t+1)+1)).sum (fun a : ℕ => (x (v - (a:ℤ)) (a-1)).toNat) := by      rw [Finset.sum_Ico_eq_sum_range, Nat.add_sub_cancel]      refine Finset.sum_congr rfl fun k _ => ?_      exact congrArg Bool.toNat (hx _ _ _ _ (by push_cast; ring) (by omega))    rw [hre, Finset.sum_Ico_succ_top (by omega), Finset.sum_eq_sum_Ico_succ_bot (by omega),      ← Finset.sum_Ico_consecutive _ (show 1+1 ≤ J+1 by omega) (show J+1 ≤ 2^(t+1) by omega),      Finset.sum_eq_sum_Ico_succ_bot (show J+1 < 2^(t+1) by omega)] at hc0    have w1 : (x (v - ((1:ℕ):ℤ)) (1-1)).toNat = 1 := by      rw [hx _ (v-1) (1-1) 0 (by simp) rfl, (hends _).1]; rfl    have wJ1 : (x (v - ((J+1:ℕ):ℤ)) (J+1-1)).toNat = 1 := by      rw [hx _ (p0+2) (J+1-1) J (by rw [hv]; push_cast; ring) (by omega), hA]; rfl    have wD : (x (v - ((2^(t+1):ℕ):ℤ)) (2^(t+1)-1)).toNat = 1 := by      rw [(hends _).2]; rfl    rw [w1, wJ1, wD, show (1:ℕ)+1 = 2 from rfl] at hc0    -- block bound up to 2^k    have key : ∀ b, 1 ≤ b → b ≤ k →        (Finset.Ico 1 (2^b)).sum (fun a : ℕ => (x (v-(a:ℤ)) a).toNat) ≤          1 + (Finset.Ico 2 (2^b)).sum (fun a : ℕ => (x (v-(a:ℤ)) (a-1)).toNat) := by      intro b hb1 hbk      induction b with      | zero => omega      | succ b ih =>        rcases Nat.lt_or_ge b 1 with h | h        · have hb0 : b = 0 := by omega          subst hb0          simp only [zero_add, pow_one, Finset.Ico_self, Finset.sum_empty, add_zero]          rw [Finset.sum_eq_sum_Ico_succ_bot (by norm_num), Finset.Ico_self, Finset.sum_empty]          cases x (v - ((1:ℕ):ℤ)) 1 <;> simp        · have h2b : 2 ≤ 2^b := by            calc 2 = 2^1 := by norm_num              _ ≤ 2^b := Nat.pow_le_pow_right (by norm_num) h          have hbb : 2^b ≤ 2^(b+1) := Nat.pow_le_pow_right (by norm_num) (by omega)          have hblk := cpd_next_paired_pow_block t x htight hexact hcover v (b+1) (by omega) (by omega)          rw [Nat.add_sub_cancel] at hblk          rw [← Finset.sum_Ico_consecutive _ (show 1 ≤ 2^b by omega) hbb,            ← Finset.sum_Ico_consecutive _ h2b hbb]          have := ih h (by omega)          omega    have hk := key k hk1 le_rfl    rw [← hJ] at hk    rw [Finset.sum_Ico_succ_top (show 1 ≤ J by omega)] at hc1    rw [Finset.sum_Ico_succ_top (show 2 ≤ J by omega)] at hc0    rw [show J+1+1 = J+2 by omega] at hc0    have hu : (x (v - (J:ℤ)) J).toNat = 1 := by      have := Bool.toNat_le (x (v - (J:ℤ)) J); omega    have hw : (x (v - (J:ℤ)) (J-1)).toNat = 0 := by omega    have hv3 : v - (J:ℤ) = p0 + 3 := by rw [hv]; ring    rw [hv3] at hu hw    have hu' : x (p0+3) J = true := by      revert hu; cases x (p0+3) J <;> simp    have hw' : x (p0+3) (J-1) = false := by      revert hw; cases x (p0+3) (J-1) <;> simp    have hpA := (cycle_power_dyadic_tight_class_parent (t+1) (k+1) (by omega) (by omega)      (x (p0+3)) (htight _) J (by omega)).2 (by rw [hkk]) hu'    rw [h2J, hx _ _ (J+2^(t+1)-2*J) (2^(t+1)-J) rfl (by omega)] at hpA    refine hcov J (Or.inl rfl) ?_ ?_ ?_    · rw [hx _ (p0+3) J J (by rw [hv]; push_cast; ring) rfl,        hx _ (p0+3) (J+2^(t+1)-2*J) (2^(t+1)-J) (by rw [hv]; push_cast; ring) (by omega), hu', hpA]; rfl    · rintro ⟨h, -⟩; rw [hw'] at h; exact absurd h (by decide)    · rintro ⟨-, h⟩; exact hrk ⟨hpA, h⟩  · rfl
See it in the graphDiscuss this resultChallenge it