A riff on Cook-Levin Chapters

Chapter 39

The oracles

Every implementation in this repository computes the same answers in its own way, and each is held to the others. The spine of the project is that they all agree.

16 counts, 4 polynomials Python C Roc SAT, rocsat JavaScript x3 Shale Nibble's wasm 16 counts, 4 polynomials Python C Roc SAT, rocsat JavaScript x3 Shale Nibble's wasm
Seven ways to the same answers

What each one checks §

One program, three runners §

js/oracle.shale runs the JavaScript port three ways (c251895), each held to the goldens. The runners are node, and two of roc-js-interpreter's, both written in Roc: its bytecode VM and its compiler to x86-64. The port is written in the subset of JavaScript that roc-js-interpreter runs, which leaves out the bitwise operators, so the OR and AND of two masks come from tables of their 7-bit halves.

By README.md's timings on this box, 2026-11-25: node takes about 0.3 s, the VM about 80 s, in about 15 million of its steps, and the compiled executable, 111,698 bytes, 0.6 to 1.0 s, at a peak of 33 MB. The compiled program is slower than node here, and that is unprofiled. These runs were left unrepeated for this book.

Why so many §

Each pair shares only the machine's rule. The interpreter branches on opcodes, the stepper evaluates polynomials, the composition substitutes them, the SAT encoding propagates clauses, and rocsat searches. A bug would have to land the same way in all of them to pass.