Minimum chain cover by Hopcroft–Karp #
minChainCover e computes a minimum chain cover and a maximum antichain of a finite poset α,
given as an enumeration e : Fin n ≃ α with decidable <. It runs Fulkerson's reduction
(CslibFrontier.Algorithms.Lean.MaxFlow.Dilworth) on the output of Hopcroft–Karp:
hopcroftKarpDense (enumLtGraph e)returns a maximum matchingMand a minimum König coverCof the bipartite graph joining indexito indexjwhene i < e j.- Starting from the labels
i ↦ i,chainLabelsscans every pair of indices and, for each pair(i, j) ∈ M, relabelsj's chain withi's label (mergeChains). The resulting label fibres are chains, and there aren - |M|labels. - The indices missed by
Con both sides form an antichain of at leastn - |C| = n - |M|elements (uncoveredStep).
minChainCover_correct proves that the label fibres are chains, the returned index set is an
antichain, and the number of labels equals the size of the antichain, n - |M|. With weak
duality this certifies both as optimal (card_le_card_antichain_of_isAntichain,
card_antichain_le_of_isChain_fibre), which is the algorithmic content of Dilworth's theorem.
Machine-checked O(n^{5/2}) word-RAM running-time bounds for minimum chain cover and maximum
antichain live in CslibFrontier.Algorithms.WordRAM.HopcroftKarp.
Main definitions #
enumLtGraph: Fulkerson's graphltGraphread through an enumeration.ChainCoverOutput,ChainCoverOutput.label,ChainCoverOutput.numChains: chain labels, antichain, matching, and chain count.mergeChains,chainLabels,uncoveredStep: the steps of the algorithm.minChainCover: the pure algorithm.
Main results #
minChainCover_correct: chain fibres, an antichain, and equal sizesn - |M|.card_le_card_antichain_of_isAntichain,card_antichain_le_of_isChain_fibre: the output is a maximum antichain and the labels form a minimum chain cover.chainLabels_eq_foldl_rowMate: row-mate fold characterization ofchainLabelsfor matchings (used by the word-RAM realization).
References #
Output of minChainCover.
Chain label of each index; indices with equal labels lie on one chain.
A maximum antichain, as a set of indices.
The maximum matching of
enumLtGraph efound by Hopcroft–Karp.
Minimum chain cover of a finite poset enumerated by e : Fin n ≃ α, by Fulkerson's
reduction: a maximum matching of enumLtGraph e from hopcroftKarpDense, chains obtained by
merging along its edges, and a maximum antichain read off the König cover.
The chain label of x : α in an output out for the enumeration e.
The number of chains of an output: the number of distinct labels in the table.
Correctness #
When rm i is the unique right mate of i (rm i = some j ↔ (i, j) ∈ M), scanning
List.finRange n ×ˢ List.finRange n in chainLabels equals a single O(n)-outer-step fold over
i ∈ List.finRange n.
Correctness of minChainCover. The label fibres are chains, the returned indices form an
antichain, and the number of labels equals the size of the antichain, namely n - |M| for the
maximum matching M found by Hopcroft–Karp. By weak duality the antichain is maximum and the
chain cover minimum (card_le_card_antichain_of_isAntichain,
card_antichain_le_of_isChain_fibre).
The antichain returned by minChainCover is maximum.
The chain cover returned by minChainCover is minimum: every covering of α by k chains
has k at least the number of its labels.