AFTD Auto-Formalizing Theoretical Domains

op2130_decision_gates

theoremverified

Two local height updates implement AND, OR, and the two required signal conversions on the indicated finite encodings, independently of both coins.

Statement

theorem op2130_decision_gates (x y : ℤ) (c1 c2 : Bool) (hx : x = 0 ∨ x = 2) (hy : y = -1 ∨ y = 1) : (op2130_gate_update x (op2130_gate_update x 2 y c1) y c2 = if x = 2 ∧ y = 1 then 2 else 0) ∧ (op2130_gate_update y (op2130_gate_update y (-1) x c1) x c2 = if x = 2 ∨ y = 1 then 1 else -1) ∧ (op2130_gate_update y (op2130_gate_update y x 2 c1) 2 c2 = if y = 1 then 2 else 0) ∧ ((y = -1 → x = 0) → op2130_gate_update x (op2130_gate_update x y (-1) c1) (-1) c2 = if x = 2 then 1 else -1)
Source
OP-2130, deterministic height decision-list gates
Verified
24 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Used by 6
  • op2130_circuit_advance_and_orFour local height updates convert an AND signal to its odd encoding and combine it with the next bit in an OR gate.
  • op2130_circuit_advance_or_andFour local height updates convert an OR signal to its even encoding and combine it with the next bit in an AND gate.
  • op2130_load_bit_gadgetsThe fixed even-bit, odd-bit, and left-reference preparation sequences give the specified Boolean encoding independently of all dummy coins.
  • op2130_load_spatial_correctThe even and odd bit-loading gadgets set exactly the desired local Boolean signal and gate value while leaving every other height…
  • op2130_load_to_eval_readyAfter the reverse loading invariant holds, four fixed local updates establish the initial invariant for the verified left-to-right gate…
  • 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.

The proof, explained

The theorem combines four finite case verifications for AND, OR, and signal copy gates. Each gate's correctness is proved by exhaustive case analysis over the finite inputs and coin states, and the main theorem bundles them into a single conjunction.

  1. op2130_decision_and holds for all inputs automation

    Case analysis and calculation.

    lines 8–9

    uses op2130_gate_update

      rcases hx with rfl | rfl <;> rcases hy with rfl | rfl <;>
        cases c1 <;> cases c2 <;> norm_num [op2130_gate_update]
  2. op2130_decision_or holds for all inputs automation

    Case analysis and calculation.

    lines 15–16

    uses op2130_gate_update

      rcases hx with rfl | rfl <;> rcases hy with rfl | rfl <;>
        cases c1 <;> cases c2 <;> norm_num [op2130_gate_update]
  3. op2130_decision_copy_even holds for all inputs automation

    Case analysis and calculation.

    lines 22–23

    uses op2130_gate_update

      rcases hx with rfl | rfl <;> rcases hy with rfl | rfl <;>
        cases c1 <;> cases c2 <;> norm_num [op2130_gate_update]
  4. op2130_decision_copy_odd holds for all inputs automation

    Case analysis and calculation.

    lines 29–30

    uses op2130_gate_update

      rcases hx with rfl | rfl <;> rcases hy with rfl | rfl <;>
        cases c1 <;> cases c2 <;> norm_num [op2130_gate_update] at *
  5. The four gate properties hold simultaneously

    Combine the four lemmas.

    line 33

    uses op2130_decision_and, op2130_decision_or, op2130_decision_copy_even, op2130_decision_copy_odd

      exact ⟨op2130_decision_and x y c1 c2 hx hy, op2130_decision_or x y c1 c2 hx hy, op2130_decision_copy_even x y c1 c2 hx hy, fun h => op2130_decision_copy_odd x y c1 c2 hx hy h⟩
op2130_decision_and
AND gate evaluation for gate updates
op2130_decision_or
OR gate evaluation for gate updates
op2130_decision_copy_even
Even copy evaluation for gate updates
op2130_decision_copy_odd
Odd copy evaluation for gate updates
op2130_gate_update
One-step gate height update function

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_gate_update (l m r : ℤ) (coin : Bool) : ℤ :=  m + if 2*m < l+r then 1 else if l+r < 2*m then -1 else if coin then 1 else -1theorem op2130_decision_and (x y : ℤ) (c1 c2 : Bool)    (hx : x = 0 ∨ x = 2) (hy : y = -1 ∨ y = 1) :    op2130_gate_update x (op2130_gate_update x 2 y c1) y c2 =      if x = 2 ∧ y = 1 then 2 else 0 := by  rcases hx with rfl | rfl <;> rcases hy with rfl | rfl <;>    cases c1 <;> cases c2 <;> norm_num [op2130_gate_update]theorem op2130_decision_or (x y : ℤ) (c1 c2 : Bool)    (hx : x = 0 ∨ x = 2) (hy : y = -1 ∨ y = 1) :    op2130_gate_update y (op2130_gate_update y (-1) x c1) x c2 =      if x = 2 ∨ y = 1 then 1 else -1 := by  rcases hx with rfl | rfl <;> rcases hy with rfl | rfl <;>    cases c1 <;> cases c2 <;> norm_num [op2130_gate_update]theorem op2130_decision_copy_even (x y : ℤ) (c1 c2 : Bool)    (hx : x = 0 ∨ x = 2) (hy : y = -1 ∨ y = 1) :    op2130_gate_update y (op2130_gate_update y x 2 c1) 2 c2 =      if y = 1 then 2 else 0 := by  rcases hx with rfl | rfl <;> rcases hy with rfl | rfl <;>    cases c1 <;> cases c2 <;> norm_num [op2130_gate_update]theorem op2130_decision_copy_odd (x y : ℤ) (c1 c2 : Bool)    (hx : x = 0 ∨ x = 2) (hy : y = -1 ∨ y = 1) (hxy : y = -1 → x = 0) :    op2130_gate_update x (op2130_gate_update x y (-1) c1) (-1) c2 =      if x = 2 then 1 else -1 := by  rcases hx with rfl | rfl <;> rcases hy with rfl | rfl <;>    cases c1 <;> cases c2 <;> norm_num [op2130_gate_update] at *theorem op2130_decision_gates (x y : ℤ) (c1 c2 : Bool) (hx : x = 0 ∨ x = 2) (hy : y = -1 ∨ y = 1) : (op2130_gate_update x (op2130_gate_update x 2 y c1) y c2 = if x = 2 ∧ y = 1 then 2 else 0) ∧ (op2130_gate_update y (op2130_gate_update y (-1) x c1) x c2 = if x = 2 ∨ y = 1 then 1 else -1) ∧ (op2130_gate_update y (op2130_gate_update y x 2 c1) 2 c2 = if y = 1 then 2 else 0) ∧ ((y = -1 → x = 0) → op2130_gate_update x (op2130_gate_update x y (-1) c1) (-1) c2 = if x = 2 then 1 else -1) := by  exact ⟨op2130_decision_and x y c1 c2 hx hy, op2130_decision_or x y c1 c2 hx hy, op2130_decision_copy_even x y c1 c2 hx hy, fun h => op2130_decision_copy_odd x y c1 c2 hx hy h⟩
See it in the graphDiscuss this resultChallenge it