Fast-Mode locState and Backyard-Pool Packed-Array Subroutines #
This module implements the parameter-free Memory.Prog subroutines and Realizes .exact
certificates for the 2-bit locState array and backyard free-pool arrays on FastMemRep:
readFastLocGenProg,writeFastLocGenProg: overflow-free 2-bit coordinate state accessors.readPoolFreeStackGenProg,writePoolFreeStackGenProg,writePoolOwnerGenProg: backyard pool free-stack and reverse-owner accessors.
Main definitions #
Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.readFastLocGenProg,writeFastLocGenProg,readPoolFreeStackGenProg,writePoolFreeStackGenProg,writePoolOwnerGenProg.
Main results #
Section 1: locState Accessors #
@[irreducible]
Read fs.locState b loc (d = (((cp, base), b), loc)).
theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.realizes_readFastLocGen :
WordRAM.Realization.Realizes WordRAM.Basis.exact readFastLocGenProg WordRAM.Realization.WordEncoding.encode
WordRAM.Realization.WordEncoding.encode
(fun (w : ℕ) (x : ((WhpCoreParams × ℕ) × ℕ) × ℕ) (x_1 : Memory.State) =>
match x with
| (((cp, base), b), loc) => WhpLargeEnvGen w cp base ∧ b < wpM cp ∧ loc < wpTotalLoc cp)
fun (x : ((WhpCoreParams × ℕ) × ℕ) × ℕ) (x_1 : Memory.State) => 0
theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.readFastLocGenProg_spec {c U V w n_max base b loc : ℕ} {fs : SuccinctWhp.FastState} {s : Memory.State} (henv : WhpLargeEnv c U V w n_max w base) (hb : b < SuccinctWhp.numBucketsWhp n_max) (hloc : loc < SuccinctWhp.totalLocalCoordsWhp n_max) (hrep : FastMemRep base c U V w n_max fs s.mem) :
have prog := readFastLocGenProg (((mkWhpCoreParams c U V w n_max, base), b), loc);
(Memory.spec 0).clientState s prog = s ∧ (Memory.spec 0).clientResult s prog = fs.locState b loc ∧ WordRAM.Realization.memoryCost prog s = 2 ∧ Succinct.ValidProg w (base + SuccinctWhp.largeSpaceWhp c U V w n_max) s prog
@[irreducible]
Write fs.locState b loc := tag (tag < 4, d = ((((cp, base), b), loc), tag)).
theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.realizes_writeFastLocGen :
WordRAM.Realization.Realizes WordRAM.Basis.exact writeFastLocGenProg WordRAM.Realization.WordEncoding.encode
WordRAM.Realization.WordEncoding.encode
(fun (w : ℕ) (x : (((WhpCoreParams × ℕ) × ℕ) × ℕ) × ℕ) (x_1 : Memory.State) =>
match x with
| ((((cp, base), b), loc), snd) => WhpLargeEnvGen w cp base ∧ b < wpM cp ∧ loc < wpTotalLoc cp)
fun (x : (((WhpCoreParams × ℕ) × ℕ) × ℕ) × ℕ) (x_1 : Memory.State) => 0
theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.writeFastLocGenProg_fastStep {c U V w n_max base b loc tag : ℕ} {θ : SuccinctWhp.SeedWhp c U n_max} {fs : SuccinctWhp.FastState} {s : Memory.State} (henv : WhpLargeEnv c U V w n_max w base) (hb : b < SuccinctWhp.numBucketsWhp n_max) (hloc : loc < SuccinctWhp.totalLocalCoordsWhp n_max) (htag : tag < 4) (hseed : SeedWhpMemRep base c U w n_max θ s.mem) (hrep : FastMemRep base c U V w n_max fs s.mem) :
have prog := writeFastLocGenProg ((((mkWhpCoreParams c U V w n_max, base), b), loc), tag);
have s' := (Memory.spec 0).clientState s prog;
WordRAM.Realization.memoryCost prog s = 4 ∧ Succinct.ValidProg w (base + SuccinctWhp.largeSpaceWhp c U V w n_max) s prog ∧ FastStateStep base c U V w n_max θ
{ quotArr := fs.quotArr, valArr := fs.valArr,
locState := Function.update fs.locState b (Function.update (fs.locState b) loc tag), bktCount := fs.bktCount,
bktSalt := fs.bktSalt, liveRole := fs.liveRole, liveInsCount := fs.liveInsCount,
overmarsRole := fs.overmarsRole, overmarsActive := fs.overmarsActive, overmarsCursor := fs.overmarsCursor,
overmarsInsCount := fs.overmarsInsCount, rebDoneFlag := fs.rebDoneFlag, rebQueued := fs.rebQueued,
backPtr := fs.backPtr, poolFreeTop := fs.poolFreeTop, poolFreeStack := fs.poolFreeStack,
poolOwner := fs.poolOwner, slices := fs.slices, buf := fs.buf, curEp := fs.curEp, epochClock := fs.epochClock,
rebStage := fs.rebStage, stageCursor := fs.stageCursor, dirtyCount := fs.dirtyCount,
dirtyBuckets := fs.dirtyBuckets, dirtyIdx := fs.dirtyIdx, rebCandSalt := fs.rebCandSalt,
rebScanCursor := fs.rebScanCursor, rebInsCount := fs.rebInsCount, rebCollision := fs.rebCollision }
s s'
Section 2: poolFreeStack and poolOwner Accessors #
@[irreducible]
Read fs.poolFreeStack j (j < poolSizeWhp n_max, d = ((cp, base), j)).
theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.realizes_readPoolFreeStackGen :
WordRAM.Realization.Realizes WordRAM.Basis.exact readPoolFreeStackGenProg WordRAM.Realization.WordEncoding.encode
WordRAM.Realization.WordEncoding.encode
(fun (w : ℕ) (x : (WhpCoreParams × ℕ) × ℕ) (x_1 : Memory.State) =>
match x with
| ((cp, base), j) => WhpLargeEnvGen w cp base ∧ j < wpPoolSize cp)
fun (x : (WhpCoreParams × ℕ) × ℕ) (x_1 : Memory.State) => 0
theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.readPoolFreeStackGenProg_spec {c U V w n_max base j : ℕ} {fs : SuccinctWhp.FastState} {s : Memory.State} (henv : WhpLargeEnv c U V w n_max w base) (hj : j < SuccinctWhp.poolSizeWhp n_max) (hrep : FastMemRep base c U V w n_max fs s.mem) :
have prog := readPoolFreeStackGenProg ((mkWhpCoreParams c U V w n_max, base), j);
(Memory.spec 0).clientState s prog = s ∧ (Memory.spec 0).clientResult s prog = fs.poolFreeStack j ∧ WordRAM.Realization.memoryCost prog s = 2 ∧ Succinct.ValidProg w (base + SuccinctWhp.largeSpaceWhp c U V w n_max) s prog
@[irreducible]
Write fs.poolFreeStack j := pSlot
(j < poolSizeWhp n_max, d = (((cp, base), j), pSlot)).
theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.realizes_writePoolFreeStackGen :
WordRAM.Realization.Realizes WordRAM.Basis.exact writePoolFreeStackGenProg WordRAM.Realization.WordEncoding.encode
WordRAM.Realization.WordEncoding.encode
(fun (w : ℕ) (x : ((WhpCoreParams × ℕ) × ℕ) × ℕ) (x_1 : Memory.State) =>
match x with
| (((cp, base), j), snd) => WhpLargeEnvGen w cp base ∧ j < wpPoolSize cp)
fun (x : ((WhpCoreParams × ℕ) × ℕ) × ℕ) (x_1 : Memory.State) => 0
theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.writePoolFreeStackGenProg_fastStep {c U V w n_max base j pSlot : ℕ} {θ : SuccinctWhp.SeedWhp c U n_max} {fs : SuccinctWhp.FastState} {s : Memory.State} (henv : WhpLargeEnv c U V w n_max w base) (hj : j < SuccinctWhp.poolSizeWhp n_max) (hp_le : pSlot ≤ n_max) (hseed : SeedWhpMemRep base c U w n_max θ s.mem) (hrep : FastMemRep base c U V w n_max fs s.mem) :
have prog := writePoolFreeStackGenProg (((mkWhpCoreParams c U V w n_max, base), j), pSlot);
have s' := (Memory.spec 0).clientState s prog;
WordRAM.Realization.memoryCost prog s = 4 ∧ Succinct.ValidProg w (base + SuccinctWhp.largeSpaceWhp c U V w n_max) s prog ∧ FastStateStep base c U V w n_max θ
{ quotArr := fs.quotArr, valArr := fs.valArr, locState := fs.locState, bktCount := fs.bktCount,
bktSalt := fs.bktSalt, liveRole := fs.liveRole, liveInsCount := fs.liveInsCount,
overmarsRole := fs.overmarsRole, overmarsActive := fs.overmarsActive, overmarsCursor := fs.overmarsCursor,
overmarsInsCount := fs.overmarsInsCount, rebDoneFlag := fs.rebDoneFlag, rebQueued := fs.rebQueued,
backPtr := fs.backPtr, poolFreeTop := fs.poolFreeTop, poolFreeStack := Function.update fs.poolFreeStack j pSlot,
poolOwner := fs.poolOwner, slices := fs.slices, buf := fs.buf, curEp := fs.curEp, epochClock := fs.epochClock,
rebStage := fs.rebStage, stageCursor := fs.stageCursor, dirtyCount := fs.dirtyCount,
dirtyBuckets := fs.dirtyBuckets, dirtyIdx := fs.dirtyIdx, rebCandSalt := fs.rebCandSalt,
rebScanCursor := fs.rebScanCursor, rebInsCount := fs.rebInsCount, rebCollision := fs.rebCollision }
s s'
@[irreducible]
Write fs.poolOwner j := enc (j < poolSizeWhp n_max, d = (((cp, base), j), enc)).
theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.realizes_writePoolOwnerGen :
WordRAM.Realization.Realizes WordRAM.Basis.exact writePoolOwnerGenProg WordRAM.Realization.WordEncoding.encode
WordRAM.Realization.WordEncoding.encode
(fun (w : ℕ) (x : ((WhpCoreParams × ℕ) × ℕ) × ℕ) (x_1 : Memory.State) =>
match x with
| (((cp, base), j), snd) => WhpLargeEnvGen w cp base ∧ j < wpPoolSize cp)
fun (x : ((WhpCoreParams × ℕ) × ℕ) × ℕ) (x_1 : Memory.State) => 0
theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.writePoolOwnerGenProg_fastStep {c U V w n_max base j enc : ℕ} {θ : SuccinctWhp.SeedWhp c U n_max} {fs : SuccinctWhp.FastState} {s : Memory.State} (henv : WhpLargeEnv c U V w n_max w base) (hj : j < SuccinctWhp.poolSizeWhp n_max) (henc_le : enc ≤ n_max) (hseed : SeedWhpMemRep base c U w n_max θ s.mem) (hrep : FastMemRep base c U V w n_max fs s.mem) :
have prog := writePoolOwnerGenProg (((mkWhpCoreParams c U V w n_max, base), j), enc);
have s' := (Memory.spec 0).clientState s prog;
WordRAM.Realization.memoryCost prog s = 4 ∧ Succinct.ValidProg w (base + SuccinctWhp.largeSpaceWhp c U V w n_max) s prog ∧ FastStateStep base c U V w n_max θ
{ quotArr := fs.quotArr, valArr := fs.valArr, locState := fs.locState, bktCount := fs.bktCount,
bktSalt := fs.bktSalt, liveRole := fs.liveRole, liveInsCount := fs.liveInsCount,
overmarsRole := fs.overmarsRole, overmarsActive := fs.overmarsActive, overmarsCursor := fs.overmarsCursor,
overmarsInsCount := fs.overmarsInsCount, rebDoneFlag := fs.rebDoneFlag, rebQueued := fs.rebQueued,
backPtr := fs.backPtr, poolFreeTop := fs.poolFreeTop, poolFreeStack := fs.poolFreeStack,
poolOwner := Function.update fs.poolOwner j enc, slices := fs.slices, buf := fs.buf, curEp := fs.curEp,
epochClock := fs.epochClock, rebStage := fs.rebStage, stageCursor := fs.stageCursor,
dirtyCount := fs.dirtyCount, dirtyBuckets := fs.dirtyBuckets, dirtyIdx := fs.dirtyIdx,
rebCandSalt := fs.rebCandSalt, rebScanCursor := fs.rebScanCursor, rebInsCount := fs.rebInsCount,
rebCollision := fs.rebCollision }
s s'