Fix wrong optimization of AST based on logical_not