blob: 69676819ab508594a10af017d09517cb2386c31d (
plain)
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
/******************************************************************************
* Top contributors (to current version):
* Abdalrhman Mohamed
*
* This file is part of the cvc5 project.
*
* Copyright (c) 2009-2021 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.
* ****************************************************************************
*
* Implementations of utility methods.
*/
#include "utils.h"
#include <iostream>
/**
* 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
*/
std::string defineFunToString(const cvc5::api::Term& f,
const std::vector<cvc5::api::Term> params,
const cvc5::api::Term body)
{
cvc5::api::Sort sort = f.getSort();
if (sort.isFunction())
{
sort = sort.getFunctionCodomainSort();
}
std::stringstream ss;
ss << "(define-fun " << f << " (";
for (size_t i = 0, n = params.size(); i < n; ++i)
{
if (i > 0)
{
ss << ' ';
}
ss << '(' << params[i] << ' ' << params[i].getSort() << ')';
}
ss << ") " << sort << ' ' << body << ')';
return ss.str();
}
void printSynthSolutions(const std::vector<cvc5::api::Term>& terms,
const std::vector<cvc5::api::Term>& sols)
{
std::cout << '(' << std::endl;
for (size_t i = 0, n = terms.size(); i < n; ++i)
{
std::vector<cvc5::api::Term> params;
cvc5::api::Term body;
if (sols[i].getKind() == cvc5::api::LAMBDA)
{
params.insert(params.end(), sols[i][0].begin(), sols[i][0].end());
body = sols[i][1];
}
std::cout << " " << defineFunToString(terms[i], params, body)
<< std::endl;
}
std::cout << ')' << std::endl;
}
|