smtlib 中的参数函数

parametric functions in smtlib

我知道有一种方法可以在 SMTLIB 中声明参数数据类型。有没有办法定义一个接受这种类型的函数?例如标准文档有:

( declare - datatypes ( ( Pair 2) ) (
( par ( X Y ) ( ( pair ( first X ) ( second Y )) ))))

现在如何声明接受参数 Pair 类型的函数?

SMTLib 允许参数函数定义。请注意,内部函数,如 +、- 等,可以是 many-sorted/parametric,例如,它们可以很好地处理整数和实数。但是用户定义的函数不允许进行多排序。也就是说,您 可以 编写一个接受 (Pair Int Bool) 的函数,但 不能 接受 (Pair a b) 的函数,其中 ab 是类型变量;即,多态。

这在 https://smtlib.cs.uiowa.edu/papers/smt-lib-reference-v2.6-r2021-05-12.pdf 的第 4.1.5 节中有解释:

Well-sortedness checks, required for commands that use sorts or terms, are always done with respect to the current signature. It is an error to declare or define a symbol that is already in the current signature. This implies in particular that, contrary to theory function symbols, user-defined function symbols cannot be overloaded.(29)

后来在脚注 29 中说:

The motivation for not overloading user-defined symbols is to simplify their processing by a solver. This restriction is significant only for users who want to extend the signature of the theory used by a script with a new polymorphic function symbol—i.e., one whose rank would contain parametric sorts if it was a theory symbol. For instance, users who want to declare a “reverse” function on arbitrary lists, must define a different reverse function symbol for each (concrete) list sort used in the script. This restriction might be removed in future versions.

TLDR;不,您不能在 SMTLib 中定义参数函数。但随着逻辑变得更加丰富,这在未来可能会改变。当前的解决方法是“单态化”过程,即在您使用的每个具体类型上生成一个新版本的函数。这可以手动完成,也可以通过为您生成 SMTLib 的高级工具自动完成。