Closing a short group publishes its parent and reopens the row
ProvedExactPatternStream.ImplementationProof.sweep_short_close_publishLet and have lengths with , over an alphabet of size . Fix the hierarchy seed and a word width , where is the integer logarithmic length used by the implementation. Choose an emitted group of either parse at a nonfinal level. Assume its key fits the short width, its packed row and registers represent the state just before its last child, and the shadow register bank and row satisfy their separation and address bounds. If is the actual parent, the close-and-restart block reaches its exit with
The same row then contains an empty short-key accumulator, a fresh counter stack and a reset group annotation, with the retained seed and controls. Input, output and coin position are preserved. Heap bits outside the row and intermediate writes obey the bounds of the contract.
import Definitions.Def_ExactPatternStream_StreamingImplementation open ExactPatternStream open ExactPatternStream.ImplementationProof open CounterProof DynBrooks MachineProof SoundProof PackedRAM CompletenessProof HashProof GroupReader
theorem ExactPatternStream.ImplementationProof.sweep_short_close_publish {σ w exponent : ℕ} (P T : List (Fin σ)) (seed : Seeds σ P.length)
(hm : 1≤ P.length) (hmn : P.length≤ T.length) (short : T.length≤2*P.length)
(hn : 3≤ T.length) (alphabet : σ≤ T.length^exponent) (word : 2*(64*(exponent+1)+33)*ell T.length≤ w)
(j : ℕ) (live : j< topIndex (seededBuild P T seed))
(pre post : Program) (tape : ℕ→BitVec w) (base start shadow : ℕ) (low : 48≤ shadow) (roomShadow : shadow+37≤ base) :
let ps := pre++(copyBank 0 shadow 37).map Assignment.instr
let preChild := ps++readShortBank++[.bor 46 36 36]
let preClose := preChild++shortRecordCallCode preChild.length
let prePad := preClose++guardedPaddingCode preClose.length
let preReturn := prePad++hashGuardedAlphaCode
let ret:=preReturn.length+(trainedGroupReturnCode preReturn.length 0 44).length
let pe:=preReturn++trainedGroupReturnCode preReturn.length ret 44
let Q:=pe++sweepRestartCode shadow++post
let L := lvl (seededBuild P T seed) j
let D := lvl (seededBuild P T seed) (j+1)
let n := T.length
let m := P.length
let k := kCnt σ m
let bits := levelBits σ m L.i
let h := countHashBits σ m L.i L.c
let g := L.c+2
let dt := Nat.clog 2 g
let width := slotBits k n
let u := packedLabelWord w σ m L.i L.u
let v := packedLabelWord w σ m L.i L.v
∀ (S : List ParseTree) (A : List Bool) (parents : List ParseTree),
(S=L.P ∧ A=L.AP ∧ parents=D.P) ∨ (S=L.T ∧ A=L.AT ∧ parents=D.T) →
∀ idx, (hit : idx< parents.length) →
let G := counterChildLabels L S A idx
let key := keyOf σ m L.i G
let x := G.getD (L.c+1) default
let q := (G.take (L.c+1)).foldl (alphaRead L.i L.u L.v) none
let vals := payloadCounterInputs σ m L S A idx
let realStack := (vals.take (g-1)).foldl (slotsRead k n) (emptySlotStack k n dt)
let oldSlots := realStack.1++[realStack.2]
let padded := vals++List.replicate (2^dt-vals.length) (0,0)
let stack := padded.foldl (slotsRead k n) (emptySlotStack k n dt)
let slots := stack.1++[stack.2]
∀ (rs rh : Fin h→Bool) (tr : Fin g×Bool) (r t : Fin g) (done spare : Bool),
let oldKey := keyOf σ m L.i (G.take (g-1))
let stored := shortBankImage rh (g*bits) (BitVec.ofBoolListBE oldKey).toNat
let recordHead := counterRecordPrefix h bits L.c rs stored (fun z=> u.toNat.testBit z.val) (fun z=> v.toNat.testBit z.val) tr r t
let bank := start+recordHead.length
let foot := bank+(dt+1)*width
let oldHead := recordHead++counterFields width oldSlots
let head := recordHead++counterFields width slots
let next := alphaRead L.i L.u L.v q x
g*bits≤ hashB σ m → ∀ a : Config w, a.pc=pre.length →
PadParameters w k base bank width dt a →
foot<2^w → base+foot/w+1<2^w →
HeaderImage a base start (oldHead++List.ofFn (counterAlphaFlags q done spare)) →
a.mem 1=BitVec.ofNat w start → a.mem 34=BitVec.ofNat w (340*hashB σ m) →
a.mem 35=BitVec.ofNat w (if L.i=0 then bigL σ m else 0) → (a.mem 36).toNat=bits →
a.mem 37=packedLabelWord w σ m L.i x → (a.mem 39).toNat=σ → (a.mem 40).toNat=L.i →
(a.mem 33).toNat=g → (a.mem 38).toNat=expBits σ m →
let fresh:=emptySlotStack k n dt
let newHead:=counterRecordPrefix h bits L.c rs (shortBankImage rh (g*bits) 0)
(fun z=> u.toNat.testBit z.val) (fun z=> v.toNat.testBit z.val) tr r t
let root:=bank+dt*width
let cells:=Finset.Ico shadow (shadow+37)∪(stackSpan w base bank root∪(putFieldCells base foot w∪
(putFieldCells base (start+h) w∪(putFieldCells base root w∪Finset.range 48))))
∃ tm,let d:=run Q tape a tm
d.pc=pe.length+115 ∧ d.mem 37=packedLabelWord w σ m (j+1) parents[idx].label ∧
d.mem 22=1 ∧ d.mem 44=MachineProof.bitWord w (alphaOf parents[idx].label) ∧
HeaderImage d base start (newHead++counterFields width (fresh.1++[fresh.2])++List.ofFn (counterAlphaFlags none done spare)) ∧
(∀ z,z< start ∨ foot+5≤ z → readBit d.mem base z=readBit a.mem base z) ∧
d.input=a.input ∧ d.output=a.output ∧ d.coinPos=a.coinPos ∧
(∀ z,48≤ z → z< base → (z< shadow ∨ shadow+37≤ z) → d.mem z=a.mem z) ∧
∀ s≤ tm,(run Q tape a s).written⊆a.written∪cells := by sorry