Skip to content

Commit

Permalink
feat(bdd): implemented substitute
Browse files Browse the repository at this point in the history
  • Loading branch information
AurumTheEnd committed May 10, 2024
1 parent 33df18b commit b1e9f5a
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/bdd/traits/boolean_function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,29 @@ impl<T: Debug + Clone + Ord> BooleanFunction<T> for Bdd<T> {
self.restrict_and_prune_map(valuation, &new_bdd)

Check warning on line 74 in src/bdd/traits/boolean_function.rs

View check run for this annotation

Codecov / codecov/patch

src/bdd/traits/boolean_function.rs#L74

Added line #L74 was not covered by tests
}

fn substitute(&self, _mapping: &BTreeMap<T, Self>) -> Self {
fn substitute(&self, mapping: &BTreeMap<T, Self>) -> Self {

Check warning on line 77 in src/bdd/traits/boolean_function.rs

View check run for this annotation

Codecov / codecov/patch

src/bdd/traits/boolean_function.rs#L77

Added line #L77 was not covered by tests
// Bdd.substitute exists, but assumes all BDDs share input variables (we need to extend)
// and does not eliminate the substituted variable from inputs afterward (we need to prune).

// Bdd.substitute currently assumes that the substituted functions does not depend on the
// substituted variables. This will be solved in lib-bdd, we can just panic for now.
todo!()
if mapping

Check warning on line 83 in src/bdd/traits/boolean_function.rs

View check run for this annotation

Codecov / codecov/patch

src/bdd/traits/boolean_function.rs#L83

Added line #L83 was not covered by tests
.iter()
.any(|(key, value_bdd)| value_bdd.inputs.contains(key))

Check warning on line 85 in src/bdd/traits/boolean_function.rs

View check run for this annotation

Codecov / codecov/patch

src/bdd/traits/boolean_function.rs#L85

Added line #L85 was not covered by tests
{
panic!("Currently not allowed to have the substituted variable also appear in the substituting BDD value");

Check warning on line 87 in src/bdd/traits/boolean_function.rs

View check run for this annotation

Codecov / codecov/patch

src/bdd/traits/boolean_function.rs#L87

Added line #L87 was not covered by tests
}

let mut extended_mapping = mapping.clone();
let (mut self_lifted, _common_inputs) = self.union_and_extend_n_ary(&mut extended_mapping);

Check warning on line 91 in src/bdd/traits/boolean_function.rs

View check run for this annotation

Codecov / codecov/patch

src/bdd/traits/boolean_function.rs#L90-L91

Added lines #L90 - L91 were not covered by tests

for (k, v) in extended_mapping.iter() {
self_lifted.bdd = self_lifted
.bdd
.substitute(self_lifted.map_var_outer_to_inner(k).unwrap(), &v.bdd)

Check warning on line 96 in src/bdd/traits/boolean_function.rs

View check run for this annotation

Codecov / codecov/patch

src/bdd/traits/boolean_function.rs#L93-L96

Added lines #L93 - L96 were not covered by tests
}

self_lifted.restrict_and_prune_map(&extended_mapping, &self_lifted)

Check warning on line 99 in src/bdd/traits/boolean_function.rs

View check run for this annotation

Codecov / codecov/patch

src/bdd/traits/boolean_function.rs#L99

Added line #L99 was not covered by tests
}

fn sat_point(&self) -> Option<BooleanPoint> {
Expand Down

0 comments on commit b1e9f5a

Please sign in to comment.