TMEval

From Language Specifications to Executable Turing Machines
253 formal languages
7 structural categories
600 frozen oracle tests per language
2,024 model–language candidates
Executable, machine-checked evaluation

From Language Specifications to Executable Turing Machines: Evaluating LLMs as Computational Machine Designers

Shahriyar Zaman Ridoy†, S. M. Muhtasimul Hasan, Azmine Toushik Wasi, Kinga Tshering, Koushik Ahamed Tonmoy, Md Mosaddek Khan

Cognitive Agents and Interaction Lab (CAIL), University of Dhaka • Computational Intelligence and Operations Laboratory (CIOL) • Department of Electrical and Computer Engineering, North South University (NSU)

†Corresponding author

Correspondence: shahriyar.zaman01@gmail.com, mosaddek@du.ac.bd

Recognizing a formal language does not imply the ability to construct the computation that decides it. TMEval turns that distinction into an executable benchmark: given a formal-language specification, a model must synthesize a deterministic or nondeterministic Turing machine that decides the language. The benchmark holds 253 language specifications across 7 structural categories spanning context-free and non-context-free phenomena, each paired with 600 oracle-labeled membership tests, and every output is judged as an executable artifact rather than a textual response. The pipeline enforces a strict output contract, validates machine construction, executes each buildable machine, and assigns one of four outcomes: static_fail, build_fail, semantic_mismatch, or exact_pass. Across eight LLMs, 2,024 model–language candidates, and up to 1,214,400 behavioral evaluations, only 11.12% exactly pass all tests. More than half fail before execution, over one-third implement the wrong language, and 75 languages remain unsolved by every system. Difficulty depends less on the context-free/non-context-free boundary than on the operational structure required to realize the specification.

TMEval workflow: benchmark construction, frozen test suites, zero-shot generation, automated evaluation, and results

Benchmark Structure and Task Categories

Axis Field Categories (counts shown)
Context-free (181) CFL-1 — Single-dependency blocks One equality, inequality, or proportional relation between separated regions of a string (27 languages)
CFL-2 — Nested recursive syntax Balanced delimiters, expression-like structures, programming-language fragments, JSON-like and XML-like forms (40)
CFL-3 — Palindrome and mirror Matching a substring against its reverse, often around a delimiter or central region (37)
CFL-4 — Linear-count and Parikh-style Linear equalities, inequalities, modular constraints, and symbol-count relations (38)
CFL-5 — Delimited composition Separators, markers, and fixed composition patterns that determine how substrings must relate (39)
Non-context-free (72) NCFL-1 — Multi-block synchronization Coordinating three or more symbol counts or separated regions through repeated marking and comparison (34)
NCFL-4 — Unary arithmetic length Arithmetic conditions over unary block lengths, expressed through tape operations rather than high-level predicates (38)
Scale Languages 253 total; 181 context-free and 72 non-context-free
Tests per language 600 frozen oracle-labeled strings, split into two suites of 300 (150 positive and 150 negative each)
Models and candidates 8 models × 253 languages = 2,024 model–language candidates
Case evaluations Up to 1,214,400 expected cases; 563,400 runnable case records observed
Protocol Prompting Zero-shot; the prompt gives only the language identifier, alphabet, and definition (temperature 0.2, 8,000 max tokens, one generation per instance)
Output contract Exactly one top-level object named tm, built with automata-lib as a DTM or NTM; no prose, helper functions, regular expressions, parser libraries, or alternative artifacts
Terminal outcomes static_fail, build_fail, semantic_mismatch, exact_pass — every candidate lands in exactly one

Categories are defined by the computational structure a decider needs, not by how the language looks on the surface. Single-dependency blocks need one comparison between two regions; nested syntax and delimited composition need control logic that tracks structure across the whole string. That design is what lets the results separate formal language family from operational difficulty — and the two turn out to come apart.

Examples

The input is a formal language specification; the output is a finite transition system. A finite controller holds the current state and follows the transition function δ, while the tape head reads, writes, and moves along an unbounded tape. Reaching an accepting state means acceptance; in our evaluation an undefined transition from a non-final state means rejection.

Schematic view of a Turing machine: finite controller, state-transition diagram, and infinite tape

Representative Languages and Test Cases

Category Example language Example strings (accept; reject) What it tests
CFL-1 L = {anbmcn | n, m ≥ 1} abc, aabbcc; abbc, aabcc A separated equality between the first and final block.
CFL-2 Balanced parentheses (), (()); ((), ()) Recursive nesting and malformed near-boundary strings.
CFL-3 L = {x#xR | x ∈ {a, b}*} ab#ba; ab#ab, aba#ba Mirror matching around a delimiter.
CFL-4 L = {anbm | n ≤ m ≤ 2n} ab, aabb, aabbbb; aaab, aabbbbb Lower and upper linear count bounds.
CFL-5 L = {xay | x, y ∈ {a, b}*, |x| = |y|} a, bab; ba, bbab Delimiter-centered equal-length composition.
NCFL-1 L = {w | |w|a = |w|b = |w|c} abc, aabbcc; aabcc, abbc Multi-symbol count synchronization.
NCFL-4 L = {ambn | m > n, or m is prime and n ≥ m} aaab, aaabbbb; aaaabbbbb, abb Unary arithmetic and primality-conditioned membership.

Positive cases cover minimal valid strings, boundary cases, longer constructions, deeper nesting, mirror structures, and arithmetic length relations. Negatives come in two kinds: simple violations that break an explicit constraint such as alphabet membership, block order, or delimiter placement, and near-boundary negatives obtained by minimally perturbing a valid string — off-by-one counts, broken mirrors, malformed nesting, incorrect copy relations, and violations of strict versus non-strict inequalities. All 600 cases per language are fixed before any model runs, and the same cases are reused for every model.

What a Valid Answer Looks Like

A model cannot pass by writing a Python predicate, parser, grammar, or regular expression. Acceptance has to come out of the transition table itself. The toy machine below accepts binary strings of odd positive length and shows the required artifact form.

from automata.tm.dtm import DTM

tm = DTM(
    states={'q_even', 'q_odd', 'q_accept', 'q_reject'},
    input_symbols={'0', '1'},
    tape_symbols={'0', '1', ' '},
    transitions={
        'q_even': {
            '0': ('q_odd', '0', 'R'),
            '1': ('q_odd', '1', 'R'),
            ' ': ('q_reject', ' ', 'N')
        },
        'q_odd': {
            '0': ('q_even', '0', 'R'),
            '1': ('q_even', '1', 'R'),
            ' ': ('q_accept', ' ', 'N')
        },
        'q_reject': {
            '0': ('q_reject', '0', 'N'),
            '1': ('q_reject', '1', 'N'),
            ' ': ('q_reject', ' ', 'N')
        }
    },
    initial_state='q_even',
    blank_symbol=' ',
    final_states={'q_accept'}
)
      

Results

Eight models, 253 languages, 2,024 model–language candidates. Exact pass is candidate-level and strict: a candidate gets credit only if it produces the correct accept/reject decision on all 600 frozen tests. E2E is case-level with a fixed denominator, so candidates that fail before execution score zero instead of dropping out of the comparison.

Global Benchmark Outcome

Metric Value
Scale
Languages253
Models8
Model–language candidates2,024
Tests per candidate600
Maximum case evaluations1,214,400
Runnable case records observed563,400
Outcome
Exact-pass candidates225 / 2,024
Exact-pass rate11.12%
End-to-end case score31.00%
Runnable candidates939 / 2,024 (46.39%)
Invalid-artifact candidates1,085 / 2,024 (53.61%)
Languages solved by at least one model178 / 253
Languages unsolved by every model75 / 253

Failure-Stage Funnel

Terminal stage Candidates Share
static_fail — the output violates the code contract52225.79%
build_fail — it parses, but no valid TM is instantiated56327.82%
semantic_mismatch — it builds and runs, but fails at least one oracle test71435.28%
exact_pass — it matches all 600 oracle labels22511.12%
Aggregate
Invalid artifact (never reaches behavioral testing)1,08553.61%
Runnable artifact93946.39%

Model Leaderboard (N = 253 candidates per model)

Model Exact EP% CI95 Run% E2E% static build semantic
gpt-5.216866.4[60.4, 71.9]74.771.861321
claude-sonnet-4.5187.1[4.6, 11.0]94.157.1213220
qwen3-235B176.7[4.2, 10.5]68.042.2576155
gemini-2.5-pro93.6[1.9, 6.6]5.54.723905
llama-3.3-70B72.8[1.4, 5.6]41.524.72012898
mistral-large41.6[0.6, 4.0]69.637.0374172
deepseek-v3.220.8[0.2, 2.8]16.29.51892339
gemma-3-27B00.0[0.0, 1.5]1.60.932464

Abbreviations: Exact → languages passing all 600 tests, EP% → exact-pass rate, CI95 → Wilson 95% confidence interval, Run% → share of candidates surviving static and build validation, E2E% → end-to-end case score with invalid artifacts counted as zero, static / build / semantic → terminal failure counts, which sum to 253 together with the exact column. Paired exact McNemar tests with Holm correction over all 28 model pairs place gpt-5.2 ahead of every other model (pHolm ≤ 1.79×10−37); differences among the remaining models are much less stable, and claude-sonnet-4.5 versus qwen3-235B is not distinguishable after correction.

Why Conditional Accuracy Misleads

Conditional case accuracy (Accc) is computed only over each model's runnable candidates, so its denominator shifts from model to model. On that metric gemini-2.5-pro looks stronger than claude-sonnet-4.5 by 23.8 points; on E2E it trails by 52.4 points, because almost all of its candidates never reach behavioral testing.

Model Runnable Accc E2E Gap
gpt-5.218996.171.824.3
gemini-2.5-pro1484.54.779.8
qwen3-235B17262.142.219.9
claude-sonnet-4.523860.757.13.6
gemma-3-27B459.30.958.4
llama-3.3-70B10559.524.734.8
deepseek-v3.24158.79.549.2
mistral-large17653.337.016.2

Per-Category Aggregates (all 8 models, sorted by exact-pass rate)

Branch Cat. #Langs N EP% static% build% semantic% E2E% Oracle%
CFLCFL-5393126.128.928.236.926.741.0
CFLCFL-2403207.225.633.433.825.342.5
Non-CFLNCFL-4383049.928.628.632.929.068.4
CFLCFL-33729612.226.422.638.932.589.2
Non-CFLNCFL-13427212.526.826.134.632.682.4
CFLCFL-43830415.520.729.334.535.584.2
CFLCFL-12721616.722.725.035.738.296.3

Oracle% is the share of languages in a category solved by at least one model. Branch-level exact-pass rates are almost identical for CFL and non-CFL (11.12% vs. 11.11%), and within-branch variation is far larger than the gap between branches. CFL-2 and CFL-5 — both context-free — are the hardest categories, and together they account for 46 of the 75 universally unsolved languages.

Direction of Semantic Error

Among the 714 machines that build and run but fail at least one oracle test, the errors are strongly asymmetric: the machines are too restrictive rather than too permissive. At case level, false negatives outnumber false positives by 6.6 to 1.

First-failure type N Share
Gold accept, model rejects58381.7%
Gold reject, model accepts13118.3%
reject_halted55778.0%
reject_all_branches_halted263.6%
accept13118.4%

Key Takeways

  • Overall Findings:
    • Exact synthesis is far from solved: only 225 of 2,024 candidates match all 600 oracle labels, an exact-pass rate of 11.12%.
    • Failure is multi-stage: 53.61% of candidates never reach behavioral testing, and a further 35.28% build cleanly but implement the wrong language.
    • One model leads by a wide margin: gpt-5.2 exact-passes 168/253 languages (66.4%); the next model reaches 7.1%, a gap of 59.3 points, and its confidence interval is disjoint from every other model's.
    • Runnable is not correct: claude-sonnet-4.5 has the highest runnable rate (94.1%) but only 7.1% exact pass. Machines that parse, build, and run are not evidence of formal correctness.
    • The CFL/non-CFL boundary is not the difficulty axis: branch-level exact pass is 11.12% vs. 11.11%. Nested recursion, synchronization, and composition explain performance far better than language family.
    • The benchmark is unsaturated: 75 languages are solved by no model, 144 by exactly one, and none by more than five.
  • Failure Regimes & Coverage:
    • Models split into two regimes. claude-sonnet-4.5, qwen3-235B, and mistral-large are semantic-bound: they emit runnable machines that recognize the wrong language. gemini-2.5-pro, deepseek-v3.2, and gemma-3-27B are artifact-bound, failing static or build validation; llama-3.3-70B sits between them with a build-heavy profile.
    • The remedies differ by regime: syntax repair helps static-bound models and schema validation helps build-bound ones, but neither addresses semantic mismatch.
    • Coverage is concentrated rather than complementary. gpt-5.2 solves 168 of the 178 solvable languages and is the unique solver for 137, so a best-per-language oracle adds only 10 languages over gpt-5.2 alone.
    • Behavior is stable within the frozen test construction: the two parallel 300-case suites give 66.77% vs. 66.85% aggregate accuracy, a difference of 0.08 points.
  • Error Analysis:
    • Static failures (522): unterminated string literals dominate at 363 cases, 69.5% of all static failures, concentrated in gemini-2.5-pro (239) and deepseek-v3.2 (189).
    • Build failures (563): FinalStateError accounts for 381 cases (67.7%), followed by InvalidStateError (108) — accepting-state and state-declaration bugs rather than syntax.
    • Semantic mismatches (714): on the first failing case, 81.7% reject a string that belongs to the target language. The recognizers undergenerate rather than overgenerate.
    • Near misses are rare where it counts: 81.4% of executable-but-wrong machines score at least 50% on their cases, but only 1.3% reach 99% — partial behavior does not sit close to exact correctness.
    • Recall, not specificity, is the bottleneck: claude-sonnet-4.5, qwen3-235B, and mistral-large hold specificity in the mid-80s to mid-90s while recall on accepted strings falls to 20.7–29.4%. gpt-5.2 keeps both (92.9% recall, 99.4% specificity).
  • What Makes a Category Hard:
    • Delimited composition (CFL-5, 6.1% EP) and nested recursive syntax (CFL-2, 7.2% EP) are the hardest; even gpt-5.2 stays below 40% on both, and no other model exceeds 10% on either.
    • Single-dependency blocks (CFL-1) are the easiest, with 96.3% of its languages solved by at least one model, against 41.0% for CFL-5.
    • Non-context-free categories are not uniformly harder: NCFL-1 reaches 12.5% EP and NCFL-4 9.9%, both above the two weakest context-free categories.
    • The pattern holds per model as well as in aggregate, so category difficulty is not an artifact of a single system's behavior.

Benchmark Design & Evaluation Methods

  • Dataset Construction & Protocol:
    • 253 language specifications drawn from theory-of-computation textbooks, formal-language exercises, instructional materials, and expert-generated variants, each with an explicit alphabet and an unambiguous membership condition.
    • Expert-guided filtering removed duplicates, underspecified definitions, inconsistent alphabets, unclear empty-string behavior, ambiguous inequalities, and anything that could not support a reliable executable oracle.
    • Every language carries 600 frozen oracle-labeled tests in two suites of 300, fixed before evaluation and identical across models; models never see the test strings.
  • Evaluation Metrics:
    • Exact pass (EP): the primary candidate-level metric, awarded only when a machine matches all 600 oracle labels for its language.
    • End-to-end case score (E2E): the primary case-level metric, with a fixed denominator of 600 cases per candidate so that pre-execution failures score zero.
    • Runnable rate and conditional accuracy (Accc) are diagnostic only; Accc is not used for ranking because its denominator varies by model.
    • Comparisons are made at the language level: Wilson 95% intervals per model, exact McNemar tests with Holm correction over 28 pairs, and a language-level bootstrap for E2E differences.
  • Scope & Open Questions:
    • Bounded guarantees: exact pass certifies agreement on 600 tests, not full equivalence over Σ*; tighter guarantees would need broader oracles or formal verification.
    • Deliberately strict interface: the output contract separates machine construction from auxiliary computation, so results do not reflect best-case performance under tool-augmented code generation.
    • Single-shot setting: all results come from zero-shot, one-generation prompting, with no few-shot examples, self-correction, execution feedback, or verifier-guided decoding.
    • Next steps: the concentration of success in one model calls for probing, mechanistic, and decontamination studies to test whether it reflects genuine algorithmic generalization.

Citation

Please cite the paper as below:

@misc{
ridoy2026tmeval,
title={From Language Specifications to Executable Turing Machines: Evaluating {LLM}s as Computational Machine Designers},
author={Shahriyar Zaman Ridoy and S. M. Muhtasimul Hasan and Azmine Toushik Wasi and Kinga Tshering and Koushik Ahamed Tonmoy and Md Mosaddek Khan},
year={2026}
}