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 54 55
|
#!/usr/bin/env python
###############################################################################
# Top contributors (to current version):
# Yoni Zohar, Abdalrhman Mohamed, Alex Ozdemir
#
# This file is part of the cvc5 project.
#
# Copyright (c) 2009-2025 by the authors listed in the file AUTHORS
# in the top-level source directory and their institutional affiliations.
# All rights reserved. See the file COPYING in the top-level source
# directory for licensing information.
# #############################################################################
#
# Utility Methods, translated from examples/api/utils.h
##
import cvc5
from cvc5 import Kind
# Get the string version of define-fun command.
# @param f the function to print
# @param params the function parameters
# @param body the function body
# @return a string version of define-fun
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
# Print solutions for synthesis conjecture to the standard output stream.
# @param terms the terms for which the synthesis solutions were retrieved
# @param sols the synthesis solutions of the given terms
def print_synth_solutions(terms, sols):
result = "(\n"
for i in range(0, len(terms)):
params = []
body = sols[i]
if sols[i].getKind() == Kind.LAMBDA:
params += sols[i][0]
body = sols[i][1]
result += " " + define_fun_to_string(terms[i], params, body) + "\n"
result += ")"
print(result)
|