Muon

From Esolang
Jump to navigation Jump to search

Muon

Muon is an esoteric programming language based entirely on tensor computation and a minimalistic, unconventional control flow system. It is Turing-complete, relying on tensors as the sole data structure and using only unconditional jumps for flow control. All logic and branching are encoded implicitly in the tensor data.

Design philosophy

Muon eliminates all explicit conditionals, loops, and standalone scalar or integer values. Instead, every instruction runs unconditionally on every cycle, and program behavior emerges from the values inside tensors acting as masks and data. Control flow is entirely data-driven and implicit, making Muon a unique exploration of computation where data controls flow rather than explicit instructions.

Syntax and instructions

Labels are declared with an `@` prefix:

@label:
...instructions...

@next_label

The only flow control instruction is the unconditional jump:

  • >> @label — jump unconditionally to a label

Instructions include:

  • ts T [d1,d2,...] — declare tensor T with shape [d1,d2,...]
  • ld T@i V — load constant value V into tensor element T@i (initialization only)
  • mv A@i B@j — move value from tensor element A@i to B@j
  • op OP A@i B@j C@k — perform operation OP on A@i and B@j, store result in C@k

Supported operations:

  • add (addition)
  • sub (subtraction)
  • mul (multiplication)
  • cmp (compare equality; results in 1 if equal, else 0)
  • pt T@i — print value at tensor element T@i

Data model

All data is stored as tensors. There are no standalone integers or scalars; numeric values always reside inside tensors, which can be multi-dimensional arrays. Logic and control are encoded through tensor masks and values, rather than explicit flow instructions.

Control flow

Muon uses only the unconditional jump (>>). Since every instruction runs every cycle, branching and loops are simulated by mutating tensor states and cycling through labels repeatedly. Program flow is implicit, determined solely by tensor values rather than explicit conditional jumps.

Examples

Conditional behavior via masking

The following example simulates a conditional statement without explicit branching:

ts A [5]
ts B [5]
ts MASK [5]
ts ONE [5]
ts OUT [5]

ld A@2 1
ld B@2 1
ld ONE@1 1

@start:
op cmp A@2 B@2 MASK@2
op ONE@1 MASK@2 OUT@2

@start

This sets OUT[2] to 1 if A[2] equals B[2], by masking operations with MASK.

Loop simulation

An infinite loop incrementing a tensor element:

ts CNT [5]
ts ONE [5]
ts TMP [5]

ld CNT@0 1
ld ONE@1 1

@loop:
pt CNT@0
op add CNT@0 ONE@1 TMP@0
mv TMP@0 CNT@0

@loop

The program increments CNT[0] endlessly, demonstrating loop-like behavior with unconditional jumps.

Applications

Muon can express any computable function, despite its minimalistic design. It serves as:

  • A platform for experimenting with tensor-driven programming
  • A tool for exploring computation without explicit branching
  • An esolang challenge for rethinking program control as data-driven
  • A symbolic tensor manipulation language bridging math and low-level operations

Limitations

Muon excludes many conventional programming constructs:

  • No explicit conditionals, loops, or integer variables
  • Control flow limited to unconditional jumps
  • Logic encoded implicitly in tensor states, increasing programming complexity
  • Difficult to debug or reason about due to pervasive unconditional execution


Summary: Muon is a minimalist tensor-based esolang that models computation with pure data-driven control flow and minimal instructions. Its unconventional design challenges traditional programming paradigms, demonstrating universal computation with only tensors and unconditional jumps.