3

I am trying to implement the Plücker relations in Sagemath. Sage has an interface for Macaulay2, and this latter has a command Grassmannian(k-1, n-1) for computing the Plücker relations of the Grassmannian $\text{Gr}(k,n)$.

My problem is: when I do this, Sage returns me a Macaulay2 object, which I want to turn into a Sage object. When I try the command Grassmannian(k-1, n-1).sage(), the compiler returns:

ValueError: variable name 'p_{0' is not alphanumeric.

So I guess the problem is that Macaulay2 uses variables p_{i,j,k}, and this is a problem for Sage. Do you know how can I fix it?

EDIT: here is the code:

R = macaulay2('QQ[apply(subsets(6,3), i -> p_i)]')
G = macaulay2.Grassmannian(2,5,R)
G.sage()

1 Answers1

3

You can use variables that SageMath can understand:

sage: macaulay2('apply(subsets(6,3), i -> "p" | concatenate(apply(i, toString)))')
{p012, p013, p023, p123, p014, p024, p124, p034, p134, p234, p015, p025, p125, p035, p135, p235, p045, p145, p245, p345}

So:

sage: R = macaulay2('QQ[apply(subsets(6,3), i -> "p" | concatenate(apply(i, toString)))]')
sage: G = macaulay2.Grassmannian(2,5,R)
sage: G.sage()
Ideal (p235*p145 - p135*p245 + p125*p345, p234*p145 - p134*p245 + p124*p345, p235*p045 - p035*p245 + p025*p345, p135*p045 - p035*p145 + p015*p345, p125*p045 - p025*p145 + p015*p245, p234*p045 - p034*p245 + p024*p345, p134*p045 - p034*p145 + p014*p345, p124*p045 - p024*p145 + p014*p245, p123*p045 - p023*p145 + p013*p245 - p012*p345, p234*p135 - p134*p235 + p123*p345, p125*p035 - p025*p135 + p015*p235, p234*p035 - p034*p235 + p023*p345, p134*p035 - p034*p135 + p013*p345, p124*p035 - p024*p135 + p014*p235 + p012*p345, p123*p035 - p023*p135 + p013*p235, p234*p125 - p124*p235 + p123*p245, p134*p125 - p124*p135 + p123*p145, p034*p125 - p024*p135 + p014*p235 + p023*p145 - p013*p245 + p012*p345, p234*p025 - p024*p235 + p023*p245, p134*p025 - p024*p135 + p023*p145 + p012*p345, p034*p025 - p024*p035 + p023*p045, p124*p025 - p024*p125 + p012*p245, p123*p025 - p023*p125 + p012*p235, p234*p015 - p014*p235 + p013*p245 - p012*p345, p134*p015 - p014*p135 + p013*p145, p034*p015 - p014*p035 + p013*p045, p124*p015 - p014*p125 + p012*p145, p024*p015 - p014*p025 + p012*p045, p123*p015 - p013*p125 + p012*p135, p023*p015 - p013*p025 + p012*p035, p124*p034 - p024*p134 + p014*p234, p123*p034 - p023*p134 + p013*p234, p123*p024 - p023*p124 + p012*p234, p123*p014 - p013*p124 + p012*p134, p023*p014 - p013*p024 + p012*p034) of Multivariate Polynomial Ring in p012, p013, p023, p123, p014, p024, p124, p034, p134, p234, p015, p025, p125, p035, p135, p235, p045, p145, p245, p345 over Rational Field

When you have numbers higher than 9 appearing you can add a separator like this:

sage: macaulay2('apply(subsets(11,11), i -> "p" | concatenate(apply(i, v -> "x" | toString v)))')
{px0x1x2x3x4x5x6x7x8x9x10}

I tried using an underscore as the separator at first but I didn't manage to make it work.

Ricardo Buring
  • 6,649
  • 7
  • 35
  • 63