# Experimental feature: SAGBI bases of subrings of quotient rings

The paper "Using SAGBI bases to compute invariants" by Stillman and Tsai (1990) describes algorithms for computing Sagbi bases of subrings contained in quotient rings. The following code demonstrates Example 2 from that paper (in the case $N=4$.)

 N = 4; gndR = QQ[(a,b,c,d)|(u_1..u_N)|(v_1..v_N), MonomialOrder => Lex]; I = ideal(a*b - b*c - 1); quot = gndR/I; U = (vars quot)_{4..(N+3)} V = (vars quot)_{(N+4)..(2*N+3)} G = flatten for i from 0 to N-1 list( {a*(U_(0,i)) + b*(V_(0,i)), c*(U_(0,i)) + d*(V_(0,i))} ); sag = sagbi G ans = matrix {{c*u_4+d*v_4, c*u_3+d*v_3, c*u_2+d*v_2, c*u_1+d*v_1, a*u_4+b*v_4, a*u_3+b*v_3, a*u_2+b*v_2, a*u_1+b*v_1, a*d*u_3*v_4-a*d*u_4*v_3-b*c*u_3*v_4+b*c*u_4*v_3, a*d*u_2*v_4-a*d*u_4*v_2-b*c*u_2*v_4+b*c*u_4*v_2, a*d*u_2*v_3-a*d*u_3*v_2-b*c*u_2*v_3+b*c*u_3*v_2, a*d*u_1*v_4-a*d*u_4*v_1-b*c*u_1*v_4+b*c*u_4*v_1, a*d*u_1*v_3-a*d*u_3*v_1-b*c*u_1*v_3+b*c*u_3*v_1, a*d*u_1*v_2-a*d*u_2*v_1-b*c*u_1*v_2+b*c*u_2*v_1}} assert (gens sag == ans);

In general, when a finite SAGBI basis does happen to exist, the algorithm *should* be able to calculate it correctly given enough time. However, there are some peculiarities in the case of quotient rings, such as false termination" Example 1 from the same paper:

 i1 : gndR = QQ[x,y, MonomialOrder => Lex]; i2 : I = ideal(x^2 - x*y); o2 : Ideal of gndR i3 : Q = gndR/I; i4 : subR = sagbi subring {x}; i5 : gens subR o5 = | x | 1 1 o5 : Matrix Q <--- Q

Although the initial algebra in this example is infinitely generated, new generators are not generated as expected from S-pairs.