Fix the error in the generation of the formulas using apply in negated formulas