SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2401.10065 · EMNLP · 2024

Code Prompting Elicits Conditional Reasoning Abilities in Text+Code LLMs

Iryna Gurevych, Aditya Somak, Xiaodan Zhu, Martin Tutek, Haritz Puerto

arXiv · PDF · Open in the Atlas

Code that ran

6 of 7 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; 1 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 5 failures of our instrument; 1 no recorded run), measured 2026-11-22; 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/2401.10065.json · badge: /api/ran/2401.10065.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
ukplab/arxiv2024-conditional-reasoning-llms canonical (classifier label)
classifier basis: census
6 ran · 1 no recorded run
FunctionStatusWhere it lives
compute_metrics Ran
ran, honoured the contract we drafted
ukplab/arxiv2024-conditional-reasoning-llms/src/conditionalqa/evaluation.py
code served (permissive licence) · get_code("61322bcb67f876e7")
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 tuple, 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 itertools
import math
import collections
import string
import re

# Define ARGS for compute_metrics function
ARGS = {
    "prediction": [
        ("Paris", ["capital", "France"]),
        ("France", ["country"])
    ],
    "reference": [
        ("Paris", ["capital"]),
        ("French Republic", ["country", "Europe"])
    ]
}
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 tuple, ndim 1, dtype family float — a tuple 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
create_contextualized_rationales Ran
ran; our contract draft was wrong, not the code
ukplab/arxiv2024-conditional-reasoning-llms/src/conditionalqa/oracle_retriever.py
code served (permissive licence) · get_code("a53867df2046c76b")
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.

import torch

# Analyze the function behavior:
# - list_sections: iterable of items, each item is iterable (used in for loop)
# - list_rationales: iterable of items that can be checked with 'in' operator
# - Each section is checked if rationale is in it
# - contextualized_rationales items are iterated and flattened
# - Final output is joined with '\n'

# Since the function does "for item in sublist in contextualized_rationales",
# each item in contextualized_rationales must be iterable (like strings or lists)

# Let's create lists of strings (since strings are iterable and support 'in' operator)

list_sections = [
    ["Introduction: This is the beginning"],
    ["The main point is about data"],
    ["Another section with no match"],
    ["This section contains important keyword"],
    ["Final thoughts"]
]

list_rationales = [
    "main point",
    "important keyword"
]

ARGS = {
    "list_sections": list_sections,
    "list_rationales": list_rationales
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — 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
evaluate Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
ukplab/arxiv2024-conditional-reasoning-llms/src/boardgameqa/evaluation.py
code served (permissive licence) · get_code("43bb95dff6d09d00")
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 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 torch
import numpy as np
from sklearn.metrics import accuracy_score, confusion_matrix

class Answer:
    YES = 1
    NO = -1
    UNKNOWN = 0

# Create a small dataset with label key
dataset = [
    {'label': 'proved'},
    {'label': 'disproved'},
    {'label': 'unknown'},
    {'label': 'proved'},
    {'label': 'disproved'},
]

# Create corresponding predictions that match the label mapping
list_predictions = [
    Answer.YES,      # 1
    Answer.NO,       # -1
    Answer.UNKNOWN,  # 0
    Answer.YES,      # 1
    Answer.NO,       # -1
]

ARGS = {
    'dataset': dataset,
    'list_predictions': list_predictions,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, sklearn, torch — 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
get_sections Ran
ran; our contract draft was wrong, not the code
ukplab/arxiv2024-conditional-reasoning-llms/src/conditionalqa/oracle_retriever.py
code served (permissive licence) · get_code("948fa8f0528211bf")
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. 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

# Construct a sample document as a list of HTML-like tags
# The function iterates through tags and groups them by sections delimited by headers
doc = [
    '<h1>Introduction</h1>',
    '<p>This is the introduction.</p>',
    '<p>More intro content.</p>',
    '<h2>Background</h2>',
    '<p>Background information here.</p>',
    '<h3>Subsection</h3>',
    '<p>Details in subsection.</p>',
    '<p>More details.</p>',
    '<h4>Minor heading</h4>',
    '<p>Minor content.</p>',
]

ARGS = {
    'doc': doc
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
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
get_summarized_doc Ran
ran; our contract draft was wrong, not the code
ukplab/arxiv2024-conditional-reasoning-llms/src/conditionalqa/oracle_retriever.py
code served (permissive licence) · get_code("9853eec4ddb2b039")
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.

# Setup code for get_summarized_doc function

# Construct a minimal url2doc dictionary
# The function expects url2doc[x['url']] to return a dict with 'contents' key
# 'contents' should be a list of tags (strings)

url2doc = {
    'https://example.com/doc1': {
        'contents': [
            '<h1>Introduction</h1>',
            '<p>This is the introduction section.</p>',
            '<p>More intro content here.</p>',
            '<h2>Background</h2>',
            '<p>Background information starts here.</p>',
            '<p>The background mentions the key concept.</p>',
            '<h3>Details</h3>',
            '<p>Detailed information about the concept.</p>',
            '<p>More details follow.</p>',
            '<h2>Evidence Section</h2>',
            '<p>This section contains important evidence.</p>',
            '<p>The evidence is relevant to the query.</p>',
        ]
    }
}

# Construct the example x with url and evidences
x = {
    'url': 'https://example.com/doc1',
    'evidences': [
        'This section contains important evidence.',
        'key concept'
    ]
}

# Define ARGS mapping all parameters
ARGS = {
    'x': x,
    'url2doc': url2doc
}
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
load_answers Ran
ran; our contract draft was wrong, not the code
ukplab/arxiv2024-conditional-reasoning-llms/src/conditionalqa/evaluation.py
code served (permissive licence) · get_code("167380b25c7e22fd")
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 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 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_answers.json")

test_data = [
    {"id": "1", "answers": ["answer1", "answer2"]},
    {"id": "2", "answers": ["answer3"]},
    {"id": "3", "answers": ["answer4", "answer5", "answer6"]}
]

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

ARGS = {
    "filename": temp_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 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
evaluate Not yet run
unverified (harvested, no recorded run)
ukplab/arxiv2024-conditional-reasoning-llms/src/conditionalqa/evaluation.py
code served (permissive licence) · get_code("80ea8ce64f656cc3")
How it ran

no invocation recorded.

Also present in other papers' code

Of 7 samples lifted from this paper's linked repositories, 7 carry a function identity and 0 do not. Of the 7 distinct functions with an identity, 1 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 0 the same month, 0 later) and 6 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
compute_metrics 1 other paper
1 dated earlier
2110.06884 (2021-10)
ConditionalQA: A Complex Reading Comprehension Dataset with Conditional Answers

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-22.

Repositories linked to this paper

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

Abstract

Reasoning is a fundamental component of language understanding. Recent prompting techniques, such as chain of thought, have consistently improved LLMs' performance on various reasoning tasks. Nevertheless, there is still little understanding of what triggers reasoning abilities in LLMs in the inference stage. In this paper, we investigate the effect of the input representation on the reasoning abilities of LLMs. We hypothesize that representing natural language tasks as code can enhance specific reasoning abilities such as entity tracking or logical reasoning. To study this, we propose code prompting, a methodology we operationalize as a chain of prompts that transforms a natural language problem into code and directly prompts the LLM using the generated code without resorting to external code execution. We find that code prompting exhibits a high-performance boost for multiple LLMs (up to 22.52 percentage points on GPT 3.5, 7.75 on Mixtral, and 16.78 on Mistral) across multiple conditional reasoning datasets. We then conduct comprehensive experiments to understand how the code representation triggers reasoning abilities and which capabilities are elicited in the underlying models. Our analysis on GPT 3.5 reveals that the code formatting of the input problem is essential for performance improvement. Furthermore, the code representation improves sample efficiency of in-context learning and facilitates state tracking of entities. 1

For agents

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

get_harvested_code_for_paper("2401.10065")
get_code_for_paper("2401.10065")
have("2401.10065")

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

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

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

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

Connect an agent — have() is free.