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::One => Err(Atom::One),
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();
result.push(var);
@ -101,7 +105,8 @@ impl Bool {
match atom {
Atom::Zero => {}
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)) => {
match nested.simplify(subs) {
Ok(variables) => {
@ -111,13 +116,16 @@ impl Bool {
}
Err(Atom::Zero) => {}
Err(Atom::One) => return Err(Atom::One),
Err(Atom::Variable(_)) => panic!("TODO nested variable"),
Err(Atom::Variable(_)) => {
panic!("TODO nested variable")
}
}
}
_ => {
result.push(*v);
}
},
}
}
}
}
@ -125,6 +133,8 @@ impl Bool {
}
}
}
}
}
pub fn map_variables<F>(&self, f: &mut F) -> Self
where