AFTD Auto-Formalizing Theoretical Domains

op2130_circuit_advance_and_or

theoremverified

Four local height updates convert an AND signal to its odd encoding and combine it with the next bit in an OR gate.

Statement

theorem op2130_circuit_advance_and_or (h : ℕ → ℤ) (p : ℕ) (a x y c1 c2 c3 c4 : Bool)
    (ha : h p = if a then 2 else 0)
    (hx : h (p+1) = if x then 1 else -1)
    (hax : x = false → a = false)
    (hg : h (p+2) = -1)
    (hy : h (p+3) = if y then 2 else 0) :
    let h1 := op2130_height_double h (p+1) c1 c2
    let h2 := op2130_height_double h1 (p+2) c3 c4
    h2 (p+2) = if a || y then 1 else -1
Source
OP-2130, deterministic decision-circuit advance
Verified
24 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 2
  • op2130_height_double_localTwo consecutive updates at one path height affect only that site, and their center value is the corresponding two-step scalar gate.
  • op2130_decision_gatesTwo local height updates implement AND, OR, and the two required signal conversions on the indicated finite encodings, independently of…
Used by 1
  • op2130_eval_ready_inductionAn arbitrary number of four-request circuit advances preserves the encoded gate value, all untouched bit and gate coordinates, and the AND…

The proof, explained

The proof proceeds in two stages, tracking the effect of two consecutive double gate updates. First, the double update at position p + 1 uses the correlation between the AND signal a at position p and the odd bit at p + 1 to convert a into an odd encoding at p + 1 via op2130_decision_copy_odd, while preserving the heights at positions p + 2 and p + 3. Second, the double update at position p + 2 combines the newly encoded bit at p + 1 with the input at p + 3 using the OR gate decision lemma op2130_decision_or, yielding 1 if a ∨ y is true and -1 otherwise.

  1. The first double update at position p + 1 produces an intermediate height function h₁ such that h₁(p + 1) = 1 if a is true and -1 if a is false.

    We define h₁ as the result of two gate updates at position p + 1. By op2130_height_double_center, the updated height h₁(p + 1) depends on its center h(p + 1) and neighbors h(p) and h(p + 2). Since h(p + 2) = -1 and the assumption x = false → a = false guarantees that h(p + 1) = -1 implies h(p) = 0, the lemma op2130_decision_copy_odd applies. It establishes that the double update produces 1 when h(p) = 2 and -1 when h(p) = 0, which equals 1 if a is true and -1 if a is false.

    lines 10–24

    uses op2130_decision_copy_odd, op2130_height_double_center

      let h1 := op2130_height_double h (p+1) c1 c2
      have hc : h1 (p+1) = if a then 1 else -1 := by
        have hcor : h (p+1) = -1 → h p = 0 := by
          rw [hx, ha]
          cases x <;> cases a <;> simp_all
        have hcopy := op2130_decision_copy_odd (h p) (h (p+1)) c1 c2
          (by rw [ha]; cases a <;> simp) (by rw [hx]; cases x <;> simp) hcor
        have hc0 := op2130_height_double_center h (p+1) (by omega) c1 c2
        have hn : p+1-1=p := by omega
        rw [hn] at hc0
        have hg2 : p+1+1=p+2 := by omega
        rw [hg2, hg] at hc0
        change h1 (p+1) = _ at hc0
        apply hc0.trans
        cases a <;> simpa [ha] using hcopy
  2. The intermediate height at position p + 2 remains unchanged: h₁(p + 2) = -1.

    Because the first double update was centered at position p + 1 and p + 2 ≠ p + 1, the lemma op2130_height_double_other guarantees that the height at p + 2 is unaffected, retaining its initial value h(p + 2) = -1.

    lines 25–27

    uses op2130_height_double_other

      have hg1 : h1 (p+2) = -1 := by
        dsimp only [h1]
        rw [op2130_height_double_other h (p+1) (p+2) c1 c2 (by omega), hg]
  3. The intermediate height at position p + 3 remains unchanged: h₁(p + 3) = 2 if y is true and 0 if y is false.

    Similarly, since p + 3 ≠ p + 1, op2130_height_double_other ensures that the double update at p + 1 leaves the height at p + 3 untouched, so h₁(p + 3) = h(p + 3).

    lines 28–30

    uses op2130_height_double_other

      have hy1 : h1 (p+3) = if y then 2 else 0 := by
        dsimp only [h1]
        rw [op2130_height_double_other h (p+1) (p+3) c1 c2 (by omega), hy]
  4. The second double update at position p + 2 computes the logical OR of a and y, yielding h₂(p + 2) = 1 if a ∨ y is true and -1 if false.

    By op2130_decision_or, two gate updates on center -1 with neighbors h₁(p + 1) ∈ {-1, 1} and h₁(p + 3) ∈ {0, 2} evaluate to 1 when h₁(p + 3) = 2 or h₁(p + 1) = 1, and to -1 otherwise. Applying op2130_height_double_center rewrites the value h₂(p + 2) as exactly this double update with neighbors at p + 1 and p + 3. Substituting the intermediate heights and performing case analysis on the boolean values a and y verifies that this condition simplifies to a ∨ y.

    lines 31–36

    uses op2130_decision_or, op2130_height_double_center

      have hor := op2130_decision_or (h1 (p+3)) (h1 (p+1)) c3 c4
        (by rw [hy1]; cases y <;> simp) (by rw [hc]; cases a <;> simp)
      change op2130_height_double h1 (p+2) c3 c4 (p+2) = _
      rw [op2130_height_double_center h1 (p+2) (by omega) c3 c4]
      simp only [show p+2-1=p+1 by omega, hg1, hc, hy1] at *
      cases a <;> cases y <;> simpa using hor
op2130_decision_copy_odd
If a center height y ∈ {-1, 1} and left neighbor x ∈ {0, 2} satisfy that y = -1 implies x = 0, then two consecutive gate updates at the center with right neighbor -1 evaluate to 1 when x = 2 and -1 when x = 0.
op2130_height_double_center
For any index j ≥ 1, the height after a double update centered at j is given by two successive gate updates on the center value h(j) using neighbors h(j - 1) and h(j + 1).
op2130_height_double_other
A double update centered at index j leaves the height at any other index i ≠ j unchanged.
op2130_decision_or
For inputs x ∈ {0, 2} and y ∈ {-1, 1}, two successive gate updates on a center with height -1 and neighbors y and x evaluate to 1 if x = 2 or y = 1, and to -1 otherwise.

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

theorem op2130_circuit_advance_and_or (h : ℕ → ℤ) (p : ℕ) (a x y c1 c2 c3 c4 : Bool)    (ha : h p = if a then 2 else 0)    (hx : h (p+1) = if x then 1 else -1)    (hax : x = false → a = false)    (hg : h (p+2) = -1)    (hy : h (p+3) = if y then 2 else 0) :    let h1 := op2130_height_double h (p+1) c1 c2    let h2 := op2130_height_double h1 (p+2) c3 c4    h2 (p+2) = if a || y then 1 else -1 := by  let h1 := op2130_height_double h (p+1) c1 c2  have hc : h1 (p+1) = if a then 1 else -1 := by    have hcor : h (p+1) = -1 → h p = 0 := by      rw [hx, ha]      cases x <;> cases a <;> simp_all    have hcopy := op2130_decision_copy_odd (h p) (h (p+1)) c1 c2      (by rw [ha]; cases a <;> simp) (by rw [hx]; cases x <;> simp) hcor    have hc0 := op2130_height_double_center h (p+1) (by omega) c1 c2    have hn : p+1-1=p := by omega    rw [hn] at hc0    have hg2 : p+1+1=p+2 := by omega    rw [hg2, hg] at hc0    change h1 (p+1) = _ at hc0    apply hc0.trans    cases a <;> simpa [ha] using hcopy  have hg1 : h1 (p+2) = -1 := by    dsimp only [h1]    rw [op2130_height_double_other h (p+1) (p+2) c1 c2 (by omega), hg]  have hy1 : h1 (p+3) = if y then 2 else 0 := by    dsimp only [h1]    rw [op2130_height_double_other h (p+1) (p+3) c1 c2 (by omega), hy]  have hor := op2130_decision_or (h1 (p+3)) (h1 (p+1)) c3 c4    (by rw [hy1]; cases y <;> simp) (by rw [hc]; cases a <;> simp)  change op2130_height_double h1 (p+2) c3 c4 (p+2) = _  rw [op2130_height_double_center h1 (p+2) (by omega) c3 c4]  simp only [show p+2-1=p+1 by omega, hg1, hc, hy1] at *  cases a <;> cases y <;> simpa using hor
See it in the graphDiscuss this resultChallenge it