Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grading + caching for affine algebra of torus invariants #3469

Merged
merged 4 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 10 additions & 13 deletions experimental/InvariantTheory/src/TorusInvariantsFast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,13 @@ end
#Setting up invariant ring for fast torus algorithm.
#####################

mutable struct TorGrpInvRing
@attributes mutable struct TorGrpInvRing
field::Field
poly_ring::MPolyDecRing #graded

group::TorusGroup
representation::RepresentationTorusGroup

fundamental::Vector{MPolyDecRingElem}

#Invariant ring of reductive group G (in representation R), no other input.
function TorGrpInvRing(R::RepresentationTorusGroup) #here G already contains information n and rep_mat
n = length(weights(R))
Expand Down Expand Up @@ -264,14 +262,9 @@ julia> fundamental_invariants(RT)
X[2]^2*X[3]
```
"""
function fundamental_invariants(z::TorGrpInvRing)
if isdefined(z, :fundamental)
return z.fundamental
else
R = z.representation
z.fundamental = torus_invariants_fast(weights(R), polynomial_ring(z))
return z.fundamental
end
@attr function fundamental_invariants(z::TorGrpInvRing)
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
@attr function fundamental_invariants(z::TorGrpInvRing)
@attr SomeType function fundamental_invariants(z::TorGrpInvRing)

Please add the return type here to make the attribute lookup type stable

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know what type to use here other than Vector{MPolyRingElem} or Vector{MPolyDecRingElem} - which are not concrete types.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Faced the same issue with the other file - InvariantTheory.jl

Copy link
Member

Choose a reason for hiding this comment

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

That's true. In most other places, we would add the field type as a type parameter to the invariant ring, which would then allow something smarter here.
But I think this is out of scope for this PR.

@fingolfin can you keep this in mind for some future refactoring?

This comment was marked as outdated.

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, I typed to slow. We can keep this here as is and I look into it in #3442.

Copy link
Member

Choose a reason for hiding this comment

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

@lgoettgens sure, I actually had pointed out the same issue on a prior PR. We'll get there eventually ;-)

R = z.representation
return torus_invariants_fast(weights(R), polynomial_ring(z))
end

function Base.show(io::IO, R::TorGrpInvRing)
Expand Down Expand Up @@ -399,10 +392,14 @@ julia> affine_algebra(RT)
(Quotient of multivariate polynomial ring by ideal (-t[1]*t[3] + t[2]^2), Hom: quotient of multivariate polynomial ring -> graded multivariate polynomial ring)
```
"""
function affine_algebra(R::TorGrpInvRing)
@attr function affine_algebra(R::TorGrpInvRing)
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
@attr function affine_algebra(R::TorGrpInvRing)
@attr SomeType function affine_algebra(R::TorGrpInvRing)

Here as well

V = fundamental_invariants(R)
s = length(V)
S,t = polynomial_ring(field(group(representation(R))), "t"=>1:s)
weights_ = zeros(Int, s)
for i in 1:s
weights_[i] = total_degree(V[i])
end
S,_ = graded_polynomial_ring(field(group(representation(R))), "t"=>1:s; weights = weights_)
R_ = polynomial_ring(R)
StoR = hom(S,R_,V)
I = kernel(StoR)
Expand Down
6 changes: 6 additions & 0 deletions experimental/InvariantTheory/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,10 @@
f = fundamental_invariants(I)
@test f == [X[1]*X[2]*X[3], X[1]^2*X[3]*X[4]]

#another example, with affine algebra computation
T = torus_group(QQ,2)
r = representation_from_weights(T, [-1 1; -1 1; 2 -2; 0 -1])
RT = invariant_ring(r)
A, _ = affine_algebra(RT)
@test ngens(modulus(A)) == 1
end
Loading