Lexical Refactoring: Contamination Tests That Keep the Logic Fixed and Move the Words

Benchmarks for logical reasoning, such as FOLIO, are now old enough to sit inside the training data of the models they grade. The standard detectors fail exactly where it matters most. After reinforcement learning, detectors based on how likely a model finds a test item drop to roughly 50–58% AUROC, close to coin flipping (On The Fragility of Benchmark Contamination Detection in Reasoning Models). The usual workaround is to rephrase the test and see whether scores fall. That has two problems. A paraphrase written by an LLM may quietly change the logic, and a drop in score cannot be separated from the paraphrase simply being harder.

This note proposes a different perturbation. For each test sentence we keep the formal meaning fixed exactly and change how that meaning is split across words. We invent a new word, give it a one-line definition, and let it absorb a chunk of the original sentence. A memorized "All students who … admire Bob" template then becomes "Bob is glorp," with glorp defined separately. A tool from classic semantic parsing makes this exact: inverse λ-calculus. λ-calculus is a notation for word meanings as functions, and the inverse operation answers "given what the whole sentence means and what the other words mean, what must the missing word mean?" Because the operation is exact, every rewritten item has a gold answer that is provably unchanged. Because we can choose how much of the sentence the new word absorbs, the rewrite has a dial. The contamination signal is not "the score dropped" but "the score dropped more on old items than on matched fresh items at the same dial setting."

Core Claim

Inverse semantic derivation turns rephrasing-based contamination tests into controlled experiments. Two properties make this possible. The rewrites preserve the answer by construction, which LLM paraphrase cannot guarantee. The rewrites also come with a depth parameter $d$, the number of logical constituents folded into new defined words. We can therefore fit how difficulty grows with $d$ on clean items and test whether old benchmark items deviate from that curve. The quantity of interest is a difference of differences:

$$\Delta = \big[A_{\text{old}}(0) - A_{\text{old}}(d)\big] - \big[A_{\text{fresh}}(0) - A_{\text{fresh}}(d)\big],$$

Here $A_{\text{old}}(d)$ and $A_{\text{fresh}}(d)$ are a model's accuracy on published and never-published items rewritten to depth $d$. A model that reasons compositionally should show $\Delta \approx 0$ at every depth. A model that recalls items as whole templates should show $\Delta > 0$, and the gap should widen as more of the familiar surface is folded away.

This controls for difficulty using the same model on fresh items, not a pool of other models. That directly addresses the open weakness of ConStat, whose correction relies on reference models that must be uncontaminated and are increasingly hard to find. The method needs only black-box answers, so the reinforcement-learning masking effect that defeats likelihood detectors does not apply.

Prior Work and Where This Sits

The mechanism comes from Baral and colleagues. Their Using Inverse lambda and Generalization to Translate English to Formal Languages introduced two operators. Inverse_L returns $F$ with $F @ G = H$, and Inverse_R returns $F$ with $G @ F = H$, where $@$ means function application. The system built on them reached 91.17 F-measure on GEOQUERY. Typed answer set programming lambda calculus theories and correctness of inverse lambda algorithms proved the operators sound and complete. It also showed their cost is exponential only in the number of variables, which stays small for FOLIO-sized formulas. Learning Word Meanings by Instruction showed that a word's meaning can be deduced from a sentence and its paraphrase, and this is the instruction format our definitions reuse.

All of this work runs the operators to learn a parser. We run them in the other direction, to write test items whose meaning is already known. That sidesteps the weakness the file records for this line of work: dependence on a syntactic parser. We never parse the benchmark sentence. We start from its gold logical form and build the new sentence from a small hand-written lexicon whose derivations we control. Turning a derived λ-term back into an English definition borrows the generation direction of A Probabilistic Forest-to-String Model for Language Generation from Typed Lambda Calculus Expressions. We use a fixed grammar so that outputs stay checkable.

On the contamination side, three works motivate the design. Studying and improving reasoning in humans and machines reports that modern LLMs predict classic logic puzzles with near-zero surprise, which shows that the inputs to Baral's puzzle work, Solving puzzles described in English by automated translation to answer set programming, are now memorized. Do LLMs Really Struggle at NL-FOL Translation? supplies our verification step: it checks logical equivalence with the Z3 solver instead of string match. It also motivates our caution about human gold data, since it found roughly 6% label errors in FOLIO. Do LLMs Game Formalization? found that a proof checker passing 87–99% of model formalizations hides mistranslated premises. We take from it the lesson that every rewrite needs a check of fidelity to the source, not only internal consistency.

Two generators are the closest relatives. A²RBench checks that whole programs invert ($g(f(x))=x$) and remaps symbols, observing a 17.7% drop. DyVal generates fresh graph-structured problems. Neither rewrites natural-language items at the level of individual words, and neither pairs its perturbation with a matched fresh control to separate contamination from difficulty. Symbol remapping is a special case of our method at $d=0$: it renames predicates without moving any logical structure between words. It is therefore our main ablation.

Research Program

The pipeline takes a benchmark item together with its gold first-order-logic premises and conclusion. For each premise with logical form $H$, it lists the subformulas that could be absorbed: a quantified restriction, a relational clause, a nested conditional. To absorb a subformula, it writes a short sentence frame with a slot. The frame's other parts have known meanings $G$ from the fixed lexicon. Inverse_L or Inverse_R then computes the slot meaning $F$. A fresh nonce word is bound to $F$, and the grammar renders a definition sentence for it ("Someone is glorp if every student admires them").

Z3 then checks two things. The rewritten premise together with the definition must be logically equivalent to $H$, and the full item must keep its gold True/False/Unknown label. Any item that fails either check is discarded. Depth $d$ counts the absorbed constituents across the item, and we generate items at $d \in \{0,1,2,3\}$. Here $d=0$ means nonce renaming of predicates only, the A²RBench-style remap.

Fresh controls come from two sources. In controlled studies, the control is a held-out half of the same benchmark that the model never saw. This matches style, topic and difficulty exactly. For frontier models, where we cannot know what they saw, we commission roughly 300 new FOLIO-style items written after the models' training cutoffs, with gold logic, and rewrite them with the same pipeline.

The per-item score is the drop in correctness from depth 0 to depth $d$ (or the drop in answer probability, where available), minus the mean drop for fresh items at that depth. Item scores feed AUROC, and the aggregate gives $\Delta$ with bootstrap intervals. A side product is a localization map: for a contaminated item, which absorbed constituent breaks the model. This says which part of the item was being recalled.

Baselines

The naive reference point is the raw accuracy drop from original to rewritten items with no fresh-item correction. If it detects contamination as well as $\Delta$, then the control adds nothing and we will say so.

The strongest black-box competitor is ConStat. It compares a model's score on original versus rephrased benchmarks after correcting difficulty with reference models, and reports a 98.4% detection rate in its controlled contamination setting. We run ConStat on identical contaminated checkpoints, with its rephrasing produced by an LLM, the same number of evaluation items, and a reference pool of open models of comparable size. Matching it at the benchmark level is not enough to beat it. Beating it means comparable benchmark-level detection without reference models, together with higher item-level AUROC. It also means staying accurate when the reference pool is deliberately contaminated, which we simulate by fine-tuning two reference models on the test half.

The strongest detector aimed at reasoning models is Min-$k$NN Distance from Detecting RLVR Training Data via Structural Convergence of Reasoning. It samples 32 completions and flags prompts whose completions collapse into near-identical text. It reports an average AUC of 0.70 (0.71 under paraphrase) at about 6.65 seconds per item. We run it with its published 32 samples and give our method the same generation budget. To beat it, we need item-level AUROC clearly above 0.70 on the RL-trained checkpoints.

Likelihood detectors serve as a floor. We run LiRA, Loss and Min-K%++ on the same checkpoints. On The Fragility of Benchmark Contamination Detection in Reasoning Models reports 89.1% AUROC for LiRA after supervised contamination, falling to 50–58% across ten detectors in the chain-of-thought setting. We expect to reproduce that collapse and to stay above it.

The key ablation holds everything fixed except the inverse-derivation step. The A²RBench-style arm uses nonce renaming only ($d=0$ throughout). The LLM-paraphrase arm uses rewrites produced by prompting a strong model to restructure the sentence around a newly defined word, filtered by an LLM judge rather than by derivation and Z3. Both arms get the same fresh-control correction.

Why not just…?

Why not just have an LLM paraphrase the items and use the same fresh-item control? This is the real threat. If LLM paraphrases rarely change the answer, most of our advantage disappears. The file gives reasons to doubt they are safe enough. Do LLMs Game Formalization? documents 107 cases of fabricated axioms by a frontier model, and Brunello et al. found roughly 6% gold errors even in a curated human dataset. At a contamination effect of a few points (ConStat estimates $\delta \approx 6.6\%$ on ARC for Llama-3-70b), a 5% rate of answer-changing rewrites is enough to swamp the signal. The paraphrase ablation settles this directly: two annotators audit 300 rewrites per arm for whether the label is preserved, and we compare detection AUROC. If paraphrase matches us on both, the contribution shrinks to a cheaper, guaranteed-correct generator. We would report it as that.

Why not just rename the predicates to nonsense words? Renaming preserves logic trivially and costs nothing, but it leaves the sentence's shape intact: quantifier order, clause frames, argument structure. These are the parts a model trained on chain-of-thought plausibly keeps after it stops memorizing exact tokens. The $d=0$ arm measures this directly. Our prediction is that $\Delta$ at $d=0$ is small on the RL-trained checkpoints and grows with $d$. If $\Delta$ is flat in $d$, the absorption step is not doing anything and the idea fails.

Why not just use Min-$k$NN Distance or likelihood scores? Likelihood scores are erased by reinforcement learning, per the Fragility paper. Min-$k$NN measures character-level similarity of sampled outputs and needs many samples. It also answers a different question, whether the model has converged on a prompt, rather than whether its answer survives a change in how the meaning is packaged. The two signals may well be complementary, so we also report a simple combination.

Proposed Experiments

The decisive experiment uses known contamination. Split FOLIO (487 stories, 1,435 conclusions, per Han et al.) into halves A and B, after removing items that Brunello et al.'s re-verification flags as mislabeled. Following the Fragility paper's protocol, contaminate Qwen3-8B and DeepSeek-R1-Distill-Llama-8B on half A with supervised fine-tuning on chain-of-thought solutions, then run one epoch of GRPO on clean data, a reinforcement-learning method. This is the regime where likelihood detectors fall to near chance. Rewrite both halves at depths 0–3 and compute item-level AUROC for A-versus-B membership, along with $\Delta$ as a function of $d$. Success means AUROC above Min-$k$NN's 0.70 and well above the likelihood floor, $\Delta$ increasing in $d$, and $\Delta \approx 0$ for an uncontaminated copy of each model. That last check is the false-positive test.

A second experiment repeats the study on the Stanford Grade Grinder set from Brunello et al. (159 items; o3-mini reaches 94% Z3-verified translation accuracy there) and on Baral's logic grid puzzles with their answer set programming translations. The aim is to test transfer across formal languages and to see whether puzzles known to be memorized show positive $\Delta$ in off-the-shelf models.

A third experiment audits black-box frontier models on original FOLIO against the commissioned fresh items. We report $\Delta$ per model with confidence intervals and compare the ranking with ConStat's estimates.

We also report three properties of the pipeline itself: the fraction of items that admit a valid rewrite at each depth (to expose coverage limits from the hand lexicon), the human-audited rate of label preservation for our rewrites versus LLM paraphrase, and whether solving the rewritten items with a solver alongside the model, in the style of Logic-LM (78.1% on FOLIO), restores performance. If it does, the depth effect is a difficulty of language understanding rather than of reasoning.