Repository navigation
XCSP3: handle reified constraints (#1248) - #1257
Merged
Merged
Conversation
- reifiedBy, hreifiedFrom and hreifiedTo are no longer ignored - a callback can deal with the reification itself: this is done for intension, sum, count, nValues, minimum, maximum, atLeast and atMost - otherwise, the constraints posted by the callback are reified, unless they rely on auxiliary variables or clauses: then, the reification is refused - the reification of slide and logic meta-constraints is refused - element with a list and a constant condition is stated on views
Contributor
|
This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again. |
ArthurGodet
approved these changes
Oct 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
XCSP3: handle reified constraints
Closes #1248 (item 10, the last one: the other items were fixed by #1254 and #1255).
Problem
The attributes
reifiedBy,hreifiedFromandhreifiedTowere ignored: the constraint was posted alone.XParserreads them, but xcsp3-tools 2.5 does not pass them to any callback.On the instance of the issue (
elementwith a list and a value,reifiedBy="r"), this gave 38 assignments, 19 of them wrong, instead of the 27 expected ones.How it works
XCSPParseroverridesloadCtr. For a reified constraint:reify(BoolVar)with the truth value of the constraint.reifyWith,impliedByorimplies).Step 3 is refused with a
ParserExceptionwhen it would be wrong: the callback introduced an auxiliary variable (views and constants are fine), added clauses, or posted nothing. So a reification is never silently ignored.Semantics, as in the XCSP3 specifications:
reifiedByisr ⇔ c,hreifiedFromisr ⇒ c,hreifiedToisr ⇐ c.Coverage
intension,sum,count,nValues,minimum,maximum,atLeast,atMost, with any kind of condition (relation with a constant or a variable, interval, set)allDifferent,allEqual,extension,ordered,lex,element,cardinality,channel,noOverlap(tested); other constraints as long as the guard above holdsregular,slideand logic meta-constraints (and,or,not...), and any callback that relies on auxiliary variables without callingreifyFor the callbacks of the first row, the result of the function goes into a fresh variable, posted as usual, and the condition on this result is reified (
resultVar).Other change
elementwith a list and a condition on a constant is now stated on Boolean views ("at least one variable satisfies the condition"), instead of anelementconstraint with a free index variable. This makes it reifiable.Tests
In
XCSPParserTest, against brute force (same solutions, each found once):ParserException;elementwith a condition, not reified;iffandxorin anintension, reified or not (parser-level test for Fix n-ary iff and xor expressions (#1248) #1255).The
xcspgroup passes: 154 tests, no failure.Limits
0..2.slideand logic meta-constraints are refused, not handled.s UNKNOWNunless the log level is INFO, where it iss UNSUPPORTED.