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.
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
1module property_assertions;2@seed(17);3@shots(256);4 5fn main() {6 property "phase-safe plus" {7 forall theta in 0 .. PI step PI / 2 {8 let q: QReg<1> = qreg[1];9 GPhase(theta);10 H(q[0]);11 assert probability(|0>) ~= 0.5 tolerance 0.1;12 assert expectation Z(q[0]) in [-1, 1];13 assert equivalent("plus") up_to_phase;14 }15 }16 return 0;17}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 = trueStable diagnostics
NM-PARSE-056NM-PARSE-057NM-PARSE-058NM-PARSE-059NM-ASSERT-007NM-ASSERT-008NM-ASSERT-009This 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.