I have recently started using z3 API with c++ bindings. My task is to obtain the individual element from an expression
example: (x || !z) && (y || !z) && (!x || !y || z)
How do I get a individual variables by indexing each position using the function arg(i)?
in case of the given example, arg(1) should return the variable 'X'. Is there any other function in z3 that can give me my desired output?
This is the code I tried but the output was not a single variable:
#include<iostream>
#include<string>
#include "z3++.h"
using namespace z3;
int main()
{
context c;
expr x = c.bool_const("x");
expr y = c.bool_const("y");
expr z = c.bool_const("z");
expr prove = (x || !z) && (y || !z) && (!x || !y || z);
solver s(c);
expr argument = prove.arg(1);
std::cout<<argument;
}
OUTPUT:
(or (not x) (not y) z)(base)
I basically need to make an automated system that indexes every position in the expression and check if its an operator or an operand and insert in into a data structure. So I thought ill create a loop and index every position in the expression. But the arg(i) was not giving me my desired output.