Implement constant folding for boolean expressions