Simplify logic expression