Motivation
SIMULTANEOUS INCONGRUENCES (P221) from Garey & Johnson, A7 AN2. An NP-complete number-theoretic problem: given a collection of forbidden residue classes {(aᵢ, bᵢ)}, determine whether there exists an integer x that avoids all of them (x ≢ aᵢ mod bᵢ for each i). Related to covering systems in number theory. NP-complete by Stockmeyer and Meyer (1973) via reduction from 3SAT. Despite the simplicity of the question (find an integer outside a union of arithmetic progressions), the interaction of different moduli makes the problem intractable.
Associated reduction rules:
- R165: 3SAT → SimultaneousIncongruences (this model is the target)
Definition
Name: SimultaneousIncongruences
Reference: Garey & Johnson, Computers and Intractability, A7 AN2
Mathematical definition:
INSTANCE: Collection {(a₁, b₁), …, (aₙ, bₙ)} of ordered pairs of positive integers, with aᵢ ≤ bᵢ for 1 ≤ i ≤ n.
QUESTION: Is there an integer x such that x ≢ aᵢ (mod bᵢ) for all 1 ≤ i ≤ n?
This is a satisfaction (feasibility) problem: Value = Or.
Variables
- Count: 1 (the unknown integer x)
- Per-variable domain: lcm(b₁, …, bₙ) — by periodicity, it suffices to search one period of the combined modular system. Values 0, 1, …, lcm − 1.
- Meaning: The single variable represents the candidate integer x. The evaluate function checks whether x mod bᵢ ≠ aᵢ for all i.
dims() returns [lcm(b₁, …, bₙ)].
Note: The lcm can be exponential in the input bit-length (this is the source of NP-completeness). For small moduli the search is fast; for large moduli, brute-force may be impractical. The dims() contract is satisfied (lcm fits in usize for representable instances).
Schema (data type)
Type name: SimultaneousIncongruences
Variants: none
| Field |
Type |
Description |
Getter |
pairs |
Vec<(u64, u64)> |
Collection of (aᵢ, bᵢ) pairs; x ≢ aᵢ (mod bᵢ). Constraint: 1 ≤ aᵢ ≤ bᵢ. |
num_pairs() → self.pairs.len() |
Problem type: Satisfaction (feasibility)
Value type: Or
Complexity
- Decision complexity: NP-complete (Stockmeyer & Meyer, 1973; transformation from 3SAT).
- Best known exact algorithm: Brute-force search over x ∈ {0, …, lcm(b₁,…,bₙ) − 1}, checking all n conditions. Time O(lcm · n), pseudo-polynomial.
- Complexity string for
declare_variants!: "num_pairs" (per-candidate check is O(n); the search space lcm is data-dependent, not expressible as a simple getter)
- Special cases: For fixed moduli (all bᵢ bounded by a constant), polynomial. For moduli that form a covering system, the answer is always NO.
- References:
- [Stockmeyer & Meyer, 1973] L. J. Stockmeyer and A. R. Meyer, "Word problems requiring exponential time", STOC 1973, pp. 1-9.
Extra Remark
Full book text:
INSTANCE: Collection {(a_1,b_1), . . . , (a_n,b_n)} of ordered pairs of positive integers, with a_i <= b_i for 1 <= i <= n.
QUESTION: Is there an integer x such that, for 1 <= i <= n, x ≢ a_i (mod b_i)?
Reference: [Stockmeyer and Meyer, 1973]. Transformation from 3SAT.
How to solve
Example Instance
Positive example (YES):
n = 4 pairs: (2, 2), (1, 3), (2, 5), (3, 7)
Meaning: x ≢ 2 (mod 2), x ≢ 1 (mod 3), x ≢ 2 (mod 5), x ≢ 3 (mod 7).
lcm(2, 3, 5, 7) = 210. Search space: {0, …, 209}.
Solution search (first few candidates):
| x |
x mod 2 ≠ 0? |
x mod 3 ≠ 1? |
x mod 5 ≠ 2? |
x mod 7 ≠ 3? |
Result |
| 0 |
0 = 0 ✗ |
— |
— |
— |
Fail |
| 1 |
1 ≠ 0 ✓ |
1 = 1 ✗ |
— |
— |
Fail |
| 2 |
0 = 0 ✗ |
— |
— |
— |
Fail |
| 3 |
1 ≠ 0 ✓ |
0 ≠ 1 ✓ |
3 ≠ 2 ✓ |
3 = 3 ✗ |
Fail |
| 4 |
0 = 0 ✗ |
— |
— |
— |
Fail |
| 5 |
1 ≠ 0 ✓ |
2 ≠ 1 ✓ |
0 ≠ 2 ✓ |
5 ≠ 3 ✓ |
Pass |
Answer: Or(true). x = 5 satisfies all incongruences.
Verification: 5 mod 2 = 1 ≠ 0 ✓; 5 mod 3 = 2 ≠ 1 ✓; 5 mod 5 = 0 ≠ 2 ✓; 5 mod 7 = 5 ≠ 3 ✓.
Out of 210 candidates, 48 are solutions and 162 are non-solutions — good coverage for round-trip testing.
Negative example (NO — covering system):
n = 2 pairs: (1, 2), (2, 2)
- (1, 2): x ≢ 1 (mod 2) → x must be even
- (2, 2): x ≢ 0 (mod 2) → x must be odd
These two conditions are contradictory — no integer x can be both even and odd. Answer: Or(false).
Expected outcome: Or(true) for the primary example.
Reduction Rule Crossref
- R165: Satisfiability (3SAT) → SimultaneousIncongruences
Motivation
SIMULTANEOUS INCONGRUENCES (P221) from Garey & Johnson, A7 AN2. An NP-complete number-theoretic problem: given a collection of forbidden residue classes {(aᵢ, bᵢ)}, determine whether there exists an integer x that avoids all of them (x ≢ aᵢ mod bᵢ for each i). Related to covering systems in number theory. NP-complete by Stockmeyer and Meyer (1973) via reduction from 3SAT. Despite the simplicity of the question (find an integer outside a union of arithmetic progressions), the interaction of different moduli makes the problem intractable.
Associated reduction rules:
Definition
Name:
SimultaneousIncongruencesReference: Garey & Johnson, Computers and Intractability, A7 AN2
Mathematical definition:
INSTANCE: Collection {(a₁, b₁), …, (aₙ, bₙ)} of ordered pairs of positive integers, with aᵢ ≤ bᵢ for 1 ≤ i ≤ n.
QUESTION: Is there an integer x such that x ≢ aᵢ (mod bᵢ) for all 1 ≤ i ≤ n?
This is a satisfaction (feasibility) problem:
Value = Or.Variables
dims()returns[lcm(b₁, …, bₙ)].Note: The lcm can be exponential in the input bit-length (this is the source of NP-completeness). For small moduli the search is fast; for large moduli, brute-force may be impractical. The
dims()contract is satisfied (lcm fits in usize for representable instances).Schema (data type)
Type name:
SimultaneousIncongruencesVariants: none
pairsVec<(u64, u64)>num_pairs()→self.pairs.len()Problem type: Satisfaction (feasibility)
Value type:
OrComplexity
declare_variants!:"num_pairs"(per-candidate check is O(n); the search space lcm is data-dependent, not expressible as a simple getter)Extra Remark
Full book text:
INSTANCE: Collection {(a_1,b_1), . . . , (a_n,b_n)} of ordered pairs of positive integers, with a_i <= b_i for 1 <= i <= n.
QUESTION: Is there an integer x such that, for 1 <= i <= n, x ≢ a_i (mod b_i)?
Reference: [Stockmeyer and Meyer, 1973]. Transformation from 3SAT.
How to solve
Example Instance
Positive example (YES):
n = 4 pairs: (2, 2), (1, 3), (2, 5), (3, 7)
Meaning: x ≢ 2 (mod 2), x ≢ 1 (mod 3), x ≢ 2 (mod 5), x ≢ 3 (mod 7).
lcm(2, 3, 5, 7) = 210. Search space: {0, …, 209}.
Solution search (first few candidates):
Answer: Or(true). x = 5 satisfies all incongruences.
Verification: 5 mod 2 = 1 ≠ 0 ✓; 5 mod 3 = 2 ≠ 1 ✓; 5 mod 5 = 0 ≠ 2 ✓; 5 mod 7 = 5 ≠ 3 ✓.
Out of 210 candidates, 48 are solutions and 162 are non-solutions — good coverage for round-trip testing.
Negative example (NO — covering system):
n = 2 pairs: (1, 2), (2, 2)
These two conditions are contradictory — no integer x can be both even and odd. Answer: Or(false).
Expected outcome: Or(true) for the primary example.
Reduction Rule Crossref