Input decoding, cost shifting, and output cost encoding subroutines #
Internal O(n²) / O(n) pre- and post-processing steps (setupCode, scanMaxCode,
fillCCode, sumCostCode) around coreCode for Data.init inst.encode.
Read n = mem[1] and set up all constants and array bases starting at baseC = 2 + n * n.
Compute rM across all n² encoded entries.
Populate [baseC, baseC + n²) with nonnegative shifted costs.
Compute Signed.encode of the optimal unshifted matching cost into acc.
theorem Cslib.Algorithms.WordRAM.Hungarian.exec_setupCode {w : ℕ} (inst : Instance) (hw : WordRAM.Fits w inst.wordBound) :
∃ (y₁ : WordRAM.Data 28),
WordRAM.ExecWithin w setupCode (WordRAM.Data.init inst.encode) y₁ 16 ∧ BaseRegs inst.n (2 + inst.n * inst.n) 0 y₁ ∧ y₁.mem = (WordRAM.Data.init inst.encode).mem
theorem Cslib.Algorithms.WordRAM.Hungarian.exec_scanMaxCode {w : ℕ} (inst : Instance) (hw : WordRAM.Fits w inst.wordBound) (y₁ : WordRAM.Data 28) (hb₁ : BaseRegs inst.n (2 + inst.n * inst.n) 0 y₁) (hmem₁ : y₁.mem = (WordRAM.Data.init inst.encode).mem) :
theorem Cslib.Algorithms.WordRAM.Hungarian.exec_fillCCode {w M : ℕ} (inst : Instance) (hw : WordRAM.Fits w inst.wordBound) (hM_le : M ≤ inst.maxMag) (hM_ge : ∀ (u v : Fin inst.n), (inst.cost (u, v)).natAbs ≤ M) (y₂ : WordRAM.Data 28) (hb₂ : BaseRegs inst.n (2 + inst.n * inst.n) M y₂) (hmem₂ : y₂.mem = (WordRAM.Data.init inst.encode).mem) :
theorem Cslib.Algorithms.WordRAM.Hungarian.exec_sumCostCode {w M : ℕ} (inst : Instance) (hw : WordRAM.Fits w inst.wordBound) (hM_le : M ≤ inst.maxMag) (hC_cast : ∀ (p : Fin inst.n × Fin inst.n), ↑(inst.cost p + ↑M).toNat = inst.cost p + ↑M) (hC_le : ∀ (u v : Fin inst.n), (inst.cost (u, v) + ↑M).toNat ≤ 2 * M) (y₄ : WordRAM.Data 28) (hb₄ : BaseRegs inst.n (2 + inst.n * inst.n) M y₄) (hC₄ : CostMem (2 + inst.n * inst.n) (fun (p : Fin inst.n × Fin inst.n) => (inst.cost p + ↑M).toNat) y₄.mem) (hrm_eq :
∀ (u : Fin inst.n), y₄.mem (2 + inst.n * inst.n + inst.n * inst.n + 7 * inst.n + 1 + ↑u) = ↑(inst.assignedCol u)) :