Skip to content

commalg · Degree

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

Worked example

The complete checked program Reduce a module element and certify a minimal free resolution uses this API directly.

# SPDX-License-Identifier: MIT
# Copyright (c) 2026 Benjamin Antieau and Deven Manam
"""Reduce a module element and certify a minimal free resolution."""

from noether import Q
from noether.commalg import Degree, MonomialOrder, PolynomialRing
from noether.homalg import (
    FreeModule,
    ModuleElement,
    ModuleHomomorphism,
    ModuleMonomialOrder,
    PresentedModule,
    Submodule,
)
from noether.linalg import Matrix, Vector


def main() -> None:
    ring = PolynomialRing(Q, ["x", "y", "z", "w"])
    x, y, z, w = ring.generators()
    order = ModuleMonomialOrder.term_over_position(MonomialOrder.GREVLEX)

    ambient = FreeModule(ring, 2)
    first = ModuleElement(ambient, Vector.from_values(ring, [x, y]))
    second = ModuleElement(ambient, Vector.from_values(ring, [y, 1]))
    submodule = Submodule.from_generators(ambient, [first, second])
    basis = submodule.groebner_basis(order)
    reduction = basis.reduce(first + second * x)
    basis.verify()
    reduction.verify()
    assert reduction.is_member()

    target = FreeModule(ring, 1, grading_rank=1, degree_shifts=[Degree([0])])
    source = FreeModule(ring, 3, grading_rank=1, degree_shifts=[Degree([-2])] * 3)
    twisted_cubic = PresentedModule(
        ModuleHomomorphism(
            source,
            target,
            Matrix.from_rows(ring, [[x * z - y**2, x * w - y * z, y * w - z**2]]),
        )
    )
    resolution = twisted_cubic.minimal_free_resolution(order)
    resolution.verify()
    betti = resolution.graded_betti_table()
    betti.verify()
    assert betti.entries == [
        (0, Degree([0]), 1),
        (1, Degree([2]), 3),
        (2, Degree([3]), 2),
    ]
    print(f"module member certified; minimal Betti entries={betti.entries}")


if __name__ == "__main__":
    main()

Run it with .venv/bin/python examples/30_modules_and_resolutions.py.

commalg.Degree

One arbitrary-precision degree in a free abelian grading group.

Degree(coordinates: Sequence[int])

noether::commalg::Degree · Direct Rust declaration

pub struct Degree { /* private fields */ }
Contract Value
Guarantee checked deterministic result
Determinism deterministic
Availability default CPU build
Domain implementation crates noether, flint-core, groebner-kernel, module-core, poly-core, resolution-kernel
GIL attached / bounded
Semantic ID noether/commalg/Degree@1

Executable usage: examples/30_modules_and_resolutions.py:33 · examples/30_modules_and_resolutions.py:34 · examples/30_modules_and_resolutions.py:47 · examples/30_modules_and_resolutions.py:48 · examples/30_modules_and_resolutions.py:49 · examples/30_modules_and_resolutions.py:6

commalg.Degree.__add__

Add another compatible value to this value.

Detailed contract

Add two degrees after checking their ranks. Returns the argument unchanged.

(self, other: Degree) -> Degree

noether::commalg::Degree::add · Direct Rust declaration

pub fn add(&self, rhs: &Self) -> Result<Self, GradingError>
fn add(self, rhs: &Degree) -> Self::Output
Contract Value
Guarantee checked deterministic result
Determinism deterministic
Availability default CPU build
Domain implementation crates noether, flint-core, groebner-kernel, module-core, poly-core, resolution-kernel
GIL attached / bounded
Semantic ID noether/commalg/Degree@1

Executable usage: validation/unit/infra/test_discovery.py:211 · validation/unit/infra/test_public_api_index.py:293

commalg.Degree.__neg__

Return the additive inverse of this value.

Detailed contract

Negate every degree coordinate.

(self) -> Degree

noether::commalg::Degree::neg · Direct Rust declaration

pub fn neg(&self) -> Self
fn neg(self) -> Self::Output
Contract Value
Guarantee checked deterministic result
Determinism deterministic
Availability default CPU build
Domain implementation crates noether, flint-core, groebner-kernel, module-core, poly-core, resolution-kernel
GIL attached / bounded
Semantic ID noether/commalg/Degree@1

commalg.Degree.__sub__

Subtract another compatible value from this value.

Detailed contract

Subtract two degrees after checking their ranks.

(self, other: Degree) -> Degree

noether::commalg::Degree::sub · Direct Rust declaration

pub fn sub(&self, rhs: &Self) -> Result<Self, GradingError>
fn sub(self, rhs: &Degree) -> Self::Output
Contract Value
Guarantee checked deterministic result
Determinism deterministic
Availability default CPU build
Domain implementation crates noether, flint-core, groebner-kernel, module-core, poly-core, resolution-kernel
GIL attached / bounded
Semantic ID noether/commalg/Degree@1

Executable usage: validation/unit/infra/test_discovery.py:212

commalg.Degree.coordinates

Return the coordinates recorded by this Degree.

Detailed contract

Ordered integer coordinates.

(self) -> list[int]

noether::commalg::Degree::coordinates · Direct Rust declaration

pub fn coordinates(&self) -> &[Integer]
Contract Value
Guarantee checked deterministic result
Determinism deterministic
Availability default CPU build
Domain implementation crates noether, flint-core, groebner-kernel, module-core, poly-core, resolution-kernel
GIL attached / bounded
Semantic ID noether/commalg/Degree@1

Executable usage: validation/unit/commalg/test_base_change.py:114 · validation/unit/commalg/test_base_change.py:54 · validation/unit/commalg/test_base_change.py:62 · validation/unit/commalg/test_kahler_differentials.py:131 · validation/unit/commalg/test_polynomial_ideal_facade.py:171 · validation/unit/commalg/test_quotient_facade.py:142

commalg.Degree.from_json

Deserialize and revalidate a Degree from typed JSON.

Detailed contract

Deserialize and revalidate a degree.

(cls, value: str) -> Degree

noether::commalg::Degree::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, groebner-kernel, module-core, poly-core, resolution-kernel
GIL attached / bounded
Semantic ID noether/commalg/Degree@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

commalg.Degree.rank

Return the rank recorded by this Degree.

Detailed contract

Rank of the ambient free abelian grading group.

(self) -> int

noether::commalg::Degree::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, groebner-kernel, module-core, poly-core, resolution-kernel
GIL attached / bounded
Semantic ID noether/commalg/Degree@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

commalg.Degree.to_json

Serialize this Degree to its canonical typed JSON representation.

Detailed contract

Serialize the complete degree as typed JSON.

(self) -> str

noether::commalg::Degree::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, groebner-kernel, module-core, poly-core, resolution-kernel
GIL attached / bounded
Semantic ID noether/commalg/Degree@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

commalg.Degree.zero

Construct a Degree using zero.

Detailed contract

The zero degree in Z^rank.

(cls, rank: int) -> Degree

noether::commalg::Degree::zero · Direct Rust declaration

pub fn zero(rank: usize) -> Self
Contract Value
Guarantee checked deterministic result
Determinism deterministic
Availability default CPU build
Domain implementation crates noether, flint-core, groebner-kernel, module-core, poly-core, resolution-kernel
GIL attached / bounded
Semantic ID noether/commalg/Degree@1

Executable usage: examples/08_finite_field_extensions.py:11 · examples/10_padic_hensel_lifting.py:15 · examples/40_exterior_algebra.py:26 · examples/distributed/f2_linear_algebra.py:28 · examples/distributed/f2_linear_algebra.py:29 · examples/distributed/f2_linear_algebra.py:30