crt_step

std.elementwise.crt_step · Level L4

Fold one congruence x ≡ rᵢ (mod mᵢ) into a solution x modulo M: x + M·t, with t = (rᵢ − x)·M⁻¹ mod mᵢ, and the modulus becomes M·mᵢ. The inverse comes from bezout. The body crt scans.

x′ = x + M·((rᵢ − x)·M⁻¹ mod mᵢ), M′ = M·mᵢ

Signature

crt_step(x: i64[], M: i64[], ri: i64[], mi: i64[]) → i64[], i64[]

Structure

The function as NOVA stores it: one box per input, operation and output, and arrows that carry values. A double border marks another library function this one runs — called once, or by Scan once per element; select it to open that function.

xi64[]rii64[]Mi64[]mii64[]SubtractdiffModMmReshapemi1MultiplyM2ModdmReshapeMm1bezoutgReduceSumu0ModumMultiplyt0ModtMultiplyliftAddx2x2i64[]M2i64[]
  • input
  • operation
  • constant
  • call
  • output

Verification

  • Signature proven by NOVA’s shape solver, for every size.
  • Equal to the reference u = M^-1 mod mi by extended Euclid; x + M*((ri - x)*u % mi), M*mi in exact rational arithmetic, on all 40 test cases.
  • All 80 int64 results are exact: the error is zero.
  • Interpreter and NumPy backend return bit-identical results.
  • At float32 too: the 40 test cases rounded to float32, and 40 of them exact, with zero error.
Accuracy in detail
correctly rounded (the int64 nearest the exact value)
100%
bit-equal to the NumPy formula in int64
100%
largest error, in units in the last place
0

Identity

Calls
Called by
sha256:5896b08e497af28f0d8e1167c473303b0e6ea7a05f8978de3dfbfee875762274

The semantic hash of the graph. It changes when the program changes, and never when only its documentation does.

Control handle

Symbol
Ω:std.elementwise.crt_step · Ω:crt_step
Pins
sha256:7f139c1ecb0e92bb295be87ccec14caffe354a9c7487fe3dcbe2c97ab0e934d0this graph and the 3 it reaches through calls
Evidence
sha256:ab9e58e364fb78969d4f429a7aacfe2b3387169822a7a8893b3c54de898d6a09the hash of its verification record
Needs
no capability: a pure function

Through NOVA’s control layer, the symbol launches this function only while the program still matches what it pins: a change to this graph, or to any graph it reaches, needs a migration first.

ΣEML 2026

Efficient New Language — a high-density semantic overlay for humans and AI agents.

This site’s demos run on the real EML toolchain, in your browser.

© 2026 EveMissLab (一言諾科技有限公司) / Neo.K. All rights reserved.