Z3 可以处理包含由声明排序/定义排序引入的排序的数据类型吗?

发布于 2024-12-22 11:25:55 字数 326 浏览 2 评论 0原文

我试图定义一个包含由声明排序或定义排序引入的排序的数据类型。 但以下尝试会导致错误。

(declare-sort A)
(define-sort B () Int)
(declare-datatypes ((listA (nilA) (consA (hdA A) (tlA listA))))) ;=> unknown sort 'A'
(declare-datatypes ((listB (nilB) (consB (hdB B) (tlB listB))))) ;=> unknown sort 'B'

有办法做到这一点吗?

提前致谢。

I'm trying to define a datatype that contains sorts introduced by declare-sort or define-sort.
But the following attempt results in errors.

(declare-sort A)
(define-sort B () Int)
(declare-datatypes ((listA (nilA) (consA (hdA A) (tlA listA))))) ;=> unknown sort 'A'
(declare-datatypes ((listB (nilB) (consB (hdB B) (tlB listB))))) ;=> unknown sort 'B'

Is there a way to do that?

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心奴独伤 2024-12-29 11:25:55

是的,可以。顺便说一句,您似乎使用的是旧版本的 Z3。
您应该尝试最新版本。
Z3 3.x 支持参数类型。因此,声明数据类型的语法发生了一些变化。
现在,您必须编写:

(declare-datatypes () ((listA (nilA) (consA (hdA A) (tlA listA)))))

在新语法中,您可以指定类型参数。由于 listA 不是参数化的,因此您只需提供类型参数的空列表 ()
有关 Z3 中数据类型的更多信息,请参阅 Z3 指南

使用参数类型,您还可以将 listAlistB 编码为:

(declare-datatypes (T) ((list (nil) (cons (hd T) (tl list))))) 
(define-sort listA () (list A))
(define-sort listB () (list B))

Yes, it can. BTW, it seems you are using an old version of Z3.
You should try the latest version.
Z3 3.x supports parametric types. So, the syntax for declaring datatypes changed a little bit.
Now, you have to write:

(declare-datatypes () ((listA (nilA) (consA (hdA A) (tlA listA)))))

In the new syntax, you can specify type parameters. Since listA is not parametric, you just provided the empty list () of type parameters.
For more information about datatypes in Z3, consult the Z3 guide.

Using parametric types, you can also encode listA and listB as:

(declare-datatypes (T) ((list (nil) (cons (hd T) (tl list))))) 
(define-sort listA () (list A))
(define-sort listB () (list B))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文