← Workbench SPECIFICATION · .RL v0.4 v0.4.0 DOI: 10.5281/zenodo.23722094

Rul (.rl) v0.4 Binary Specification — 128-Bit ISA & O(N) Verifier

Official binary layout specification of Rul (.rl) v0.4: 64-byte RulHeader, 16-byte ArenaDescriptor, 16-byte ProofEntry, 128-bit NodeFrame across 29 opcodes, and single-pass O(N) verification rules.

[0x01] CORE EQUATION

Artifact (.rl) = Algorithm + Schedule + Proof

Every executable Rul program is a flat binary .rl image aligned on 16-byte and 64-byte boundaries for direct zero-copy memory mapping (mmap). The core execution engine contains zero textual lexers or AST parsers.

1. Binary-First

Lossless bidirectional .rls <-> .rl conversion in ~8.8 µs at the boundary via src/transpiler.rs.

2. Topological SSA-DAG

Every instruction node i may only reference operands strictly < i, guaranteeing termination.

3. Safety + Intent Split

Layer 1 proves memory/bounds safety in 5.78 ns/node; Layer 2 verifies AssertContract & rul trace.

[0x02] SECTION 1 OF .RL

RulHeader (64 Bytes, Cache-Line Aligned)

BYTE OFFSETFIELDTYPEDESCRIPTION
0..8magic[u8; 8]Canonical magic signature: b"RUL\x00\x01\x00\x00\x00"
8..16graph_hashu6464-bit FNV-1a integrity hash over Arena, Proof, and Node sections
16..24capability_masku64Hardware I/O sandbox mask (0x00 = Pure Compute, 0x01 = NetRing, 0x02 = StorageDMA, 0x04 = GpuDispatch)
24..28arena_countu32Number of 16-byte ArenaDescriptor entries
28..32proof_countu32Number of 16-byte ProofEntry bounds certificates
32..36node_countu32Number of 128-bit (16-byte) NodeFrame instructions
36..40output_nodeu320-based index of the primary output SSA node
40..64reserved[u8; 24]Zero-filled padding aligning header to 64-byte CPU cache line
[0x03] SECTIONS 2 & 3 OF .RL

ArenaDescriptor (16 Bytes) & ProofEntry (16 Bytes)

BYTE OFFSETArenaDescriptorTYPEDESCRIPTION
0..4arena_idu32Columnar Arena identifier (0 .. arena_count - 1)
4..8element_countu32Homogeneous column length (Shape Length)
8type_laneu8Element type & SIMD lane width (e.g. 0x18 = f64x8)
9mutabilityu80 = Immutable Input | 1 = Linear Mutable Region
10..12alignmentu16Byte alignment requirement (64 bytes for AVX-512 / cache line)
12..16initial_versionu32Initial AffineToken version (starts at 1)
BYTE OFFSETProofEntryTYPEDESCRIPTION
0..2rule_kindu161 = SliceBounds (lo <= hi <= len) | 2 = GatherIndexInBounds (max_idx <= target_len)
2..4target_arenau16Target Arena ID strictly bound to operand origin_arena
4..8bound_lou32Non-negative lower index bound
8..12bound_hiu32Upper bound <= effective_target_len
12..16witness_nodeu32Witness SSA index node (in_b for Gather)
[0x04] SECTION 4 OF .RL

128-Bit NodeFrame Layout (16 Bytes)

Algorithm Lane (What to compute: Opcode / Operands) Schedule Lane (How to run: SIMD / MultiCore) Proof Lane (Safety: Version Ticket / Bounds)
NODE #3 ($n3) node $n3 = Mul f64x8 fg=1 pol=simd proof=0 tok=pure a=$n0 b=$n0
16 BYTES = 128 BITS
8-BIT REGISTER BREAKDOWN · BYTE 2 (b16..b23) 0x12
0 2^7
0 2^6
0 2^5
1 2^4
0 2^3
0 2^2
1 2^1
0 2^0
Field: schedule_hint Type: u8
✓ O(N) Verifier Invariant Checked at Load Time (~5.78 ns) (fusion_group << 4) | exec_policy

Orthogonal hardware schedule byte: mutating 0x11 (SimdStream) -> 0x12 (MultiCore) changes CPU execution without altering safety proofs.

Node #3: Elementwise 8-lane vector square ($n0 * $n0) fused in L1 cache registers with zero intermediate heap allocation.
[0x05] 29-OPCODE ISA (v0.4.0)

Complete 29-Opcode Instruction Set

HEXOPCODECATEGORYSEMANTICSDESCRIPTION
0x01ArenaInputMemory & ArenaArenaDescriptor[in_a] -> ColumnLoad columnar slice from ArenaDescriptor[in_a] with ReadLease.
0x02ConstF64Memory & Arenain_a | (in_b << 32) -> Scalar f64Immediate 64-bit IEEE-754 floating-point scalar constant.
0x03ArenaSliceMemory & ArenaSlice(in_a, ProofEntry[proof_idx]) -> ColumnZero-copy sub-slice of column in_a certified by ProofEntry.
0x04ArenaMutateMemory & ArenaMutate(Arena[in_a], in_b) -> ver + 1Linear in-place mutation consuming AffineToken (ver -> ver + 1).
0x10AddArithmetic & Mathout[i] = a[i] + b[i]Elementwise SIMD addition (VADDPD).
0x11SubArithmetic & Mathout[i] = a[i] - b[i]Elementwise SIMD subtraction (VSUBPD).
0x12MulArithmetic & Mathout[i] = a[i] * b[i]Elementwise SIMD multiplication (VMULPD).
0x13DivArithmetic & Mathout[i] = a[i] / b[i]Elementwise IEEE-754 SIMD division (VDIVPD).
0x14CmpGtPredicate & Maskmask[i] = a[i] > b[i]Branchless greater-than predicate mask (VCMPPD).
0x15SelectZeroPredicate & Maskout[i] = mask[i] ? val[i] : 0.0Branchless predicated selection zeroing masked-out lanes (VANDPD).
0x16MinArithmetic & Mathout[i] = min(a[i], b[i])Branchless elementwise minimum (VMINPD).
0x17MaxArithmetic & Mathout[i] = max(a[i], b[i])Branchless elementwise maximum (VMAXPD).
0x18CmpLtPredicate & Maskmask[i] = a[i] < b[i]Branchless less-than predicate mask.
0x19CmpEqPredicate & Maskmask[i] = a[i] == b[i]Branchless equality predicate mask.
0x1AAbsArithmetic & Mathout[i] = |a[i]|Branchless IEEE-754 sign-bit clear absolute value.
0x1BSqrtArithmetic & Mathout[i] = sqrt(a[i])Hardware SIMD square root (VSQRTPD).
0x1CFloorArithmetic & Mathout[i] = floor(a[i])Branchless rounding toward -Infinity (VROUNDPD).
0x1DCeilArithmetic & Mathout[i] = ceil(a[i])Branchless rounding toward +Infinity (VROUNDPD).
0x1ELnArithmetic & Mathout[i] = ln(a[i])Elementwise natural logarithm stencil.
0x1FExpArithmetic & Mathout[i] = exp(a[i])Elementwise natural exponential stencil.
0x20FilterCompactReduction & CompactionCompact(mask=in_a, vals=in_b)Stream compaction packing matching elements contiguously.
0x21ReduceSumReduction & Compactionsum(in_a) -> Scalar f648-accumulator horizontal sum reduction to scalar.
0x22ReduceMaxReduction & Compactionmax(in_a) -> Scalar f64Horizontal maximum reduction to scalar.
0x23GatherReduction & Compactiontarget[indices[i]] (proof_idx > 0)Certified indirect indexed gather backed by ProofEntry.
0x24ReduceMinReduction & Compactionmin(in_a) -> Scalar f64Horizontal minimum reduction to scalar.
0x25MaskAndPredicate & Maskmask[i] = a[i] && b[i]Bitwise boolean mask conjunction.
0x26MaskOrPredicate & Maskmask[i] = a[i] || b[i]Bitwise boolean mask disjunction.
0x30RingEnqueueHardware & ContractEnqueue(in_a) [Requires CAP_NET_RING]Capability-gated hardware ring buffer output.
0x40AssertContractHardware & ContractAssert(!is_nan(in_a) && is_finite(in_a))Runtime domain contract verifying finite, non-NaN output.
[0x06] STATIC VERIFICATION (~5.78 NS/NODE)

Four Single-Pass O(N) Linear Verification Rules

1. Topological SSA Rule

Every node at index i must satisfy in_a < i and in_b < i, mathematically preventing cycles.

2. Linear Ownership Conservation

ReadLease(a, ver) checks live_version[a] == ver. AffineConsume(a, ver) checks mutability and increments live_version[a] via checked_add(1).

3. Origin-Bound Refinement Proof

ArenaSlice and Gather verify ProofEntry.target_arena == origin_arena and bound_lo <= bound_hi <= effective_target_len.

4. Zero-Trust CapabilityMask

Hardware I/O opcodes (0x30 RingEnqueue) require the matching bit in RulHeader.capability_mask or are rejected before execution.