[ BENCHMARKS / v5.0 / TASKS / 192_pike_regex ]

Pike-VM linear-time regex engine in Python.

A regex matcher that reproduces Python’s re exactly on a stated pattern language, group spans included, and never takes super-linear time.

Unit
192_pike_regex
Category
Algorithms & DSString algorithms
Language
Python
Difficulty
Hard900 s wall clock (15 min)
Origin
New in v5
Ranked rows passed
0/7single seed each

The prompt

The agent receives exactly this text as its task, verbatim. The harness adds its own system prompt and, in some campaign arms, guidance of its own; the harness chapter describes those. The task’s setup also writes the files its working directory starts with (a worked sample, a repository or a service, where the prompt names them); they are not reproduced here.

Prompt · 192_pike_regex
Create /tmp/eval_pike192/rx.py (Python >= 3.11, standard library only): a regular-expression matcher that reproduces Python's re exactly on the pattern language below and never takes super-linear time.

API
- search(pattern, string) -> None or list. It must equal what re.search(pattern, string) (no flags) gives: None when there is no match; otherwise a list of 1+G entries, G = the number of capturing groups in the pattern, where entry k is the (start, end) tuple of group k (k=0 is the whole match), or None if group k did not participate in the match. In other words: [m.span(k) if m.span(k) != (-1, -1) else None for k in range(G + 1)].
- finditer(pattern, string) -> list of such lists, one per match that re.finditer(pattern, string) yields, in order (empty matches included, under re's rules for them).

Pattern language (test patterns use only this; anything else need not be handled)
- Literal: any printable ASCII character except the metacharacters \ . [ ] ( ) { } * + ? | ^ $
- Escapes: a backslash before any metacharacter or before - is that literal character; \n and \t are newline and tab. \d \w \s are [0-9], [A-Za-z0-9_] and [ \t\n\r\f\v] (ASCII only); \D \W \S are their complements.
- . matches any character except newline.
- Character class [...] or negated [^...]: a non-empty sequence of items. An item is a literal (printable ASCII except \ [ ] - and, in first position, ^), an escape as above (including \] \- \\ \d \W ...), or a range x-y of two single characters (literal or escaped) with x <= y.
- Groups: (...) capturing, numbered by their opening parenthesis from left to right starting at 1; (?:...) non-capturing. Alternation | binds loosest; an alternative may be empty.
- Anchors (zero width, never quantified): ^ matches only at position 0; $ matches at the end of the string or just before a newline that is the string's last character; \b matches where exactly one of the characters on its two sides is a \w character (outside the string counts as non-word); \B matches wherever \b does not.
- Quantifiers, applied to a literal, escape, ., class or group: * + ? {n} {n,} {n,m} with 0 <= n <= m <= 100, each optionally followed by ? to make it lazy. Whenever the quantified operand can match the empty string, the quantifier is one of ? ?? {n} {n}?.
- Patterns are at most 60 characters. Strings are at most 5000 characters of printable ASCII, newline and tab.

Rules
- Do not use re or any other regex engine. The validator rejects code in which any of these identifiers appears: addaudithook, attrgetter, __base__, __bases__, breakpoint, BuiltinImporter, builtins, __builtins__, __class__, __code__, create_builtin, create_dynamic, create_module, ctypes, delattr, __dict__, eval, exec, exec_builtin, exec_module, execv, execve, fnmatch, fork, Formatter, gc, get_field, getattr, __getattribute__, glob, globals, __globals__, _imp, __import__, importlib, loader, __loader__, locals, meta_path, methodcaller, modules, __mro__, multiprocessing, os, path_hooks, posix, posix_spawn, _posixsubprocess, pty, re, regex, resource, setattr, _signal, signal, __spec__, _sre, sre_compile, sre_constants, sre_parse, __subclasses__, subprocess, _sys, sys, _thread, threading, vars.
- rx.py is loaded in a process in which re is disabled, no file can be opened and no module can be newly imported. Only these already-loaded modules may be imported: __future__ abc array bisect collections collections.abc contextlib copy dataclasses enum functools heapq io itertools math operator random string types typing weakref.
- rx.py runs in its own process: it may not start other processes or programs.
- search must run in worst-case time O(P * len(string)) for every pattern in the language, where P is the size of the pattern once counted repeats are written out, including the patterns that make backtracking engines (re among them) take exponential time, such as (a|a)*b against 4000 a's.

Validation: about 14000 hidden, seeded search cases (some 5000 distinct patterns) and 1500 finditer cases, then about 3000 search and 600 finditer cases on strings of 28-64 characters whose patterns make backtracking engines (re among them) take exponential time, all checked exactly against re; then a timed set of 98 search cases of the same kind on strings up to 5000 characters. Each set has a CPU-time budget, the timed set 4 seconds (more under a loaded harness); a correct Pike VM needs a tenth of that. Only a failing case's index is reported. Write your own tests; you may use re in them.

What it tests and why it is in the suite

What it asks. A regex matcher that reproduces Python’s re exactly on a stated pattern language, group spans included, and never takes super-linear time.

Why it is here. A new family. With the bigint division it carries Algorithms & DS: the v4 families 71 and 20 were left out because every v4 variant writes its expected outputs into the agent’s directory, and their rework did not clear review.

In the suite README: evals/README.md:133 · evals/README.md:158

How it is graded

The validator holds its checks where the agent cannot read them, and runs them against what the agent left on disk once it stops. Its hidden cases are generated inside the validator from a seed; any worked sample the prompt names is only a sample, and no expected output for a hidden case is in the agent’s directory. Before any model ran it, the unit was proven: its reference solution passes, plausible wrong solutions fail for the reason declared in advance, an empty solution and a leak probe fail, and, where the unit is timed, a slow solution fails by the validator’s own limit. The family also went through up to three adversarial review rounds, in which an independent verifier tried to pass every unit without solving it.

Upstream: the prover’s controls · one unit’s life cycle · why v5 is built this way

How each ranked run did

One run per board row, the DGX Spark pair first, then the RTX 5090, then the gold standard. Each is a single seed: a pass or a fail on one unit is one draw, and a difference between two rows on one unit says little on its own. Claude Opus 5.5 is the unranked reference, in its own scaffold.

DGX Spark pair

One RTX 5090

Gold standard · unranked

  • Claude Opus 5.5Claude Code tools, no turn cap, 2× wallPassedPassed the validator.