fix bug in is_unique

This commit is contained in:
Folkert 2020-03-22 13:22:52 +01:00
parent db502fe2e7
commit c6fa301d8b

View file

@ -94,6 +94,10 @@ impl Bool {
Atom::Zero => Err(Atom::Zero), Atom::Zero => Err(Atom::Zero),
Atom::One => Err(Atom::One), Atom::One => Err(Atom::One),
Atom::Variable(var) => { Atom::Variable(var) => {
// The var may still point to Zero or One!
match subs.get_without_compacting(var).content {
Content::Structure(FlatType::Boolean(nested)) => nested.simplify(subs),
_ => {
let mut result = Vec::new(); let mut result = Vec::new();
result.push(var); result.push(var);
@ -101,7 +105,8 @@ impl Bool {
match atom { match atom {
Atom::Zero => {} Atom::Zero => {}
Atom::One => return Err(Atom::One), Atom::One => return Err(Atom::One),
Atom::Variable(v) => match subs.get_without_compacting(*v).content { Atom::Variable(v) => {
match subs.get_without_compacting(*v).content {
Content::Structure(FlatType::Boolean(nested)) => { Content::Structure(FlatType::Boolean(nested)) => {
match nested.simplify(subs) { match nested.simplify(subs) {
Ok(variables) => { Ok(variables) => {
@ -111,13 +116,16 @@ impl Bool {
} }
Err(Atom::Zero) => {} Err(Atom::Zero) => {}
Err(Atom::One) => return Err(Atom::One), Err(Atom::One) => return Err(Atom::One),
Err(Atom::Variable(_)) => panic!("TODO nested variable"), Err(Atom::Variable(_)) => {
panic!("TODO nested variable")
}
} }
} }
_ => { _ => {
result.push(*v); result.push(*v);
} }
}, }
}
} }
} }
@ -125,6 +133,8 @@ impl Bool {
} }
} }
} }
}
}
pub fn map_variables<F>(&self, f: &mut F) -> Self pub fn map_variables<F>(&self, f: &mut F) -> Self
where where