Input scanning and unsigned cost-matrix initialization for Word-RAM auction #
First-stage memory-client subroutines of Bertsekas's auction algorithm:
scanMaxProg: scans the signedn × ninput matrix atmatBasefor an entry magnitude boundM ≤ maxMag.fillCProg: reads each signed input entry and stores the shifted, scaled unsigned integer costws.scale * (cost (i, j) + M)in row-major order atws.bC.
All inner iteration step functions, state encodings (ScanState), and per-step realize
certificates remain private to this module.
Main definitions #
Cslib.Algorithms.WordRAM.Auction.ScanArgs,Cslib.Algorithms.WordRAM.Auction.encScanArgs: two-word scan descriptor(matBase, total).Cslib.Algorithms.WordRAM.Auction.scanMaxProg,Cslib.Algorithms.WordRAM.Auction.ScanMaxSafe: input-magnitude scan program and its safety predicate.Cslib.Algorithms.WordRAM.Auction.fillCProg,Cslib.Algorithms.WordRAM.Auction.FillCProgSafe: shifted-scaled matrix-fill program and its safety predicate.
Main results #
Cslib.Algorithms.WordRAM.Auction.scanMaxProg_realizes,Cslib.Algorithms.WordRAM.Auction.scanMaxProg_spec: Word-RAM realization and specification ofscanMaxProg.Cslib.Algorithms.WordRAM.Auction.fillCProg_realizes,Cslib.Algorithms.WordRAM.Auction.fillC_spec: Word-RAM realization and specification offillCProg.
The tuple word encoding of the fields of encScanArgs.
Registered WordEncoding for ScanArgs.
Scanning input costs for M ≤ maxMag #
Word-width safety predicate for scanMaxProg.
realize certificate for scanMaxProg.
Specification of scanMaxProg: preserves memory state, incurs cost ≤ n * n, and bounds
every entry's magnitude by the returned M ≤ maxM.
Filling the shifted, scaled unsigned cost matrix #
Populate the shifted, scaled unsigned cost matrix at ws.bC[0..n*n).
Word-width safety predicate for fillCProg.
realize certificate for fillCProg.
Specification of fillCProg: writes ws.scale * (cost (i, j) + ws.M).toNat row-major at
ws.bC in at most 2 * n * n memory steps without touching outside addresses.