Skip to content

Commit 14868d5

Browse files
committed
fix: give reason to root-level propagation in nogood propagator (#124)
When preprocessing a nogood, if it becomes a unit nogood, the propagator would assign the negation of the predicate with an empty reason. However, from the perspective of the proof log, that is invalid as the input to the propagator was a non-unit nogood.
1 parent 0781357 commit 14868d5

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

pumpkin-solver/src/propagators/nogoods/nogood_propagator.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use crate::basic_types::moving_averages::MovingAverage;
1010
use crate::basic_types::ConstraintOperationError;
1111
use crate::basic_types::Inconsistency;
1212
use crate::basic_types::PropositionalConjunction;
13-
use crate::conjunction;
1413
use crate::containers::KeyedVec;
1514
use crate::engine::conflict_analysis::Mode;
1615
use crate::engine::nogoods::Lbd;
@@ -1001,6 +1000,11 @@ impl NogoodPropagator {
10011000
return Ok(());
10021001
}
10031002

1003+
// After preprocessing the nogood may propagate. If that happens, there is no reason for
1004+
// the propagation which breaks the proof logging. Therefore, we keep the original nogood
1005+
// here so we can construct a reason for the propagation later.
1006+
let mut input_nogood = nogood.clone();
1007+
10041008
// Then we pre-process the nogood such that (among others) it does not contain duplicates
10051009
Self::preprocess_nogood(&mut nogood, context);
10061010

@@ -1015,8 +1019,12 @@ impl NogoodPropagator {
10151019
// return success
10161020
Ok(())
10171021
} else {
1022+
// Get the reason for the propagation.
1023+
input_nogood.retain(|&p| p != nogood[0]);
1024+
10181025
// Post the negated predicate at the root to respect the nogood.
1019-
let result = context.post_predicate(!nogood[0], conjunction!());
1026+
let result = context
1027+
.post_predicate(!nogood[0], PropositionalConjunction::from(input_nogood));
10201028
match result {
10211029
Ok(_) => Ok(()),
10221030
Err(_) => {

0 commit comments

Comments
 (0)