Skip to main content
Language v0.2.0 · Preview

Bounded typed values after measurement

Negotiate immutable Int, Float, fixed arrays, explicit measurement conversions, deterministic runtime evidence, and fail-closed numeric bounds.

Typed classical values at the quantum boundary

NM-RFC-0005 makes post-measurement aggregation explicit and bounded. Stable N/M 0.1 Bit behavior stays unchanged until every surface negotiates the feature.

NM-RFC-0005experimental0.2.0-runtime-experimental
256
maximum array length
52
bits_to_int width
1,000,000,000,000
maximum |Float|

Immutable scalar values

Int is a safe integer and Float is finite and bounded. Numeric widening is explicit, so a sampled Bit cannot silently enter arithmetic.

let ratio: Float = int_to_float(count) / 3.0;

Fixed bounded arrays

Array<Bit|Int|Float, N> fixes its element type and 1..256 length in source. Indexes are compile-time literals and are checked before execution.

let bits: Array<Bit, 3> = [a, b, c];

Safe measurement helpers

bit_to_int, bits_to_int, count_ones, int_to_float, and mean cover the first deterministic aggregation boundary without general-purpose mutable state.

bit_to_int · int_to_float · bits_to_int · count_ones · mean · sin · cos · sqrt · exp · log · log1p · expm1 · tanh · sigmoid · abs · floor · ceil · round · min · max · clamp · sum · dot · norm · add · sub · scale · variance · stddev · argmin · argmax · radians · degrees · to_radians · to_degrees

Ordered runtime evidence

Core and Worker expose the same ordered name, canonical type, value, and source-line evidence. Missing values and invalid arithmetic fail closed.

deterministic-fail-closed-with-ordered-evidence

Measurement aggregation example

module typed_measurement_summary;@seed(17); fn main() {  let q: QReg<3> = qreg[3];  H(q[0]);  CNOT(q[0], q[1]);  let a: Bit = measure(q[0]);  let b: Bit = measure(q[1]);  let c: Bit = measure(q[2]);  let outcomes: Array<Bit, 3> = [a, b, c];  let encoded: Int = bits_to_int(outcomes);  let ones: Int = count_ones(outcomes);  let ratio: Float = int_to_float(ones) / 3.0;  return encoded;}

Explicit surface negotiation

parseNMCode(source, { experimental: { typedClassicalValues: true } })nm run main.nm --experimental-typed-classical-values --jsoninitializationOptions.nm.experimental.typedClassicalValues = truenm.experimental.typedClassicalValues = true

Stable diagnostics

NM-PARSE-062NM-PARSE-063NM-TYPE-023NM-TYPE-024NM-RUNTIME-032

The first contract excludes mutation, dynamic indexes, nested arrays, arbitrary classical functions, implicit casts, and branch-sensitive result inference. NM-RFC-0007 adds structured main results only when separately negotiated.