Z3 使用相同数量的参数排序和返回排序减少函数声明
我有一个smt程序,它需要声明具有相同数量参数(和排序)和相同返回排序的多个函数。 例如:Z3 使用相同数量的参数排序和返回排序减少函数声明,z3,smt,Z3,Smt,我有一个smt程序,它需要声明具有相同数量参数(和排序)和相同返回排序的多个函数。 例如: (declare-fun main0 (Bool Bool Bool Bool Bool Bool Bool) Bool) (declare-fun main1 (Bool Bool Bool Bool Bool Bool Bool) Bool) (declare-fun main2 (Bool Bool Bool Bool Bool Bool Bool) Bool) (declare-fun main3
(declare-fun main0 (Bool Bool Bool Bool Bool Bool Bool) Bool)
(declare-fun main1 (Bool Bool Bool Bool Bool Bool Bool) Bool)
(declare-fun main2 (Bool Bool Bool Bool Bool Bool Bool) Bool)
(declare-fun main3 (Bool Bool Bool Bool Bool Bool Bool) Bool)
...
是否有任何方法可以减少声明,以便对这些函数的参数(例如body)进行排序,并且我需要定义的所有内容包括:
(declare-fun main0 (body) Bool)
(declare-fun main1 (body) Bool)
(declare-fun main2 (body) Bool)
(declare-fun main3 (body) Bool)
...
这对你有用吗
(declare-sort MySort 7)
(define-sort Body (Bool) (MySort Bool Bool Bool Bool Bool Bool Bool))
(declare-fun main0 (Body (Bool)) Bool)
(declare-fun main1 (Body (Bool)) Bool)
(declare-fun main2 (Body (Bool)) Bool)
(declare-fun main3 (Body (Bool)) Bool)
如果所有的参数都是BoL,可以考虑使用位向量:
(declare-fun main0 (_ BitVec 7) Bool)
(declare-fun main1 (_ BitVec 7) Bool)
(declare-fun main2 (_ BitVec 7) Bool)
(declare-fun main3 (_ BitVec 7) Bool)
您可以使用数据类型理论生成8元组
(declare-datatypes () ((BodyTuple (mk8 (a1 Bool) (a2 Bool) (a3 Bool) (a4 Bool) (a5 Bool) (a6 Bool) (a7 Bool) (a8 Bool) ))))
(declare-fun main0 (BodyTuple) Bool)
但这确实需要通过构造函数mk8进行应用
(assert (main0 (mk8 true true true true true true true true)))
(但这就是尝试将inject宏放入一阶函数声明中的痛苦。)Body没有任何自由变量,因此可以删除define sort中的(Bool)和声明mainX中的(Body)。此外,Body是一种不奇怪的排序,而不是Bool的元组。下面是sat,但如果这些是1元组,则将是unsat。(declare sort MySort 1)(define sort Body()(MySort Bool))(declare fun x()Body)(declare fun y()Body)(declare fun z()Body)(assert(distinct x y z))