Skip to content

[Rule] 3-Dimensional Matching to MinimumWeightDecoding #916

@isPANN

Description

@isPANN

Source: 3-Dimensional Matching (ThreeDimensionalMatching)
Target: Minimum Weight Decoding (MinimumWeightDecoding)

Motivation: Establishes NP-hardness of the minimum-weight codeword problem (a.k.a. nearest-codeword / minimum-distance decoding) by encoding a 3-dimensional matching instance as a binary parity-check system over GF(2). Each matching triple becomes a length-3q column with exactly three 1s; the all-ones syndrome forces every element of X ∪ Y ∪ Z to be covered an odd number of times, and the optimal codeword has weight q iff a perfect 3DM matching exists. This is the classical Berlekamp–McEliece–van Tilborg (1978) construction.
Reference: Garey & Johnson, Computers and Intractability, A1.2 MS7; Berlekamp, McEliece, van Tilborg 1978

GJ Source Entry

[MS7] DECODING OF LINEAR CODES
INSTANCE: n×m binary matrix A, binary m-vector ȳ, positive integer K ≤ m.
QUESTION: Is there a binary m-vector x̄ having at most K ones and satisfying Ax̄ = ȳ over GF(2)?
Reference: [Berlekamp, McEliece, and van Tilborg, 1978]. Transformation from 3-DIMENSIONAL MATCHING.
Comment: The problem of computing the minimum Hamming distance of a linear code is a special case.

Reduction Algorithm

Reduction direction and semantics. This is a witness reduction from ThreeDimensionalMatching (whose Value is Or) to MinimumWeightDecoding (whose Value is Min<usize>). The bridge from the source feasibility answer to the target objective value, on the main branch, is

source.evaluate(matching) == Or(true)target.evaluate(codeword) == Min(Some(q))

where q = universe_size is the perfect-matching size. A target witness x ∈ {0,1}^{m} decodes back to the column subset S = { t_j ∈ T : x_j = 1 }, and the recovered source answer is source.evaluate(S).

Inputs. A ThreeDimensionalMatching instance with

  • universe_size = q, representing three disjoint sets X = Y = Z = {0, 1, ..., q-1},
  • triples = T = [t_0, ..., t_{m-1}] with t_j = (a_j, b_j, c_j) ∈ X × Y × Z.

Construction.

  1. Sentinel branch (degenerate inputs: T = [] or q = 0). The source model legally accepts triples = [] for any universe_size, and universe_size = 0 with triples = []. But MinimumWeightDecoding::new panics on matrices with zero rows or zero columns (assert!(!matrix.is_empty(), ...) and assert!(num_cols > 0, ...) in src/models/algebraic/minimum_weight_decoding.rs). To keep the reduction total, the algorithm emits a fixed sentinel MinimumWeightDecoding instance whenever T = [] or q = 0:

    matrix       = [[true]]           // 1×1 matrix with a single 1
    target       = [false]            // syndrome 0 of length 1
    

    The unique feasible codeword for this sentinel is x = (0) with Hamming weight 0 (minimum weight 0). The witness-extraction routine then decodes x back to the empty column subset S = ∅ and consults source.evaluate(S) for the recovered source answer. Because the source's evaluate on the empty subset correctly returns

    • Or(true) if q = 0 (the empty matching is a perfect matching of the empty universe), and
    • Or(false) if q ≥ 1 (the empty set of triples cannot cover a non-empty universe),

    the sentinel correctly preserves the source answer through the reduction without any special-case bookkeeping on the bridge side. We use a syndrome of 0 (not 1) precisely so that the unique min-weight codeword has weight 0 and decodes to S = ∅, which is the right object to hand back to source.evaluate.

    Note that the bridge min weight(x) == q does not hold on the sentinel branch in general (e.g., q = 1 with T = [] gives min weight = 0 ≠ 1 but source is correctly Or(false)). The witness-extraction path via source.evaluate(S) is what guarantees correctness on this branch.

  2. Main branch (q ≥ 1 and |T| ≥ 1). Build the parity-check matrix H ∈ {0,1}^{3q × m} whose row blocks correspond to X, Y, Z in that order:

    • Row a (for a ∈ X) has H[a, j] = 1 iff the first coordinate of t_j equals a.
    • Row q + b (for b ∈ Y) has H[q + b, j] = 1 iff the second coordinate of t_j equals b.
    • Row 2q + c (for c ∈ Z) has H[2q + c, j] = 1 iff the third coordinate of t_j equals c.

    Each column therefore has exactly three 1s. Set the syndrome (target) to the all-ones vector s = 1^{3q}. The target instance is MinimumWeightDecoding(matrix = H, target = s).

Correctness (main branch).

  • Forward. If S ⊆ T is a perfect 3D matching (|S| = q, every element of X ∪ Y ∪ Z covered exactly once), the indicator vector x ∈ {0,1}^{m} with x_j = 1 ⇔ t_j ∈ S has weight q and satisfies Hx ≡ 1^{3q} (mod 2) because each row contains exactly one 1 among the selected columns. Hence the minimum codeword weight is ≤ q.
  • Reverse. For any x with Hx ≡ 1^{3q} (mod 2), each row sum is odd, so each row uses at least one selected column, giving total column-coverage ≥ 3q. Each column contributes coverage exactly 3, so 3 · weight(x) ≥ 3q, i.e. weight(x) ≥ q. Equality forces every row to be covered exactly once (any row covered ≥ 3 times would push the total over 3q), which is precisely a perfect 3DM matching on the supports of x.

Combining the two directions: min weight(x) = q iff a perfect matching exists, otherwise min weight(x) > q (or the target is infeasible and returns Min(None)).

Witness extraction (both branches).

Given a target witness x ∈ {0,1}^{|columns|} returned by the MinimumWeightDecoding solver:

  1. Compute S = { t_j ∈ T : x_j = 1 }. On the sentinel branch x = (0) and S = ∅; on the main branch S is the subset of triples whose corresponding columns were selected.
  2. Call source.evaluate(S) and return its result as the recovered source answer.
  3. The bridge min weight(x) = q ⇔ source.evaluate(S) = Or(true) is what guarantees that on the main branch this S is a valid perfect matching iff the target's optimum equals q; if min weight(x) > q or the target returned Min(None), the same source.evaluate(S) will return Or(false) (the extracted S cannot be a perfect matching).

source.evaluate(S) therefore doubles as the bridge's defensive verifier: it catches any case where the target solver returns a feasible but non-optimal x whose support does not cover the universe correctly.

Time complexity of reduction: O(q · m) to construct the matrix on the main branch; O(1) for the sentinel branch. Witness extraction is O(m).

Size Overhead

Symbols:

  • universe_size = q = size of each partition set in the 3DM instance (|X| = |Y| = |Z| = q)
  • num_triples = m = |T| = number of triples

MinimumWeightDecoding exposes size_fields = [num_cols, num_rows] (see pred show MinimumWeightDecoding --json). The overhead table lists those two fields only — there is no K / weight_bound field on the target. The weight constraint weight(x) = q is not part of the target instance; it is verified implicitly via source.evaluate(S) in witness extraction.

Target metric (code name) Polynomial (using symbols above)
num_rows 3 * universe_size
num_cols num_triples

Derivation: On the main branch each element of X ∪ Y ∪ Z becomes a row (3q rows total) and each triple becomes a column (m columns); the matrix is sparse with 3 ones per column. The syndrome is 1^{3q}. On the sentinel branch the target is a fixed 1×1 instance, well within these polynomial bounds.

Validation Method

  • Closed-loop test (main branch). Build a 3DM instance with q ≥ 1 and |T| ≥ 1, run the reduction, solve the target by brute-force enumeration of all 2^m binary vectors against the syndrome, apply the witness-extraction recipe (S = supp(x); source.evaluate(S)), and assert that the round-trip recovered answer matches source.evaluate(<original perfect-matching witness>) for YES instances and Or(false) for NO instances.
  • Sentinel-branch tests. Cover all degenerate combinations:
    • q = 0, T = [] → sentinel target solves to x = (0), extracted S = ∅, source.evaluate(∅) == Or(true) (empty matching of empty universe).
    • q = 1, T = [] → sentinel target solves to x = (0), extracted S = ∅, source.evaluate(∅) == Or(false) (universe non-empty, no triples).
    • q = 2, T = [] → same as above, Or(false).
  • YES instance (main branch). q = 2, T = [(0,0,0), (1,1,1), (0,1,0), (1,0,1)] — both {t_0, t_1} and {t_2, t_3} are perfect matchings; target's optimum should be Min(Some(2)).
  • NO instance (main branch). q = 2, T = [(0,0,0), (0,0,1), (1,0,0)] — element 1 ∈ Y is never covered, so the target is infeasible (Min(None)); witness extraction with any feasible attempt returns Or(false).
  • GF(2) arithmetic check. For any candidate x over the constructed H, verify Hx ≡ 1^{3q} (mod 2) row by row.

Example

Source instance (3-Dimensional Matching):
q = universe_size = 2, so X = Y = Z = {0, 1}.
T = [t_0 = (0,0,0), t_1 = (1,1,1), t_2 = (0,1,0), t_3 = (1,0,1)].
Perfect matchings: {t_0, t_1} and {t_2, t_3} (each covers every element of X ∪ Y ∪ Z exactly once).

Constructed target instance (MinimumWeightDecoding, main branch):
H ∈ {0,1}^{6 × 4}, with row blocks X (rows 0–1), Y (rows 2–3), Z (rows 4–5):

       t0 t1 t2 t3
X=0:    1  0  1  0
X=1:    0  1  0  1
Y=0:    1  0  0  1
Y=1:    0  1  1  0
Z=0:    1  0  1  0
Z=1:    0  1  0  1

Syndrome (target) = (1, 1, 1, 1, 1, 1). There is no separate K field on the target; the weight q constraint is enforced implicitly by the witness-extraction step calling source.evaluate.

Brute-force solution. Enumerating all 2^4 = 16 binary vectors x and keeping those with Hx ≡ 1^6 (mod 2):

  • x = (1, 1, 0, 0) → weight 2 → extracted S = {t_0, t_1}, source.evaluate(S) = Or(true)
  • x = (0, 0, 1, 1) → weight 2 → extracted S = {t_2, t_3}, source.evaluate(S) = Or(true)

Both attain the minimum weight 2 = q, confirming min weight(x) = q ⇔ 3DM has a perfect matching. The reduction returns Or(true) with either S as a valid recovered matching.

Sentinel example. For q = 1, T = [], the sentinel target is MinimumWeightDecoding(matrix = [[1]], target = [0]). The unique feasible codeword is x = (0) with weight 0; the extracted subset is S = ∅; and source.evaluate(∅) with q = 1 returns Or(false) (the empty set of triples does not cover element 0). For q = 0, T = [], the same sentinel target gives the same x = (0) and S = ∅, but source.evaluate(∅) with q = 0 returns Or(true).

References

  • [Berlekamp, McEliece, and van Tilborg, 1978]: E. R. Berlekamp, R. J. McEliece, and H. C. A. van Tilborg (1978). "On the inherent intractability of certain coding problems." IEEE Transactions on Information Theory IT-24(3), pp. 384–386.
  • [Garey and Johnson, 1979]: M. R. Garey and D. S. Johnson (1979). Computers and Intractability: A Guide to the Theory of NP-Completeness. W. H. Freeman, p. 226 (MS7).

Metadata

Metadata

Assignees

No one assigned

    Labels

    GoodAn issue passed all checks.ruleA new reduction rule to be added.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions