I am attempting to get an int list
of coefficients of a remainder of the division of two polynomials. I have been attempting to use mod
from Polynomial.thy
on two polynomials of type int poly
. However, I am getting the error:
Type unification failed: No type arity int :: field
My function is:
fun testFunc :: "int poly ⇒ int poly ⇒ int list"
where
"testFunc p q = int_list (coeffs (p mod q))"
Where int_list
simply converts a list of reals to a list of ints by flooring each element:
fun int_list :: "real list ⇒ int list"
where
"int_list [] = []" |
"int_list lst = [floor (hd lst)] @ int_list (tl lst)"
This works when I define my function as:
fun testFunc :: "'a::field poly ⇒ 'a poly ⇒ int list"
where
"testFunc p q = int_list (coeffs (p mod q))"
However, the two arguments being passed into the function are specifically of type int poly
. If I pass in two polynomials 'a::field poly
and 'a poly
using the second definition, then an 'a list
is returned and I cannot run my int_list function.
If I change int_list
's signature to 'a list => int list
, then I must use int_of
on each element, which ultimately does not evaluate the integers in my list. (i.e. I get something like [int_of 2, int_of 3]
rather than [2, 3]
, and when I try to do something with those lists, it is returned with the int_of x
expression rather than an evaluation)
Is it possible to get an int list
of the coefficients of the modulo of two polynomials?