Skip to content

Proposal: parametrize FunctionField by polynomial ring type, mirroring RationalFunctionField #2407

@alexey-orlov-math

Description

@alexey-orlov-math

I'd like to propose changing the type signature of FunctionField from

FunctionField{T <: FieldElement}

to

FunctionField{T <: FieldElement, U <: PolyRingElem{T}}

mirroring the existing two-parameter design of RationalFunctionField{T, U}. This is a semi-breaking change, so I want to gauge interest before drafting a PR.

Motivation

Several fields of the FunctionField struct are currently typed existentially or abstractly, because the polynomial ring type U is not carried in the type signature, for example:

  • num::Poly{<:PolyRingElem{T}} — existential; concretely stored as Poly{U} for some U <: PolyRingElem{T}, but U does not appear in the struct's type parameters.
  • den::PolyRingElem{T} — PolyRingElem is abstract.

Or even

pol::Poly{RationalFunctionFieldElem{T, U}} where U <: PolyRingElem{T}
base_ring::RationalFunctionField{T, U} where U <: PolyRingElem{T}

essentially document that U ought to be a type parameter: RationalFunctionField already takes it, but FunctionField discards it.

Adding U as a second parameter would:

  1. Make every field of FunctionField concretely typed, improving type stability and codegen for downstream code.
  2. Bring FunctionField in line with RationalFunctionField{T, U}, removing an asymmetry between two closely related types.
  3. Eliminate the where U <: PolyRingElem{T} existentials currently needed in field declarations and method signatures.

Cost

I did a quick survey of downstream packages:

  • Hecke.jl: roughly 100 references would need updating.
  • Oscar.jl: a handful of references.

Further, FunctionField{T, U} would still allow FunctionField{T} usage most of the time, so this should not break the "usual" code.

Should I? Happy to prepare the PR for AbstractAlgebra and the corresponding follow-ups in Hecke and Oscar if this is welcome.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions