Datasets:
File size: 6,653 Bytes
382025d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | ---
license: cc-by-4.0
language:
- en
task_categories:
- question-answering
- text-generation
tags:
- code
- python
- code-tracing
- program-execution
- synthetic
size_categories:
- 10K<n<100K
---
# code_trace: execution-verified Python tracing questions
Each document shows a short piece of Python (one function plus the helpers, constants and classes it needs) and asks a
question about what happens when one specific call runs. Every answer was obtained by running that exact code in a sandbox.
The questions, answers and worked traces are produced by deterministic code from recorded executions; no language model
wrote or checked any question, answer or trace. The Python source code itself is ALEA's own synthetic code written by
language models: GLM-5.3-Flash, DeepSeek-V4.1-Flash and Qwen3.8 for the OpenLemma modules, gpt-6-luna for the R3 functions,
and OpenAI Codex agents for the code library.
## Question kinds
- **final_output**: what a call returns (as a Python repr) or prints.
- **var_at_line**: the value of a named local variable just before a marked line runs for the k-th time.
- **loop_state**: the values of one or two variables after the body of a marked loop has completed N passes (stated as
"just before pass N+1 begins"), or how many times the loop body runs.
- **exception**: whether the call raises, and if so which exception class; otherwise the returned value.
- **return_type**: the type name of the returned value, asked on a version of the code with parameter / return annotations,
local variable annotations and docstrings removed.
- **call_count**: how many times a helper or recursive function is called during the call.
Minimal pairs: many questions come in twins that share the code and differ in one element of the input (input twins), or
share the input and differ in one token of the code, such as `<` vs `<=` or a constant (code twins), with different answers.
Functions whose return type depends on the branch taken contribute type twins. About 29% of the documents show a short
step-by-step trace (line-by-line variable updates, per-pass loop values or the list of calls, all copied from the recorded
execution) before a final `Answer:` line; the same questions also appear elsewhere with the answer only. About 5% of the
documents start with one or two solved examples from other code. Documents are rendered as plain instructions, Q/A pairs or
chat turns.
## Source code
ALEA's own synthetic Python code from three pools: verified function modules with tests from the OpenLemma code collection
(excluding every item that matches the OpenLemma held-out evaluation set), verified single functions with assertion checks
from the KL3M R3 verified-code collection, and larger tested modules from ALEA's synthetic code library (from which only the
self-contained functions are cut out, at most about 80 lines with their dependencies). Only the Python standard library is
used.
## How the answers were made
1. Each code unit's own tests were run in an isolated sandbox (no network, no file system access outside a temporary
directory, memory and time limits) with a profiler that records the arguments of calls to the unit's functions.
2. Those recorded arguments were changed by one edit at a time (a number up or down, a list element dropped, duplicated or
swapped, a string character changed, an empty value) to make new inputs; a second edit of an edited input gives the
input twins. The original test inputs are used only for the trace-state kinds, never for final-output questions.
3. Every call was executed in the sandbox under a line tracer, on the cut-out snippet and on the full original module (the
two must agree), at two hash seeds (the two must agree). Answers with memory addresses, unordered sets of strings, very
long floats or long output were dropped.
4. Every document was then re-executed independently (plain evaluation, a counting wrapper for call counts, and an inserted
recording statement for line and loop questions) at six hash seeds; any function unit with a disagreement was removed.
## Surface-cue controls
Exception answers are balanced between "raises" and "returns" overall (1,752 raise / 1,794 return), within each function, and within
groups defined by whether the code contains a `raise` statement and whether the input contains an empty, zero or negative
value. Call-count, iteration-count and return-type answers are capped per value. A classifier that sees only the question
text, or only the call, was trained with cross-validation grouped by code unit; documents it could answer from the call
text alone were removed for the exception and return-type kinds until its gain over the majority answer was below 4
points. On the released documents the largest gain of any question-only or call-only classifier over the majority answer is 4.8 points.
## Counts
| kind | docs | sw32k tokens |
|---|---:|---:|
| final_output | 8,173 | 2,476,007 |
| var_at_line | 5,154 | 1,860,750 |
| loop_state | 4,358 | 1,530,879 |
| exception | 3,546 | 1,259,301 |
| return_type | 1,621 | 404,657 |
| call_count | 1,290 | 578,933 |
| **total** | **24,142** | **8,110,527** |
| code pool | docs | share |
|---|---:|---:|
| OpenLemma verified code modules | 9,532 | 39.5% |
| synthetic code library modules | 8,901 | 36.9% |
| R3 verified functions | 5,709 | 23.6% |
3,914 code units, 5,354 function units; no topic or skill above 4.4% of documents. Presentations: qa 7,352, chat 7,113, plain 9,677.
## Review
Before release, every document was re-executed by independent drivers at six hash seeds, and any function unit with a
disagreement was removed (about 0.07% of executions disagreed, all from unordered-set iteration or helper call paths). We
traced 34 documents by hand (all correct) and re-ran 12 encoded documents in the sandbox (all matching); the cosmetic issues
found (a duplicated word in one loop template, a doubled answer label, sign artifacts such as `-0` in edited inputs, and
local variable annotations that revealed return types) were fixed before encoding. An independent blind review of 60
documents, 30 of them re-executed, found 1 ambiguous call-count question about a generator function (a generator's body is
re-entered on every resume). As a result, all call-count questions about generator functions were removed, together with
line-state questions whose answer only repeats an unchanged argument; the remaining notes were minor style points. The texts
were screened for overlap with ALEA's evaluation sets and held-out probes, and documents sharing a 13-word span with the
OpenLemma held-out evaluation code were removed.
|