Documentation

CslibFrontier.Algorithms.WordRAM.Auction.ScanFill

Input scanning and unsigned cost-matrix initialization for Word-RAM auction #

First-stage memory-client subroutines of Bertsekas's auction algorithm:

All inner iteration step functions, state encodings (ScanState), and per-step realize certificates remain private to this module.

Main definitions #

Main results #

Arguments for scanning a contiguous total-word signed matrix starting at matBase.

  • matBase : ℕ

    Start address of the encoded signed matrix words.

  • total : ℕ

    Number of entries to scan (n * n).

Instances For
    @[reducible, inline]

    The tuple word encoding of the fields of encScanArgs.

    theorem Cslib.Algorithms.WordRAM.Auction.encScanArgs_fits {w : ℕ} {a : ScanArgs} (h_matBase : WordRAM.Fits w a.matBase) (h_total : WordRAM.Fits w a.total) (j✝ : Fin 2) :

    Scanning input costs for M ≤ maxMag #

    Scan d.total Signed.encode words from d.matBase, returning max |cost|.

    theorem Cslib.Algorithms.WordRAM.Auction.scanMaxProg_spec {w n matBase maxM : ℕ} {cost : Fin n × Fin n → ℤ} {s₀ : DataStructure.Memory.State} (hcost_mem : ∀ (i j : Fin n), s₀.mem (matBase + (↑i * n + ↑j)) = WordRAM.Signed.encode (cost (i, j))) (hmag : ∀ (i j : Fin n), (cost (i, j)).natAbs ≤ maxM) (hfr : matBase + n * n ≤ s₀.frontier) (hfit2 : WordRAM.Fits w 2) (hfit_end : WordRAM.Fits w (matBase + n * n)) :
    have d := { matBase := matBase, total := n * n }; have M := (DataStructure.Memory.spec 0).clientResult s₀ (scanMaxProg d); ScanMaxSafe w d s₀ ∧ (DataStructure.Memory.spec w).ValidHistory s₀ ((DataStructure.Memory.spec w).clientHistory s₀ (scanMaxProg d)) ∧ WordRAM.Realization.memoryCost (scanMaxProg d) s₀ ≤ n * n ∧ (DataStructure.Memory.spec 0).clientState s₀ (scanMaxProg d) = s₀ ∧ M ≤ maxM ∧ ∀ (i j : Fin n), (cost (i, j)).natAbs ≤ M

    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).

    theorem Cslib.Algorithms.WordRAM.Auction.fillC_spec {w : ℕ} (ws : AuctionWS) {cost : Fin ws.n × Fin ws.n → ℤ} (s₀ : DataStructure.Memory.State) (hsc : 1 ≤ ws.scale) (hdisj : ws.matBase + ws.n * ws.n ≤ ws.bC) (hfr : ws.bC + ws.n * ws.n ≤ s₀.frontier) (hcost_mem : ∀ (i j : Fin ws.n), s₀.mem (ws.matBase + (↑i * ws.n + ↑j)) = WordRAM.Signed.encode (cost (i, j))) (hM_ge : ∀ (i j : Fin ws.n), (cost (i, j)).natAbs ≤ ws.M) (hfit2 : WordRAM.Fits w 2) (hfit_addr : WordRAM.Fits w (ws.bC + ws.n * ws.n)) (hfit_val : WordRAM.Fits w (ws.scale * (2 * ws.M))) :
    have prog := fillCProg ws; have s' := (DataStructure.Memory.spec 0).clientState s₀ prog; FillCProgSafe w ws s₀ ∧ (DataStructure.Memory.spec w).ValidHistory s₀ ((DataStructure.Memory.spec w).clientHistory s₀ prog) ∧ WordRAM.Realization.memoryCost prog s₀ ≤ 2 * (ws.n * ws.n) ∧ s'.frontier = s₀.frontier ∧ (∀ (a : ℕ), ¬(ws.bC ≤ a ∧ a < ws.bC + ws.n * ws.n) → s'.mem a = s₀.mem a) ∧ ∀ (i j : Fin ws.n), s'.mem (ws.bC + (↑i * ws.n + ↑j)) = ws.scale * (cost (i, j) + ↑ws.M).toNat

    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.