Recording the candidate after a block
ProvedDirKECC1549.Asm.fopAfter_specAfter a block, fopAfter either reports that the stack emptied, or that the excluded vertex is on top (storing the current stack path in the first slot), or stores the candidate path (the stack prefix of least height in the block) in the next slot, within height ticks.
Context. This lemma belongs to the machine-checked word-RAM implementation of Lemma 1 (p.11): Algorithm 1 refining by small -out sets, with the deterministic local search of [GKK+26, Proposition 6] (FindOutPaths and recursive path reversals). The program is written in the structured language Stmt compiled to the published word-RAM; Run E s mem Q states that the statement s, started on mem, reaches its end in a state satisfying Q t mem' within t ticks. The input cells double as registers; they are saved at SV and read through the image ImgAt. All definitions are in the Definitions.Def_DirKECC1549_Impl_* modules.
import Definitions.Def_DirKECC1549_Impl_L1Fop1
set_option autoImplicit false
open WordRAM Classical Finset
open DirKECC1549.Main DirKECC1549.Main.CostAux
open DirKECC1549 DirKECC1549.Asm
variable {w : Width} {n m : ℕ}theorem DirKECC1549.Asm.fopAfter_spec (E : Env) (mm orig : Memory w) (hm : 0 < m) (P : LP) (B : Fin m → Fin n × Fin n)
(perm : Equiv.Perm (Fin m)) (F : Finset (Fin m)) (v s : Fin n) (st : DS n m)
(hC : LsC P orig mm B perm F) (hD : DRep hm P B perm F 1 v st mm)
(hI : DInv (flipEdges B F) (adjOf B perm F (inL hm (fun x => its B x) P.CF P.IN mm)) v st)
(SA nx NC SW mH : ℕ) (h30 : (mm (P.SV + 30)).toNat = s) (h32 : (mm (P.SV + 32)).toNat = mH)
(h37 : (mm (P.SV + 37)).toNat = SW) (h39 : (mm (P.SV + 39)).toNat = SA) (h40 : (mm (P.SV + 40)).toNat = NC)
(h41 : (mm (P.SV + 41)).toNat = nx) (hmH : st.stk ≠ [] → 1 ≤ mH ∧ mH ≤ st.stk.length)
(hSA : P.IP + m ≤ SA) (hnx : P.IP + m ≤ nx) (hw : SA + nx + SW + NC + n + 10 < 2 ^ w.bits) :
Run E fopAfter mm (fun t mm' => t ≤ 9 * st.stk.length + 60 ∧ DRep hm P B perm F 1 v st mm' ∧
((st.stk = [] ∧ (mm' (P.SV + 34)).toNat = 1 ∧ ∀ a, FaReg a → a ≠ P.SV + 34 → mm' a = mm a) ∨
(st.stk ≠ [] ∧ st.stk.getLast? = some s ∧ (mm' (P.SV + 34)).toNat = 1 ∧ (mm' (P.SV + 40)).toNat = 1 ∧
SlotEnc mm' SA (candP st st.stk.length) ∧
∀ a, FaReg a → a ≠ P.SV + 34 → a ≠ P.SV + 40 → (a < SA ∨ SA + n ≤ a) → mm' a = mm a) ∨
(st.stk ≠ [] ∧ st.stk.getLast? ≠ some s ∧ (mm' (P.SV + 40)).toNat = NC + 1 ∧
(mm' (P.SV + 41)).toNat = nx + SW ∧ SlotEnc mm' nx (candP st mH) ∧
∀ a, FaReg a → a ≠ P.SV + 40 → a ≠ P.SV + 41 → (a < nx ∨ nx + n ≤ a) → mm' a = mm a))) := by sorry