Skip to content

Commit

Permalink
add Clause::watches
Browse files Browse the repository at this point in the history
  • Loading branch information
shnarazk committed Jan 12, 2025
1 parent 92e70ae commit 07efd88
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/assign/propagate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,7 @@ impl PropagateIF for AssignStack {
//
//## normal clause loop
//
// TODO: check whether dead clauses exists. If so, run `retain()` after propagation.
let mut source = cdb.watch_cache_iter(propagating);
'next_clause: while let Some((cid, mut cached)) = source
.next()
Expand All @@ -444,6 +445,9 @@ impl PropagateIF for AssignStack {
"dead clause in propagation: {:?}",
cdb.is_garbage_collected(cid),
);
if cdb[cid].watches(propagating) {
continue;
}
debug_assert!(!self.var[cached.vi()].is(FlagVar::ELIMINATED));
#[cfg(feature = "maintain_watch_cache")]
debug_assert!(
Expand Down
3 changes: 3 additions & 0 deletions src/cdb/clause.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,9 @@ impl ClauseIF for Clause {
}
false
}
fn watches(&self, lit: Lit) -> bool {
self.lits[0] == lit || self.lits[1] == lit
}
fn len(&self) -> usize {
self.lits.len()
}
Expand Down
2 changes: 2 additions & 0 deletions src/cdb/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ pub trait ClauseIF {
fn contains(&self, lit: Lit) -> bool;
/// check clause satisfiability
fn is_satisfied_under(&self, asg: &impl AssignIF) -> bool;
/// return `true` if the clause is watching the literal
fn watches(&self, lit: Lit) -> bool;
/// return an iterator over its literals.
fn iter(&self) -> Iter<'_, Lit>;
/// return the number of literals.
Expand Down

0 comments on commit 07efd88

Please sign in to comment.