SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2405.06680 · EMNLP · 2024

Exploring the Compositional Deficiency of Large Language Models in Mathematical Reasoning Through Trap Problems

Ming Zhang, Qi Zhang, Xuanjing Huang, Jun Zhao, Jingqi Tong, Yurong Mou

arXiv · PDF · Open in the Atlas

Code that ran

9 of 10 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 1 violated it and 0 have no contract verdict; 8 failures of our instrument; 1 no recorded run); 1 of them was also run on the host, not in the jail, by the peer-agreement lane that set its level, measured 2026-11-23; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2405.06680.json · badge: /api/ran/2405.06680.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
tongjingqi/MathTrap canonical (classifier label)
classifier basis: plan_row
9 ran · 1 no recorded run
FunctionStatusWhere it lives
is_number Ran
ran, violated the contract we drafted
tongjingqi/MathTrap/eval/eval_GSM8K_category.py
code served (permissive licence) · get_code("0fe9cf6c00ef56ea")
How it ran

Ran in Syntology's jail on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned bool, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. The comparison behind this sample's level is a different run: the peer-agreement lane ran it again on the host, not in the jail (report dated 2026-09-04T22:34:05Z). If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

# Setup code for is_number function

ARGS = {
    "s": "3.14"
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type bool, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
batch_data Ran
ran; our contract draft was wrong, not the code
tongjingqi/MathTrap/eval/eval_GSM8K_category.py
code served (permissive licence) · get_code("66b3b5450182da3a")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned list. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import sys

torch.manual_seed(0)

MAX_INT = sys.maxsize

def batch_data(data_list, batch_size=1):
    n = len(data_list) // batch_size
    batch_data = []
    for i in range(n - 1):
        start = i * batch_size
        end = (i + 1) * batch_size
        batch_data.append(data_list[start:end])
    last_start = (n - 1) * batch_size
    last_end = MAX_INT
    batch_data.append(data_list[last_start:last_end])
    return batch_data


# Create a simple data list with distinct elements
data_list = [
    torch.randn(2, 4),
    torch.randn(2, 4),
    torch.randn(2, 4),
    torch.randn(2, 4),
    torch.randn(2, 4),
]

batch_size = 2

ARGS = {
    "data_list": data_list,
    "batch_size": batch_size,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list — a list output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
jload Ran
ran; our contract draft was wrong, not the code
tongjingqi/MathTrap/train_math.py
code served (permissive licence) · get_code("d07d04439cd1d44f")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import io
import json
import tempfile
import os

# Create a temporary JSON file with test data
temp_dir = tempfile.mkdtemp()
temp_file = os.path.join(temp_dir, "test.json")

test_data = {
    "key1": "value1",
    "key2": [1, 2, 3],
    "key3": {"nested": "dict"}
}

with open(temp_file, 'w') as f:
    json.dump(test_data, f)

# Define ARGS with the file path
ARGS = {
    "f": temp_file,
    "mode": "r"
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
last_boxed_only Ran
ran; our contract draft was wrong, not the code
tongjingqi/MathTrap/eval/util.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from Rambo-Yi/TLora, is pointer only (licence: NONE) · get_code("8720975b15d076e8")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from Rambo-Yi/TLora, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

last_boxed_only_string Ran
ran; our contract draft was wrong, not the code
tongjingqi/MathTrap/eval/util.py
code served (permissive licence) · get_code("0b14c648516c38a7")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

# Analyzing the function: last_boxed_only_string
# The function takes a single parameter 'string' which is a string
# It searches for '\boxed' or '\fbox' in the string and extracts the boxed content
# The function uses string methods: rfind, len, indexing

ARGS = {
    "string": r"Some text before \boxed{answer here} and some text after"
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
only_until_first_boxed_from_tokens Ran
ran; our contract draft was wrong, not the code
tongjingqi/MathTrap/eval/util.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from Rambo-Yi/TLora, is pointer only (licence: NONE) · get_code("0bbf876ced018c83")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from Rambo-Yi/TLora, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

preprocess Ran
ran; our contract draft was wrong, not the code
tongjingqi/MathTrap/train_math.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from sail-sg/p-dos, is pointer only (licence: NONE) · get_code("51c01dd0d033f660")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from sail-sg/p-dos, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

read_json Ran
ran; our contract draft was wrong, not the code
tongjingqi/MathTrap/GPT4_eval/get_response_example.py
code served (permissive licence) · get_code("0bb621c7242d2fbe")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import json
import os
import tempfile

# Create a temporary directory for testing
temp_dir = tempfile.mkdtemp()
test_file = os.path.join(temp_dir, "test.json")

# Pre-populate the file with valid JSON content
with open(test_file, 'w', encoding='utf-8') as f:
    json.dump([{"key": "value"}], f)

ARGS = {
    "file": test_file
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family float — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
remove_boxed Ran
ran; our contract draft was wrong, not the code
tongjingqi/MathTrap/eval/eval_MATH_category2.py
code served (permissive licence) · get_code("f3bbe264b05aadd3")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

# Analyze the function
# remove_boxed(s) takes a string parameter 's'
# It checks if the string starts with '\boxed{' and ends with '}'
# If so, it returns the content between them
# Otherwise it returns None

# Create test cases for the ARGS dict
ARGS = {
    "s": "\\boxed{answer}"
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
make_supervised_data_module Not yet run
unverified (harvested, no recorded run)
tongjingqi/MathTrap/train_math.py
code served (permissive licence) · get_code("abbd983f4f37a1d5")
How it ran

no invocation recorded.

Also present in other papers' code

Of 10 samples lifted from this paper's linked repositories, 10 carry a function identity and 0 do not. Of the 10 distinct functions with an identity, 8 are also present in other papers whose code we hold (8 with at least one paper dated earlier, 6 the same month, 8 later) and 2 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
jload 46 other papers
24 dated earlier, 3 the same month, 16 later, 3 same year, order not determinable
2302.13971 (2023-02)
LLaMA: Open and Efficient Foundation Language Models
2305.12870 (2023-05)
Lion: Adversarial Distillation of Proprietary Large Language Models
2305.13068 (2023-05)
Making Language Models Better Tool Learners with Execution Feedback
and 43 more not named here
preprocess 23 other papers
15 dated earlier, 1 the same month, 5 later, 2 same year, order not determinable
2305.12870 (2023-05)
Lion: Adversarial Distillation of Proprietary Large Language Models
2306.17194 (2023-06)
On the Exploitability of Instruction Tuning
2308.07286 (2023-08)
The Devil is in the Errors: Leveraging Large Language Models for Fine-grained Machine Translation Evaluation
and 20 more not named here
remove_boxed 20 other papers
6 dated earlier, 2 the same month, 11 later, 1 same year, order not determinable · 1 only as an assembly brick
2103.03874 (2021-03)
Measuring Mathematical Problem Solving With the MATH Dataset
2309.06275 (2023-09)
Re-Reading Improves Reasoning in Large Language Models
2309.12284 (2023-09)
MetaMath: Bootstrap Your Own Mathematical Questions for Large Language Models
and 17 more not named here
is_number 18 other papers
10 dated earlier, 1 the same month, 7 later
1807.06756 (2018-07)
SySeVR: A Framework for Using Deep Learning to Detect Software Vulnerabilities
1906.02425 (2019-06)
Uncertainty-guided Continual Learning with Bayesian Neural Networks
2005.00558 (2020-05)
POINTER: Constrained Progressive Text Generation via Insertion-based Generative Pre-training
and 15 more not named here
last_boxed_only_string 17 other papers
4 dated earlier, 12 later, 1 same year, order not determinable
2309.06275 (2023-09)
Re-Reading Improves Reasoning in Large Language Models
2310.05914 (2023-10)
NEFTune: Noisy Embeddings Improve Instruction Finetuning
2024.findings-emnlp.407 (2024 (year only))
MultiAgent Collaboration Attack: Investigating Adversarial Attacks in Large Language Model Collaborations via Debate
and 14 more not named here
batch_data 7 other papers
2 dated earlier, 2 the same month, 3 later
2309.12284 (2023-09)
MetaMath: Bootstrap Your Own Mathematical Questions for Large Language Models
2404.10346 (2024-04)
Self-Explore: Enhancing Mathematical Reasoning in Language Models with Fine-grained Rewards
2405.14804 (2024-05)
Can LLMs Solve longer Math Word Problems Better?
and 4 more not named here
last_boxed_only 6 other papers
1 dated earlier, 5 later
2404.02078 (2024-04)
Advancing LLM Reasoning Generalists with Preference Trees
2406.14024 (2024-06)
LLM Critics Help Catch Bugs in Mathematics: Towards a Better Mathematical Verifier with Natural Language Feedback
2408.04556 (2024-08)
BA-LoRA: Bias-Alleviating Low-Rank Adaptation to Mitigate Catastrophic Inheritance in Large Language Models
and 3 more not named here
only_until_first_boxed_from_tokens 6 other papers
1 dated earlier, 1 the same month, 4 later
2404.02078 (2024-04)
Advancing LLM Reasoning Generalists with Preference Trees
2405.15179 (2024-05)
VB-LoRA: Extreme Parameter Efficient Fine-Tuning with Vector Banks
2406.14024 (2024-06)
LLM Critics Help Catch Bugs in Mathematics: Towards a Better Mathematical Verifier with Natural Language Feedback
and 3 more not named here

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-23.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Human cognition exhibits systematic compositionality, the algebraic ability to generate infinite novel combinations from finite learned components, which is the key to understanding and reasoning about complex logic. In this work, we investigate the compositionality of large language models (LLMs) in mathematical reasoning. Specifically, we construct a new dataset MATHTRAP ‡ by introducing carefully designed logical traps into the problem descriptions of MATH and GSM8K. Since problems with logical flaws are quite rare in the real world, these represent "unseen" cases to LLMs. Solving these requires the models to systematically compose (1) the mathematical knowledge involved in the original problems with (2) knowledge related to the introduced traps. Our experiments show that while LLMs possess both components of requisite knowledge, they do not spontaneously combine them to handle these novel cases. We explore several methods to mitigate this deficiency, such as natural language prompts, few-shot demonstrations, and fine-tuning. Additionally, we test the recently released OpenAI o1 model and find that human-like 'slow thinking' helps improve the compositionality of LLMs. Overall, systematic compositionality remains an open challenge for large language models.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2405.06680")
get_code_for_paper("2405.06680")
have("2405.06680")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2405.06680.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2405.06680.svg)](https://syntology.ai/paper/2405.06680)

Connect an agent — have() is free.