Source: 3-SATISFIABILITY (3SAT)
Target: FEASIBLE REGISTER ASSIGNMENT
Motivation: The previous issue body used variable source-pairs plus 5-node clause chains. That is not the classical reduction cited by Garey–Johnson. This replacement follows Sethi's actual Reduction 3 / Theorem 5.11 for realizability of a preassigned register allocation.
Reference: Garey & Johnson, Computers and Intractability, A11 PO2; Ravi Sethi, "Complete Register Allocation Problems," SIAM J. Comput. 4(3), 1975, Reduction 3 and Theorem 5.11.
GJ Source Entry
[PO2] FEASIBLE REGISTER ASSIGNMENT
INSTANCE: Directed acyclic graph G = (V, A), positive integer K, register assignment f: V -> {R_1, ..., R_K}.
QUESTION: Is there a computation for G that respects the register assignment f?
Reference: [Sethi, 1975]. Transformation from 3SAT.
Orientation Convention
Use Sethi's orientation: an arc (u, v) means that v is a direct descendant of u, so v must appear before u in any realization.
Reduction Algorithm
Input: a 3-CNF formula
phi = C_1 and ... and C_m
over variables x_1, ..., x_n, where each clause is
C_i = (Y[i,1] or Y[i,2] or Y[i,3]).
Create variable leaves:
For each k = 1..n, create two leaves
s_pos[k] (represents literal x_k)
s_neg[k] (represents literal not x_k)
Assign both leaves to the same register:
f(s_pos[k]) = S[k]
f(s_neg[k]) = S[k]
Create one clause gadget per literal occurrence:
For each clause i = 1..m and each position j = 1..3, create nodes
p[i,j]
q[i,j]
r[i,j]
rbar[i,j]
Assign registers:
f(p[i,j]) = P[i,j]
f(q[i,j]) = Q[i,j]
f(r[i,j]) = R[i,j]
f(rbar[i,j]) = R[i,j]
Internal clause-gadget arcs:
For each i,j, add
(q[i,j], p[i,j])
(p[i,j], r[i,j])
For each clause i, add the 3 cyclic links
(q[i,1], rbar[i,2])
(q[i,2], rbar[i,3])
(q[i,3], rbar[i,1])
Literal-attachment arcs:
For each occurrence Y[i,j]:
- if
Y[i,j] = x_k, add
(r[i,j], s_pos[k])
(rbar[i,j], s_neg[k])
- if
Y[i,j] = not x_k, add
(r[i,j], s_neg[k])
(rbar[i,j], s_pos[k])
Let
V = {s_pos[k], s_neg[k] : 1 <= k <= n} union {p[i,j], q[i,j], r[i,j], rbar[i,j] : 1 <= i <= m, 1 <= j <= 3}
and let E be the union of all arcs above.
The number of distinct register names used by f is
K = n + 9*m.
Output the FeasibleRegisterAssignment instance (G=(V,E), K, f).
Solution Extraction
Given a realization Q of (G, f):
For each variable x_k, set
tau(x_k) = true iff s_pos[k] appears before s_neg[k] in Q,
tau(x_k) = false otherwise.
This is exactly the assignment extracted in Sethi's converse proof.
Correctness Sketch
-
If phi is satisfiable, Sethi constructs a realization by:
- placing the truth-selected leaf first for each variable,
- appending all direct ancestors of that chosen leaf,
- appending the opposite leaf,
- then unlocking each clause gadget starting from one satisfied literal.
-
Conversely, in any realization, every clause gadget must have some position j with r[i,j] before rbar[i,j]. By the shared-register order lemma, this forces the corresponding literal leaf to appear before its opposite leaf, so that literal is true under tau. Hence every clause is satisfied.
Size Overhead
| Target metric (code name) |
Expression |
num_vertices |
2*num_vars + 12*num_clauses |
num_arcs |
15*num_clauses |
num_registers |
num_vars + 9*num_clauses |
So this construction is polynomial and already satisfies the max-out-degree-2 restriction.
Implementation Notes
- Please implement the actual Sethi clause gadget; do not replace it with a 5-node linear chain.
- The crucial shared-register pairs are:
{s_pos[k], s_neg[k]} on S[k]
{r[i,j], rbar[i,j]} on R[i,j]
- The cyclic links among the
q and rbar nodes are essential. They are what force at least one literal per clause to be true in any realization.
Example
Source (KSatisfiability):
phi = (x_1 or not x_2 or x_3) and (not x_1 or x_2 or not x_3)
Then n = 3, m = 2, so
K = 3 + 9*2 = 21
num_vertices = 2*3 + 12*2 = 30
num_arcs = 15*2 = 30
Variable registers:
S[1] on {s_pos[1], s_neg[1]}
S[2] on {s_pos[2], s_neg[2]}
S[3] on {s_pos[3], s_neg[3]}
Clause 1 internal arcs:
(q[1,1], p[1,1]), (p[1,1], r[1,1])
(q[1,2], p[1,2]), (p[1,2], r[1,2])
(q[1,3], p[1,3]), (p[1,3], r[1,3])
(q[1,1], rbar[1,2])
(q[1,2], rbar[1,3])
(q[1,3], rbar[1,1])
Clause 1 attachment arcs:
(r[1,1], s_pos[1]), (rbar[1,1], s_neg[1])
(r[1,2], s_neg[2]), (rbar[1,2], s_pos[2])
(r[1,3], s_pos[3]), (rbar[1,3], s_neg[3])
Clause 2 is generated the same way from (not x_1, x_2, not x_3).
Validation Method
- Closed-loop test: reduce KSatisfiability to FeasibleRegisterAssignment, solve via FeasibleRegisterAssignment → ILP, extract truth assignment from realization ordering, verify all clauses satisfied
- Test with both satisfiable and unsatisfiable instances
- Verify vertex/arc/register counts match overhead formulas
References
- Sethi, R. (1975). "Complete Register Allocation Problems." SIAM Journal on Computing, 4(3), pp. 226–248.
- Garey, M. R., & Johnson, D. S. (1979). Computers and Intractability, A11 PO2.
Source: 3-SATISFIABILITY (3SAT)
Target: FEASIBLE REGISTER ASSIGNMENT
Motivation: The previous issue body used variable source-pairs plus 5-node clause chains. That is not the classical reduction cited by Garey–Johnson. This replacement follows Sethi's actual Reduction 3 / Theorem 5.11 for realizability of a preassigned register allocation.
Reference: Garey & Johnson, Computers and Intractability, A11 PO2; Ravi Sethi, "Complete Register Allocation Problems," SIAM J. Comput. 4(3), 1975, Reduction 3 and Theorem 5.11.
GJ Source Entry
Orientation Convention
Use Sethi's orientation: an arc
(u, v)means thatvis a direct descendant ofu, sovmust appear beforeuin any realization.Reduction Algorithm
Input: a 3-CNF formula
phi = C_1 and ... and C_mover variables
x_1, ..., x_n, where each clause isC_i = (Y[i,1] or Y[i,2] or Y[i,3]).Create variable leaves:
For each
k = 1..n, create two leavess_pos[k](represents literalx_k)s_neg[k](represents literalnot x_k)Assign both leaves to the same register:
f(s_pos[k]) = S[k]f(s_neg[k]) = S[k]Create one clause gadget per literal occurrence:
For each clause
i = 1..mand each positionj = 1..3, create nodesp[i,j]q[i,j]r[i,j]rbar[i,j]Assign registers:
f(p[i,j]) = P[i,j]f(q[i,j]) = Q[i,j]f(r[i,j]) = R[i,j]f(rbar[i,j]) = R[i,j]Internal clause-gadget arcs:
For each
i,j, add(q[i,j], p[i,j])(p[i,j], r[i,j])For each clause
i, add the 3 cyclic links(q[i,1], rbar[i,2])(q[i,2], rbar[i,3])(q[i,3], rbar[i,1])Literal-attachment arcs:
For each occurrence
Y[i,j]:Y[i,j] = x_k, add(r[i,j], s_pos[k])(rbar[i,j], s_neg[k])Y[i,j] = not x_k, add(r[i,j], s_neg[k])(rbar[i,j], s_pos[k])Let
V = {s_pos[k], s_neg[k] : 1 <= k <= n} union {p[i,j], q[i,j], r[i,j], rbar[i,j] : 1 <= i <= m, 1 <= j <= 3}and let
Ebe the union of all arcs above.The number of distinct register names used by
fisK = n + 9*m.Output the
FeasibleRegisterAssignmentinstance(G=(V,E), K, f).Solution Extraction
Given a realization
Qof(G, f):For each variable
x_k, settau(x_k) = trueiffs_pos[k]appears befores_neg[k]inQ,tau(x_k) = falseotherwise.This is exactly the assignment extracted in Sethi's converse proof.
Correctness Sketch
If
phiis satisfiable, Sethi constructs a realization by:Conversely, in any realization, every clause gadget must have some position
jwithr[i,j]beforerbar[i,j]. By the shared-register order lemma, this forces the corresponding literal leaf to appear before its opposite leaf, so that literal is true undertau. Hence every clause is satisfied.Size Overhead
num_vertices2*num_vars + 12*num_clausesnum_arcs15*num_clausesnum_registersnum_vars + 9*num_clausesSo this construction is polynomial and already satisfies the max-out-degree-2 restriction.
Implementation Notes
{s_pos[k], s_neg[k]}onS[k]{r[i,j], rbar[i,j]}onR[i,j]qandrbarnodes are essential. They are what force at least one literal per clause to be true in any realization.Example
Source (KSatisfiability):
phi = (x_1 or not x_2 or x_3) and (not x_1 or x_2 or not x_3)Then
n = 3,m = 2, soK = 3 + 9*2 = 21num_vertices = 2*3 + 12*2 = 30num_arcs = 15*2 = 30Variable registers:
S[1]on{s_pos[1], s_neg[1]}S[2]on{s_pos[2], s_neg[2]}S[3]on{s_pos[3], s_neg[3]}Clause 1 internal arcs:
(q[1,1], p[1,1]),(p[1,1], r[1,1])(q[1,2], p[1,2]),(p[1,2], r[1,2])(q[1,3], p[1,3]),(p[1,3], r[1,3])(q[1,1], rbar[1,2])(q[1,2], rbar[1,3])(q[1,3], rbar[1,1])Clause 1 attachment arcs:
(r[1,1], s_pos[1]),(rbar[1,1], s_neg[1])(r[1,2], s_neg[2]),(rbar[1,2], s_pos[2])(r[1,3], s_pos[3]),(rbar[1,3], s_neg[3])Clause 2 is generated the same way from
(not x_1, x_2, not x_3).Validation Method
References