AFTD Auto-Formalizing Theoretical Domains

prioritized_borel_state_predictor_trace_tracker

theoremverified

A predictor of the next state yields an encoded-node memory component that stays unchanged on every correct prediction and is reset on an error.

Statement

theorem prioritized_borel_state_predictor_trace_tracker {Q : Type} [Fintype Q]
    (G : PrioritizedBorelGame Q 3) (P : List Bool → Q → Bool → Q) :
    ∃ (I : Type) (start : I) (view : I → List Bool → Q → Option (List Bool))
      (advance : I → TreeGameEdge Q 3 → I),
      view start [] G.init_state = some [] ∧
      (∀ i (e : TreeGameEdge Q 3) w, e ∈ G.edges → view i e.source_node e.source_state = some w →
        view (advance i e) (e.source_node ++ [e.dir]) e.target_state = some (w ++ enc1385Block e)) ∧
      (∀ i (e : TreeGameEdge Q 3), e.target_state = P e.source_node e.source_state e.dir → advance i e = i)
Source
arXiv:2611.10136, Conjecture 19 and Proposition 27. Strategy compression for OP-1385.
Verified
28 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 3
  • enc1385GameGiven a finite-state three-priority tree game, construct a phase-state game that encodes each original direction followed by a one-hot…
  • TreeGameEdgeA structure TreeGameEdge (Q : Type*) (k : ℕ) representing an edge in a binary tree game arena with state space Q and k priorities, with…
  • PrioritizedBorelGameA structure PrioritizedBorelGame (Q : Type*) (k : ℕ) representing a prioritized Borel game with state space Q and k priorities, with…
Used by 1

The proof, explained

The proof first establishes an auxiliary lemma showing that folding the prediction step along a list of direction bits appends those bits to the tree node component of the state. It then constructs a trace-tracking memory component whose states store an anchor node, state, and accumulated block encoding. Between prediction errors, the memory state remains unchanged, and the trace decoder simulates the path forward using the deterministic predictor; when an error occurs, the memory state is reset to anchor at the current transition with the trace updated. Invariance along game edges splits into showing that a correct prediction extends the simulation by one step, while an error restarts the anchor at the new position.

  1. Folding the predictor step over a list of directions appends that list to the anchor node component.

    By induction on the list of directions ds, generalizing over the anchor triple z. The base case of an empty list holds immediately. For the inductive step b :: ds, the fold consumes b via List.foldl_cons to update the anchor node to z.1 ++ [b], and applying the induction hypothesis with List.append_assoc rearranges (z.1 ++ [b]) ++ ds to z.1 ++ (b :: ds).

    lines 12–14

    uses List.foldl_cons, List.append_assoc

      induction ds generalizing z with
      | nil => simp
      | cons b ds ih => simp [List.foldl_cons,ih,op1385PredictionStep,List.append_assoc]
  2. The memory type I, simulator scan, decoder view, update function advance, and initial anchor start are defined, satisfying view start [] G.init_state = some [].

    We define the memory state as a triple z = (v, q, w) recording an anchor node, state, and accumulated trace. The function `scan` folds the deterministic predictor step over the remaining path from the anchor node to the target node, while `view` verifies that the simulated node and state match the target, returning the accumulated encoding. A helper lemma `seed` verifies that view on any anchor (v, q, w) immediately yields some w. The update function `advance` leaves z unchanged if the predictor correctly predicted the edge's target state, and otherwise resets the anchor to the new node and state while appending the edge block encoding. We instantiate the existential quantifier with these components.

    lines 24–34

      classical
      let I := List Bool × Q × List Bool
      let scan (z : I) (v : List Bool) := (v.drop z.1.length).foldl (op1385PredictionStep P) z
      let view (z : I) (v : List Bool) (q : Q) : Option (List Bool) :=
        if (scan z v).1 = v ∧ (scan z v).2.1 = q then some (scan z v).2.2 else none
      have seed (v : List Bool) (q : Q) (w : List Bool) : view (v,q,w) v q = some w := by
        simp [view,scan]
      let advance (z : I) (e : TreeGameEdge Q 3) : I :=
        if e.target_state = P e.source_node e.source_state e.dir then z else
          (e.source_node ++ [e.dir], e.target_state, (view z e.source_node e.source_state).getD [] ++ enc1385Block e)
      refine ⟨I,([],G.init_state,[]),view,advance,seed _ _ _,?_,?_⟩
  3. When the predictor correctly predicts the target state of an edge e, advance z e leaves z unchanged.

    Assume e ∈ G.edges and view z e.source_node e.source_state = some w. We case-split on whether the edge target state matches the predictor P. When it matches, advance z e reduces to z by definition, so the goal is to evaluate view z on the extended node and target state.

    lines 35–37

      · intro z e w _ hw
        by_cases ht : e.target_state = P e.source_node e.source_state e.dir
        · rw [show advance z e = z by simp [advance,ht]]
  4. The simulation from the anchor z successfully reached e.source_node in state e.source_state with accumulated trace w.

    Since view z e.source_node e.source_state = some w is not none, the condition in the definition of view must be true: the first component of scan z e.source_node is e.source_node and the second is e.source_state. Evaluating view with this satisfied condition simplifies to the equality that the third component of scan is w.

    lines 38–41

    uses if_pos, Option.some.injEq

          have hc : (scan z e.source_node).1 = e.source_node ∧ (scan z e.source_node).2.1 = e.source_state := by
            by_contra hn
            simp [view,hn] at hw
          have hval : (scan z e.source_node).2.2 = w := by simpa only [view,if_pos hc,Option.some.injEq] using hw
  5. The anchor node z.1 has length at most the length of e.source_node. automation

    By op1385_prediction_fold_node, folding the prediction step over the remainder of e.source_node appends that remainder to z.1. Equating this to e.source_node and taking lengths shows that length(e.source_node) = length(z.1) + length(remainder), from which linear arithmetic over ℕ concludes length(z.1) ≤ length(e.source_node).

    lines 42–48

    uses op1385_prediction_fold_node, congrArg, List.length, List.length_append

          have hle : z.1.length ≤ e.source_node.length := by
            have eqn := op1385_prediction_fold_node P z (e.source_node.drop z.1.length)
            change (scan z e.source_node).1 = _ at eqn
            rw [hc.1] at eqn
            have hlen := congrArg List.length eqn
            simp only [List.length_append] at hlen
            omega
  6. When the prediction is correct, view z on the extended node and target state yields some (w ++ enc1385Block e).

    Because z.1 is no longer than e.source_node, dropping z.1.length from e.source_node ++ [e.dir] decomposes as the drop from e.source_node followed by [e.dir]. Folding across this concatenation applies one additional prediction step op1385PredictionStep to scan z e.source_node. Since the prediction matches e.target_state, this step updates the state to e.target_state and appends enc1385Block e to the accumulated trace w, matching the requirements of view.

    lines 49–51

    uses List.drop_append_of_le_length, List.foldl_append, enc1385Block

          have hs : scan z (e.source_node ++ [e.dir]) = op1385PredictionStep P (scan z e.source_node) e.dir := by
            simp [scan,List.drop_append_of_le_length hle,List.foldl_append]
          simp [view,hs,op1385PredictionStep,hc.1,hc.2,hval,← ht,enc1385Block]
  7. When the prediction is incorrect, view (advance z e) yields some (w ++ enc1385Block e).

    On a prediction error, advance resets the memory state to an anchor at e.source_node ++ [e.dir] with state e.target_state and accumulated trace w ++ enc1385Block e. Evaluating view at this new anchor on the same node and state immediately produces some (w ++ enc1385Block e) by the seed lemma.

    line 52

        · simp [advance,ht,hw,seed]
  8. advance leaves any memory state unchanged whenever the predictor correctly guesses the transition.

    This follows directly by expanding the definition of advance, which tests whether e.target_state = P e.source_node e.source_state e.dir and returns the unchanged state z in the affirmative branch.

    lines 53–54

      · intro z e ht
        simp [advance,ht]
List.foldl_cons
Folding over a list `a :: l` equals folding over `l` starting from the updated accumulator `f b a`.
List.append_assoc
List concatenation is associative.
if_pos
If the condition of an if-then-else expression holds, the expression evaluates to its then-branch.
Option.some.injEq
Equality between two `some` values is equivalent to equality of their contents.
op1385_prediction_fold_node
Folding the prediction step over a sequence of edge directions appends those directions to the anchor's tree node component.
congrArg
Applying a function to both sides of an equality yields an equality of the results.
List.length
The number of elements in a list.
List.length_append
The length of the concatenation of two lists is the sum of their individual lengths.
List.drop_append_of_le_length
Dropping k elements from a concatenation l₁ ++ l₂ distributes to dropping from l₁ when k ≤ length(l₁).
List.foldl_append
Folding a function over the concatenation of two lists equals folding over the first and then folding over the second starting from the result.
enc1385Block
The encoding of a game edge as a list of booleans, consisting of its direction bit followed by the encoding of its target state.

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

set_option maxHeartbeats 900000private noncomputable def op1385PredictionStep {Q : Type} [Fintype Q]    (P : List Bool → Q → Bool → Q) (z : List Bool × Q × List Bool) (b : Bool) :    List Bool × Q × List Bool :=  let q := P z.1 z.2.1 b  (z.1 ++ [b],q,z.2.2 ++ (b :: enc1385StateCode q))private theorem op1385_prediction_fold_node {Q : Type} [Fintype Q]    (P : List Bool → Q → Bool → Q) (z : List Bool × Q × List Bool) (ds : List Bool) :    (ds.foldl (op1385PredictionStep P) z).1 = z.1 ++ ds := by  induction ds generalizing z with  | nil => simp  | cons b ds ih => simp [List.foldl_cons,ih,op1385PredictionStep,List.append_assoc]theorem prioritized_borel_state_predictor_trace_tracker {Q : Type} [Fintype Q]    (G : PrioritizedBorelGame Q 3) (P : List Bool → Q → Bool → Q) :    ∃ (I : Type) (start : I) (view : I → List Bool → Q → Option (List Bool))      (advance : I → TreeGameEdge Q 3 → I),      view start [] G.init_state = some [] ∧      (∀ i (e : TreeGameEdge Q 3) w, e ∈ G.edges → view i e.source_node e.source_state = some w →        view (advance i e) (e.source_node ++ [e.dir]) e.target_state = some (w ++ enc1385Block e)) ∧      (∀ i (e : TreeGameEdge Q 3), e.target_state = P e.source_node e.source_state e.dir → advance i e = i) := by  classical  let I := List Bool × Q × List Bool  let scan (z : I) (v : List Bool) := (v.drop z.1.length).foldl (op1385PredictionStep P) z  let view (z : I) (v : List Bool) (q : Q) : Option (List Bool) :=    if (scan z v).1 = v ∧ (scan z v).2.1 = q then some (scan z v).2.2 else none  have seed (v : List Bool) (q : Q) (w : List Bool) : view (v,q,w) v q = some w := by    simp [view,scan]  let advance (z : I) (e : TreeGameEdge Q 3) : I :=    if e.target_state = P e.source_node e.source_state e.dir then z else      (e.source_node ++ [e.dir], e.target_state, (view z e.source_node e.source_state).getD [] ++ enc1385Block e)  refine ⟨I,([],G.init_state,[]),view,advance,seed _ _ _,?_,?_⟩  · intro z e w _ hw    by_cases ht : e.target_state = P e.source_node e.source_state e.dir    · rw [show advance z e = z by simp [advance,ht]]      have hc : (scan z e.source_node).1 = e.source_node ∧ (scan z e.source_node).2.1 = e.source_state := by        by_contra hn        simp [view,hn] at hw      have hval : (scan z e.source_node).2.2 = w := by simpa only [view,if_pos hc,Option.some.injEq] using hw      have hle : z.1.length ≤ e.source_node.length := by        have eqn := op1385_prediction_fold_node P z (e.source_node.drop z.1.length)        change (scan z e.source_node).1 = _ at eqn        rw [hc.1] at eqn        have hlen := congrArg List.length eqn        simp only [List.length_append] at hlen        omega      have hs : scan z (e.source_node ++ [e.dir]) = op1385PredictionStep P (scan z e.source_node) e.dir := by        simp [scan,List.drop_append_of_le_length hle,List.foldl_append]      simp [view,hs,op1385PredictionStep,hc.1,hc.2,hval,← ht,enc1385Block]    · simp [advance,ht,hw,seed]  · intro z e ht    simp [advance,ht]
See it in the graphDiscuss this resultChallenge it