A sarcastic sentence says one thing and means its opposite: "What a wonderful day to get a flat tire." Today's detectors decide this by pattern matching or by having a language model write out a rationale. Neither shows which facts make the literal reading untenable, and neither can be checked. We propose to treat the literal attitude of an utterance as a small logical claim, such as "the speaker is pleased that event E happened." A logic engine then tests that claim against a handful of background facts, for example "flat tires are undesirable" or "this author has repeatedly opposed this policy." Sarcasm is flagged only when the claim and the facts cannot all be true together. When the engine cannot decide, it names the one missing fact that would settle the question, and retrieval searches for exactly that fact rather than for text that merely looks similar to the tweet.
The payoff is not mainly a higher accuracy number. The strongest current systems already reach about 72% macro-F1 on author-labelled sarcasm. What they lack is a checkable explanation: a minimal set of retrieved, cited facts that provably clashes with the literal reading. A system that produces one can be audited, can abstain honestly when no clash is found, and can have its explanations tested by deleting the facts they rest on. Sarcasm is the main application. Formal logic supplies the verification mechanism, and retrieval is the component the logic steers.
Core Claim
We represent each utterance with a deliberately small vocabulary. It records what attitude the speaker literally expresses toward a target (positive or negative, with an ordinal strength). It records how desirable the target event normally is, what stance the speaker is known to hold toward the target, and a few general rules linking these. One rule says that a speaker who sincerely holds a negative stance toward X does not sincerely express strong approval of X. Write $L$ for the literal attitude claim extracted from the utterance and $K$ for the set of retrieved, source-attributed background facts plus the linking rules. The decision rule is
$$\text{sarcastic} \iff (K \wedge L \models \bot) \;\text{and}\; (K \wedge \tilde{L} \not\models \bot),$$
where $\bot$ means contradiction and $\tilde{L}$ is $L$ with the attitude reversed. In words, the literal reading is inconsistent with what we know, and the inverted reading is consistent. When $K \wedge L$ is unsatisfiable, the solver returns an unsat core, the smallest subset of facts responsible for the contradiction, and that core is the explanation.
When neither $K \wedge L$ nor $K \wedge \tilde{L}$ is unsatisfiable, the solver identifies which open atom would decide the case, such as "is E undesirable?" or "what is this author's stance on P?" It then issues a retrieval query for that atom alone. This is the specific new element: gap-directed retrieval for pragmatic inference. The contradiction is decided by a solver over a restricted logical vocabulary, not by a neural entailment classifier.
Relation to Prior Work
The closest system is Detecting Emotional Incongruity of Sarcasm by Commonsense Reasoning (EICR). EICR retrieves web text with a hybrid BERT and BM25 scorer, has a language model write background knowledge grounded in those passages, and builds a dependency graph. A fine-tuned RoBERTa entailment model then marks subgraphs where sentiments conflict, and adversarial contrastive learning suppresses spurious word-label shortcuts. EICR establishes the premise of our work, that sarcasm often depends on unstated external knowledge. It departs from our design in three ways. Its retrieval is driven by similarity to the input, its contradiction test is a soft classifier, and its authors list verifiable explanations as future work.
Sarcasm-R1 trains Qwen2.5-7B with reinforcement learning against reward models for linguistic, contextual and emotional reasoning. It motivates our design in two ways. It finds that emotional reversal is the main driver of sarcasm, which is why our vocabulary centres on attitude polarity. It also finds that plain chain-of-thought prompting hallucinates, which is the failure a solver-checked core is meant to prevent. Sarcasm-R1's reasoning, however, stays inside the network, and nothing checks it. The explanation generators EDGE, which uses a sentiment graph and a BART decoder, and Sarcasm SIGN, which flips sentiment-word clusters to produce a literal paraphrase, produce fluent output with no certificate behind it.
The methods we reuse come from the formal-reasoning side. Open-World LLM Logical Reasoning (OpenIKLR) uses a first-order prover's failed proof to locate the missing premise. It then has a language model propose a minimal completion and checks that completion both logically and factually. It also argues that similarity-based retrieval brings in logically useless distractors. We borrow the gap-location idea but fill the gap by retrieval from real sources rather than by language-model generation, because sarcasm depends on contingent facts about authors and events that a model's memory is least likely to hold correctly. Quantifying Cross-Query Contradictions supplies the machinery of extracting commitments, checking them incrementally with a satisfiability solver, and localizing conflicts with unsat cores. Neurosymbolic Language Reasoning as Satisfiability Modulo Theory (Logitext) supplies "textual let bindings," which tie a natural-language span to a logical variable. We use them so that each atom stays anchored to the words it came from.
Two constraints from this literature shape the design. OpenIKLR reports that 78.54% of its failures come from mistranslating language into logic, and that was on clean benchmarks; tweets will be harder. The cross-query work reports an extraction accuracy of 92.75% and notes that extraction errors produce spurious contradictions. For these reasons we avoid full first-order logic. Our vocabulary has fewer than ten predicate types, which keeps parsing tractable and keeps solving trivially cheap. The exponential blow-up of provers never arises at this size.
Research Program
The work has four parts.
The first part is the representation and parser. We define the attitude vocabulary and hand-annotate about 600 utterances drawn from iSarcasm and SemEval-2018 Task 3 with gold logical forms. We then few-shot prompt, and separately fine-tune, a mid-sized open model to produce $L$ with span bindings. Parser accuracy on the attitude atom and the target atom is reported on its own, because it is the failure point OpenIKLR identified.
The second part is gap-directed retrieval. For an undecided case, the solver lists the open atoms whose value would change the verdict. Each open atom becomes a templated query, such as a general-norm question about the event or a stance question about the author or public figure. The query goes to a web or Wikipedia index, and to the author's prior posts where a dataset makes them available. Retrieved passages are turned into candidate facts, each of which must cite its source span. An entailment filter keeps only facts the passage actually supports, and the solver is rerun. We allow a budget of at most three retrieval rounds.
The third part is the decision and the certificate. The system outputs sarcastic, non-sarcastic, or undecided. Undecided cases fall back to a neural classifier, and the coverage of the formal path is always reported alongside accuracy. Every sarcastic verdict on the formal path includes its unsat core, rendered as cited sentences. Reversing $L$ within the core also yields a literal paraphrase at no extra cost.
The fourth part is error analysis, in which every wrong verdict is attributed to parsing, retrieval, fact extraction, or a genuine limit of the vocabulary. One expected limit is sarcasm that works through exaggeration rather than contradiction.
Baselines
The naive reference point is direct prompting of GPT-4o on iSarcasm. Sarcasm-R1 reports 76.0% accuracy and 59.4% macro-F1 for this setup. We rerun it with our prompt and data split so that the comparison is exact.
The strongest detector is Sarcasm-R1 itself, which reports 85.4% accuracy and 72.3% macro-F1 on iSarcasm. It is the strongest competitor because it already models emotional reversal with explicit reasoning. We use its released numbers and, if weights are available, rerun it on our splits. Our full system uses the same 7B-class backbone for parsing, so the difference lies in the pipeline rather than in model size.
The strongest retrieval-based competitor is EICR. It reports 83.3% accuracy and 70.4% macro-F1 on iSarcasm, 80.1% and 80.3% on SemEval-2018, 77.2% and 75.3% on SARC, 84.5% and 83.8% on IAC-V2, and 86.2% and 84.3% on Ghosh. We run it with our retrieval index and the same number of retrieved passages per example, so that any difference reflects how the query is formed rather than which corpus is searched.
Two ablations isolate the key ingredients. The first, "retrieval without the gap," keeps the solver but queries with the utterance text, as EICR does. The second, "gap without the solver," keeps retrieval but lets a language model read $K$ and $L$ in prose and judge whether they contradict. All systems receive an equal tuning budget of the same number of development-set configurations.
The success criteria are set in advance. On detection, the system must at least match EICR's macro-F1 on iSarcasm with a 7B model. Beating Sarcasm-R1's 72.3 would be a bonus, and failing to do so would not refute the proposal. The claims that must hold are the following. On the formal path, precision must exceed every baseline's precision at matched coverage. Gap-directed queries must retrieve decisive facts more often than utterance queries. Certificates must pass the faithfulness test described below, where language-model rationales do not.
Why not just…?
Why not just fine-tune a reasoning model, as Sarcasm-R1 does? On the headline F1 score this may well win, and we say so openly. What it cannot provide is a rationale whose removal changes the verdict. The faithfulness experiment tests this directly. If Sarcasm-R1's rationales prove as faithful under deletion as our cores, the case for the solver collapses to coverage and cost alone.
Why not just use EICR-style retrieval with a better query, for example by letting a language model guess what background is missing? This is a real threat to the retrieval claim, because a capable model can often guess the missing fact without a solver. We add an arm in which a language model proposes the retrieval query from the utterance with no solver gap. Gap-directed retrieval must beat this arm on decisive-fact recall, which is judged on 300 annotated cases. If it does not, we drop the retrieval-steering claim and keep only the certificate claim.
Why not just have the language model check whether the retrieved facts contradict the literal reading? With a vocabulary this small, the solver's reasoning is shallow, and the decisive work may lie entirely in parsing and retrieval. The "gap without the solver" ablation measures this. We expect similar accuracy but worse precision and worse faithfulness, since the cross-query work finds that unconstrained models keep only 0.56 case-level consistency against 0.94 with solver checks. If precision and faithfulness also come out similar, we will report that the formal layer adds auditability but no accuracy, and treat that as the finding.
Proposed Experiments and Decisive Checks
Detection is measured with accuracy and macro-F1 on iSarcasm, SemEval-2018, SARC, IAC-V2 and Ghosh. We report the formal-path coverage and the selective precision and recall curves on each dataset. We emphasize iSarcasm because its labels reflect authors' intent, and iSarcasm shows that third-party annotators reach only 0.616 F-score against those labels.
The first decisive check is faithfulness by deletion. For each sarcastic verdict, we remove the core facts and rerun the system; for the neural baselines, we remove the facts their rationales cite. We then measure how often the verdict flips. A genuine certificate should flip nearly always, and a post-hoc rationale should not.
The second decisive check is agreement with authors. iSarcasm's authors supplied their own explanations and literal rephrasings. Annotators judge whether our core names the same clash the author described, compared against Sarcasm-R1's rationales and against EDGE-style generated explanations.
The third check is literal paraphrase. On the SIGN parallel corpus, we measure intended-sentiment accuracy of the paraphrases produced by reversing the attitude claim. SIGN-context reports 46.2% and the Moses translation baseline 25.7%.
The fourth check is the translation wall. We report parser error rates on tweets and on code-mixed text; since no reported result was found on Lacuna for MixSarc, we will produce the first numbers there. This tells us whether a restricted vocabulary brings informal text below the 78.54% translation-failure share that OpenIKLR measured on clean logic benchmarks.
References
- Detecting Emotional Incongruity of Sarcasm by Commonsense Reasoning
- Sarcasm-R1: Enhancing Sarcasm Detection through Focused Reasoning
- Sentiment-Enhanced Graph-Based Sarcasm Explanation in Dialogue
- Sarcasm SIGN: Interpreting Sarcasm with Sentiment Based Monolingual Machine Translation
- Open-World LLM Logical Reasoning
- Quantifying Cross-Query Contradictions in Multi-Query LLM Reasoning
- Neurosymbolic Language Reasoning as Satisfiability Modulo Theory
- iSarcasm: A Dataset of Intended Sarcasm