# matrix over symbolic ring to matrix over finite field

I have a bunch of ideals defined symbolically, that I would like to decompose over GF(101).

However I think that the only symbolic computation that's happening is when I define the matrices whose minors give me the ideals.

So, once a matrix is constructed, is it possible to reduce it mod p? Thanks for any help!

EDIT 1: I have a list of variables `svs = x_{i}_{j}_{k}`

and it is used to define a ring

```
R = PolynomialRing(GF(101),svs)
R.inject_variables()
```

Then I introduce the symbolic variables `var('x, s')`

in order to form
a list of companion matrices.
For concreteness let's say I have two companion matrices,
one for `p = x**2 * (x-s)**3`

and one for `q = x - s`

. I make a list

```
L = [companion_matrix(p.coefficients(x, sparse=False), format='bottom'),
companion_matrix(q.coefficients(x, sparse=False), format='bottom')]
```

Finally I create a block matrix `block_matrix(R['s'], L)`

.

Next I look at ideals of minors of this matrix. So I might have a relation like `rel = [x_1_2_1, x_1_2_1*s]`

that I use to define an ideal `I = ideal(rel)`

. I want to apply `groebner_basis`

and `primary_decomposition`

to these ideals but I run into errors like `Ideal_generic' object has no attribute 'groebner_basis`

or `Not implemented`

.

So the question is at what point and how should I tell sage that `s`

is no longer to be treated as a symbolic variable.
By the way `I = R['s'].ideal(rel)`

also results in a class generic ideal.

I also tried `S.<s> = PolynomialRing(R)`

and `S.ideal([x_1_2_1, x_1_2_1*polynomial(s, base_ring=R)])`

which did not work.

Sorry for being such a data types ignoramus!

EDIT 2: Here's a non-minimal example of how the x_i_j_k end up in my (block) matrices.

Use inputs

```
mu1, mu2, mu = [1,1],[1,1],[2,2]
```

on

```
def mu_vars(mu):
svs = []
for i in range(1,2):
for j in range(i+1,2+1):
for k in range(0,mu[j-1]):
svs.append('x_{}_{}_{}'.format(i,j,k+1))
return svs
svs = mu_vars(mu)
R = PolynomialRing(GF(101),svs)
R.inject_variables()
def insert_row(mat,row):
return matrix(mat.rows()[:mat.nrows()]+[row]+mat.rows()[mat.nrows():])
def upper_row_matrix(row):
symbMat = []
for i in range(row,2):
mat = matrix(mu[row-1]-1,mu[i])
v = [var(v) for v in svs if v.startswith('x_{}_{}'.format(row,i+1))]
d = insert_row(mat,v)
symbMat.append(d)
return symbMat
var('x,s')
def mu_matrix(mu1,mu2):
symbMat = []
for i in range(0,2):
row = [] + [0]*i
p = x**(mu1[i])*(x-s)**(mu2[i])
row.append(companion_matrix(p.coefficients(x,sparse=False),format='bottom'))
row += upper_row_matrix(i+1)
symbMat.append(row)
return block_matrix(R['s'],symbMat)
```

Run m = mu_matrix(mu1,mu2) to get

```
[ 0 1| 0 0]
[ 0 s|x_1_2_1 x_1_2_2]
[---------------+---------------]
[ 0 0| 0 1]
[ 0 0| 0 s]
```

consider m.minors(2)[29] which is x_1_2_1*s. Then for example the ideal ideal(m.minors(2)[29]) does not have a groebner basis. In particular the call ideal(m.minors(2)[29]).groebner_basis() ends in error.

Please give us a small concrete example, with self-contained code.

Edited. No self-contained code. But enough detail I think to render the issue intelligible.

https://stackoverflow.com/help/minima...

Yes, please add a complete block of code that ends in an error. So far, it is not clear how e.g.

`x_1_2_1`

ends up in the matrix (with the current code, it doesn't). Also, the best way to solve your issue will be to skip the symbolic ring altogether.@rburing my bad, thanks - added how the x's appear in the matrix. How would you skip the symbolic ring if your matrices involve companion matrices?