我正在尝试使用if-then-else来表示(伪代码):
if (expression) is true then
(my_bool_var || true) //set variable to true
else
(my_bool_var || false) //set variable to false
但是Z3会在if语句中评估表达式(这很好),但问题是如果表达式被评估为false
,那么它将问题转换为UNSAT
并终止不是s.add(ite(expression, my_bool_var || true, my_bool_var && false), "assertion1");
我的意图。
实际代码(c ++ API):
n = 5 #depth of the pascal tree
pascal = []
for x in range(n):
if x == 0:
help_list = [1]
pascal.append(help_list)
continue
if x==1:
help_list = [1,1]
pascal.append(help_list)
continue
help_list = [l for l in range(x+1)] #this will just initialize list so you can add to it
for y in range(1,x):
help_list[0] = 1
help_list[x] = 1
help_list[y] = pascal[x-1][y] + pascal[x-1][y-1]
pascal.append(help_list)
print(pascal)
我只想打印布尔变量,无论是真还是假,只有表达式为真,才有办法解决这个问题?