Constraint propagation: domains, rules and fixed points
约束传播
Build an integer-bound propagation engine, prove what it preserves, and distinguish a stable worklist from a satisfiable model.
constraint-propagationAn inspection at slot 4 moves an earlier deadline
Four process milestones A, B, C and D use integer time slots. A must precede B by at least two slots, B must precede C by at least one, and D must follow C by at least one. C is fixed at slot 4; the other milestones initially allow any slot from 0 to 6.
C’s time immediately tells us that B can be no later than 3. That new upper bound tells us that A can be no later than 1. Nothing chose a value for A. One rule tightened B, which made another rule worth running again.
Constraint propagation repeatedly removes possibilities that cannot participate in a solution of the relevant constraints. A propagator performs one such inference; a propagation engine decides which propagator to run next. Schulte and Stuckey separate these roles in their model of propagation engines. Sections 2 and 3, 2006 preprint
The program below reduces the original 343 combinations to an interval box containing 8 combinations. Exactly 6 are valid schedules. This gap matters: a collection of remaining domains does not record every dependency between values.
Preserve solutions while domains shrink
A current domain store gives each variable its remaining values. Write when every domain in is a subset of its counterpart in . Thus a smaller store carries tighter restrictions. Any empty variable domain makes the Cartesian product empty; our implementation represents that failure by one canonical bottom value, None.
For a propagator associated with constraint , distinguish three properties:
The first is contraction: no values are added. The second is monotonicity: starting with less freedom cannot yield more freedom than propagation from a larger store. The third is solution preservation: the removed values destroy no solution of . Since a solution of the whole model satisfies each individual constraint, such steps preserve all global solutions too. These are separate obligations; a function that deletes every value is contracting and monotone but generally unsound. A function that changes nothing preserves solutions but may infer nothing useful. Schulte and Stuckey, section 2
A common fixed point satisfies for every installed propagator. On finite domains, strictly shrinking steps cannot continue forever. A schedule must also revisit every propagator that could still change the store. Repeating one inactive rule forever while ignoring another rule would not establish a common fixed point. Apt formalizes fairness and stabilization for monotone iterations. His information order reverses set inclusion; our convention therefore calls the result the greatest common fixed point below the initial store. Definitions 3 to 6, Theorem 7 and Corollary 8, 1998 preprint
Here is the short argument for independence from a fair execution order. Let be any common fixed point contained in the initial store. If , monotonicity gives . Induction keeps inside every intermediate store. When propagation finishes at a common fixed point, that result contains every such , so different fair schedules reach the same result. This conclusion assumes the same operators and initial store; it does not say their running times agree.
A fixed point describes the inference rules’ remaining power. It need not prove satisfiability. Even contraction, monotonicity and solution preservation alone do not guarantee that a singleton fixed point is a solution: the identity operator passes all three requirements. The two concrete operators below additionally reject every violating singleton assignment, so a nonempty all-singleton fixed point for this implementation is a solution.
Wake a rule when one of its input bounds changes
Represent an integer interval by (lower, upper), including every integer between the endpoints. For , values of X above cannot work, and values of Y below cannot work. Update both bounds using the incoming store:
The other endpoints stay unchanged. If a lower endpoint exceeds its upper endpoint, the constraint has no supporting pair in this box. For , a singleton Y forbids its value in X. An interval representation can remove that value directly only if it is an endpoint; the rule treats X and Y symmetrically. With X in [0,2] and Y fixed at 1, both endpoints of X are supported, so the interval remains [0,2] even though its interior value 1 has no support.
This is integer bounds consistency, specifically bounds(): each endpoint has a supporting integer assignment within the other intervals for that individual constraint. It is weaker than demanding support for every retained value. Since our stores have no holes, bounds(D) and bounds() use the same possible supporting values here. This does not identify either notion with real-valued support or claim they coincide on arbitrary sparse domains. Choi and colleagues distinguish those definitions explicitly. Definitions 1 and 3 to 5
The complete Python 3.10+ example keeps a queue of rule indices and a set to prevent duplicate pending entries. Every rule is initially pending. If a variable’s interval changes, all rules mentioning it are queued, including the rule just executed. This conservative policy avoids relying on an idempotence optimization. A rule outside the queue has already been checked since its inputs last changed. An empty queue therefore certifies a common fixed point.
calls counts every propagator invocation, including calls that do nothing or discover failure. changes counts invocations that produce a strictly smaller, still nonempty box. It counts neither deleted values nor individual endpoint edits. max_calls is an invocation budget, excluding validation and queue construction. budget reports pending work; fixedpoint reports an empty queue; failure reports an empty box. The function validates and copies its input. Names must be distinct within a rule; Boolean endpoints, offsets, indices and budgets are rejected. revise is an internal helper for already validated, nonempty boxes.
from collections import deque
def revise(box, rule):
# Internal helper: validated, nonempty integer intervals; two distinct names.
kind, x, y = rule[:3]
lx, ux = box[x]
ly, uy = box[y]
if kind == 'le': # x + offset <= y
offset = rule[3]
left = (lx, min(ux, uy - offset))
right = (max(ly, lx + offset), uy)
else: # x != y; remove a forbidden value only when it is an endpoint.
left = (lx + (ly == uy == lx), ux - (ly == uy == ux))
right = (ly + (lx == ux == ly), uy - (lx == ux == uy))
if left[0] > left[1] or right[0] > right[1]:
return None
return {x: left, y: right}
def propagate(bounds, rules, policy='fifo', order=None, max_calls=None):
if type(bounds) is not dict or any(type(v) is not str or not v for v in bounds):
raise ValueError('bounds must map nonempty names to integer pairs')
box = {v: tuple(pair) for v, pair in bounds.items()}
if any(len(pair) != 2 or any(type(x) is not int for x in pair) for pair in box.values()):
raise ValueError('each interval needs two integers, not booleans')
rules = tuple(tuple(rule) for rule in rules)
for rule in rules:
if (len(rule) not in (3, 4) or rule[0] not in ('le', 'ne')
or len(rule) != (4 if rule[0] == 'le' else 3)
or any(type(v) is not str or v not in box for v in rule[1:3])
or rule[1] == rule[2]
or (rule[0] == 'le' and type(rule[3]) is not int)):
raise ValueError('use (le, x, y, integer offset) or (ne, x, y), x != y')
if policy not in ('fifo', 'lifo'):
raise ValueError('policy must be fifo or lifo')
order = tuple(range(len(rules))) if order is None else tuple(order)
if (any(type(i) is not int for i in order) or len(order) != len(rules)
or set(order) != set(range(len(rules)))):
raise ValueError('order must be a permutation of rule indices')
if max_calls is not None and (type(max_calls) is not int or max_calls < 0):
raise ValueError('max_calls must be None or a nonnegative integer')
calls = changes = 0
if any(lo > hi for lo, hi in box.values()):
return dict(status='failure', bounds=None, calls=0, changes=0)
watchers = {v: [] for v in box}
for i, rule in enumerate(rules):
for v in rule[1:3]:
watchers[v].append(i)
todo, queued = deque(order), set(order)
while todo:
if max_calls is not None and calls >= max_calls:
return dict(status='budget', bounds=box, calls=calls, changes=changes)
i = todo.popleft() if policy == 'fifo' else todo.pop()
queued.remove(i)
calls += 1
proposed = revise(box, rules[i])
if proposed is None:
return dict(status='failure', bounds=None, calls=calls, changes=changes)
changed = [v for v in proposed if proposed[v] != box[v]]
if changed:
changes += 1
box.update(proposed)
for v in changed:
for j in watchers[v]:
if j not in queued:
todo.append(j)
queued.add(j)
return dict(status='fixedpoint', bounds=box, calls=calls, changes=changes)
BOUNDS = {'A': (0, 6), 'B': (0, 6), 'C': (4, 4), 'D': (0, 6)}
RULES = (('le', 'A', 'B', 2), ('le', 'B', 'C', 1), ('le', 'C', 'D', 1))
for policy in ('fifo', 'lifo'):
print(policy, propagate(BOUNDS, RULES, policy))
for cap in (0, 1, 5, 6, 7):
print('cap', cap, propagate(BOUNDS, RULES, max_calls=cap))
print('interior:', propagate({'X': (0, 2), 'Y': (1, 1)}, [('ne', 'X', 'Y')]))
print('inconsistent:', propagate({'X': (0, 2), 'Y': (0, 2)},
[('le', 'X', 'Y', 0), ('le', 'Y', 'X', 0), ('ne', 'X', 'Y')]))
For the displayed rule order, both policies return A [0,1], B [2,3], C [4,4] and D [5,6]:
The table uses rule indices 0, 1 and 2. Narrowings count calls that produce a smaller, still nonempty box.
| Policy | Invocation order | Calls | Narrowings |
|---|---|---|---|
| FIFO | 0, 1, 2, 0, 1, 2, 0 | 7 | 4 |
| LIFO | 2, 2, 1, 1, 0, 1, 0 | 7 | 3 |
The first policy tightens A twice because B’s deadline arrives later. The second settles B before running the A/B rule. These two runs happen to use the same number of calls; the change count records how reductions were grouped, not propagation quality. The legal (A,B) pairs are (0,2), (0,3) and (1,3), with either D = 5 or D = 6. The remaining pair (1,2) violates the two-slot lag.
At FIFO budgets 5 and 6, the returned bounds already equal the eventual result, but pending rules remain unchecked. The status is still budget. Budget 7 permits the final no-change call and returns fixedpoint, even though the budget has been reached exactly. With no rules, budget 0 immediately returns fixedpoint; an initially empty interval returns failure before any call. With zero variables and no rules, the store {} describes the one empty assignment.
A queue can empty while the model is impossible
Let X and Y both start in [0,2], and install three separate rules: , , and . The first two together require equality, contradicting the third. Yet no individual bounds rule changes either interval, so the program returns a nonempty fixed point after three calls. Full enumeration of the nine pairs finds no solution.
This implementation keeps these rules separate, including rules on the same variable pair. A propagator for their conjunction would detect the contradiction immediately. The common fixed point is therefore relative to a specified propagator set and constraint decomposition. It is not necessarily the tightest interval box enclosing all global solutions. Arc consistency examines support filtering for explicit binary relations, including what changes when relations are combined.
Why does the worklist terminate? For initially nonempty intervals, set . Each nonempty narrowing call reduces this nonnegative integer potential by at least one. Each such call can add at most distinct rules to a queue holding at most entries. Thus at most invocations can occur before a fixed point or failure. No-change calls add nothing. This also rules out permanent starvation in either of the finite FIFO/LIFO implementations here; arbitrary scheduling schemes still require their own fairness argument.
With variables, binary rules and actual invocations, validation and storage use units under unit-cost labels and integer arithmetic, with expected constant-time hash operations. Queue processing has the conservative bound , because each narrowing call scans the changed variables’ watcher lists. This bound depends on numeric interval widths, which may be exponentially larger than their bit encoding; it is not a polynomial-in-input-bits guarantee. Large-integer arithmetic has additional bit costs. The code stores interval endpoints rather than enumerating their contents; enumeration belongs to the small-instance tests.
Forward checking invokes filtering after a search decision. This example only propagates the supplied root store. A search procedure that narrows a domain speculatively must later restore every affected domain, using a trail or equivalent saved state; clearing a queue alone does not undo deductions. Propagation removes impossible candidates under a fixed model. It neither learns a model from observations nor optimizes a preference objective.
Check the bounds and the stopping claim separately
1. Derive the final intervals in the milestone example and count the legal schedules.
Answer: C = 4 makes B at most 3 and D at least 5. A starts at least 0, so B is at least 2. B at most 3 makes A at most 1. The remaining intervals are A [0,1], B [2,3], C [4,4], D [5,6]. Their product has 8 tuples, but only the three (A,B) pairs listed above satisfy the lag; two choices of D give 6 schedules. Propagation preserved every original solution without selecting one.
2. X is in [0,2], Y is fixed at 1, and X ≠ Y. Why can a bounds-consistent interval still contain an unsupported value?
Answer: X’s endpoints 0 and 2 both differ from 1, and Y = 1 has a supporting X value. The interior X = 1 has no support. Removing it requires the sparse domain {0,2}, which one contiguous interval cannot represent. Bounds consistency checks endpoints; domain consistency also checks interior values.
3. A budget-6 run returns the eventual bounds. May the interface call it a fixed point? Does the three-rule X/Y fixed point prove a solution exists?
Answer: The bounded run still has pending work, so this interface reports budget; matching a separately computed result does not mean that run performed the certification. The X/Y rules reach a certified common fixed point but have no solution: the two inequalities imply X = Y, which violates X ≠ Y. The former issue is incomplete execution, the latter incomplete inference.
4. Why should execution order preserve the final bounds, and why could adding a propagator change them?
Answer: For the same monotone contracting operators, fair completion yields the greatest common fixed point below the initial store. Every common fixed point remains contained in each intermediate store by the induction in the theory section. Adding a sound operator changes which stores are common fixed points and may tighten the result or find failure. It must still preserve solutions. If search later retracts an assumed bound, restoring only that endpoint can leave deductions from the abandoned branch behind; all affected domains need restoration.
Verify the operator before measuring its queue
The tests compare each local rule with an independent enumeration of its satisfying pairs and their interval hull, then check contraction, solution preservation, monotonicity and idempotence on small boxes. A second oracle applies those enumerated hulls in synchronous rounds rather than using the worklist. Random models are compared across FIFO/LIFO and several initial orders, with full solution sets checked before and after propagation. The contradiction and unsupported-interior examples are executed tests, not claims inferred from an empty queue.
The queue, bounded API, milestone data and test code are original. The cited preprints provide the operator model, fixed-point reasoning and consistency terminology; no upstream implementation or benchmark is reproduced. To compare a stronger propagator, hold the constraints and initial domains fixed, then report both the residual domains and the work needed to obtain them. A faster queue and a stronger inference rule answer different engineering questions.
Make a prediction, then check
X and Y both have [0,2]. Separate propagation of X≤Y, Y≤X and X≠Y empties the queue without changing domains. What follows?
Learning objectives
- Distinguish contraction, monotonicity and solution preservation, explain finite fair propagation's greatest common fixed point for specified operators, and identify why it need not imply satisfiability.
- Implement integer-interval precedence and disequality propagators, auditing endpoint support, worklist scheduling, invocation budgets, empty-domain failure and restoration obligations in search.
Prerequisites & connections
Explore related knowledge →References
- Efficient Constraint Propagation Engines, arXiv:cs/0611009v1
Christian Schulte; Peter J. Stuckey · 2006 - The Essence of Constraint Propagation, arXiv:cs/9811024v1
Krzysztof R. Apt · 1998 - Finite Domain Bounds Consistency Revisited, arXiv:cs/0412021v1
Chiu Wo Choi; Warwick Harvey; Jimmy Ho-Man Lee; Peter J. Stuckey · 2004
Version1 · Editorial status: Recorded technical checks completed
View technical check record (AI)
Codex · 2026-09-05 · Codex technical check: primary-source locations, original runnable models, independent finite-state oracles, bilingual review and second-agent cross-checks; not independent human peer review.
- Author AI technical check: reread both complete articles, aligning two display equations, the complete Python block, six stable anchors and four answered exercises. Both code blocks are byte-identical to example.py. Edited with the repository's pinned English/Chinese Humanizer guides and passed the targeted stock-phrase scan; Chinese parenthetical term emphasis uses strong. This is not human peer review.
- Eight tests passed: 1,350 single-rule boxes exactly match interval hulls of independently enumerated supporting pairs, with idempotence and solution preservation checked; 29,400 nested small-box cases check monotonicity. For 300 random two-to-four-variable models, FIFO/LIFO and three initial orders yield 1,800 runs compared with synchronous hull iteration that does not use the worklist and with full solution sets before/after propagation.
- The main instance starts with 343 candidate tuples, retains eight interval combinations and has six actual solutions. All six initial rule orders × two scheduling policies reach the same bounds. Default FIFO calls 0,1,2,0,1,2,0; LIFO calls 2,2,1,1,0,1,0: seven calls each, with four/three nonempty narrowing calls. Checked that caps 5/6 already have final bounds but report budget, cap 7 reports fixedpoint exactly, plus zero-budget rule-free models, zero variables, initial empty intervals and singleton contradictions.
- Independent full enumeration checks two limitations: X∈[0,2], Y=1, X≠Y retains unsupported interior value 1; separate X≤Y, Y≤X and X≠Y propagators reach a nonempty fixed point although all nine pairs are invalid. The article states that same-pair rules are not combined, confines D/Z support coincidence to dense integer intervals, avoids inferring singleton satisfiability from arbitrary solution-preserving operators, and explains restoration of every affected search domain.
- Checked H as the sum of initial interval widths, the m(1+H) invocation bound and conservative O(1+T+mH) queue-processing bound; observed call/narrowing counts satisfy these bounds on 300 random models. Input/storage O(1+n+m) is qualified by expected hash costs, integer bit costs and widths potentially far larger than bit encodings. Both MDX files compiled individually with remark-math and KaTeX strict:error/throwOnError; no whole-site check/build or publication-data edits were made.
- Reread both complete articles, program, eight tests and metadata. Checked separate contraction/monotonicity/preservation obligations, the identity-operator checking counterexample, the finite greatest-common-fixed-point inclusion proof, canonical None failure, off-queue invariants, conservative self-requeue, finite FIFO/LIFO termination and budget-versus-completion status.
- Built a separate fixed-point reference without the author’s revise or synchronous propagation: enumerate every subinterval box inside the initial box, directly enumerate integer witnesses for each endpoint, and take the coordinate hull of all common fixed boxes. All4,608 models matched under18,432 schedule/initial-order runs;23,820 budget prefixes preserved complete solutions and respected budget versus final failure/fixedpoint statuses.
- Separately enumerated21,952 main-example subboxes;18 common fixed boxes have greatest hull A[0,1]/B[2,3]/C=4/D[5,6]. There are six full solutions and eight residual combinations. Independently logged calls to confirm FIFO seven calls/four narrowings and LIFO seven calls/three narrowings; caps5/6 remain budget despite final bounds, and cap7 is fixedpoint.
- Checked that le produces the integer interval hull of each relation’s solution projections and ne contracts only endpoints excluded by a singleton partner. Dense integer ranges make bounds(D) and bounds(Z) support sets coincide without equating them with domain consistency or arbitrary real support. Full enumeration reconfirmed unsupported interior values and a nonempty unsatisfiable three-rule fixed point; keeping same-pair rules separate is explicitly distinguished from merged AC relations.
- Identified missing fixed overhead in O(n+m) for zero variables/rules and O(T+mH) for zero-call budgets. The author changed them to O(1+n+m) and O(1+T+mH); reread both locales and metadata. The m(1+H) call bound and at-most-H nonempty changes follow from the stated potential, all independent model runs meet them, and numeric-width versus bit-cost limitations are correctly qualified.
- Reran all eight tests on the final snapshot. Independently compiled with current project math plugins, remark-math and strict:error/throwOnError:true KaTeX, then actually rendered both locales via React renderToStaticMarkup: two display equations and four strong answer labels each, correct Chinese parenthetical strong, no literal ** or KaTeX errors. Both code blocks equal example.py. No author files/repository were changed; no whole-site check/build or browser visual QA ran. This is second-agent AI technical review, not human peer review.
- Promotion preserves full prose, equations, program and exercises. Test loading alone changes from temporary drafts to repository articles; implementation and oracle logic are unchanged. Final review binds both MDX SHA-256 hashes.
- After viewing the actual 390×844 mobile screenshot, shortened scheduling-table headers and moved the original rule-index and nonempty-narrowing-call meaning into adjacent prose. FIFO/LIFO order and every number are unchanged; both locales align, with no equation, program or exercise changes.
Source locations checked:
- Efficient Constraint Propagation Engines, arXiv:cs/0611009v1 · Read PDF section 2, printed pages 3–5, extracted lines 90–192, on finite domains, contraction/monotonicity, correctness versus checking, mutual fixed points and bounds notions. Read section 3 and Figure 2 text, printed pages 6–7, lines 221–261, on pending-propagator invariants and input-change wakeups; read section 6, printed page 25, lines 1044–1054, on FIFO fairness and LIFO. Did not derive claims from the paper's performance experiments.
- The Essence of Constraint Propagation, arXiv:cs/9811024v1 · Read arXiv PDF pages 4–8: Definition 3 at extracted lines 110–120 for fair runs; Definition 4 at 121–124 for inflationary, monotonic and idempotent functions; finite-chain and reversed-inclusion setup at 136–161; Theorem 7 at 192–204 with proof 205–242, and Corollary 8 at 247–256. The article explicitly reverses Apt's information ordering before calling the finite result greatest under inclusion and supplies its own short invariant proof.
- Finite Domain Bounds Consistency Revisited, arXiv:cs/0412021v1 · Read arXiv abstract/submission history and PDF page 1 header for v1/date; PDF section 2, printed pages 2–3, lines 49–81 for interval domains and domain consistency; section 3, printed page 3, lines 88–106 for Definitions 3–5 of bounds(D), bounds(Z) and bounds(R). The article's interval stores are dense integer ranges, explaining coincidence of D/Z supporting values here while retaining the distinction from every-value support.
- Efficient Constraint Propagation Engines, arXiv:cs/0611009v1 · Independently opened arXiv cs/0611009v1 PDF and read §2, printed pp.3–5 (extracted lines90–192): domain inclusion, contraction/monotonicity, correctness versus checking, greatest mutual fixed points, domain/bounds(Z)/bounds(R) definitions. Read §3/Figure2 and basic input-change propagation, printed pp.6–7 (lines207–304), including the off-queue fixed-point invariant. Did not independently verify §6 scheduling experiments or any performance figures, and did not inspect the later2008 journal version. Readable extracted text was used; no page-scan visual check claimed.
- The Essence of Constraint Propagation, arXiv:cs/9811024v1 · Independently opened arXiv cs/9811024v1 PDF and read Definitions3–6 (printed pp.4–5; extracted lines110–161), finite-chain condition, reverse-set-inclusion information order, Theorem7 and its proof (printed pp.6–7; lines192–242), and Corollary8 (printed p.8; lines247–256). Also read the generic worklist invariant and finite-chain termination discussion (lines390–428). Checked that the draft reverses the order and supplies a finite inclusion-based invariant proof, and does not claim unrestricted LIFO fairness on infinite domains.
- Finite Domain Bounds Consistency Revisited, arXiv:cs/0412021v1 · Explicit-version abs/pdf URLs returned Internal Error in this review. Independently opened the unversioned author-submitted arXiv PDF https://arxiv.org/pdf/cs/0412021 and abstract https://arxiv.org/abs/cs/0412021 instead. PDF page1 header states cs/0412021v1 and6Dec2004 while body date is3Aug2018; do not conflate them. Read §2 (printed pp.2–3,lines49–81), Definitions1/3/4/5 (printed p.3,lines75–106) and Proposition8 (printed p.4,lines143–155) for domain/bounds(D)/bounds(Z)/bounds(R) and dense-range D/Z equivalence. No source numerical example was used as the independent test oracle.
Related topics