AFTD Auto-Formalizing Theoretical Domains

op2130_height_two_level_reset

theoremverified

When a site and its two neighbors have heights in {-1,1}, two consecutive greedy height updates replace the site with the common neighbor sign when neighbors agree and with the second fair coin sign when they differ.

Statement

theorem op2130_height_two_level_reset (h : ℕ → ℤ) (j : ℕ) (hj : 1 ≤ j) (c1 c2 : Bool)
    (hl : h (j-1) = 1 ∨ h (j-1) = -1)
    (hm : h j = 1 ∨ h j = -1)
    (hr : h (j+1) = 1 ∨ h (j+1) = -1) :
    op2130_height_step (op2130_height_step h j c1) j c2 j =
      if h (j-1) = h (j+1) then h (j-1) else if c2 then 1 else -1
Source
OP-2130, two-level path-height dynamics
Verified
24 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 3
  • op2130_height_stepOne greedy update of a path cumulative-height profile at an interior site, using the supplied coin for a tie.
  • LinearOrder.toTotalPreorderEvery LinearOrder is a TotalPreorder.
  • TotalPreorderA total preorder: a preorder where ≤ is total (complete). This is weaker than LinearOrder — it does NOT require antisymmetry or…

The proof, explained

The proof first establishes the local two-level reset property by an exhaustive case check over all 32 combinations of neighbor heights, center height, and coin flips. It then evaluates the two consecutive height updates at site j: since an update at site j does not affect the heights at the neighboring sites j - 1 and j + 1, the two-step process reduces to the local reset lemma with fixed neighbor heights. Thus, site j resets to the common neighbor value when the neighbors agree, and to the value of the second coin flip when they differ.

  1. The local two-level reset property holds for any three heights in {-1, 1} and boolean coin flips. automation

    The proof splits into all cases for the hypotheses: each of the heights l, m, r can be 1 or -1, and each of the coin flips c1, c2 can be true or false. For each of the 2³ × 2² = 32 cases, numerical evaluation (norm_num) unfolds the definition of op2130_local_height and verifies the resulting equality.

    lines 8–10

      rcases hl with rfl | rfl <;> rcases hm with rfl | rfl <;>
        rcases hr with rfl | rfl <;> cases c1 <;> cases c2 <;>
        norm_num [op2130_local_height]
  2. The neighboring indices j - 1 and j + 1 are distinct from j. automation

    Since j ≥ 1, we have j - 1 < j and j < j + 1. Linear arithmetic over ℕ establishes that both j - 1 ≠ j and j + 1 ≠ j.

    lines 18–19

      have hn1 : j-1 ≠ j := by omega
      have hp1 : j+1 ≠ j := by omega
  3. The first update at site j leaves the neighbor heights at j - 1 and j + 1 unchanged, and updates the height at site j according to the local height rule.

    By definition, an update step at site j only modifies the function value at index j. Because the neighbor indices j - 1 and j + 1 are distinct from j, their heights after the update are identical to their original values h(j - 1) and h(j + 1). At site j itself, the new height is by definition op2130_local_height evaluated on h(j - 1), h j, and h(j + 1) with coin c1.

    lines 20–26

      have ha : op2130_height_step h j c1 (j-1) = h (j-1) := by
        simp [op2130_height_step, hn1]
      have hb : op2130_height_step h j c1 j =
          op2130_local_height (h (j-1)) (h j) (h (j+1)) c1 := by
        simp [op2130_height_step, op2130_local_height]
      have hc : op2130_height_step h j c1 (j+1) = h (j+1) := by
        simp [op2130_height_step, hp1]
  4. The second update at site j is given by the local height function applied to the intermediate configuration's heights at j - 1, j, and j + 1 with coin c2.

    Unfolding the definition of op2130_height_step shows that performing an update at site j on the intermediate configuration evaluates op2130_local_height on the values of the intermediate configuration at sites j - 1, j, and j + 1 using coin c2.

    lines 27–30

      have hd : op2130_height_step (op2130_height_step h j c1) j c2 j =
          op2130_local_height (op2130_height_step h j c1 (j-1))
            (op2130_height_step h j c1 j) (op2130_height_step h j c1 (j+1)) c2 := by
        simp [op2130_height_step, op2130_local_height]
  5. The two-step update at site j reduces to the local two-level reset, completing the proof.

    Rewriting the second update using the intermediate values replaces the arguments of op2130_local_height with the original neighbor heights h(j - 1) and h(j + 1) and the intermediate center height. Since the original heights at j - 1, j, and j + 1 all belong to {-1, 1}, the lemma op2130_local_two_level_reset applies, concluding that the final height is h(j - 1) when the neighbors agree and the value of c2 (1 if true, -1 if false) when they differ.

    lines 31–32

    uses op2130_local_two_level_reset

      rw [hd, ha, hb, hc]
      exact op2130_local_two_level_reset (h (j-1)) (h j) (h (j+1)) c1 c2 hl hm hr
op2130_local_two_level_reset
For any three heights l, m, r in {-1, 1} and boolean coin flips c1, c2, applying two consecutive local height updates to m with neighbors l and r yields l if l = r, and otherwise yields 1 if c2 is true and -1 if c2 is false.

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

def op2130_local_height (l m r : ℤ) (c : Bool) : ℤ :=  m + if 2*m < l+r then 1 else if l+r < 2*m then -1 else if c then 1 else -1theorem op2130_local_two_level_reset (l m r : ℤ) (c1 c2 : Bool)    (hl : l = 1 ∨ l = -1) (hm : m = 1 ∨ m = -1) (hr : r = 1 ∨ r = -1) :    op2130_local_height l (op2130_local_height l m r c1) r c2 =      if l = r then l else if c2 then 1 else -1 := by  rcases hl with rfl | rfl <;> rcases hm with rfl | rfl <;>    rcases hr with rfl | rfl <;> cases c1 <;> cases c2 <;>    norm_num [op2130_local_height]theorem op2130_height_two_level_reset (h : ℕ → ℤ) (j : ℕ) (hj : 1 ≤ j) (c1 c2 : Bool)    (hl : h (j-1) = 1 ∨ h (j-1) = -1)    (hm : h j = 1 ∨ h j = -1)    (hr : h (j+1) = 1 ∨ h (j+1) = -1) :    op2130_height_step (op2130_height_step h j c1) j c2 j =      if h (j-1) = h (j+1) then h (j-1) else if c2 then 1 else -1 := by  have hn1 : j-1 ≠ j := by omega  have hp1 : j+1 ≠ j := by omega  have ha : op2130_height_step h j c1 (j-1) = h (j-1) := by    simp [op2130_height_step, hn1]  have hb : op2130_height_step h j c1 j =      op2130_local_height (h (j-1)) (h j) (h (j+1)) c1 := by    simp [op2130_height_step, op2130_local_height]  have hc : op2130_height_step h j c1 (j+1) = h (j+1) := by    simp [op2130_height_step, hp1]  have hd : op2130_height_step (op2130_height_step h j c1) j c2 j =      op2130_local_height (op2130_height_step h j c1 (j-1))        (op2130_height_step h j c1 j) (op2130_height_step h j c1 (j+1)) c2 := by    simp [op2130_height_step, op2130_local_height]  rw [hd, ha, hb, hc]  exact op2130_local_two_level_reset (h (j-1)) (h j) (h (j+1)) c1 c2 hl hm hr
See it in the graphDiscuss this resultChallenge it