Skip to content

Commit

Permalink
fix: essential input selection, updating assigment for inputs only
Browse files Browse the repository at this point in the history
  • Loading branch information
saraseidl committed Aug 3, 2021
1 parent 811537b commit 06de1b4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/engine/symbolic_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,10 @@ impl<'a> Formula for FormulaView<'a> {
!matches!(self.data_flow[NodeIndex::new(sym)], Symbol::Operator(_))
}

fn is_input(&self, sym: SymbolId) -> bool {
matches!(self.data_flow[NodeIndex::new(sym)], Symbol::Input(_))
}

fn traverse<V, R>(&self, n: SymbolId, visit_map: &mut HashMap<SymbolId, R>, v: &mut V) -> R
where
V: FormulaVisitor<R>,
Expand Down
2 changes: 2 additions & 0 deletions src/solver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ pub trait Formula: Index<SymbolId, Output = Symbol> {

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

fn is_input(&self, sym: SymbolId) -> bool;

fn traverse<V, R>(&self, n: SymbolId, visit_map: &mut HashMap<SymbolId, R>, v: &mut V) -> R
where
V: FormulaVisitor<R>,
Expand Down
12 changes: 7 additions & 5 deletions src/solver/monster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@ fn select<F: Formula>(
(rhs, lhs, OperandSide::Rhs)
} else if is_constant(f, rhs) {
(lhs, rhs, OperandSide::Lhs)
} else if is_essential(f, lhs, OperandSide::Lhs, rhs, t, ab) {
} else if is_essential(f, idx, lhs, OperandSide::Lhs, t, ab) {
(lhs, rhs, OperandSide::Lhs)
} else if is_essential(f, rhs, OperandSide::Rhs, lhs, t, ab) {
} else if is_essential(f, idx, rhs, OperandSide::Rhs, t, ab) {
(rhs, lhs, OperandSide::Rhs)
} else if random() {
(rhs, lhs, OperandSide::Rhs)
Expand Down Expand Up @@ -440,15 +440,15 @@ fn value<F: Formula>(

fn is_essential<F: Formula>(
formula: &F,
n: SymbolId,
this: SymbolId,
on_side: OperandSide,
other: SymbolId,
t: BitVector,
ab: &[BitVector],
) -> bool {
let ab_nx = ab[this];

match &formula[other] {
match &formula[n] {

This comment has been minimized.

Copy link
@saraseidl

saraseidl Aug 9, 2021

Author Collaborator

this operand of n is essential, if there exists no inverse value for the other operand of n.

This comment has been minimized.

Copy link
@mstarzinger

mstarzinger Aug 17, 2021

Collaborator

Wow, how did this ever work before? Nice catch!

Symbol::Operator(op) => !is_invertible(*op, ab_nx, t, on_side.other()),
// TODO: not mentioned in paper => improvised. is that really true?
Symbol::Constant(_) | Symbol::Input(_) => false,
Expand Down Expand Up @@ -637,7 +637,9 @@ fn sat<F: Formula>(
n = nx;
}

update_assignment(formula, &mut ab, n, t);
if formula.is_input(n) {
update_assignment(formula, &mut ab, n, t);
}
}

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

2 comments on commit 06de1b4

@saraseidl
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Path Selection
This fixes the essential input check.

Down-Propagation
Only fully extended paths that lead to an input node result in an update of the assignment (nothing to do for constants).

@mstarzinger
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit LGTM.

Please sign in to comment.