object Prop {
def simplify(prop : Prop) : Prop = {
prop match {
case Not(Or(a,b)) => simplify(And(Not(a),Not(b)))
case Not(And(a,b)) => simplify(Or(Not(a),Not(b)))
case Not(Not(a)) => simplify(a)
case _ => {
if (simplify(prop) == prop) prop
else prop
}
}
}
}
I am sure that I have an infinite loop caused by my default case. In all cases, I use recursion. It should be, but only if Prop can be simplified. As soon as Prop cannot be simplified, it should return all this.
I do not see how I can verify further simplification. (I am not allowed to use other libraries, as suggested in the freenodes # scala channel).
Can someone explain if this is a “case” causing a loop, and how to solve it? How can I check for possible simplification without creating a loop?
Thanks in advance!
source
share