AFTD Auto-Formalizing Theoretical Domains

prioritized_borel_latch_lookahead_cycles_unique

theoremverified

In the four-state latch and lookahead graph, two closed state walks from the same state spelling the same public word coincide.

Statement

theorem prioritized_borel_latch_lookahead_cycles_unique
    (p : Bool × Bool) (xs ys : List (Bool × (Bool × Bool)))
    (hx : Op1385StateWalk op1385LatchLookaheadStep p xs p)
    (hy : Op1385StateWalk op1385LatchLookaheadStep p ys p)
    (hword : xs.map Prod.fst = ys.map Prod.fst) : xs = ys
Source
arXiv:2611.10136, Conjecture 19. A four-state separation example for OP-1385, experiment 44458.
Verified
29 Nov 2026
Axioms
Quot.soundpropext
Built on 4
  • Op1385StateWalkA walk of a fixed binary-labeled state graph records its sequence of public directions and successor states.
  • op1385LatchLookaheadStepA four-state transition keeps a hidden latch nondecreasing and requires the current public direction to match the second source-state bit.
  • 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 proceeds by establishing an inductive invariant for walks from state p to state q: the first state component is non-decreasing along the walk, and the sequence of second components of arrival states is a shifted copy of the edge label sequence. For a closed walk (q = p), the monotonicity constraint forces the first component of every intermediate state to remain equal to p.1. Furthermore, the shift relation implies that the second components of all arrival states are uniquely determined by the edge labels. Since two closed walks spelling the same public word must agree on edge labels and on both state components at each step, they coincide.

  1. We define a projection onto the second bit of arrival states, formulate a general walk invariant, and verify the base case for an empty walk.

    We define `bit` to project a transition (b, r) to the second component of its target state, r.2. We formulate an invariant `props` for any walk from p to q with trace z: (1) p.1 ≤ q.1; (2) every transition a ∈ z has its arrival state's first coordinate bounded by p.1 ≤ a.2.1 ≤ q.1; and (3) prepending p.2 to the list of target state bits z.map bit equals the label word z.map Prod.fst appended with q.2. We proceed by induction on the walk. For the empty walk from p to p, the inequality p.1 ≤ p.1 holds by reflexivity, the universal quantification over intermediate transitions is vacuously true, and [p.2] = [] ++ [p.2] holds identically.

    lines 6–11

      let bit (a : Bool × (Bool × Bool)) := a.2.2
      have props {z q} (h : Op1385StateWalk op1385LatchLookaheadStep p z q) :
          p.1 ≤ q.1 ∧ (∀ a ∈ z, p.1 ≤ a.2.1 ∧ a.2.1 ≤ q.1) ∧
          p.2 :: z.map bit = z.map Prod.fst ++ [q.2] := by
        induction h with
        | root => simp
  2. In the inductive step, the first coordinate remains non-decreasing, and intermediate states remain bounded between p.1 and the new arrival state.

    Consider extending a walk z ending at q by a transition (b, r) satisfying `op1385LatchLookaheadStep q b r`. By definition, q.1 ≤ r.1 and b = q.2. By the induction hypothesis, p.1 ≤ q.1, so p.1 ≤ r.1 by transitivity. For any transition a ∈ z ++ [(b, r)], a belongs either to z or to the singleton [(b, r)]. In the former case, p.1 ≤ a.2.1 ≤ q.1 ≤ r.1 by the induction hypothesis and transitivity. In the latter case, a = (b, r), so a.2.1 = r.1, which satisfies p.1 ≤ r.1 and r.1 ≤ r.1 by reflexivity (`le_rfl`).

    lines 12–21

    uses List.mem_append.mp, List.mem_singleton.mp, le_rfl

        | @step z q h b r he ih =>
          obtain ⟨hlo,hr,hmap⟩ := ih
          obtain ⟨hinc,hb⟩ := he
          refine ⟨hlo.trans hinc,?_,?_⟩
          · intro a ha
            rcases List.mem_append.mp ha with ha | ha
            · exact ⟨(hr a ha).1,(hr a ha).2.trans hinc⟩
            · have h := List.mem_singleton.mp ha
              subst a
              exact ⟨hlo.trans hinc,le_rfl⟩
  3. The lookahead shift identity holds for the extended walk, completing the proof of the invariant `props`.

    Appending [r.2] to both sides of the induction hypothesis p.2 :: z.map bit = z.map Prod.fst ++ [q.2] via `congrArg` gives (p.2 :: z.map bit) ++ [r.2] = (z.map Prod.fst ++ [q.2]) ++ [r.2]. On the left-hand side, since bit (b, r) = r.2, this equals p.2 :: (z ++ [(b, r)]).map bit. On the right-hand side, by associativity of concatenation (`List.append_assoc`) and the step condition b = q.2, this simplifies to (z ++ [(b, r)]).map Prod.fst ++ [r.2].

    line 22

    uses List.append_assoc, congrArg

          · simpa [bit,List.append_assoc,hb] using congrArg (fun l => l ++ [r.2]) hmap
  4. The two closed walks produce identical sequences of second state components (`xs.map bit = ys.map bit`).

    Because both xs and ys are closed walks starting and ending at p, applying the shift identity from `props` gives p.2 :: xs.map bit = xs.map Prod.fst ++ [p.2] and p.2 :: ys.map bit = ys.map Prod.fst ++ [p.2]. Since the public words match (xs.map Prod.fst = ys.map Prod.fst), the right-hand sides are equal, implying p.2 :: xs.map bit = p.2 :: ys.map bit. Stripping the common head p.2 using injectivity of list construction (`List.cons.inj`) proves xs.map bit = ys.map bit.

    lines 23–25

    uses List.cons.inj

      have hbits : xs.map bit = ys.map bit := by
        exact (List.cons.inj (show p.2 :: xs.map bit = p.2 :: ys.map bit by
          rw [(props hx).2.2,(props hy).2.2,hword])).2
  5. The two walks have the same length, reducing their equality to pointwise agreement of transitions.

    By `List.ext_getElem`, two lists are identical if they have the same length and equal elements at every index. Applying `congrArg List.length` to the assumption xs.map Prod.fst = ys.map Prod.fst shows that xs and ys have equal length, because mapping preserves list length.

    lines 26–27

    uses List.ext_getElem, congrArg

      apply List.ext_getElem
      · simpa using congrArg List.length hword
  6. At every index i, the transitions xs[i] and ys[i] are identical, concluding that xs = ys.

    For any index i < |xs|: (1) Applying indexing to xs.map Prod.fst = ys.map Prod.fst via `congrArg` and `List.getElem?_eq_getElem` shows that the edge labels match: xs[i].1 = ys[i].1. (2) Applying indexing to xs.map bit = ys.map bit similarly shows that the second components of arrival states match: xs[i].2.2 = ys[i].2.2. (3) For the first components of the arrival states, since both walks end at p, the bounding invariant from `props` guarantees p.1 ≤ xs[i].2.1 ≤ p.1 and p.1 ≤ ys[i].2.1 ≤ p.1. By antisymmetry (`le_antisymm`), both xs[i].2.1 and ys[i].2.1 equal p.1, hence they are equal. Combining the equalities of all three components via `Prod.ext` proves xs[i] = ys[i].

    lines 28–35

    uses congrArg, List.getElem?_eq_getElem, List.getElem_mem, le_antisymm, Prod.ext

      · intro i hi hj
        have dirs := congrArg (fun l => l[i]?) hword
        have bits := congrArg (fun l => l[i]?) hbits
        have hd : xs[i].1 = ys[i].1 := by simpa [List.getElem?_eq_getElem,hi,hj] using dirs
        have hb : xs[i].2.2 = ys[i].2.2 := by simpa [List.getElem?_eq_getElem,hi,hj,bit] using bits
        have a := (props hx).2.1 _ (List.getElem_mem hi)
        have b := (props hy).2.1 _ (List.getElem_mem hj)
        exact Prod.ext hd (Prod.ext ((le_antisymm a.2 a.1).trans (le_antisymm b.2 b.1).symm) hb)
List.mem_append.mp
An element belongs to a concatenated list if and only if it belongs to the first list or the second list.
List.mem_singleton.mp
If an element belongs to a singleton list [x], then it equals x.
le_rfl
The preorder relation ≤ is reflexive (a ≤ a).
List.append_assoc
List concatenation is associative: (as ++ bs) ++ cs = as ++ (bs ++ cs).
congrArg
Functions respect equality: if a = b, then f(a) = f(b).
List.cons.inj
The cons constructor is injective: head₁ :: tail₁ = head₂ :: tail₂ implies head₁ = head₂ and tail₁ = tail₂.
List.ext_getElem
Two lists are equal if they have the same length and their elements agree at every index.
List.getElem?_eq_getElem
At any in-bounds index i < |l|, optional indexing l[i]? evaluates to some l[i].
List.getElem_mem
The element l[n] at an in-bounds index n < |l| is a member of the list l.
le_antisymm
The partial order relation ≤ is antisymmetric: a ≤ b and b ≤ a imply a = b.
Prod.ext
Two ordered pairs are equal if their first components are equal and their second components are equal.

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 prioritized_borel_latch_lookahead_cycles_unique    (p : Bool × Bool) (xs ys : List (Bool × (Bool × Bool)))    (hx : Op1385StateWalk op1385LatchLookaheadStep p xs p)    (hy : Op1385StateWalk op1385LatchLookaheadStep p ys p)    (hword : xs.map Prod.fst = ys.map Prod.fst) : xs = ys := by  let bit (a : Bool × (Bool × Bool)) := a.2.2  have props {z q} (h : Op1385StateWalk op1385LatchLookaheadStep p z q) :      p.1 ≤ q.1 ∧ (∀ a ∈ z, p.1 ≤ a.2.1 ∧ a.2.1 ≤ q.1) ∧      p.2 :: z.map bit = z.map Prod.fst ++ [q.2] := by    induction h with    | root => simp    | @step z q h b r he ih =>      obtain ⟨hlo,hr,hmap⟩ := ih      obtain ⟨hinc,hb⟩ := he      refine ⟨hlo.trans hinc,?_,?_⟩      · intro a ha        rcases List.mem_append.mp ha with ha | ha        · exact ⟨(hr a ha).1,(hr a ha).2.trans hinc⟩        · have h := List.mem_singleton.mp ha          subst a          exact ⟨hlo.trans hinc,le_rfl⟩      · simpa [bit,List.append_assoc,hb] using congrArg (fun l => l ++ [r.2]) hmap  have hbits : xs.map bit = ys.map bit := by    exact (List.cons.inj (show p.2 :: xs.map bit = p.2 :: ys.map bit by      rw [(props hx).2.2,(props hy).2.2,hword])).2  apply List.ext_getElem  · simpa using congrArg List.length hword  · intro i hi hj    have dirs := congrArg (fun l => l[i]?) hword    have bits := congrArg (fun l => l[i]?) hbits    have hd : xs[i].1 = ys[i].1 := by simpa [List.getElem?_eq_getElem,hi,hj] using dirs    have hb : xs[i].2.2 = ys[i].2.2 := by simpa [List.getElem?_eq_getElem,hi,hj,bit] using bits    have a := (props hx).2.1 _ (List.getElem_mem hi)    have b := (props hy).2.1 _ (List.getElem_mem hj)    exact Prod.ext hd (Prod.ext ((le_antisymm a.2 a.1).trans (le_antisymm b.2 b.1).symm) hb)
See it in the graphDiscuss this resultChallenge it