在Isabelle中将多项式模的系数作为整数列表

在Isabelle中将多项式模的系数作为整数列表,isabelle,Isabelle,我试图得到两个多项式除法余数的系数的int列表。我一直试图在两个int poly类型的多项式上使用modfrompolymone.thy。但是,我得到了一个错误: Type unification failed: No type arity int :: field 我的职能是: fun testFunc :: "int poly ⇒ int poly ⇒ int list" where "testFunc p q = int_list (coeffs (p mod q))" 其中,in

我试图得到两个多项式除法余数的系数的
int列表。我一直试图在两个
int poly
类型的多项式上使用
mod
from
polymone.thy
。但是,我得到了一个错误:

Type unification failed: No type arity int :: field
我的职能是:

fun testFunc :: "int poly ⇒ int poly ⇒ int list"
where
  "testFunc p q = int_list (coeffs (p mod q))"
其中,
int\u list
通过为每个元素添加地板,简单地将real列表转换为int列表:

fun int_list :: "real list ⇒ int list"
where
  "int_list [] = []" |
  "int_list lst = [floor (hd lst)] @ int_list (tl lst)"
当我将我的函数定义为:

fun testFunc :: "'a::field poly ⇒ 'a poly ⇒ int list"
where
  "testFunc p q = int_list (coeffs (p mod q))"
但是,传递到函数中的两个参数的类型是
int poly
。如果我使用第二个定义传入两个多项式
'a::field poly
'a poly
,则返回一个
'a list
,我无法运行我的int_list函数

如果我将
int\u list
的签名更改为
'a list=>int list
,那么我必须在每个元素上使用
int\u of
,这最终不会计算列表中的整数。(也就是说,我得到的是
[int\u of 2,int\u of 3]
而不是
[2,3]
,当我尝试对这些列表执行某些操作时,它会返回
int\u of x
表达式而不是计算)


有可能获得两个多项式的模系数的
int列表吗?

函数需要一个被实例化为class
floor\u-ceiling
()的类型

因此,我使用
'a::floor\u-ceiling
,使您的
int\u列表尽可能通用:

fun int_list :: "'a::{floor_ceiling} list => int list" where
  "int_list [] = []" |
  "int_list lst = [floor (hd lst)] @ int_list (tl lst)"
类型
poly
已为类
ring\u div
实例化,这为其提供了
mod
函数,但仅适用于
'a::field
()

因为
testFunc
使用了
int\u列表
,所以我使用
'a:{field,floor\u天花}
使您的
testFunc
尽可能通用:

fun testFunc :: "'a::{field,floor_ceiling} poly => 'a poly => int list"
  where
  "testFunc p q = int_list (coeffs (p mod q))"

value "testFunc ([:1,2,3:]::real poly) ([:5,6,7:]::real poly)"
  (*OUTPUT: "[- (2::int), - (1::int)]" :: "int list" *)
一些信息命令:

declare[[show_sorts, show_consts]]
print_classes 
  (*At 'class ring_div', it shows ' poly :: (field) ring_div'.*)  
print_dependencies floor_ceiling  
print_dependencies ring_div