Skip to main content
Language v0.2.0 · Preview

Deterministic N/M property assertions

Negotiate seeded finite-shot tolerances, inclusive observable ranges, explicit global-phase equivalence, and auditable property counterexamples.

Deterministic N/M 0.2 property assertions

NM-RFC-0003 turns finite-shot checks, observable bounds, and global-phase equivalence into explicit machine-readable contracts. The stable 0.1 parser remains unchanged unless the feature is negotiated.

NM-RFC-0003experimental0.2.0-runtime-experimental
32
property cases
1
max tolerance
1,000,000
max |bound|

Seeded shot tolerance

The ~= form requires both @seed and @shots. Each property case receives a derived random stream and records sampled value, analytic value, standard error, shot count, and tolerance.

assert probability(|bits>) ~= expected tolerance delta;

Inclusive observable range

The in [minimum, maximum] form evaluates the complete weighted observable analytically and includes both endpoints with a bounded numeric epsilon.

assert expectation <observable> in [minimum, maximum];

Equivalent up to global phase

up_to_phase records phasePolicy=global and compares state fidelity. A global exp(iφ) factor cannot change the verdict.

assert equivalent("target") up_to_phase;

Auditable counterexamples

Execution stops at the first failing property case and retains the parameter value, derived seed, ordered assertion evidence, and stable diagnostic codes.

fnv1a32(base-seed,property-name,parameter,canonical-value)

Experimental source

module property_assertions;@seed(17);@shots(256); fn main() {  property "phase-safe plus" {    forall theta in 0 .. PI step PI / 2 {      let q: QReg<1> = qreg[1];      GPhase(theta);      H(q[0]);      assert probability(|0>) ~= 0.5 tolerance 0.1;      assert expectation Z(q[0]) in [-1, 1];      assert equivalent("plus") up_to_phase;    }  }  return 0;}

Explicit surface negotiation

Core callers pass the parser option; CLI, LSP, and VS Code expose separate opt-ins. Defaults stay disabled so experimental syntax cannot silently enter stable projects.

parseNMCode(source, { experimental: { propertyAssertions: true } })nm test main.nm --experimental-property-assertionsinitializationOptions.nm.experimental.propertyAssertions = truenm.experimental.propertyAssertions = true

Stable diagnostics

NM-PARSE-056NM-PARSE-057NM-PARSE-058NM-PARSE-059NM-ASSERT-007NM-ASSERT-008NM-ASSERT-009

This experimental slice does not include arbitrary generators, shrinking, confidence intervals, per-assertion shot counts, density-matrix equivalence, or exhaustive failure collection. FNV seed derivation is for reproducibility, not security.