-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcvc5_util.py
More file actions
53 lines (47 loc) · 1.27 KB
/
cvc5_util.py
File metadata and controls
53 lines (47 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
from cvc5 import Kind
from collections import defaultdict
TIMEOUT = str(300000)
reserved_ids = {
'true': lambda solver: solver.mkTrue(),
'false': lambda solver: solver.mkFalse()
}
MINUS = '-'
reserved_functions = {
'<': Kind.LT,
'<=': Kind.LEQ,
'>': Kind.GT,
'>=': Kind.GEQ,
'=': Kind.EQUAL,
'distinct': Kind.DISTINCT,
'ite': Kind.ITE,
'+': Kind.ADD,
'*': Kind.MULT,
'-': Kind.SUB,
'or': Kind.OR,
'and': Kind.AND,
'not': Kind.NOT
}
kind_dict = defaultdict(lambda: Kind.APPLY_UF)
for k, v in reserved_functions.items():
kind_dict[k] = v
def define_fun_to_string(f, params, body):
sort = f.getSort()
if sort.isFunction():
sort = f.getSort().getFunctionCodomainSort()
result = "(define-fun " + str(f) + " ("
for i in range(0, len(params)):
if i > 0:
result += " "
result += "(" + str(params[i]) + " " + str(params[i].getSort()) + ")"
result += ") " + str(sort) + " " + str(body) + ")"
return result
def print_synth_solutions(f, sol):
result = "(\n"
params = []
body = sol
if sol.getKind() == Kind.LAMBDA:
params += sol[0]
body = sol[1]
result += " " + define_fun_to_string(f, params, body) + "\n"
result += ")"
print(result)