Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Ideals in Algebraic Rings of Integers

Constructing ideals

Available functions

Available predicates

Factoring example

use algebraeon::rings::algebraic_number_field::AlgebraicNumberFieldSignature;
use algebraeon::rings::algebraic_number_field::FullRankIntegerSubmoduleWithBasisSignature;
use algebraeon::rings::polynomial::PolynomialFromStr;
use algebraeon::sets::structure::InjectiveFunction;
use algebraeon::{
    nzq::*,
    rings::{polynomial::Polynomial, structure::*},
};

// Construct the ring of integers Z[i]
let anf = Polynomial::<Rational>::from_str("x^2+1", "x")
    .unwrap()
    .algebraic_number_field()
    .unwrap();
let roi = anf.ring_of_integers();

// The ideal (27i - 9) in Z[i]
let ideal = roi.ideals().principal_ideal(
    &roi.outbound_order_to_anf_inclusion()
        .try_preimage(&Polynomial::from_str("27*x-9", "x").unwrap())
        .unwrap(),
);

// Factor the ideal
for (prime_ideal, power) in roi.ideals().factor(&ideal).into_powers().unwrap() {
    println!("power = {power} prime_ideal_factor = {:?}", prime_ideal);
}

// There's not yet a nice way to print ideals so the output is messy
// But it prints the following factorization into primes
// ideal = (1+i) * (1+2i) * (3)^2