Skip to content

linalg · Lattice

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

Worked example

The complete checked program Enumerate and verify the six shortest vectors of the A2 lattice uses this API directly.

# SPDX-License-Identifier: MIT
# Copyright (c) 2026 Benjamin Antieau and Deven Manam
"""Enumerate and verify the six shortest vectors of the A2 lattice."""

from noether import Z
from noether.linalg import Lattice, Matrix


def main() -> None:
    lattice = Lattice(Matrix.from_rows(Z, [[2, -1], [-1, 2]]))
    shortest = lattice.shortest_vectors()
    shortest.verify(lattice)
    assert shortest.signed_count == 6
    assert shortest.max_norm == 2
    print(f"A2 has {shortest.signed_count} shortest vectors of norm {shortest.max_norm}")


if __name__ == "__main__":
    main()

Run it with .venv/bin/python examples/06_shortest_lattice_vectors.py.

linalg.Lattice

A positive-definite integral lattice presented by its Gram matrix.

Lattice(gram_matrix: Matrix[IntegerRing])

noether::linalg::Lattice · Direct Rust declaration

pub struct Lattice { /* private fields */ }
Contract Value
Guarantee checked deterministic result
Determinism deterministic
Availability default CPU build
Domain implementation crates noether, flint-core, m4rst, m4rst-distributed, m4rste, mzs, pwvla, spar-core, sparla, sparb, lattice-enum
GIL attached / bounded
Semantic ID noether/linalg/Lattice@1

Executable usage: examples/06_shortest_lattice_vectors.py:10 · examples/06_shortest_lattice_vectors.py:6 · validation/unit/infra/test_concurrency.py:17 · validation/unit/infra/test_concurrency.py:73 · validation/unit/infra/test_discovery.py:150 · validation/unit/infra/test_public_api_index.py:159

linalg.Lattice.closest_vectors

Compute closest vectors for this Lattice.

Detailed contract

Find every closest lattice vector to an exact rational target. target_numerators / target_denominator gives coordinates in the Gram presentation. Returned coordinates are currently word-sized; search geometry, Gram arithmetic, distances and comparisons are exact and arbitrary precision.

(self, target_numerators: Iterable[int], target_denominator: int=1, *, max_count: int | None=None) -> ClosestLatticeVectors

noether::linalg::Lattice::closest_vectors · Direct Rust declaration

pub fn closest_vectors( &self, target_numerators: &[i64], target_denominator: i64, max_count: Option<usize>, ) -> Result<ClosestLatticeVectors, LatticeError>
Contract Value
Guarantee checked deterministic result
Determinism deterministic
Availability default CPU build
Domain implementation crates noether, flint-core, m4rst, m4rst-distributed, m4rste, mzs, pwvla, spar-core, sparla, sparb, lattice-enum
GIL released
Semantic ID noether/linalg/Lattice@1

Executable usage: validation/unit/linalg/test_lattice_facade.py:69

linalg.Lattice.gram_matrix

Exact integral Gram matrix.

Detailed contract

The exact integral Gram matrix.

(self) -> Matrix[IntegerRing]

noether::linalg::Lattice::gram_matrix · Direct Rust declaration

pub fn gram_matrix(&self) -> &Matrix<IntegerRing>
Contract Value
Guarantee checked deterministic result
Determinism deterministic
Availability default CPU build
Domain implementation crates noether, flint-core, m4rst, m4rst-distributed, m4rste, mzs, pwvla, spar-core, sparla, sparb, lattice-enum
GIL attached / bounded
Semantic ID noether/linalg/Lattice@1

Executable usage: examples/29_integral_line_configurations.py:28 · validation/unit/linalg/test_lattice_facade.py:33

linalg.Lattice.minimum_vector_configuration

Compute and certify the complete minimum-vector configuration.

(self) -> MinimumVectorConfiguration

noether::linalg::Lattice::minimum_vector_configuration · Direct Rust declaration

pub fn minimum_vector_configuration( &self, ) -> Result<MinimumVectorConfiguration, LatticeError>
Contract Value
Guarantee checked deterministic result
Determinism deterministic
Availability default CPU build
Domain implementation crates noether, flint-core, m4rst, m4rst-distributed, m4rste, mzs, pwvla, spar-core, sparla, sparb, lattice-enum
GIL released
Semantic ID noether/linalg/Lattice@1

Executable usage: validation/unit/infra/test_discovery.py:150 · validation/unit/linalg/test_lattice_facade.py:41 · validation/unit/linalg/test_lattice_facade.py:58

linalg.Lattice.rank

Lattice rank.

Detailed contract

The lattice rank.

(self) -> int

noether::linalg::Lattice::rank · Direct Rust declaration

pub fn rank(&self) -> usize
Contract Value
Guarantee checked deterministic result
Determinism deterministic
Availability default CPU build
Domain implementation crates noether, flint-core, m4rst, m4rst-distributed, m4rste, mzs, pwvla, spar-core, sparla, sparb, lattice-enum
GIL attached / bounded
Semantic ID noether/linalg/Lattice@1

Executable usage: examples/38_exact_linear_systems.py:78 · examples/distributed/f2_linear_algebra.py:34 · examples/distributed/f2_linear_algebra.py:54 · examples/distributed/f2_linear_algebra.py:55 · examples/distributed/f2_linear_algebra.py:60 · validation/unit/combin/test_acceptance_workload.py:74

linalg.Lattice.shortest_vectors

Enumerate all shortest signed lattice vectors with an exact certificate.

Detailed contract

Enumerate one canonical representative from each ± pair up to a norm bound. With no bound, this returns the complete shortest-vector shell. Supplying max_pairs permits a deterministic prefix and bypasses the kernel’s whole-ellipsoid work estimate. The returned value states whether that prefix is complete. A rank-zero lattice accepts bounded empty-shell queries but rejects the unbounded form because no nonzero minimum is attained.

(self, *, bound: int | None=None, max_pairs: int | None=None) -> LatticeEnumeration

noether::linalg::Lattice::shortest_vectors · Direct Rust declaration

pub fn shortest_vectors( &self, bound: Option<Integer>, max_pairs: Option<usize>, ) -> Result<LatticeEnumeration, LatticeError>
Contract Value
Guarantee checked deterministic result
Determinism deterministic
Availability default CPU build
Dispatch / backing lattice-enum
GIL released
Semantic ID noether/linalg/Lattice@1
Evidence LatticeEnumeration.verify

Executable usage: examples/06_shortest_lattice_vectors.py:11 · validation/unit/infra/test_concurrency.py:83 · validation/unit/infra/test_public_api_index.py:159 · validation/unit/linalg/test_lattice_facade.py:29 · validation/unit/linalg/test_lattice_facade.py:52 · validation/unit/linalg/test_lattice_facade.py:53