hv-chemical-compute

A Minsky machine to Chemical Reaction Network compiler. Takes a 5-instruction Minsky program and emits a CRN specification using multi-rail register encoding, sharp zero detectors, and instruction markers. Verifies that the compiled CRN computes the same function as the source VM on 11 reference programs.

Size: ~22 KB source, no weights. Runtime: <1 s for the full benchmark. Dependencies: NumPy only.

The primitive

A Minsky machine has five instruction types:

instruction semantics
INC r increment register r
DECJZ r, addr if r > 0, decrement and continue; else jump to addr
JMP addr unconditional jump
HALT halt

Minsky (1967) proved this is Turing-complete. The compiler translates a Minsky program into a formal CRN spec β€” species names, reaction stoichiometry, rate constants β€” that a strand-design tool could realize in DNA.

The compilation scheme

Registers are encoded as multi-rail species:

R_{r}_0  R_{r}_1  ...  R_{r}_{n_max}

Exactly one rail is at concentration 1 at a time. Register value k means R_{r}_k = 1.

Zero detector for each register:

βˆ…  β†’ ZD_r              (source, K_zd = 0.3)
ZD_r β†’ βˆ…               (decay)
ZD_r + R_{r}_k β†’ R_{r}_k   (catalytic, k β‰₯ 1)

ZD stays at K_zd when the register is 0, drops to 0 when any nonzero rail is present.

Instructions fire by consuming an instruction marker:

INC r:              I_i + R_{r}_k β†’ R_{r}_{k+1} + I_{i+1}
DECJZ (r > 0):      I_i + R_{r}_k β†’ R_{r}_{k-1} + I_{i+1}
DECJZ (r = 0):      I_i + R_{r}_0 β†’ I_addr
JMP:                I_i β†’ I_addr
HALT:               I_i β†’ WASTE

Auto-sizing. n_max is computed from the VM trace (max register value seen, plus 1). This eliminates the fixed ceiling that would otherwise cap the compileable program class.

Headline numbers

11 reference programs, all verified:

program n_max species reactions strands
ADD_2_3 6 21 31 60
ADD_5_5 11 31 51 100
COPY_2 3 15 19 36
COPY_5 6 21 31 60
SUB_5_2 6 21 32 62
SUB_8_3 9 27 44 86
DOUBLE_3 7 24 42 82
COND_REL_0_0 1 15 16 29
COND_REL_0_1 2 18 22 41
COND_REL_1_0 2 18 22 41
COND_REL_1_1 2 18 22 41

All programs are under the 200-strand practical DSD limit.

62/62 consistency checks pass.

Zero detector thresholds

From the source archive (SKILLS Β§3.5):

parameter threshold purpose
K_zd ≀ 0.3 steady-state ZD at zero
n_zd β‰₯ 8 amplification factor
k_instr β‰₯ 10 instruction firing rate

Configurations violating these are flagged.

The 16-ISA taxonomy

The toolkit includes the 16-paradigm ISA registry from SKILLS Β§3.6:

category count status
one-shot marker 10 9 implemented, 1 not (Homoiconic)
pulse-quantum 2 both implemented
external clock 1 implemented
position-state 3 all implemented

15 of 16 have demonstrated or commercial chemical implementations. HomoiconicISA β€” where instructions and operands are the same species β€” has no known implementation.

How to use

from hv_chemical_compute import (
    Instruction, MinskyVM, CRNCompiler, CRNSimulator,
    make_reference_programs, isa_registry_summary,
)

# Define a program
program = [
    Instruction('DECJZ', reg=1, target=3),
    Instruction('INC', reg=0),
    Instruction('JMP', target=0),
    Instruction('HALT'),
]
n_regs = 2
initial = [2, 3]

# Run the reference VM
vm = MinskyVM(program, n_regs, initial)
print(vm.run()['final_regs'])      # [5, 0]

# Compile to CRN
compiler = CRNCompiler()
spec, meta = compiler.compile(program, n_regs, initial)
print(spec.summary())
print(f"strand budget: {spec.strand_budget()}")

# Simulate the compiled CRN
sim = CRNSimulator(spec, meta)
print(sim.run(program)['final_regs'])   # [5, 0]

# Get the ISA registry
print(isa_registry_summary())
Downloads last month
35
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support