-
Notifications
You must be signed in to change notification settings - Fork 3
[Model] IntegerExpressionMembership #552
Description
Motivation
INTEGER EXPRESSION MEMBERSHIP (P237) from Garey & Johnson, A7 AN18. Given an integer expression built using union (∪) and set addition (+, Minkowski sum) over singleton positive integers, and a target integer K, the problem asks whether K belongs to the set denoted by the expression. NP-complete by reduction from SUBSET SUM (Stockmeyer and Meyer, 1973). Part of a family of problems with varying complexity: the related INEQUIVALENCE problem (do two expressions denote different sets?) is Sigma_2^p-complete, and adding complementation (¬) makes both MEMBERSHIP and INEQUIVALENCE PSPACE-complete. This problem connects formal language theory and arithmetic circuit complexity.
Associated reduction rules:
- As target: R181 (SUBSET SUM to INTEGER EXPRESSION MEMBERSHIP)
- As source: (none known)
Definition
Name: IntegerExpressionMembership
Canonical name: Integer Expression Membership
Reference: Garey & Johnson, Computers and Intractability, A7 AN18
Mathematical definition:
INSTANCE: Integer expression e over the operations ∪ and +, where if n ∈ Z^+, the binary representation of n is an integer expression representing n, and if f and g are integer expressions representing the sets F and G, then f ∪ g is an integer expression representing the set F ∪ G and f + g is an integer expression representing the set {m + n: m ∈ F and n ∈ G}, and a positive integer K.
QUESTION: Is K in the set represented by e?
Variables
- Count:
num_union_nodes— the number ofUnionnodes in the expression tree. - Per-variable domain: Binary (2 choices per union node: 0 = left branch, 1 = right branch).
- Meaning: Each variable corresponds to one
Unionnode in the expression tree and selects which branch to follow. Given a full assignment of all union choices, the expression collapses to a chain ofSumandAtomnodes that evaluates to a single integer. The problem is satisfiable (Or(true)) iff there exists an assignment of union choices such that the resulting integer equals the target K. dims():vec![2; num_union_nodes]Value:Or(feasibility/decision problem)
Schema (data type)
Type name: IntegerExpressionMembership
Variants: none
| Field | Type | Description |
|---|---|---|
expression |
IntExpr |
Integer expression tree over ∪ and + operations |
target |
u64 |
Positive integer K to test for membership |
Where IntExpr is a recursive type:
Atom(u64)-- a positive integer literalUnion(Box<IntExpr>, Box<IntExpr>)-- set union F ∪ GSum(Box<IntExpr>, Box<IntExpr>)-- Minkowski sum {m+n : m ∈ F, n ∈ G}
Size fields (getter methods):
| Getter | Type | Description |
|---|---|---|
expression_size |
usize |
Total number of nodes in the expression tree |
num_union_nodes |
usize |
Number of Union nodes (= number of variables) |
num_atoms |
usize |
Number of Atom leaf nodes |
expression_depth |
usize |
Maximum depth of the expression tree |
Complexity
- Best known exact algorithm: Brute-force over all union branch choices. Each
Unionnode is a binary decision; enumerate all 2^d assignments (where d =num_union_nodes), evaluate each to a single integer, and check if any equals K. Time complexity:2^num_union_nodes(times polynomial overhead per evaluation). No specialized sub-exponential algorithm is known for this problem. - NP-completeness: Established by Stockmeyer and Meyer (1973) via reduction from SUBSET SUM. [Stockmeyer & Meyer, "Word Problems Requiring Exponential Time," STOC 1973, pp. 1-9; DOI: 10.1145/800125.804029.]
- Related complexity results: The INTEGER EXPRESSION INEQUIVALENCE problem (do two expressions denote different sets?) is Σ₂ᵖ-complete [Stockmeyer & Meyer, 1973; Stockmeyer, TCS 3:1-22, 1976]. Adding complementation (¬) makes both MEMBERSHIP and INEQUIVALENCE PSPACE-complete.
Specialization
- SUBSET SUM is a special case: given set {a_1, ..., a_n} and target B, the expression ({0} ∪ {a_1}) + ({0} ∪ {a_2}) + ... + ({0} ∪ {a_n}) with target B encodes the subset sum question (using a shifted encoding since atoms must be positive).
- INTEGER EXPRESSION INEQUIVALENCE (do two expressions denote different sets?) is Sigma_2^p-complete with ∪ and +.
- With ∪, +, and ¬: both MEMBERSHIP and INEQUIVALENCE become PSPACE-complete.
Extra Remark
Full book text:
INSTANCE: Integer expression e over the operations ∪ and +, where if n ∈ Z^+, the binary representation of n is an integer expression representing n, and if f and g are integer expressions representing the sets F and G, then f ∪ g is an integer expression representing the set F ∪ G and f + g is an integer expression representing the set {m + n: m ∈ F and n ∈ G}, and a positive integer K.
QUESTION: Is K in the set represented by e?
Reference: [Stockmeyer and Meyer, 1973]. Transformation from SUBSET SUM.
Comment: The related INTEGER EXPRESSION INEQUIVALENCE problem, "given two integer expressions e and f, do they represent different sets?" is NP-hard and in fact complete for Σ_2^p in the polynomial hierarchy ([Stockmeyer and Meyer, 1973], [Stockmeyer, 1976a], see also Section 7.2). If the operator "¬" is allowed, with ¬e representing the set of all positive integers not represented by e, then both the membership and inequivalence problems become PSPACE-complete [Stockmeyer and Meyer, 1973].
How to solve
- It can be solved by (existing) bruteforce. (Enumerate all 2^d union-branch assignments where d =
num_union_nodes. For each assignment, evaluate the expression to a single integer by collapsing unions to the chosen branch and computing sums. Check if any evaluation equals K.) -
It can be solved by reducing to integer programming.(Not planned. The natural ILP encoding would require exponentially many constraints to capture the recursive set structure.) - Other: For expressions of bounded depth, dynamic programming on reachable sums at each node. Pseudo-polynomial when atom values are small.
Example Instance
Input:
Expression: e = (2 ∪ 5) + (3 ∪ 7)
Target: K = 10
Analysis:
The set represented by (2 ∪ 5) is {2, 5}.
The set represented by (3 ∪ 7) is {3, 7}.
The Minkowski sum {2, 5} + {3, 7} = {2+3, 2+7, 5+3, 5+7} = {5, 9, 8, 12}.
Set = {5, 8, 9, 12}.
Is K = 10 in {5, 8, 9, 12}? NO.
Another example (YES answer):
Expression: e = (1 ∪ 4) + (3 ∪ 6) + (2 ∪ 5)
Target: K = 12
Set computation:
- {1, 4} + {3, 6} = {4, 7, 7, 10} = {4, 7, 10}
- {4, 7, 10} + {2, 5} = {6, 9, 9, 12, 12, 15} = {6, 9, 12, 15}
Is K = 12 in {6, 9, 12, 15}? YES ✓
Witness path: choose 4 from (1 ∪ 4), choose 6 from (3 ∪ 6), choose 2 from (2 ∪ 5). Sum = 4 + 6 + 2 = 12 = K.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status