Deterministic 1/2-approximation for weighted MaxCut on the word RAM #
Implements the method of conditional expectations for weighted multigraph MaxCut on a
deterministic Basis.standard word RAM (Cslib.WordRAM.Code .standard 18).
Memory layout and algorithm #
On an n-vertex weighted multigraph edges : List WeightedEdge (m = edges.length) whose
endpoints satisfy e.u < n and e.v < n, Data.init (encode n edges) stores:
- cell
0: total input word length2 + 3 * m; - cell
1: vertex countn; - cell
2: edge countm; [3, 3 + 3 * m): flat triples[u₀, v₀, w₀, u₁, v₁, w₁, ...].
The scratch array [3 + 3 * m, 3 + 3 * m + n) stores the chosen vertex sides 0 (false) or 1
(true). For each vertex z = 0, …, n - 1 in order, the inner scan walks the m edges and
accumulates:
w0: total weight of edges betweenzand an earlier vertexu < zcurrently on side1(edges cut ifzis placed on side0), andw1: total weight of edges betweenzand an earlier vertexu < zcurrently on side0(edges cut ifzis placed on side1).
Self-loops (u = v = z) are ignored, and edges with an endpoint > z remain balanced between both
sides under conditional expectations. Placing z on the larger-gain side (1 when w0 ≤ w1, 0
when w1 < w0) adds max w0 w1 ≥ (w0 + w1) / 2 to Reg.cutWt, maintaining that twice the cut
weight on edges inside {0, …, z - 1} is at least the total non-loop weight inside
{0, …, z - 1}.
At z = n, all endpoints lie below n, so maxCutCode halts within
maxCutTime n m = n * (20 * m + 15) + 12 (O(|V| |E| + |V|)) instructions with Reg.cutWt
holding cutWeight edges side and nonLoopWeight edges ≤ 2 * cutWeight edges side, giving a
certified deterministic 1 / 2-approximation against every cut τ : ℕ → Bool.
Main definitions #
Cslib.Algorithms.WordRAM.MaxCut.encodeEdges,encode: flat word-list encoding of(n, edges).Cslib.Algorithms.WordRAM.MaxCut.wordBound: sufficient word-size bound3 + 3 * edges.length + n + totalWeight edges.Cslib.Algorithms.WordRAM.MaxCut.sideAt: cut indicatorℕ → Boolread from memory.Cslib.Algorithms.WordRAM.MaxCut.Reg.cutWt: output register holding the achieved cut weight.Cslib.Algorithms.WordRAM.MaxCut.maxCutCode,maxCutProgram: structured and compiled word-RAM1 / 2-approximation algorithm for weightedMaxCut.Cslib.Algorithms.WordRAM.MaxCut.maxCutTime: explicitO(n * m + n)instruction bound.
Main results #
Cslib.Algorithms.WordRAM.MaxCut.inputFits_encode:InputFitscertificate forencode n edgeswhenever all endpoints lie belownandFits w (wordBound n edges).Cslib.Algorithms.WordRAM.MaxCut.maxCutCode_spec: structured execution withinmaxCutTime n edges.lengthinstructions computingsideandcutWeight edges sidewithnonLoopWeight edges ≤ 2 * cutWeight edges sideand∀ τ, cutWeight edges τ ≤ 2 * cutWeight edges side.Cslib.Algorithms.WordRAM.MaxCut.maxCutProgram_spec: compiledProgram .standard 18halting certificate (Executes) withinmaxCutTime n edges.length + 1instructions returning a cut weight at least half ofnonLoopWeight edges(and at least half of every cutτ).
References #
Input encoding and memory views #
Flat [u, v, weight] word list for a list of weighted edges.
Full input word list [n, edges.length, u₀, v₀, w₀, ...] for maxCutProgram.
Sufficient upper bound on every constant, vertex/edge counter, memory address and accumulated
cut weight computed during maxCutProgram.
Every word of encode n edges and (encode n edges).length fit in width w whenever all
endpoints lie below n and Fits w (wordBound n edges).
Prefix conditional-expectation invariants #
Registers and word-RAM program #
Output register holding the accumulated cut weight.
Complete structured conditional-expectations MaxCut program.
Compiled flat Program .standard 18 halting with the achieved cut weight in Reg.cutWt.
Instruction budget of maxCutCode on n vertices and m edges (O(n * m + n)).
Correctness and instruction-count proof #
Structured word-RAM specification of deterministic 1 / 2-approximation MaxCut.
When every endpoint in edges is below n and Fits w (wordBound n edges), maxCutCode executes
within maxCutTime n edges.length = n * (20 * edges.length + 15) + 12 instructions, writing a
boolean cut side = sideAt y.mem (3 + 3 * edges.length) n to [3 + 3 * edges.length, 3 + 3 * edges.length + n) and leaving cutWeight edges side in register Reg.cutWt with
nonLoopWeight edges ≤ 2 * cutWeight edges side and cutWeight edges τ ≤ 2 * cutWeight edges side
for every cut τ : ℕ → Bool.
Compiled word-RAM specification of deterministic 1 / 2-approximation MaxCut.
At any word width w with Fits w (wordBound n edges), maxCutProgram halts within
maxCutTime n edges.length + 1 instructions from State.init (encode n edges) and outputs the
weight cutWeight edges side of an explicit cut side : ℕ → Bool achieving at least half of
nonLoopWeight edges and at least half of every cut τ : ℕ → Bool.