AFTD Auto-Formalizing Theoretical Domains

op2130_circuit_advance_or_and

theoremverified

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

Statement

theorem op2130_circuit_advance_or_and (h : ℕ → ℤ) (p : ℕ) (a x y c1 c2 c3 c4 : Bool)
    (ha : h p = if a then 1 else -1)
    (hx : h (p+1) = if x then 2 else 0)
    (hg : h (p+2) = 2)
    (hy : h (p+3) = if y then 1 else -1) :
    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 2 else 0
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 computes the effect of two consecutive double-gate height updates. The first update at position $p+1$ reads the odd-encoded signal $a$ at $p$ and converts it into an even-encoded signal ($2$ or $0$) at $p+1$, leaving positions $p+2$ and $p+3$ unchanged. The second update at position $p+2$ acts as an AND gate combining the converted signal at $p+1$ with the odd-encoded bit $y$ at $p+3$, producing height $2$ if both $a$ and $y$ are true, and $0$ otherwise.

  1. After the first double height update centered at $p+1$, the new height $h_1(p+1)$ is $2$ if $a$ is true and $0$ if $a$ is false.

    By `op2130_height_double_center`, the value $h_1(p+1)$ is computed by two consecutive gate updates at center $h(p+1)$ using left neighbor $h(p)$ and right neighbor $h(p+2) = 2$. Since $h(p+1) \in \{0, 2\}$ and $h(p) \in \{-1, 1\}$, lemma `op2130_decision_copy_even` evaluates this update to $2$ when $h(p) = 1$ and $0$ otherwise. Substituting $h(p) = \text{if } a \text{ then } 1 \text{ else } -1$ yields the desired even encoding for $a$.

    lines 9–20

    uses op2130_decision_copy_even, op2130_height_double_center

      let h1 := op2130_height_double h (p+1) c1 c2
      have hc : h1 (p+1) = if a then 2 else 0 := by
        have hcopy := op2130_decision_copy_even (h (p+1)) (h p) c1 c2
          (by rw [hx]; cases x <;> simp) (by rw [ha]; cases a <;> simp)
        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 height at position $p+2$ is unchanged by the first update: $h_1(p+2) = 2$.

    Since $p+2 \ne p+1$, `op2130_height_double_other` guarantees that updating at $p+1$ does not affect position $p+2$, preserving the hypothesis $h(p+2) = 2$.

    lines 21–23

    uses op2130_height_double_other

      have hg1 : h1 (p+2) = 2 := by
        dsimp only [h1]
        rw [op2130_height_double_other h (p+1) (p+2) c1 c2 (by omega), hg]
  3. The height at position $p+3$ is unchanged by the first update: $h_1(p+3) = \text{if } y \text{ then } 1 \text{ else } -1$.

    Because $p+3 \ne p+1$, `op2130_height_double_other` ensures $h_1(p+3) = h(p+3)$, preserving the odd encoding of $y$.

    lines 24–26

    uses op2130_height_double_other

      have hy1 : h1 (p+3) = if y then 1 else -1 := by
        dsimp only [h1]
        rw [op2130_height_double_other h (p+1) (p+3) c1 c2 (by omega), hy]
  4. A double gate update at position $p+2$ with inputs $h_1(p+1)$ and $h_1(p+3)$ evaluates to $2$ if $h_1(p+1) = 2$ and $h_1(p+3) = 1$, and $0$ otherwise.

    Given that $h_1(p+1) \in \{0, 2\}$ and $h_1(p+3) \in \{-1, 1\}$, lemma `op2130_decision_and` shows that two successive gate updates on an initial value of $2$ compute the logical AND of the left and right inputs.

    lines 27–28

    uses op2130_decision_and

      have hand := op2130_decision_and (h1 (p+1)) (h1 (p+3)) c3 c4
        (by rw [hc]; cases a <;> simp) (by rw [hy1]; cases y <;> simp)
  5. The second update produces the final height $h_2(p+2) = \text{if } a \land y \text{ then } 2 \text{ else } 0$.

    By `op2130_height_double_center`, $h_2(p+2)$ is given by the double gate update on center $h_1(p+2) = 2$ with neighbors $h_1(p+1)$ and $h_1(p+3)$. Rewriting with the characterization from `op2130_decision_and` and splitting into truth cases for the booleans $a$ and $y$, the condition $(h_1(p+1) = 2 \land h_1(p+3) = 1)$ reduces directly to $a \land y = \text{true}$.

    lines 29–32

    uses op2130_height_double_center

      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 hand
op2130_decision_copy_even
If a center height $x \in \{0, 2\}$ undergoes two gate updates with left neighbor $y \in \{-1, 1\}$ and right neighbor $2$, the result copies $y$ into even encoding: $2$ if $y = 1$ and $0$ otherwise.
op2130_height_double_center
For $j \ge 1$, a double height update at center position $j$ modifies the height at $j$ by applying two successive gate updates using left neighbor $h(j - 1)$ and right neighbor $h(j + 1)$.
op2130_height_double_other
A double height update centered at $j$ leaves the height at any distinct index $i \ne j$ unchanged.
op2130_decision_and
If an initial height of $2$ undergoes two gate updates with left input $x \in \{0, 2\}$ and right input $y \in \{-1, 1\}$, the resulting height computes their logical AND: $2$ if $x = 2$ and $y = 1$, and $0$ 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_or_and (h : ℕ → ℤ) (p : ℕ) (a x y c1 c2 c3 c4 : Bool)    (ha : h p = if a then 1 else -1)    (hx : h (p+1) = if x then 2 else 0)    (hg : h (p+2) = 2)    (hy : h (p+3) = if y then 1 else -1) :    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 2 else 0 := by  let h1 := op2130_height_double h (p+1) c1 c2  have hc : h1 (p+1) = if a then 2 else 0 := by    have hcopy := op2130_decision_copy_even (h (p+1)) (h p) c1 c2      (by rw [hx]; cases x <;> simp) (by rw [ha]; cases a <;> simp)    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) = 2 := 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 1 else -1 := by    dsimp only [h1]    rw [op2130_height_double_other h (p+1) (p+3) c1 c2 (by omega), hy]  have hand := op2130_decision_and (h1 (p+1)) (h1 (p+3)) c3 c4    (by rw [hc]; cases a <;> simp) (by rw [hy1]; cases y <;> 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 hand
See it in the graphDiscuss this resultChallenge it