1 /********************* */
4 ** Top contributors (to current version):
5 ** Abdalrhman Mohamed, Andrew Reynolds, Aina Niemetz
6 ** This file is part of the CVC4 project.
7 ** Copyright (c) 2009-2020 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.\endverbatim
12 ** \brief Base of the pretty-printer interface
14 ** Base of the pretty-printer interface.
17 #include "cvc4_private.h"
19 #ifndef CVC4__PRINTER__PRINTER_H
20 #define CVC4__PRINTER__PRINTER_H
25 #include "expr/node.h"
26 #include "options/language.h"
27 #include "smt/model.h"
28 #include "util/result.h"
29 #include "util/sexpr.h"
42 * Since the printers are managed as unique_ptr, we need public acces to
43 * the virtual destructor.
47 /** Get the Printer for a given OutputLanguage */
48 static Printer
* getPrinter(OutputLanguage lang
);
50 /** Write a Node out to a stream with this Printer. */
51 virtual void toStream(std::ostream
& out
,
54 size_t dag
) const = 0;
56 /** Write a CommandStatus out to a stream with this Printer. */
57 virtual void toStream(std::ostream
& out
, const CommandStatus
* s
) const = 0;
59 /** Write a Model out to a stream with this Printer. */
60 virtual void toStream(std::ostream
& out
, const smt::Model
& m
) const;
62 /** Write an UnsatCore out to a stream with this Printer. */
63 virtual void toStream(std::ostream
& out
, const UnsatCore
& core
) const;
65 /** Print empty command */
66 virtual void toStreamCmdEmpty(std::ostream
& out
,
67 const std::string
& name
) const;
69 /** Print echo command */
70 virtual void toStreamCmdEcho(std::ostream
& out
,
71 const std::string
& output
) const;
73 /** Print assert command */
74 virtual void toStreamCmdAssert(std::ostream
& out
, Node n
) const;
76 /** Print push command */
77 virtual void toStreamCmdPush(std::ostream
& out
) const;
79 /** Print pop command */
80 virtual void toStreamCmdPop(std::ostream
& out
) const;
82 /** Print declare-fun command */
83 virtual void toStreamCmdDeclareFunction(std::ostream
& out
,
84 const std::string
& id
,
87 /** Print declare-sort command */
88 virtual void toStreamCmdDeclareType(std::ostream
& out
,
91 /** Print define-sort command */
92 virtual void toStreamCmdDefineType(std::ostream
& out
,
93 const std::string
& id
,
94 const std::vector
<TypeNode
>& params
,
97 /** Print define-fun command */
98 virtual void toStreamCmdDefineFunction(std::ostream
& out
,
99 const std::string
& id
,
100 const std::vector
<Node
>& formals
,
104 /** Print define-fun-rec command */
105 virtual void toStreamCmdDefineFunctionRec(
107 const std::vector
<Node
>& funcs
,
108 const std::vector
<std::vector
<Node
>>& formals
,
109 const std::vector
<Node
>& formulas
) const;
111 /** Print set-user-attribute command */
112 void toStreamCmdSetUserAttribute(std::ostream
& out
,
113 const std::string
& attr
,
116 /** Print check-sat command */
117 virtual void toStreamCmdCheckSat(std::ostream
& out
,
118 Node n
= Node::null()) const;
120 /** Print check-sat-assuming command */
121 virtual void toStreamCmdCheckSatAssuming(
122 std::ostream
& out
, const std::vector
<Node
>& nodes
) const;
124 /** Print query command */
125 virtual void toStreamCmdQuery(std::ostream
& out
, Node n
) const;
127 /** Print declare-var command */
128 virtual void toStreamCmdDeclareVar(std::ostream
& out
,
130 TypeNode type
) const;
132 /** Print synth-fun command */
133 virtual void toStreamCmdSynthFun(std::ostream
& out
,
135 const std::vector
<Node
>& vars
,
137 TypeNode sygusType
= TypeNode::null()) const;
139 /** Print constraint command */
140 virtual void toStreamCmdConstraint(std::ostream
& out
, Node n
) const;
142 /** Print inv-constraint command */
143 virtual void toStreamCmdInvConstraint(
144 std::ostream
& out
, Node inv
, Node pre
, Node trans
, Node post
) const;
146 /** Print check-synth command */
147 virtual void toStreamCmdCheckSynth(std::ostream
& out
) const;
149 /** Print simplify command */
150 virtual void toStreamCmdSimplify(std::ostream
& out
, Node n
) const;
152 /** Print get-value command */
153 virtual void toStreamCmdGetValue(std::ostream
& out
,
154 const std::vector
<Node
>& nodes
) const;
156 /** Print get-assignment command */
157 virtual void toStreamCmdGetAssignment(std::ostream
& out
) const;
159 /** Print get-model command */
160 virtual void toStreamCmdGetModel(std::ostream
& out
) const;
162 /** Print block-model command */
163 void toStreamCmdBlockModel(std::ostream
& out
) const;
165 /** Print block-model-values command */
166 void toStreamCmdBlockModelValues(std::ostream
& out
,
167 const std::vector
<Node
>& nodes
) const;
169 /** Print get-proof command */
170 virtual void toStreamCmdGetProof(std::ostream
& out
) const;
172 /** Print get-instantiations command */
173 void toStreamCmdGetInstantiations(std::ostream
& out
) const;
175 /** Print get-synth-solution command */
176 void toStreamCmdGetSynthSolution(std::ostream
& out
) const;
178 /** Print get-interpol command */
179 void toStreamCmdGetInterpol(std::ostream
& out
,
180 const std::string
& name
,
182 TypeNode sygusType
) const;
184 /** Print get-abduct command */
185 virtual void toStreamCmdGetAbduct(std::ostream
& out
,
186 const std::string
& name
,
188 TypeNode sygusType
) const;
190 /** Print get-quantifier-elimination command */
191 void toStreamCmdGetQuantifierElimination(std::ostream
& out
, Node n
) const;
193 /** Print get-unsat-assumptions command */
194 virtual void toStreamCmdGetUnsatAssumptions(std::ostream
& out
) const;
196 /** Print get-unsat-core command */
197 virtual void toStreamCmdGetUnsatCore(std::ostream
& out
) const;
199 /** Print get-assertions command */
200 virtual void toStreamCmdGetAssertions(std::ostream
& out
) const;
202 /** Print set-info :status command */
203 virtual void toStreamCmdSetBenchmarkStatus(std::ostream
& out
,
204 Result::Sat status
) const;
206 /** Print set-logic command */
207 virtual void toStreamCmdSetBenchmarkLogic(std::ostream
& out
,
208 const std::string
& logic
) const;
210 /** Print set-info command */
211 virtual void toStreamCmdSetInfo(std::ostream
& out
,
212 const std::string
& flag
,
215 /** Print get-info command */
216 virtual void toStreamCmdGetInfo(std::ostream
& out
,
217 const std::string
& flag
) const;
219 /** Print set-option command */
220 virtual void toStreamCmdSetOption(std::ostream
& out
,
221 const std::string
& flag
,
224 /** Print get-option command */
225 virtual void toStreamCmdGetOption(std::ostream
& out
,
226 const std::string
& flag
) const;
228 /** Print set-expression-name command */
229 void toStreamCmdSetExpressionName(std::ostream
& out
,
231 const std::string
& name
) const;
233 /** Print declare-datatype(s) command */
234 virtual void toStreamCmdDatatypeDeclaration(
235 std::ostream
& out
, const std::vector
<TypeNode
>& datatypes
) const;
237 /** Print reset command */
238 virtual void toStreamCmdReset(std::ostream
& out
) const;
240 /** Print reset-assertions command */
241 virtual void toStreamCmdResetAssertions(std::ostream
& out
) const;
243 /** Print quit command */
244 virtual void toStreamCmdQuit(std::ostream
& out
) const;
246 /** Print comment command */
247 virtual void toStreamCmdComment(std::ostream
& out
,
248 const std::string
& comment
) const;
249 /** Declare heap command */
250 virtual void toStreamCmdDeclareHeap(std::ostream
& out
,
252 TypeNode dataType
) const;
254 /** Print command sequence command */
255 virtual void toStreamCmdCommandSequence(
256 std::ostream
& out
, const std::vector
<Command
*>& sequence
) const;
258 /** Print declaration sequence command */
259 virtual void toStreamCmdDeclarationSequence(
260 std::ostream
& out
, const std::vector
<Command
*>& sequence
) const;
263 /** Derived classes can construct, but no one else. */
267 * To stream model sort. This prints the appropriate output for type
268 * tn declared via declare-sort or declare-datatype.
270 virtual void toStreamModelSort(std::ostream
& out
,
272 TypeNode tn
) const = 0;
275 * To stream model term. This prints the appropriate output for term
276 * n declared via declare-fun.
278 virtual void toStreamModelTerm(std::ostream
& out
,
282 /** write model response to command using another language printer */
283 void toStreamUsing(OutputLanguage lang
,
285 const smt::Model
& m
) const;
288 * Write an error to `out` stating that command `name` is not supported by
291 void printUnknownCommand(std::ostream
& out
, const std::string
& name
) const;
294 /** Disallow copy, assignment */
295 Printer(const Printer
&) = delete;
296 Printer
& operator=(const Printer
&) = delete;
298 /** Make a Printer for a given OutputLanguage */
299 static std::unique_ptr
<Printer
> makePrinter(OutputLanguage lang
);
301 /** Printers for each OutputLanguage */
302 static std::unique_ptr
<Printer
> d_printers
[language::output::LANG_MAX
];
304 }; /* class Printer */
308 #endif /* CVC4__PRINTER__PRINTER_H */