Skip to content

Conversation

@SirToby25
Copy link
Collaborator

@SirToby25 SirToby25 commented Nov 29, 2024

This is the first approach of implementing Clifford algebras and Clifford orders for quadratic spaces and lattices. There will be some future development, but it already allows for the standard computations one might want to perform within these structures.

Resolves #2312

SirToby25 and others added 30 commits October 25, 2024 15:11
Provides Basic functionality for Clifford algebras over free quadratic
lattices. Still a lot of work to do: Implement Clifford orders, handle
pseudo-bases in the non-free case, etc.
This commit also contains minor changes to the CliffordAlgebras-files,
mainly due to consistency with the CliffordOrders-files
Clifford orders are now fully functional. Some methods for Clifford
algebras were renamed for consistency. Consequently the tests for
Clifford algebras were modified as well.
divexact methods were implemented for Clifford orders. Also updated the
existing one for Clifford algebras for consistency.
Merge branch 'tb/CliffordAlgebras' of github:SirToby25/Oscar.jl into tb/CliffordAlgebras
@lgoettgens lgoettgens requested a review from thofma December 10, 2024 10:14
@thofma
Copy link
Collaborator

thofma commented Dec 10, 2024

Why the ping? I was already happy, but @lgoettgens and @fingolfin had many comments and they should indicate whether they have been addressed.

@lgoettgens
Copy link
Member

My comments are all resolved, but I am not familiar enough with the mathematics to approve this.

@joschmitt joschmitt removed the request for review from thofma December 10, 2024 14:27
@joschmitt
Copy link
Member

@fingolfin could you have a quick look again regarding your comments?

Copy link
Member

@fingolfin fingolfin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a bunch of type stability issue. But since this is code for experimental, I think we could merge it.

One other thing I'd like to see added to this eventually are "ring interface conformance tests". I.e. calls to test_Ring_interface or better yet, test_Ring_interface_recursive. This may require adding test_elem methods.

Comment on lines 74 to 76
coeffs::Vector{S} where S<:NumFieldElem
even_coeffs::Vector{S} where S<:NumFieldElem
odd_coeffs::Vector{S} where S<:NumFieldElem
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This declaration means access to these three vectors will be type unstable.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine to do (for reducing the number of method compilations) if you assert the concrete type every time you access these fields.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this commit I changed Vector{S} where S<:NumFieldElem to Vector{<:NumFieldElem}. Does this change anything?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this has no real difference. What you could do here is to add a type assertion to each place you access these vectors (ideally only in a getter)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As of this commit, these attributes are of type Any but the concrete type is now asserted at access time

################################################################################

### Algebra ###
mutable struct CliffordAlgebra{T,S} <: Hecke.AbstractAssociativeAlgebra{T}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are T and S? I would recommend to e.g. add a comment indicating what kind of types to expect here. People other than the original author who need to modify the code will probably grateful (based on experience that includes "the author in 1 year" ;-)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added some clarifying comments in this commit.

dim::Int
basis_of_centroid::Any
disq::T
basis_of_center::Any
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lots of underspecified members (base_ring, space, basis_of_centroid, basis_of_center) meaning that code accessing them directly will be type unstable. You could compensate for that by using accessor function that have type assertions with the correct rings. It seems you already do so for base_ring and space but not for the others?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in this commit

SirToby25 and others added 7 commits December 24, 2024 13:29
Co-authored-by: Max Horn <max@quendi.de>
Co-authored-by: Max Horn <max@quendi.de>
Co-authored-by: Max Horn <max@quendi.de>
Co-authored-by: Max Horn <max@quendi.de>
two elements. The first one is the multiplicative identity of $C$. The square of
the second basis element, if present, equals `quadratic_discriminant(C)`.
"""
function basis_of_centroid(C::CliffordAlgebra)::Vector{elem_type(C)}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
function basis_of_centroid(C::CliffordAlgebra)::Vector{elem_type(C)}
function basis_of_centroid(C::CliffordAlgebra)

This lowers to a type conversion. To get a type assertion, instead put this to each line with a return, eg here return C.basis_of_centroid::Vector{elem_type(C)}. (at all places you just modified

Copy link
Collaborator Author

@SirToby25 SirToby25 Dec 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not know that, thanks. It should work now, due to this commit

"""
function even_coefficients(x::CliffordAlgebraElem)
if isdefined(x, :even_coeffs)
return x.even_coeffs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This eg needs a type assertion as well (and 2 times below, and the other functions here)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really? I thought the type declarations of the data structure would be sufficient in this case.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes they are. I didn't notice that you changed that up there


Return the vector of coefficient ideals of the canonical pseudo-basis of $C$.
"""
coefficient_ideals(C::CliffordOrder) = C.coefficient_ideals::Vector{typeof(fractional_ideal(base_ring(C), one(base_ring(C))))}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe there is fractional_ideal_type to get this type at compile time (ie without typeof). Maybe you need to write Hecke.fractional_ideal_type (not sure, maybe @thofma knows)

Copy link
Collaborator

@thofma thofma Dec 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hecke.fractional_ideal_type(base_ring(C)) should do the trick.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even better to use Hecke.fractional_ideal_type(base_ring_type(C)) to make it compile time computable

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this works

This commit adds many generic methods for elements of Clifford orders
that are not automatically available from AbstractAssociativeAlgebra.
Examples are: minimal_polynomial, characteristic_polynomial, inv, etc.
@lgoettgens
Copy link
Member

I think all comments are resovled now. And after all, this only adds experimental code, so it can just we revised later. Let's get this in. And thanks again to @SirToby25 for putting work into this!

@lgoettgens lgoettgens enabled auto-merge (squash) January 2, 2025 14:34
@lgoettgens lgoettgens merged commit 258fe1d into oscar-system:master Jan 2, 2025
29 of 30 checks passed
@lgoettgens lgoettgens changed the title Clifford algebras and Clifford orders Experimental: Add Clifford algebras and Clifford orders Feb 20, 2025
@lgoettgens lgoettgens added the release notes: use title For PRs: the title of this PR is suitable for direct use in the release notes label Feb 20, 2025
@fingolfin fingolfin changed the title Experimental: Add Clifford algebras and Clifford orders Add Clifford algebras and Clifford orders Feb 27, 2025
@thofma thofma changed the title Add Clifford algebras and Clifford orders Experimental: Add Clifford algebras and Clifford orders Feb 28, 2025
@SirToby25 SirToby25 deleted the tb/CliffordAlgebras branch August 19, 2025 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

experimental Only changes experimental parts of the code release notes: use title For PRs: the title of this PR is suitable for direct use in the release notes topic: number theory

Projects

None yet

Development

Successfully merging this pull request may close these issues.

clifford_algebra

5 participants