1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Abdalrhman Mohamed |
4 |
|
* |
5 |
|
* This file is part of the cvc5 project. |
6 |
|
* |
7 |
|
* Copyright (c) 2009-2021 by the authors listed in the file AUTHORS |
8 |
|
* in the top-level source directory and their institutional affiliations. |
9 |
|
* All rights reserved. See the file COPYING in the top-level source |
10 |
|
* directory for licensing information. |
11 |
|
* **************************************************************************** |
12 |
|
* |
13 |
|
* Datastructures used for printing commands internally. |
14 |
|
*/ |
15 |
|
|
16 |
|
#include "cvc5_private.h" |
17 |
|
|
18 |
|
#ifndef CVC5__SMT__NODE_COMMAND_H |
19 |
|
#define CVC5__SMT__NODE_COMMAND_H |
20 |
|
|
21 |
|
#include <string> |
22 |
|
|
23 |
|
#include "expr/node.h" |
24 |
|
#include "expr/type_node.h" |
25 |
|
#include "options/language.h" |
26 |
|
|
27 |
|
namespace cvc5 { |
28 |
|
|
29 |
|
/** |
30 |
|
* A node version of Command. DO NOT use this version unless there is a need |
31 |
|
* to buffer commands for later use (e.g., printing models). |
32 |
|
*/ |
33 |
292855 |
class NodeCommand |
34 |
|
{ |
35 |
|
public: |
36 |
|
/** Destructor */ |
37 |
|
virtual ~NodeCommand(); |
38 |
|
|
39 |
|
/** Print this NodeCommand to output stream */ |
40 |
|
virtual void toStream( |
41 |
|
std::ostream& out, |
42 |
|
int toDepth = -1, |
43 |
|
size_t dag = 1, |
44 |
|
OutputLanguage language = language::output::LANG_AUTO) const = 0; |
45 |
|
|
46 |
|
/** Get a string representation of this NodeCommand */ |
47 |
|
std::string toString() const; |
48 |
|
|
49 |
|
/** Clone this NodeCommand (make a shallow copy). */ |
50 |
|
virtual NodeCommand* clone() const = 0; |
51 |
|
}; |
52 |
|
|
53 |
|
std::ostream& operator<<(std::ostream& out, const NodeCommand& nc); |
54 |
|
|
55 |
|
/** |
56 |
|
* Declare n-ary function symbol. |
57 |
|
* SMT-LIB: ( declare-fun <id> ( <type.getArgTypes()> ) <type.getRangeType()> ) |
58 |
|
*/ |
59 |
278826 |
class DeclareFunctionNodeCommand : public NodeCommand |
60 |
|
{ |
61 |
|
public: |
62 |
|
DeclareFunctionNodeCommand(const std::string& id, Node fun, TypeNode type); |
63 |
|
void toStream( |
64 |
|
std::ostream& out, |
65 |
|
int toDepth = -1, |
66 |
|
size_t dag = 1, |
67 |
|
OutputLanguage language = language::output::LANG_AUTO) const override; |
68 |
|
NodeCommand* clone() const override; |
69 |
|
const Node& getFunction() const; |
70 |
|
|
71 |
|
private: |
72 |
|
std::string d_id; |
73 |
|
Node d_fun; |
74 |
|
TypeNode d_type; |
75 |
|
}; |
76 |
|
|
77 |
|
/** |
78 |
|
* Create datatype sort. |
79 |
|
* SMT-LIB: ( declare-datatypes ( <datatype decls>{n+1} ) ( <datatypes>{n+1} ) ) |
80 |
|
*/ |
81 |
3315 |
class DeclareDatatypeNodeCommand : public NodeCommand |
82 |
|
{ |
83 |
|
public: |
84 |
|
DeclareDatatypeNodeCommand(const std::vector<TypeNode>& datatypes); |
85 |
|
void toStream( |
86 |
|
std::ostream& out, |
87 |
|
int toDepth = -1, |
88 |
|
size_t dag = 1, |
89 |
|
OutputLanguage language = language::output::LANG_AUTO) const override; |
90 |
|
NodeCommand* clone() const override; |
91 |
|
|
92 |
|
private: |
93 |
|
std::vector<TypeNode> d_datatypes; |
94 |
|
}; |
95 |
|
|
96 |
|
/** |
97 |
|
* Declare uninterpreted sort. |
98 |
|
* SMT-LIB: ( declare-sort <id> <arity> ) |
99 |
|
*/ |
100 |
8453 |
class DeclareTypeNodeCommand : public NodeCommand |
101 |
|
{ |
102 |
|
public: |
103 |
|
DeclareTypeNodeCommand(const std::string& id, size_t arity, TypeNode type); |
104 |
|
void toStream( |
105 |
|
std::ostream& out, |
106 |
|
int toDepth = -1, |
107 |
|
size_t dag = 1, |
108 |
|
OutputLanguage language = language::output::LANG_AUTO) const override; |
109 |
|
NodeCommand* clone() const override; |
110 |
|
const std::string getSymbol() const; |
111 |
|
const TypeNode& getType() const; |
112 |
|
|
113 |
|
private: |
114 |
|
std::string d_id; |
115 |
|
size_t d_arity; |
116 |
|
TypeNode d_type; |
117 |
|
}; |
118 |
|
|
119 |
|
/** |
120 |
|
* Define n-ary function. |
121 |
|
* SMT-LIB: ( define-fun <id> ( <formals> ) <fun.getType()> <formula> ) |
122 |
|
*/ |
123 |
2269 |
class DefineFunctionNodeCommand : public NodeCommand |
124 |
|
{ |
125 |
|
public: |
126 |
|
DefineFunctionNodeCommand(const std::string& id, |
127 |
|
Node fun, |
128 |
|
const std::vector<Node>& formals, |
129 |
|
Node formula); |
130 |
|
void toStream( |
131 |
|
std::ostream& out, |
132 |
|
int toDepth = -1, |
133 |
|
size_t dag = 1, |
134 |
|
OutputLanguage language = language::output::LANG_AUTO) const override; |
135 |
|
NodeCommand* clone() const override; |
136 |
|
|
137 |
|
private: |
138 |
|
std::string d_id; |
139 |
|
Node d_fun; |
140 |
|
std::vector<Node> d_formals; |
141 |
|
Node d_formula; |
142 |
|
}; |
143 |
|
|
144 |
|
} // namespace cvc5 |
145 |
|
|
146 |
|
#endif /* CVC5__SMT__NODE_COMMAND_H */ |