padic_valuation

std.elementwise.padic_valuation · Level L4

The p-adic valuation vₚ(a), elementwise: the exponent of the highest power of p dividing a ≠ 0, found by dividing p out of |a| until it no longer divides. A negative a is taken by its absolute value. vₚ(0) is infinite, so for a = 0 the loop reaches max_steps and fails rather than return a number.

vₚ(a) = max{k : pᵏ | a}

Signature

padic_valuation(a: i64[s], p: i64[s]) → i64[s]

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.

ai64[s]0pi64[s]NegatenaMultiplyk0Maximumm0While·valuation_stepm_end, k_endIdentityvvi64[s]
  • input
  • operation
  • constant
  • call
  • output

Verification

  • Signature proven by NOVA’s shape solver, for every size.
  • Equal to the reference divide |a| by p while it divides; count in exact rational arithmetic, on all 40 test cases.
  • All 166 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

sha256:ad78f4c673cb57f1b1a9a457aaf45446c0e6c3672512df4848a44816924b8790

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

Control handle

Symbol
Ω:std.elementwise.padic_valuation · Ω:padic_valuation
Pins
sha256:260c065223b2c69cf7fbe8ecf2c715f168a3679571b9678d9719cc04b20d5538this graph and the 2 it reaches through calls
Evidence
sha256:7a5d5382a9437a7df812a5447330edb1f24597b69b513f46718606544113fb22the 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.