简体   繁体   English

z3 C ++ API:获取expr的操作

[英]z3 C++ API: get operation of expr

I'm using z3 as a C++ library. 我正在使用z3作为C ++库。 Within in my current programming project I have boolean equations I'm simplifying using z3. 在我当前的编程项目中,我具有使用z3进行简化的布尔方程。

In order to use the simplified equations within my project I need the lhs, rhs and the operation of the simplified equation. 为了在我的项目中使用简化方程,我需要lhs,rh和简化方程的运算。

eG: expression (x==3)&&(x<5) is simplified to (x==3) in z3 eG:z3中的表达式(x == 3)&&(x <5)简化为(x == 3)

(= x 3)

lhs argument -> x lhs参数-> x

expression.arg(0)

rhs argument -> 3 rhs参数-> 3

expression.arg(1)

How do I get the operation(=) ? 我如何获得操作(=)?

Any expr with more than 1 argument should have a operation right? 任何具有超过1个参数的expr应该具有运算权吗?

I'm looking at the API for 3hrs now and I just can't figure it out. 我正在看API 3个小时了,但我无法弄清楚。

Hopefully, anyone can point me in the right direction! 希望任何人都可以指出正确的方向!

Thanks Toebs 感谢Toebs

要以字符串形式获取“ top”级别的运算符,即对于原始的“ and”和简化的“ =“,可以使用:

expression.decl().name().str()

Function applications in Z3 are represented as a vector of arguments and a function declaration. Z3中的函数应用程序表示为参数的向量和函数的声明。 For instance, suppose that function f is applied to the arguments x and y . 例如,假设函数f应用于参数xy In the C++ API this takes the shape of an expr object e which has e.num_args() arguments, x , y are e.arg(0) , e.arg(1) and e.decl() is applied to those arguments. 在C ++ API中,这采用具有e.num_args()参数的expr对象e的形状, xye.arg(0)e.arg(1)e.decl()应用于这些参数。

(Obviously this also works for 0 arguments, which is often referred to as const in various parts of the API, because they are applications of constant functions .) (显然,这也适用于0参数,在API的各个部分中通常称为const ,因为它们是常量函数的应用。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM