Skip to content

groups · RandomElement

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

Worked example

The complete checked program Construct S4 natively and inspect its stabilizer chain consequences uses this API directly.

# SPDX-License-Identifier: MIT
# Copyright (c) 2026 Benjamin Antieau and Deven Manam
"""Construct S4 natively and inspect its stabilizer chain consequences."""

from noether.groups import Permutation, PermutationGroup


def main() -> None:
    group = PermutationGroup.from_generators(
        4,
        [Permutation.from_images([1, 0, 2, 3]), Permutation.from_images([1, 2, 3, 0])],
    )
    assert group.order == 24
    assert group.is_transitive
    assert group.stabilizer(0).order == 6
    random = group.uniform_random_element(seed=2026)
    assert random.element in group
    print(f"|S4|={group.order}; |Stab(0)|={group.stabilizer(0).order}; sample={random.element}")


if __name__ == "__main__":
    main()

Run it with .venv/bin/python examples/19_permutation_groups.py.

groups.RandomElement

A seeded uniform random group element.

Detailed contract

A seeded uniform random group element. Carries the element and the seed that produced it, so the draw is fully reproducible.

class RandomElement

noether::groups::RandomElement · Direct Rust declaration

pub struct RandomElement { pub element: Perm, pub seed: u64, }
Contract Value
Guarantee checked deterministic result
Determinism deterministic
Availability default CPU build
Domain implementation crates noether, perm-core
GIL attached / bounded

Executable usage: validation/unit/groups/test_acceptance_workload.py:15 · validation/unit/groups/test_acceptance_workload.py:88

groups.RandomElement.element

The element itself.

(self) -> Permutation

noether::groups::RandomElement · Python projection

Python projection convenience over this Rust mathematical type
Contract Value
Guarantee checked deterministic result
Determinism deterministic
Availability default CPU build
Domain implementation crates noether, perm-core
GIL attached / bounded

Executable usage: examples/19_permutation_groups.py:17 · examples/19_permutation_groups.py:18 · examples/30_modules_and_resolutions.py:3 · examples/38_exact_linear_systems.py:52 · examples/38_exact_linear_systems.py:56 · examples/38_exact_linear_systems.py:58

groups.RandomElement.seed

The seed the element was generated from.

(self) -> int

noether::groups::RandomElement · Python projection

Python projection convenience over this Rust mathematical type
Contract Value
Guarantee checked deterministic result
Determinism deterministic
Availability default CPU build
Domain implementation crates noether, perm-core
GIL attached / bounded

Executable usage: examples/19_permutation_groups.py:16 · examples/distributed/f2_linear_algebra.py:46 · validation/unit/groups/test_acceptance_workload.py:86 · validation/unit/groups/test_acceptance_workload.py:87 · validation/unit/groups/test_acceptance_workload.py:89 · validation/unit/groups/test_acceptance_workload.py:98