Documentation

CslibFrontier.Algorithms.WordRAM.Auction.Workspace

Shared workspace layout and memory invariants for Word-RAM auction #

Internal workspace layout record (AuctionWS), its 10-word faithful word_enc_structure encoding, and the two shared memory invariants connecting Word-RAM state to pure AuctionState:

Main definitions #

Main results #

Workspace layout and parameters for the memory-client auction solver.

  • n : ℕ

    Common number of persons and objects.

  • eps : ℕ

    Positive bidding increment ε.

  • scale : ℕ

    Cost scaling factor (1 or n + 1).

  • M : ℕ

    Scanned entry magnitude bound M.

  • matBase : ℕ

    Start address of encoded input matrix (3 or 2).

  • bC : ℕ

    Base address of working unsigned n × n matrix C[0..n*n).

  • bOwner : ℕ

    Base address of owner[0..n) (n denotes none, i < n denotes some i).

  • bPrice : ℕ

    Base address of nonnegative integer prices price[0..n).

  • bStack : ℕ

    Base address of reversed unassigned-person stack stack[0..n).

  • outBase : ℕ

    Base address of length-prefixed output list (n + 1 cells).

Instances For
    theorem Cslib.Algorithms.WordRAM.Auction.encAuctionWS_fits {w : ℕ} {a : AuctionWS} (h_n : WordRAM.Fits w a.n) (h_eps : WordRAM.Fits w a.eps) (h_scale : WordRAM.Fits w a.scale) (h_M : WordRAM.Fits w a.M) (h_matBase : WordRAM.Fits w a.matBase) (h_bC : WordRAM.Fits w a.bC) (h_bOwner : WordRAM.Fits w a.bOwner) (h_bPrice : WordRAM.Fits w a.bPrice) (h_bStack : WordRAM.Fits w a.bStack) (h_outBase : WordRAM.Fits w a.outBase) (j✝ : Fin 10) :
    @[reducible, inline]
    abbrev Cslib.Algorithms.WordRAM.Auction.encAuctionWSFields :
    ((((((((ℕ × ℕ) × ℕ) × ℕ) × ℕ) × ℕ) × ℕ) × ℕ) × ℕ) × ℕ ↪ Fin (1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1) → ℕ

    The tuple word encoding of the fields of encAuctionWS.

    Memory s represents pure st : AuctionState ws.n over unsigned cost matrix C at ws.

    Disjointness and frontier validity of ws : AuctionWS.

    • hbOwner : ws.bOwner = ws.bC + ws.n * ws.n

      owner begins immediately after the n × n matrix C.

    • hbPrice : ws.bPrice = ws.bOwner + ws.n

      price begins immediately after owner.

    • hbStack : ws.bStack = ws.bPrice + ws.n

      stack begins immediately after price.

    • houtBase : ws.outBase = ws.bStack + ws.n

      Length-prefixed output array begins immediately after stack.

    • hfrontier : ws.outBase + ws.n + 1 ≤ s.frontier

      Allocated frontier covers the entire output buffer (n + 1 words).

    ValidWS is preserved by any memory step that leaves frontier unchanged.

    theorem Cslib.Algorithms.WordRAM.Auction.AuctionMem.redCost_read {W : ℕ} {ws : AuctionWS} {C : Fin ws.n × Fin ws.n → ℕ} {st : Lean.Assignment.AuctionState ws.n} {s : DataStructure.Memory.State} (ham : AuctionMem ws C st s) (hC_le : ∀ (i j : Fin ws.n), C (i, j) ≤ W) (hp_nn : ∀ (j : Fin ws.n), 0 ≤ st.price j) (hp_le : ∀ (j : Fin ws.n), st.price j ≤ ↑W + ↑ws.eps) (i₀ j : Fin ws.n) :
    have rc := s.mem (ws.bC + ↑i₀ * ws.n + ↑j) + s.mem (ws.bPrice + ↑j); rc ≤ 2 * W + ws.eps ∧ ↑rc = Lean.Assignment.redCost (fun (e : Fin ws.n × Fin ws.n) => ↑(C e)) st.price i₀ j

    Reading C[i₀, j] and price[j] in memory computes redCost (fun e => (C e : ℤ)) st.price i₀ j and stays bounded by 2 * W + ws.eps. Shared by both row scans in Auction.RowScan.