LogicAttack: Adversarial Attacks for Evaluating Logical Consistency of Natural Language Inference

Mutsumi Nakamura, Santosh Mashetty, Mihir Parmar, Neeraj Varshney, Chitta Baral

Introduction

Natural Language Inference (NLI) is a fundamental task in NLP, requiring models to determine the relationship—entailment, contradiction, or neutrality—between a premise and a hypothesis. While modern Large Language Models (LLMs) achieve high accuracy on standard benchmarks, there is growing concern that they rely on surface-level heuristics rather than robust logical reasoning. This paper introduces LogicAttack, a framework designed to stress-test the logical consistency of these models using formal propositional logic.

Methodology: The LogicAttack Framework

LogicAttack systematically transforms standard NLI "entailment" pairs into complex, logically equivalent versions. By applying six rules from Propositional Logic (PL), the framework creates adversarial examples that preserve the underlying truth while increasing linguistic and logical complexity.

Examples of LogicAttack transformations using propositional logic rules.

The rules include:

  1. Modus Tollens: If $P \rightarrow H$ and $\neg H$, then $\neg P$.
  2. Constructive/Destructive Dilemmas: Complex multi-premise arguments.
  3. Transposition: $P \rightarrow H$ is equivalent to $\neg H \rightarrow \neg P$.
  4. Material Implication: $P \rightarrow H$ is equivalent to $\neg P \lor H$.

To ensure natural-sounding text, the researchers utilized GPT-3 to generate high-precision negations, maintaining a high linguistic overlap (approx. 60% F1) with the original sentences.

Experimental Evaluation

The framework was tested on the SNLI and MNLI datasets. The primary metric, Attack Success Rate (ASR), measures how often the adversarial transformation flips a model's correct prediction to an incorrect one.

Key Results

The study found that models are highly vulnerable to these logical perturbations:

  • Average Vulnerability: Across various architectures, LogicAttack achieved an average ASR of ~53%.
  • Model Robustness: GPT-4 proved the most resilient (20.0% ASR on SNLI), while smaller models like RoBERTa were significantly more susceptible (76.1% ASR).
  • The Heuristic Trap: Models struggled most with rules involving multiple negations, such as the Destructive Dilemma, suggesting they fail to track complex logical inversions.

Logical "Vaccination"

A significant finding of the research is that models can be "vaccinated" against these attacks. By fine-tuning a model on a small subset of logic-based adversarial samples, its robustness improves dramatically without sacrificing general accuracy.

Impact of fine-tuning on logical adversarial samples (Proposed) vs. Baseline on Accuracy and Attack Success Rate (ASR).

As shown in the figure above, the proposed fine-tuning method reduced the ASR from 56.1% to a mere 0.7%, while maintaining a stable accuracy of 91.6%.

Discussion and Insights

The results suggest a gap between pattern matching and true reasoning. Chain-of-Thought (CoT) analysis revealed that while GPT-4 attempts to map logical relations, earlier models like GPT-3 often default to direct comparison, leading to errors when the logical structure is non-trivial.

Limitations and Future Work

While LogicAttack provides a rigorous testbed, it is currently limited to propositional logic and simple linguistic connectors. Future research should expand to predicate logic (quantifiers like "all" or "some") and more diverse reasoning tasks beyond NLI, such as question-answering and common-sense reasoning.

Summary updated

BibTeX
@inproceedings{nakamura2023logicattack,
  author = {Mutsumi Nakamura and Santosh Mashetty and Mihir Parmar and Neeraj Varshney and Chitta Baral},
  title = {{LogicAttack: Adversarial Attacks for Evaluating Logical Consistency of Natural Language Inference}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2023},
  doi = {10.18653/v1/2023.findings-emnlp.889},
}
Figure