You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/paper/reductions.typ
+183-2Lines changed: 183 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -3671,7 +3671,7 @@ In all graph problems below, $G = (V, E)$ denotes an undirected graph with $|V|
3671
3671
#problem-def("SetSplitting")[
3672
3672
Given a finite universe $U$ and a collection $cal(C) = {C_1, dots, C_m}$ of subsets of $U$ each of size $gt.eq 2$, does there exist a 2-coloring $chi: U -> {0, 1}$ such that every $C_i$ is non-monochromatic — i.e., contains at least one element of each color?
3673
3673
][
3674
-
One of Garey and Johnson's NP-complete problems (SP4 in @garey1979), shown NP-complete by reduction from 3-SAT. It is equivalent to deciding whether a hypergraph is 2-colorable (also called Property B). The problem is trivially satisfiable when every subset has size exactly 2, reducing to 2-colorability of the corresponding graph; it becomes NP-complete for subsets of size $gt.eq 3$. The best known exact algorithm runs in $O^*(2^n)$ by brute-force enumeration over the $n = |U|$ elements.
3674
+
One of Garey and Johnson's NP-complete problems (SP4 in @garey1979), shown NP-complete by #cite(<lovasz1973>, form: "prose") via reduction from Not-All-Equal 3-Satisfiability. It is equivalent to deciding whether a hypergraph is 2-colorable (also called Property B). The problem is trivially satisfiable when every subset has size exactly 2, reducing to 2-colorability of the corresponding graph; it becomes NP-complete for subsets of size $gt.eq 3$. The best known exact algorithm runs in $O^*(2^n)$ by brute-force enumeration over the $n = |U|$ elements.
3675
3675
3676
3676
*Example.* Let $U = {1, 2, dots, #n}$ and $cal(C) = {C_1, dots, C_#m}$ with #range(m).map(i => $C_#(i + 1) = #fmt-set(subsets.at(i))$).join(", "). Coloring $S_1 = #fmt-set(part0)$ and $S_2 = #fmt-set(part1)$ splits all subsets: each $C_i$ has at least one element in each part.
3677
3677
@@ -3736,6 +3736,39 @@ In all graph problems below, $G = (V, E)$ denotes an undirected graph with $|V|
caption: [Consecutive Sets: the string $w = (#sol.map(str).join(", "))$ with each subset $Sigma_i$ occupying a contiguous block. Colored bars below indicate the span of each subset.]
3771
+
) <fig:consecutive-sets>
3739
3772
]
3740
3773
]
3741
3774
}
@@ -3765,6 +3798,43 @@ In all graph problems below, $G = (V, E)$ denotes an undirected graph with $|V|
let covered-by = selected.filter(j => subs.at(j).contains(k))
3821
+
let covered = covered-by.len() > 0
3822
+
circle(pos, radius: 0.22,
3823
+
fill: if covered { graph-colors.at(0) } else { white },
3824
+
stroke: 0.8pt + black)
3825
+
content(pos, text(7pt, fill: if covered { white } else { black }, [#(k + 1)]))
3826
+
}
3827
+
// Subset nodes
3828
+
for (j, pos) in sub-pos.enumerate() {
3829
+
let is-sel = selected.contains(j)
3830
+
circle(pos, radius: 0.26,
3831
+
fill: if is-sel { graph-colors.at(0).lighten(70%) } else { luma(240) },
3832
+
stroke: if is-sel { 1pt + graph-colors.at(0) } else { 0.8pt + black })
3833
+
content(pos, text(7pt, $S_#(j + 1)$))
3834
+
}
3835
+
}),
3836
+
caption: [Exact Cover by 3-Sets: the selected cover $cal(C)' = {#selected.map(i => $S_#(i + 1)$).join(", ")}$ (blue) partitions the universe $X = {1, dots, #n}$ into $q = #q$ disjoint triples. Every element (top) is covered by exactly one selected subset (bottom).]
3837
+
) <fig:exact-cover-by-3-sets>
3768
3838
]
3769
3839
]
3770
3840
}
@@ -3793,6 +3863,43 @@ In all graph problems below, $G = (V, E)$ denotes an undirected graph with $|V|
// Draw each group as a rounded rectangle with elements inside
3949
+
for (gi, group) in partition.enumerate() {
3950
+
let gx = (gi - (total-groups - 1) / 2) * 2.2
3951
+
let w = group.len() * 0.55 + 0.3
3952
+
rect((gx - w / 2, y - 0.35), (gx + w / 2, y + 0.35),
3953
+
stroke: 0.8pt + group-colors.at(mi), radius: 4pt)
3954
+
// Elements inside the group
3955
+
for (ei, elem) in group.enumerate() {
3956
+
let ex = gx + (ei - (group.len() - 1) / 2) * 0.5
3957
+
let is-sel = selected.contains(elem)
3958
+
circle((ex, y), radius: 0.18,
3959
+
fill: if is-sel { graph-colors.at(0) } else { white },
3960
+
stroke: 0.6pt + black)
3961
+
content((ex, y), text(7pt, fill: if is-sel { white } else { black }, str(elem)))
3962
+
}
3963
+
}
3964
+
}
3965
+
}),
3966
+
caption: [Three-Matroid Intersection: each row shows one partition matroid's groups (rounded boxes). The selected elements $E' = #fmt-set(selected)$ (blue) place at most one element per group in all three matroids.]
3967
+
) <fig:three-matroid-intersection>
3828
3968
]
3829
3969
]
3830
3970
}
@@ -4000,7 +4140,7 @@ In all graph problems below, $G = (V, E)$ denotes an undirected graph with $|V|
4000
4140
][
4001
4141
A functional dependency $X arrow Y$ on attribute set $A$ means: whenever two database rows agree on every attribute in $X$, they must also agree on every attribute in $Y$. The _closure_ $X^+_F$ of a subset $X subset.eq A$ under a set $F$ of functional dependencies is the largest set of attributes determined by $X$: start with $X^+_F = X$, then repeatedly apply every rule $L arrow R in F$ for which $L subset.eq X^+_F$, adding $R$ to $X^+_F$, until no more attributes can be added. A _superkey_ is any $K subset.eq A$ with $K^+_F = A$ (knowing $K$ determines everything). A _candidate key_ is a minimal superkey — no proper subset of $K$ is itself a superkey. An attribute $x$ is _prime_ if it belongs to at least one candidate key.
4002
4142
4003
-
Determining whether an attribute is prime is NP-complete (Lucchesi and Osborn, 1978; Garey & Johnson SR28). The brute-force approach enumerates all $2^n$ subsets of $A$ containing $x$ and checks each for the key property; no algorithm significantly improving on this is known for the general problem.
4143
+
Determining whether an attribute is prime is NP-complete @lucchesi1978keys (Garey & Johnson SR28 @garey1979). The brute-force approach enumerates all $2^n$ subsets of $A$ containing $x$ and checks each for the key property; no algorithm significantly improving on this is known for the general problem.
fill: if is-key { graph-colors.at(0) } else { white },
4265
+
stroke: 0.8pt + black)
4266
+
content(pos, text(8pt, fill: if is-key { white } else { black }, [$#k$]))
4267
+
}
4268
+
}),
4269
+
caption: [Minimum Cardinality Key: optimal key $K = #fmt-set(key-attrs)$ shown in blue. Each FD is drawn as lines converging to a dot (LHS) with arrows fanning out to RHS attributes. Chaining all FDs from $K$ reaches every attribute in $A$.]
0 commit comments