Skip to content

commalg · WeightedGrading

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

Worked example

The complete checked program Decompose a polynomial by a nonstandard positive grading uses this API directly.

# SPDX-License-Identifier: MIT
# Copyright (c) 2026 Benjamin Antieau and Deven Manam
"""Decompose a polynomial by a nonstandard positive grading."""

from noether import Z
from noether.commalg import PolynomialRing, WeightedGrading


def main() -> None:
    ring = PolynomialRing(Z, ["x", "y", "z"], grading=WeightedGrading([1, 2, 3]))
    x, y, z = ring.generators()
    sparse = ring.from_terms([([0, 0, 0], 1), ([2, 0, 0], 1), ([0, 1, 0], 1)])
    polynomial = sparse + z
    assert sparse * (x + y) == (1 + x**2 + y) * (x + y)
    components = polynomial.homogeneous_components()
    assert [degree for degree, _ in components] == [0, 2, 3]
    assert x**2 + y == components[1][1]
    print(f"weighted homogeneous degrees: {[degree for degree, _ in components]}")


if __name__ == "__main__":
    main()

Run it with .venv/bin/python examples/14_weighted_polynomials.py.

commalg.WeightedGrading

A positive integer weight for each generator in an ordered context.

WeightedGrading(weights: Sequence[int])

noether::commalg::WeightedGrading · Direct Rust declaration

pub struct WeightedGrading { /* 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/WeightedGrading@1

Executable usage: examples/14_weighted_polynomials.py:10 · examples/14_weighted_polynomials.py:6 · validation/unit/commalg/test_base_change.py:13 · validation/unit/commalg/test_base_change.py:23 · validation/unit/commalg/test_context_tower_workload.py:16 · validation/unit/commalg/test_context_tower_workload.py:42

commalg.WeightedGrading.arity

Return the arity recorded by this WeightedGrading.

Detailed contract

Number of ordered generators graded by this value.

(self) -> int

noether::commalg::WeightedGrading::arity · Direct Rust declaration

pub fn arity(&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/WeightedGrading@1

Executable usage: validation/unit/commalg/test_polynomial_facade.py:197 · validation/unit/commalg/test_polynomial_facade.py:205 · validation/unit/commalg/test_polynomial_ideal_facade.py:259 · validation/unit/commalg/test_power_series_facade.py:65 · validation/bench/groebner_compare.py:120 · validation/bench/groebner_compare.py:121

commalg.WeightedGrading.as_free_abelian

View this WeightedGrading as free abelian.

Detailed contract

View this positive rank-one grading in the general free-abelian model.

(self) -> FreeAbelianGrading

noether::commalg::WeightedGrading::as_free_abelian · Direct Rust declaration

pub fn as_free_abelian(&self) -> FreeAbelianGrading
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/WeightedGrading@1

Executable usage: validation/unit/commalg/test_polynomial_facade.py:45 · validation/unit/homalg/test_module_facade.py:204

commalg.WeightedGrading.degree

Compute degree for this WeightedGrading.

Detailed contract

Weighted degree of an exponent vector.

(self, exponent: Sequence[int]) -> int

noether::commalg::WeightedGrading::degree · Direct Rust declaration

pub fn degree(&self, exponent: &[u64]) -> Result<u64, GradingError>
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/WeightedGrading@1

Executable usage: examples/14_weighted_polynomials.py:16 · examples/14_weighted_polynomials.py:18 · examples/15_groebner_twisted_cubic.py:15 · examples/15_groebner_twisted_cubic.py:28 · examples/31_local_fields_and_precision.py:37 · examples/33_simplicial_cohomology_operations.py:26

commalg.WeightedGrading.from_json

Deserialize and revalidate a positive grading.

(cls, value: str) -> WeightedGrading

noether::commalg::WeightedGrading::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/WeightedGrading@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.WeightedGrading.is_standard

Test whether this WeightedGrading is standard.

Detailed contract

Whether every generator has the default weight one.

(self) -> bool

noether::commalg::WeightedGrading::is_standard · Direct Rust declaration

pub fn is_standard(&self) -> bool
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/WeightedGrading@1

Executable usage: validation/unit/commalg/test_power_series_facade.py:64

commalg.WeightedGrading.standard

Construct a WeightedGrading using standard.

Detailed contract

Construct the standard grading, with every generator in degree one.

(cls, arity: int) -> WeightedGrading

noether::commalg::WeightedGrading::standard · Direct Rust declaration

pub fn standard(arity: usize) -> Result<Self, GradingError>
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/WeightedGrading@1

Executable usage: validation/unit/commalg/test_monomial_ideal_facade.py:57 · validation/unit/commalg/test_polynomial_facade.py:34 · validation/unit/commalg/test_polynomial_facade.py:42 · validation/unit/commalg/test_polynomial_facade.py:43 · validation/unit/commalg/test_polynomial_facade.py:44 · validation/unit/commalg/test_polynomial_facade.py:45

commalg.WeightedGrading.to_json

Serialize the positive weights as canonical typed JSON.

(self) -> str

noether::commalg::WeightedGrading::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/WeightedGrading@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.WeightedGrading.weights

Return the weights recorded by this WeightedGrading.

Detailed contract

Positive weights in generator order.

(self) -> list[int]

noether::commalg::WeightedGrading::weights · Direct Rust declaration

pub fn weights(&self) -> &[u64]
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/WeightedGrading@1

Executable usage: examples/23_kashiwara_crystals.py:16 · validation/unit/commalg/test_polynomial_facade.py:330 · validation/unit/commalg/test_polynomial_facade.py:435 · validation/unit/commalg/test_power_series_facade.py:111 · validation/unit/commalg/test_power_series_facade.py:115 · validation/unit/commalg/test_power_series_facade.py:221