Skip to content

numthy · IntegerFactorization

7 accepted declarations. Python and Rust forms, contracts, evidence, failure boundaries, and checked usages are kept together below.

Worked example

The complete checked program Compute a fast Smith form without transformation matrices uses this API directly.

# SPDX-License-Identifier: MIT
# Copyright (c) 2026 Benjamin Antieau and Deven Manam
"""Compute a fast Smith form without transformation matrices."""

from noether import Z
from noether.linalg import Matrix


def main() -> None:
    matrix = Matrix.from_rows(Z, [[2, 4, 4], [6, 6, 12], [10, 4, 16]])
    smith = matrix.smith_normal_form()
    smith.verify()
    assert all(
        right % left == 0
        for left, right in zip(smith.invariant_factors, smith.invariant_factors[1:])
    )
    print(f"invariant factors: {smith.invariant_factors}")


if __name__ == "__main__":
    main()

Run it with .venv/bin/python examples/04_smith_normal_form.py.

numthy.IntegerFactorization

A complete proved prime factorization that reconstructs its input.

class IntegerFactorization

noether::numthy::IntegerFactorization · Direct Rust declaration

pub struct IntegerFactorization { /* private fields */ }
Contract Value
Guarantee checked deterministic result
Determinism deterministic
Availability default CPU build
Domain implementation crates noether, flint-core
GIL attached / bounded
Semantic ID noether/numthy/IntegerFactorization@1

Executable usage: validation/unit/numthy/test_acceptance_workload.py:14 · validation/unit/numthy/test_acceptance_workload.py:25 · validation/unit/numthy/test_acceptance_workload.py:29 · validation/unit/numthy/test_acceptance_workload.py:33 · validation/unit/numthy/test_acceptance_workload.py:38 · validation/unit/numthy/test_integer_arithmetic_facade.py:11

numthy.IntegerFactorization.factors

Strictly increasing proved prime factors with positive exponents.

Detailed contract

Strictly increasing (prime, exponent) pairs.

(self) -> list[tuple[int, int]]

noether::numthy::IntegerFactorization::factors · Direct Rust declaration

pub fn factors(&self) -> &[(Integer, u64)]
Contract Value
Guarantee checked deterministic result
Determinism deterministic
Availability default CPU build
Domain implementation crates noether, flint-core
GIL attached / bounded
Semantic ID noether/numthy/IntegerFactorization@1

Executable usage: examples/04_smith_normal_form.py:17 · examples/07_integer_factorization.py:12 · validation/unit/commalg/test_context_tower_workload.py:87 · validation/unit/commalg/test_polynomial_facade.py:126 · validation/unit/commalg/test_polynomial_facade.py:147 · validation/unit/commalg/test_polynomial_facade.py:158

numthy.IntegerFactorization.from_json

Deserialize and validate a canonical factorization from JSON.

Detailed contract

Deserialize and validate a canonical integer factorization from JSON.

(cls, value: str) -> IntegerFactorization

noether::numthy::IntegerFactorization::from_json · Direct Rust declaration

pub fn from_json(value: &str) -> Result<Self, NoetherError>
Contract Value
Guarantee checked deterministic result
Determinism deterministic
Availability default CPU build
Domain implementation crates noether, flint-core
GIL attached / bounded
Semantic ID noether/numthy/IntegerFactorization@1

Executable usage: validation/unit/category/test_category.py:14 · validation/unit/combin/test_acceptance_workload.py:65 · validation/unit/combin/test_acceptance_workload.py:86 · validation/unit/combin/test_graph_facade.py:106 · validation/unit/combin/test_graph_facade.py:25 · validation/unit/combinatorics/test_kashiwara_crystal.py:32

numthy.IntegerFactorization.to_json

Canonical JSON representation.

Detailed contract

Serialize this factorization to canonical JSON.

(self) -> str

noether::numthy::IntegerFactorization::to_json · Direct Rust declaration

pub fn to_json(&self) -> Result<String, NoetherError>
Contract Value
Guarantee checked deterministic result
Determinism deterministic
Availability default CPU build
Domain implementation crates noether, flint-core
GIL attached / bounded
Semantic ID noether/numthy/IntegerFactorization@1

Executable usage: validation/unit/category/test_category.py:14 · validation/unit/category/test_category.py:15 · validation/unit/combin/test_acceptance_workload.py:30 · validation/unit/combin/test_acceptance_workload.py:65 · validation/unit/combin/test_acceptance_workload.py:86 · validation/unit/combin/test_graph_facade.py:106

numthy.IntegerFactorization.unit

Multiplicative unit, either -1 or 1.

Detailed contract

The multiplicative unit, either -1 or 1.

(self) -> int

noether::numthy::IntegerFactorization::unit · Direct Rust declaration

pub fn unit(&self) -> i8
Contract Value
Guarantee checked deterministic result
Determinism deterministic
Availability default CPU build
Domain implementation crates noether, flint-core
GIL attached / bounded
Semantic ID noether/numthy/IntegerFactorization@1

Executable usage: validation/unit/commalg/test_local_algebra.py:42 · validation/unit/commalg/test_local_algebra.py:44 · validation/unit/commalg/test_local_algebra.py:45 · validation/unit/commalg/test_polynomial_ideal_facade.py:62 · validation/unit/commalg/test_polynomial_ideal_facade.py:68 · validation/unit/commalg/test_polynomial_ideal_facade.py:69

numthy.IntegerFactorization.value

Reconstruct the exact factored integer.

Detailed contract

Reconstruct the exact integer represented by this factorization.

(self) -> int

noether::numthy::IntegerFactorization::value · Direct Rust declaration

pub fn value(&self) -> Integer
Contract Value
Guarantee checked deterministic result
Determinism deterministic
Availability default CPU build
Domain implementation crates noether, flint-core
GIL attached / bounded
Semantic ID noether/numthy/IntegerFactorization@1

Executable usage: examples/09_finite_field_isomorphisms.py:13 · examples/09_finite_field_isomorphisms.py:14 · examples/13_chinese_remainder_theorem.py:12 · examples/13_chinese_remainder_theorem.py:13 · examples/13_chinese_remainder_theorem.py:14 · examples/17_weighted_power_series.py:18

numthy.IntegerFactorization.verify

Verify reconstruction against an exact Python integer.

Detailed contract

Verify that this factorization reconstructs value.

(self, value: int) -> bool

noether::numthy::IntegerFactorization::verify · Direct Rust declaration

pub fn verify(&self, value: &Integer) -> bool
Contract Value
Guarantee checked deterministic result
Determinism deterministic
Availability default CPU build
Domain implementation crates noether, flint-core
GIL attached / bounded
Semantic ID noether/numthy/IntegerFactorization@1

Executable usage: examples/01_bezout_certificates.py:10 · examples/01_bezout_certificates.py:3 · examples/03_exact_linear_systems.py:13 · examples/03_exact_linear_systems.py:3 · examples/04_smith_normal_form.py:12 · examples/06_shortest_lattice_vectors.py:12