Ask Your Question

Revision history [back]

Here is how i would do from scratch, without looking whether there is already some tools to do that.

First, define the associahedron :

sage: A = polytopes.associahedron(['A',3])
sage: A
Generalized associahedron of type ['A', 3] with 14 vertices

Then, the list of faces :

sage: F = list(A.face_generator())
sage: F
[A 3-dimensional face of a Polyhedron in QQ^3 defined as the convex hull of 14 vertices,
 A -1-dimensional face of a Polyhedron in QQ^3,
 A 2-dimensional face of a Polyhedron in QQ^3 defined as the convex hull of 5 vertices,
 A 2-dimensional face of a Polyhedron in QQ^3 defined as the convex hull of 4 vertices,
...

Then, you can define your fraction field:

sage: R = Frac(PolynomialRing(QQ,x,len(F)+1))
sage: R
Fraction Field of Multivariate Polynomial Ring in x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20, x21, x22, x23, x24, x25, x26, x27, x28, x29, x30, x31, x32, x33, x34, x35, x36, x37, x38, x39, x40, x41, x42, x43, x44, x45, x46 over Rational Field
sage: R.inject_varibles()
sage: R.inject_variables()
Defining x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20, x21, x22, x23, x24, x25, x26, x27, x28, x29, x30, x31, x32, x33, x34, x35, x36, x37, x38, x39, x40, x41, x42, x43, x44, x45, x46

At this point, you can do:

sage: P = 3*x6*x7 + x2 ; P
3*x6*x7 + x2

Now, we can define a bridge between both worlds in both ways:

sage: face = {x:f for x,f in list(zip(R.gens(),F))}  
sage: x = {f:x for x,f in list(zip(R.gens(),F))}
sage: face[x3]                                                                                                                                                                                               
A 2-dimensional face of a Polyhedron in QQ^3 defined as the convex hull of 4 vertices
sage: x[face[x3]]                                                                                                                                                                                            
x3

Now, you can play:

For example, you can define the polynomial that corresponds to facets (faces of codimension 1):

sage: sum([x[id[f]] for f in A.facets()]) ;
x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10

If you have a fraction, you can get the set the vertices involved in it

sage: p = (x11 + x12) / (x9 + x10)
sage: set(flatten([face[a].vertices() for a in p.numerator().variables() + p.denominator().variables()]))
{A vertex at (-3/2, 0, -1/2),
 A vertex at (-3/2, 1, -3/2),
 A vertex at (-3/2, 2, -3/2),
 A vertex at (-3/2, 2, 3/2),
 A vertex at (3/2, -2, 1/2),
 A vertex at (3/2, -2, 3/2),
 A vertex at (3/2, 0, -3/2),
 A vertex at (3/2, 2, -3/2),
 A vertex at (3/2, 2, 3/2)}