Documentation

CslibFrontier.Algorithms.WordRAM.EdmondsKarp.UniformBipartite

Uniform Word-RAM programs for bipartite matching and König vertex cover #

Uniform Basis.exact flat programs and O((m + r + 1) ^ 5) / O((n + 1) ^ 5) runtime bounds for maximum bipartite matching with König minimum vertex cover (exists_bipartiteMatching_program) and perfect matching decision (exists_perfectMatching_program) by reduction to ekProg.

Main definitions #

Main results #

References #

Uniform bipartite matching, König vertex cover, and perfect matching #

Row-major 0/1 encoding of G : Fin m × Fin r → Bool.

Word-RAM input m :: r :: encodeBipartiteMatrix G: left count at address 1, right count at 2, and G (u, v) (0 or 1) at 3 + u * r + v.

Output address of the matching indicator for (u, v) (1 iff (u, v) ∈ M).

Output address of the König left-cover indicator for u (1 iff u ∈ C.left).

Output address of the König right-cover indicator for v (1 iff v ∈ C.right).

theorem Cslib.Algorithms.WordRAM.EdmondsKarp.exists_bipartiteMatching_program :
∃ (R : ℕ) (C : ℕ) (pc : ℕ), 0 < C ∧ ∃ (prog : WordRAM.Program WordRAM.Basis.exact R), ∀ {m r w : ℕ} (G : Fin m × Fin r → Bool), WordRAM.Fits w (ekBound (2 + (m + r)) 1) → ∃ (y : WordRAM.Data R) (steps : ℕ) (res : ℕ) (M : Finset (Fin m × Fin r)) (cov : Lean.MaxFlow.VertexCover (Fin m) (Fin r)), WordRAM.Runs w prog (WordRAM.State.init (encodeBipartiteInput G)) { pc := pc, data := y } steps ∧ WordRAM.step w prog { pc := pc, data := y } = WordRAM.Outcome.halt res ∧ steps + 1 ≤ C * (m + r + 1) ^ 5 ∧ Lean.MaxFlow.IsMaxMatching G M ∧ Lean.MaxFlow.IsMinVertexCover G cov ∧ M.card = cov.size ∧ res = M.card ∧ (∀ (u : Fin m) (v : Fin r), y.mem (bmMatchAddr m r ↑u ↑v) = if (u, v) ∈ M then 1 else 0) ∧ (∀ (u : Fin m), y.mem (bmCovLAddr m r ↑u) = if u ∈ cov.left then 1 else 0) ∧ ∀ (v : Fin r), y.mem (bmCovRAddr m r ↑v) = if v ∈ cov.right then 1 else 0

Maximum bipartite matching and König vertex cover on the Word-RAM ([Kon31]; [CLRS09], Section 26.3): one uniform flat program over Basis.exact that, on encodeBipartiteInput G for any G : Fin m × Fin r → Bool, halts within C * (m + r + 1) ^ 5 instructions at every word width fitting ekBound (2 + (m + r)) 1. It returns the maximum matching cardinality M.card = C.size, stores M at bmMatchAddr, and stores a minimum König vertex cover C at bmCovLAddr and bmCovRAddr.

theorem Cslib.Algorithms.WordRAM.EdmondsKarp.exists_perfectMatching_program :
∃ (R : ℕ) (C : ℕ) (pc : ℕ), 0 < C ∧ ∃ (prog : WordRAM.Program WordRAM.Basis.exact R), ∀ {n w : ℕ} (G : Fin n × Fin n → Bool), WordRAM.Fits w (ekBound (2 + (n + n)) 1) → ∃ (y : WordRAM.Data R) (steps : ℕ) (res : ℕ), WordRAM.Runs w prog (WordRAM.State.init (encodeBipartiteInput G)) { pc := pc, data := y } steps ∧ WordRAM.step w prog { pc := pc, data := y } = WordRAM.Outcome.halt res ∧ steps + 1 ≤ C * (n + 1) ^ 5 ∧ (res = 1 ↔ Circuits.BipartiteMatching.HasPerfectMatching G) ∧ res ≤ 1

Bipartite perfect matching decision on the Word-RAM: one uniform flat program over Basis.exact that, on encodeBipartiteInput G for any G : Fin n × Fin n → Bool, halts within C * (n + 1) ^ 5 instructions at every word width fitting ekBound (2 + (n + n)) 1, returning 1 iff Cslib.Circuits.BipartiteMatching.HasPerfectMatching G and 0 otherwise.