Skip to content

Commit 06de1b4

Browse files
committed
fix: essential input selection, updating assigment for inputs only
1 parent 811537b commit 06de1b4

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

src/engine/symbolic_state.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,10 @@ impl<'a> Formula for FormulaView<'a> {
411411
!matches!(self.data_flow[NodeIndex::new(sym)], Symbol::Operator(_))
412412
}
413413

414+
fn is_input(&self, sym: SymbolId) -> bool {
415+
matches!(self.data_flow[NodeIndex::new(sym)], Symbol::Input(_))
416+
}
417+
414418
fn traverse<V, R>(&self, n: SymbolId, visit_map: &mut HashMap<SymbolId, R>, v: &mut V) -> R
415419
where
416420
V: FormulaVisitor<R>,

src/solver/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ pub trait Formula: Index<SymbolId, Output = Symbol> {
155155

156156
fn is_operand(&self, sym: SymbolId) -> bool;
157157

158+
fn is_input(&self, sym: SymbolId) -> bool;
159+
158160
fn traverse<V, R>(&self, n: SymbolId, visit_map: &mut HashMap<SymbolId, R>, v: &mut V) -> R
159161
where
160162
V: FormulaVisitor<R>,

src/solver/monster.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,9 @@ fn select<F: Formula>(
154154
(rhs, lhs, OperandSide::Rhs)
155155
} else if is_constant(f, rhs) {
156156
(lhs, rhs, OperandSide::Lhs)
157-
} else if is_essential(f, lhs, OperandSide::Lhs, rhs, t, ab) {
157+
} else if is_essential(f, idx, lhs, OperandSide::Lhs, t, ab) {
158158
(lhs, rhs, OperandSide::Lhs)
159-
} else if is_essential(f, rhs, OperandSide::Rhs, lhs, t, ab) {
159+
} else if is_essential(f, idx, rhs, OperandSide::Rhs, t, ab) {
160160
(rhs, lhs, OperandSide::Rhs)
161161
} else if random() {
162162
(rhs, lhs, OperandSide::Rhs)
@@ -440,15 +440,15 @@ fn value<F: Formula>(
440440

441441
fn is_essential<F: Formula>(
442442
formula: &F,
443+
n: SymbolId,
443444
this: SymbolId,
444445
on_side: OperandSide,
445-
other: SymbolId,
446446
t: BitVector,
447447
ab: &[BitVector],
448448
) -> bool {
449449
let ab_nx = ab[this];
450450

451-
match &formula[other] {
451+
match &formula[n] {
452452
Symbol::Operator(op) => !is_invertible(*op, ab_nx, t, on_side.other()),
453453
// TODO: not mentioned in paper => improvised. is that really true?
454454
Symbol::Constant(_) | Symbol::Input(_) => false,
@@ -637,7 +637,9 @@ fn sat<F: Formula>(
637637
n = nx;
638638
}
639639

640-
update_assignment(formula, &mut ab, n, t);
640+
if formula.is_input(n) {
641+
update_assignment(formula, &mut ab, n, t);
642+
}
641643
}
642644

643645
let assignment: Assignment = formula.symbol_ids().map(|i| (i, ab[i])).collect();

0 commit comments

Comments
 (0)