feat: multi-tape and nondeterministic Turing machines #76
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/tm-extend"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Extends the
Tmcontract as authorized in #73 (one-day-old service, zero users — the new shape becomes the frozen one).Core:
Tm.tapes1..=4; transitionsstate → read-tuple → action list(list > 1 = nondeterministic); deterministic fast path + PDA-style BFS (visited set, explored counter, 50k config cap, truncated = inconclusive, shortest accepting path); serde shims accept old single-action payloads; grade charges BFS explored 1:1 and det steps ÷16.API: same
/api/v1/tm/run; openapi.yaml + schema.d.ts updated; multi-tape/ND round-trip tests.Web:
tapes NDSL directive, per-tape transition lines, repeated LHS = ND; dynamic meta ({n} TAPES · DET/ND); per-tape tape rows; explored/truncated display; per-tape diagram labels; bilingual keys.Dojo: 3 verified library entries — {ww} and palindromes via 2 tapes, one ND decider for aⁿbⁿ — with a BFS mini-simulator oracle test (all 9 entries vs oracle, 8098 assertions).
cargo fmt/clippy/test green (152 rust tests); svelte-check/test/build green (51 web tests); end-to-end validated all 9 library machines against the live engine over exhaustive words ≤ 6 with zero mismatches.
Closes #73.
Tm gains a tapes field (1..=4, default 1) and transitions become state -> read-tuple -> action lists; TmAction carries per-tape writes and moves. Old single-action payloads {write, move, to} still parse via serde shims. Single-tape single-action machines keep the exact step loop; anything else runs a PDA-style BFS over configurations (canonical visited keys doubling as a parent map, shortest accepting path as the trace, reject branches pruned, 50k-configuration cap). Grading charges searched runs 1:1 per configuration and deterministic ones per step as before. Refs #73. Co-Authored-By: GLM (OpenCode) <dev@yhkze.net>parseTm gains a 'tapes N' directive (1..=4, default 1) and, for multi-tape machines, transition lines with one read symbol per tape on the left and per-tape 'write, move' groups separated by '|' on the right. Repeated left-hand sides now collect into the action list in all modes (nondeterminism); only fully identical lines are rejected, as a typo guard. The tape count is inferred from the first transition line when no directive is present. The machines page derives its panel meta from the edited text (tape count with localized plural, deterministic vs nondeterministic), renders one labelled tape row per tape, shows the explored-configuration count for search runs, and reports traceless nondeterministic outcomes (reject / truncated timeout). diagramFa labels multi-tape edges per tape ('1: a→X, R | 2: _→_, L'). Refs #73. Co-Authored-By: GLM (OpenCode) <dev@yhkze.net>Three new reference deciders, each checked by tmLibrary.test.ts against its member oracle over every word of length <= 7: { ww } on two tapes (copy, find the middle at double speed, compare the halves), palindromes on two tapes (copy, compare against the reversed copy), and { a^n b^n } on a single nondeterministic tape (each pass marks an a and guesses which b to pair it with). The test's mini-simulator now mirrors the engine: multi-tape configurations and a capped breadth-first search with visited-set pruning. Entries whose reference is not a deterministic single-tape machine carry full taskEn/taskEs wording; the offline bank and the sensei's library fallback use it, and the sensei prompt asks for 'a Turing machine' instead of prescribing the shape. Refs #73. Co-Authored-By: GLM (OpenCode) <dev@yhkze.net>