Documentation

CslibFrontier.Computability.Complexity.Problems.MaxCut

Weighted maximum cut #

MaxCut is the set of MaxCutInstance values (edges, bound) such that some set S of vertices cuts edges of total weight at least bound [Kar72] Garey and Johnson, Problem ND16: an edge crosses the cut when exactly one of its endpoints lies in S. Vertices, weights and the bound are natural numbers in binary (encNat). The edge list is a weighted multigraph of MaxCut.WeightedEdge: parallel edges add their weights and self-loops never cross a cut. Weights may be zero. MaxCut.cutWeight reads the weight of a cut from an encodable edge list, without a vertex type; Cslib.WeightedCut.cutWeight is the corresponding weight for a weight matrix on a Fintype.

Karp's reduction from Partition takes the complete graph on the positions 0, …, n - 1 of the numbers a, with weight a[i] * a[j] on the edge between positions i < j (Partition.toMaxCut). A cut putting numbers of sum x on one side has weight x * (σ - x), where σ = a.sum (Partition.cutWeight_productEdges), and x * (σ - x) ≥ ⌈σ² / 4⌉ holds exactly when 2 * x = σ. The bound is ⌈σ² / 4⌉ = (σ * σ + 3) / 4. All weights are products of two input numbers, so the reduction is polynomial in the binary encoding.

Main definitions #

Main results #

References #

A weighted edge between u and v of weight weight.

  • u : ℕ

    The first endpoint.

  • v : ℕ

    The second endpoint.

  • weight : ℕ

    The edge weight.

Instances For
    theorem Cslib.Complexity.MaxCut.encWeightedEdge_u_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → WeightedEdge} :

    Weighted edges are encoded as (u, v, weight) in binary.

    Instances For
      @[reducible, inline]

      The tuple of the fields of encWeightedEdge.

      Instances For
        theorem Cslib.Complexity.MaxCut.encWeightedEdge_v_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → WeightedEdge} :
        theorem Cslib.Complexity.MaxCut.encWeightedEdge_mk_inO {γ : Type} {encIn : γ ↪ List Bool} {x0 T0 S0 x1 T1 S1 x2 T2 S2 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInO x0 encIn Turing.MultiTapeTM.encNat T0 S0) (h1 : Turing.MultiTapeTM.ComputableInO x1 encIn Turing.MultiTapeTM.encNat T1 S1) (h2 : Turing.MultiTapeTM.ComputableInO x2 encIn Turing.MultiTapeTM.encNat T2 S2) :
        Turing.MultiTapeTM.ComputableInO (fun (x : γ) => { u := x0 x, v := x1 x, weight := x2 x }) encIn encWeightedEdge (fun (x : γ) => T0 x + (T1 x + T2 x)) fun (x : γ) => S0 x + (S1 x + S2 x)
        theorem Cslib.Complexity.MaxCut.encWeightedEdge_mk_budget {γ : Type} {encIn : γ ↪ List Bool} {budget x0 x1 x2 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInSpace x0 encIn Turing.MultiTapeTM.encNat budget) (h1 : Turing.MultiTapeTM.ComputableInSpace x1 encIn Turing.MultiTapeTM.encNat budget) (h2 : Turing.MultiTapeTM.ComputableInSpace x2 encIn Turing.MultiTapeTM.encNat budget) :
        Turing.MultiTapeTM.ComputableInSpace (fun (x : γ) => { u := x0 x, v := x1 x, weight := x2 x }) encIn encWeightedEdge budget
        theorem Cslib.Complexity.MaxCut.encWeightedEdge_weight_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → WeightedEdge} :

        Whether the edge e crosses the cut whose sides are given by side.

        Instances For

          The weight of the cut side in the weighted edges E: the total weight of the crossing edges. Parallel edges add their weights; self-loops never cross.

          Instances For

            The endpoints of the weighted edges E, in order and with repetitions.

            Instances For
              theorem Cslib.Complexity.MaxCut.cutWeight_congr {E : List WeightedEdge} {side side' : ℕ → Bool} (h : ∀ v ∈ endpoints E, side v = side' v) :
              cutWeight E side = cutWeight E side'

              The weight of a cut depends only on the sides of the endpoints.

              An instance of weighted maximum cut: a list of weighted edges and a target cut weight bound.

              Instances For
                theorem Cslib.Complexity.encMaxCut_bound_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → MaxCutInstance} :
                theorem Cslib.Complexity.encMaxCut_mk_budget {γ : Type} {encIn : γ ↪ List Bool} {budget : γ → ℕ} {x0 : γ → List MaxCut.WeightedEdge} {x1 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInSpace x0 encIn (Turing.MultiTapeTM.encList MaxCut.encWeightedEdge) budget) (h1 : Turing.MultiTapeTM.ComputableInSpace x1 encIn Turing.MultiTapeTM.encNat budget) :
                Turing.MultiTapeTM.ComputableInSpace (fun (x : γ) => { edges := x0 x, bound := x1 x }) encIn encMaxCut budget
                @[reducible, inline]

                The tuple of the fields of encMaxCut.

                Instances For
                  theorem Cslib.Complexity.encMaxCut_mk_inO {γ : Type} {encIn : γ ↪ List Bool} {x0 : γ → List MaxCut.WeightedEdge} {T0 S0 x1 T1 S1 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInO x0 encIn (Turing.MultiTapeTM.encList MaxCut.encWeightedEdge) T0 S0) (h1 : Turing.MultiTapeTM.ComputableInO x1 encIn Turing.MultiTapeTM.encNat T1 S1) :
                  Turing.MultiTapeTM.ComputableInO (fun (x : γ) => { edges := x0 x, bound := x1 x }) encIn encMaxCut (fun (x : γ) => T0 x + T1 x) fun (x : γ) => S0 x + S1 x
                  theorem Cslib.Complexity.encMaxCut_edges_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → MaxCutInstance} :

                  Instances of MaxCut are encoded as the framed list of weighted edges followed by the bound, all in binary.

                  Instances For

                    Weighted maximum cut [Kar72]: the weighted edges edges have a cut of weight at least bound, a set S of vertices such that the edges with exactly one endpoint in S have total weight at least bound.

                    Instances For

                      The check of a side S of a cut, given as a list: the cut has weight at least the bound.

                      Instances For

                        The verifier for MaxCut, a subset verifier (Cslib.Complexity.subsetVerifier): select the side of the cut among the endpoints and check the weight of the cut.

                        Instances For

                          A side of a cut may be taken among the endpoints.

                          MaxCut.verifier verifies MaxCut with certificates of twice the length of the encoded instance.

                          theorem Cslib.Complexity.mem_Partition_iff_exists_side {a : List ℕ} :
                          a ∈ Partition ↔ ∃ (side : ℕ → Bool), 2 * (List.map (fun (x : ℕ) => a.getD x 0) (List.filter side (List.range a.length))).sum = a.sum

                          A partition is a set of positions holding half of the total sum.

                          The weighted edges of the complete graph on the positions 0, …, n - 1 of the numbers a: the edge between positions i < j has weight a[i] * a[j].

                          Instances For

                            Karp's reduction from Partition to MaxCut [Kar72]: the complete graph on the positions of the numbers a, weighted by products, with bound ⌈a.sum² / 4⌉.

                            Instances For
                              theorem Cslib.Complexity.Partition.cutWeight_productEdges (a : List ℕ) (side : ℕ → Bool) (n : ℕ) :
                              MaxCut.cutWeight (productEdges a n) side = (List.map (fun (x : ℕ) => a.getD x 0) (List.filter side (List.range n))).sum * (List.map (fun (x : ℕ) => a.getD x 0) (List.filter (fun (i : ℕ) => !side i) (List.range n))).sum

                              A cut of the complete graph weighted by products has the weight of the product of the sums of its two sides.

                              Weighted maximum cut is NP-complete, with the weights in binary [Kar72].