GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/smt/command.h Lines: 62 78 79.5 %
Date: 2021-05-22 Branches: 4 16 25.0 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Abdalrhman Mohamed, Tim King, Andrew Reynolds
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
 * Implementation of the command pattern on SmtEngines.
14
 *
15
 * Command objects are generated by the parser (typically) to implement the
16
 * commands in parsed input (see Parser::parseNextCommand()), or by client
17
 * code.
18
 */
19
20
#include "cvc5_public.h"
21
22
#ifndef CVC5__COMMAND_H
23
#define CVC5__COMMAND_H
24
25
#include <iosfwd>
26
#include <sstream>
27
#include <string>
28
#include <vector>
29
30
#include "api/cpp/cvc5.h"
31
#include "cvc5_export.h"
32
#include "options/language.h"
33
34
namespace cvc5 {
35
36
namespace api {
37
class Solver;
38
class Term;
39
}  // namespace api
40
41
class SymbolManager;
42
class Command;
43
class CommandStatus;
44
45
namespace smt {
46
class Model;
47
}
48
49
/**
50
 * Convert a symbolic expression to string. This method differs from
51
 * Term::toString in that it does not depend on the output language.
52
 *
53
 * @param sexpr the symbolic expression to convert
54
 * @return the symbolic expression as string
55
 */
56
std::string sexprToString(api::Term sexpr) CVC5_EXPORT;
57
58
std::ostream& operator<<(std::ostream&, const Command&) CVC5_EXPORT;
59
std::ostream& operator<<(std::ostream&, const Command*) CVC5_EXPORT;
60
std::ostream& operator<<(std::ostream&, const CommandStatus&) CVC5_EXPORT;
61
std::ostream& operator<<(std::ostream&, const CommandStatus*) CVC5_EXPORT;
62
63
/** The status an SMT benchmark can have */
64
enum BenchmarkStatus
65
{
66
  /** Benchmark is satisfiable */
67
  SMT_SATISFIABLE,
68
  /** Benchmark is unsatisfiable */
69
  SMT_UNSATISFIABLE,
70
  /** The status of the benchmark is unknown */
71
  SMT_UNKNOWN
72
}; /* enum BenchmarkStatus */
73
74
std::ostream& operator<<(std::ostream& out, BenchmarkStatus status) CVC5_EXPORT;
75
76
/**
77
 * IOStream manipulator to print success messages or not.
78
 *
79
 *   out << Command::printsuccess(false) << CommandSuccess();
80
 *
81
 * prints nothing, but
82
 *
83
 *   out << Command::printsuccess(true) << CommandSuccess();
84
 *
85
 * prints a success message (in a manner appropriate for the current
86
 * output language).
87
 */
88
class CVC5_EXPORT CommandPrintSuccess
89
{
90
 public:
91
  /** Construct a CommandPrintSuccess with the given setting. */
92
170
  CommandPrintSuccess(bool printSuccess) : d_printSuccess(printSuccess) {}
93
  void applyPrintSuccess(std::ostream& out);
94
  static bool getPrintSuccess(std::ostream& out);
95
  static void setPrintSuccess(std::ostream& out, bool printSuccess);
96
97
 private:
98
  /** The allocated index in ios_base for our depth setting. */
99
  static const int s_iosIndex;
100
101
  /**
102
   * The default setting, for ostreams that haven't yet had a setdepth()
103
   * applied to them.
104
   */
105
  static const int s_defaultPrintSuccess = false;
106
107
  /** When this manipulator is used, the setting is stored here. */
108
  bool d_printSuccess;
109
110
}; /* class CommandPrintSuccess */
111
112
/**
113
 * Sets the default print-success setting when pretty-printing an Expr
114
 * to an ostream.  Use like this:
115
 *
116
 *   // let out be an ostream, e an Expr
117
 *   out << Expr::setdepth(n) << e << endl;
118
 *
119
 * The depth stays permanently (until set again) with the stream.
120
 */
121
std::ostream& operator<<(std::ostream& out,
122
                         CommandPrintSuccess cps) CVC5_EXPORT;
123
124
class CVC5_EXPORT CommandStatus
125
{
126
 protected:
127
  // shouldn't construct a CommandStatus (use a derived class)
128
18854
  CommandStatus() {}
129
130
 public:
131
54
  virtual ~CommandStatus() {}
132
  void toStream(std::ostream& out,
133
                OutputLanguage language = language::output::LANG_AUTO) const;
134
  virtual CommandStatus& clone() const = 0;
135
}; /* class CommandStatus */
136
137
9400
class CVC5_EXPORT CommandSuccess : public CommandStatus
138
{
139
  static const CommandSuccess* s_instance;
140
141
 public:
142
602210
  static const CommandSuccess* instance() { return s_instance; }
143
  CommandStatus& clone() const override
144
  {
145
    return const_cast<CommandSuccess&>(*this);
146
  }
147
}; /* class CommandSuccess */
148
149
9400
class CVC5_EXPORT CommandInterrupted : public CommandStatus
150
{
151
  static const CommandInterrupted* s_instance;
152
153
 public:
154
  static const CommandInterrupted* instance() { return s_instance; }
155
  CommandStatus& clone() const override
156
  {
157
    return const_cast<CommandInterrupted&>(*this);
158
  }
159
}; /* class CommandInterrupted */
160
161
class CVC5_EXPORT CommandUnsupported : public CommandStatus
162
{
163
 public:
164
  CommandStatus& clone() const override
165
  {
166
    return *new CommandUnsupported(*this);
167
  }
168
}; /* class CommandSuccess */
169
170
72
class CVC5_EXPORT CommandFailure : public CommandStatus
171
{
172
  std::string d_message;
173
174
 public:
175
36
  CommandFailure(std::string message) : d_message(message) {}
176
  CommandFailure& clone() const override { return *new CommandFailure(*this); }
177
36
  std::string getMessage() const { return d_message; }
178
}; /* class CommandFailure */
179
180
/**
181
 * The execution of the command resulted in a non-fatal error and further
182
 * commands can be processed. This status is for example used when a user asks
183
 * for an unsat core in a place that is not immediately preceded by an
184
 * unsat/valid response.
185
 */
186
36
class CVC5_EXPORT CommandRecoverableFailure : public CommandStatus
187
{
188
  std::string d_message;
189
190
 public:
191
18
  CommandRecoverableFailure(std::string message) : d_message(message) {}
192
  CommandRecoverableFailure& clone() const override
193
  {
194
    return *new CommandRecoverableFailure(*this);
195
  }
196
18
  std::string getMessage() const { return d_message; }
197
}; /* class CommandRecoverableFailure */
198
199
class CVC5_EXPORT Command
200
{
201
 public:
202
  typedef CommandPrintSuccess printsuccess;
203
204
  Command();
205
  Command(const Command& cmd);
206
207
  virtual ~Command();
208
209
  /**
210
   * Invoke the command on the solver and symbol manager sm.
211
   */
212
  virtual void invoke(api::Solver* solver, SymbolManager* sm) = 0;
213
  /**
214
   * Same as above, and prints the result to output stream out.
215
   */
216
  virtual void invoke(api::Solver* solver,
217
                      SymbolManager* sm,
218
                      std::ostream& out);
219
220
  virtual void toStream(
221
      std::ostream& out,
222
      int toDepth = -1,
223
224
      size_t dag = 1,
225
      OutputLanguage language = language::output::LANG_AUTO) const = 0;
226
227
  std::string toString() const;
228
229
  virtual std::string getCommandName() const = 0;
230
231
  /**
232
   * If false, instruct this Command not to print a success message.
233
   */
234
10849
  void setMuted(bool muted) { d_muted = muted; }
235
  /**
236
   * Determine whether this Command will print a success message.
237
   */
238
301210
  bool isMuted() { return d_muted; }
239
  /**
240
   * Either the command hasn't run yet, or it completed successfully
241
   * (CommandSuccess, not CommandUnsupported or CommandFailure).
242
   */
243
  bool ok() const;
244
245
  /**
246
   * The command completed in a failure state (CommandFailure, not
247
   * CommandSuccess or CommandUnsupported).
248
   */
249
  bool fail() const;
250
251
  /**
252
   * The command was ran but was interrupted due to resource limiting.
253
   */
254
  bool interrupted() const;
255
256
  /** Get the command status (it's NULL if we haven't run yet). */
257
  const CommandStatus* getCommandStatus() const { return d_commandStatus; }
258
  virtual void printResult(std::ostream& out, uint32_t verbosity = 2) const;
259
260
  /**
261
   * Clone this Command (make a shallow copy).
262
   */
263
  virtual Command* clone() const = 0;
264
265
  /**
266
   * This field contains a command status if the command has been
267
   * invoked, or NULL if it has not.  This field is either a
268
   * dynamically-allocated pointer, or it's a pointer to the singleton
269
   * CommandSuccess instance.  Doing so is somewhat asymmetric, but
270
   * it avoids the need to dynamically allocate memory in the common
271
   * case of a successful command.
272
   */
273
  const CommandStatus* d_commandStatus;
274
275
  /**
276
   * True if this command is "muted"---i.e., don't print "success" on
277
   * successful execution.
278
   */
279
  bool d_muted;
280
281
 protected:
282
  // These methods rely on Command being a friend of classes in the API.
283
  // Subclasses of command should use these methods for conversions,
284
  // which is currently necessary for e.g. printing commands.
285
  /** Helper to convert a Term to an internal Node */
286
  static Node termToNode(const api::Term& term);
287
  /** Helper to convert a vector of Terms to internal Nodes. */
288
  static std::vector<Node> termVectorToNodes(
289
      const std::vector<api::Term>& terms);
290
  /** Helper to convert a Sort to an internal TypeNode */
291
  static TypeNode sortToTypeNode(const api::Sort& sort);
292
  /** Helper to convert a vector of Sorts to internal TypeNodes. */
293
  static std::vector<TypeNode> sortVectorToTypeNodes(
294
      const std::vector<api::Sort>& sorts);
295
  /** Helper to convert a Grammar to an internal TypeNode */
296
  static TypeNode grammarToTypeNode(api::Grammar* grammar);
297
  /** Get original options from the solver (for ResetCommand) */
298
  Options& getOriginalOptionsFrom(api::Solver* s);
299
}; /* class Command */
300
301
/**
302
 * EmptyCommands are the residue of a command after the parser handles
303
 * them (and there's nothing left to do).
304
 */
305
880
class CVC5_EXPORT EmptyCommand : public Command
306
{
307
 public:
308
  EmptyCommand(std::string name = "");
309
  std::string getName() const;
310
  void invoke(api::Solver* solver, SymbolManager* sm) override;
311
  Command* clone() const override;
312
  std::string getCommandName() const override;
313
  void toStream(
314
      std::ostream& out,
315
      int toDepth = -1,
316
      size_t dag = 1,
317
      OutputLanguage language = language::output::LANG_AUTO) const override;
318
319
 protected:
320
  std::string d_name;
321
}; /* class EmptyCommand */
322
323
18
class CVC5_EXPORT EchoCommand : public Command
324
{
325
 public:
326
  EchoCommand(std::string output = "");
327
328
  std::string getOutput() const;
329
330
  void invoke(api::Solver* solver, SymbolManager* sm) override;
331
  void invoke(api::Solver* solver,
332
              SymbolManager* sm,
333
              std::ostream& out) override;
334
335
  Command* clone() const override;
336
  std::string getCommandName() const override;
337
  void toStream(
338
      std::ostream& out,
339
      int toDepth = -1,
340
      size_t dag = 1,
341
      OutputLanguage language = language::output::LANG_AUTO) const override;
342
343
 protected:
344
  std::string d_output;
345
}; /* class EchoCommand */
346
347
161372
class CVC5_EXPORT AssertCommand : public Command
348
{
349
 protected:
350
  api::Term d_term;
351
  bool d_inUnsatCore;
352
353
 public:
354
  AssertCommand(const api::Term& t, bool inUnsatCore = true);
355
356
  api::Term getTerm() const;
357
358
  void invoke(api::Solver* solver, SymbolManager* sm) override;
359
360
  Command* clone() const override;
361
  std::string getCommandName() const override;
362
  void toStream(
363
      std::ostream& out,
364
      int toDepth = -1,
365
      size_t dag = 1,
366
      OutputLanguage language = language::output::LANG_AUTO) const override;
367
}; /* class AssertCommand */
368
369
9790
class CVC5_EXPORT PushCommand : public Command
370
{
371
 public:
372
  void invoke(api::Solver* solver, SymbolManager* sm) override;
373
  Command* clone() const override;
374
  std::string getCommandName() const override;
375
  void toStream(
376
      std::ostream& out,
377
      int toDepth = -1,
378
      size_t dag = 1,
379
      OutputLanguage language = language::output::LANG_AUTO) const override;
380
}; /* class PushCommand */
381
382
8230
class CVC5_EXPORT PopCommand : public Command
383
{
384
 public:
385
  void invoke(api::Solver* solver, SymbolManager* sm) override;
386
  Command* clone() const override;
387
  std::string getCommandName() const override;
388
  void toStream(
389
      std::ostream& out,
390
      int toDepth = -1,
391
      size_t dag = 1,
392
      OutputLanguage language = language::output::LANG_AUTO) const override;
393
}; /* class PopCommand */
394
395
182742
class CVC5_EXPORT DeclarationDefinitionCommand : public Command
396
{
397
 protected:
398
  std::string d_symbol;
399
400
 public:
401
  DeclarationDefinitionCommand(const std::string& id);
402
403
  void invoke(api::Solver* solver, SymbolManager* sm) override = 0;
404
  std::string getSymbol() const;
405
}; /* class DeclarationDefinitionCommand */
406
407
351422
class CVC5_EXPORT DeclareFunctionCommand : public DeclarationDefinitionCommand
408
{
409
 protected:
410
  api::Term d_func;
411
  api::Sort d_sort;
412
413
 public:
414
  DeclareFunctionCommand(const std::string& id, api::Term func, api::Sort sort);
415
  api::Term getFunction() const;
416
  api::Sort getSort() const;
417
418
  void invoke(api::Solver* solver, SymbolManager* sm) override;
419
  Command* clone() const override;
420
  std::string getCommandName() const override;
421
  void toStream(
422
      std::ostream& out,
423
      int toDepth = -1,
424
      size_t dag = 1,
425
      OutputLanguage language = language::output::LANG_AUTO) const override;
426
}; /* class DeclareFunctionCommand */
427
428
6
class CVC5_EXPORT DeclarePoolCommand : public DeclarationDefinitionCommand
429
{
430
 protected:
431
  api::Term d_func;
432
  api::Sort d_sort;
433
  std::vector<api::Term> d_initValue;
434
435
 public:
436
  DeclarePoolCommand(const std::string& id,
437
                     api::Term func,
438
                     api::Sort sort,
439
                     const std::vector<api::Term>& initValue);
440
  api::Term getFunction() const;
441
  api::Sort getSort() const;
442
  const std::vector<api::Term>& getInitialValue() const;
443
444
  void invoke(api::Solver* solver, SymbolManager* sm) override;
445
  Command* clone() const override;
446
  std::string getCommandName() const override;
447
  void toStream(
448
      std::ostream& out,
449
      int toDepth = -1,
450
      size_t dag = 1,
451
      OutputLanguage language = language::output::LANG_AUTO) const override;
452
}; /* class DeclarePoolCommand */
453
454
8072
class CVC5_EXPORT DeclareSortCommand : public DeclarationDefinitionCommand
455
{
456
 protected:
457
  size_t d_arity;
458
  api::Sort d_sort;
459
460
 public:
461
  DeclareSortCommand(const std::string& id, size_t arity, api::Sort sort);
462
463
  size_t getArity() const;
464
  api::Sort getSort() const;
465
466
  void invoke(api::Solver* solver, SymbolManager* sm) override;
467
  Command* clone() const override;
468
  std::string getCommandName() const override;
469
  void toStream(
470
      std::ostream& out,
471
      int toDepth = -1,
472
      size_t dag = 1,
473
      OutputLanguage language = language::output::LANG_AUTO) const override;
474
}; /* class DeclareSortCommand */
475
476
412
class CVC5_EXPORT DefineSortCommand : public DeclarationDefinitionCommand
477
{
478
 protected:
479
  std::vector<api::Sort> d_params;
480
  api::Sort d_sort;
481
482
 public:
483
  DefineSortCommand(const std::string& id, api::Sort sort);
484
  DefineSortCommand(const std::string& id,
485
                    const std::vector<api::Sort>& params,
486
                    api::Sort sort);
487
488
  const std::vector<api::Sort>& getParameters() const;
489
  api::Sort getSort() const;
490
491
  void invoke(api::Solver* solver, SymbolManager* sm) override;
492
  Command* clone() const override;
493
  std::string getCommandName() const override;
494
  void toStream(
495
      std::ostream& out,
496
      int toDepth = -1,
497
      size_t dag = 1,
498
      OutputLanguage language = language::output::LANG_AUTO) const override;
499
}; /* class DefineSortCommand */
500
501
4484
class CVC5_EXPORT DefineFunctionCommand : public DeclarationDefinitionCommand
502
{
503
 public:
504
  DefineFunctionCommand(const std::string& id,
505
                        api::Term func,
506
                        api::Term formula,
507
                        bool global);
508
  DefineFunctionCommand(const std::string& id,
509
                        api::Term func,
510
                        const std::vector<api::Term>& formals,
511
                        api::Term formula,
512
                        bool global);
513
514
  api::Term getFunction() const;
515
  const std::vector<api::Term>& getFormals() const;
516
  api::Term getFormula() const;
517
518
  void invoke(api::Solver* solver, SymbolManager* sm) override;
519
  Command* clone() const override;
520
  std::string getCommandName() const override;
521
  void toStream(
522
      std::ostream& out,
523
      int toDepth = -1,
524
      size_t dag = 1,
525
      OutputLanguage language = language::output::LANG_AUTO) const override;
526
527
 protected:
528
  /** The function we are defining */
529
  api::Term d_func;
530
  /** The formal arguments for the function we are defining */
531
  std::vector<api::Term> d_formals;
532
  /** The formula corresponding to the body of the function we are defining */
533
  api::Term d_formula;
534
  /**
535
   * Stores whether this definition is global (i.e. should persist when
536
   * popping the user context.
537
   */
538
  bool d_global;
539
}; /* class DefineFunctionCommand */
540
541
/**
542
 * The command when parsing define-fun-rec or define-funs-rec.
543
 * This command will assert a set of quantified formulas that specify
544
 * the (mutually recursive) function definitions provided to it.
545
 */
546
238
class CVC5_EXPORT DefineFunctionRecCommand : public Command
547
{
548
 public:
549
  DefineFunctionRecCommand(api::Term func,
550
                           const std::vector<api::Term>& formals,
551
                           api::Term formula,
552
                           bool global);
553
  DefineFunctionRecCommand(const std::vector<api::Term>& funcs,
554
                           const std::vector<std::vector<api::Term> >& formals,
555
                           const std::vector<api::Term>& formula,
556
                           bool global);
557
558
  const std::vector<api::Term>& getFunctions() const;
559
  const std::vector<std::vector<api::Term> >& getFormals() const;
560
  const std::vector<api::Term>& getFormulas() const;
561
562
  void invoke(api::Solver* solver, SymbolManager* sm) override;
563
  Command* clone() const override;
564
  std::string getCommandName() const override;
565
  void toStream(
566
      std::ostream& out,
567
      int toDepth = -1,
568
      size_t dag = 1,
569
      OutputLanguage language = language::output::LANG_AUTO) const override;
570
571
 protected:
572
  /** functions we are defining */
573
  std::vector<api::Term> d_funcs;
574
  /** formal arguments for each of the functions we are defining */
575
  std::vector<std::vector<api::Term> > d_formals;
576
  /** formulas corresponding to the bodies of the functions we are defining */
577
  std::vector<api::Term> d_formulas;
578
  /**
579
   * Stores whether this definition is global (i.e. should persist when
580
   * popping the user context.
581
   */
582
  bool d_global;
583
}; /* class DefineFunctionRecCommand */
584
585
/**
586
 * In separation logic inputs, which is an extension of smt2 inputs, this
587
 * corresponds to the command:
588
 *   (declare-heap (T U))
589
 * where T is the location sort and U is the data sort.
590
 */
591
174
class CVC5_EXPORT DeclareHeapCommand : public Command
592
{
593
 public:
594
  DeclareHeapCommand(api::Sort locSort, api::Sort dataSort);
595
  api::Sort getLocationSort() const;
596
  api::Sort getDataSort() const;
597
  void invoke(api::Solver* solver, SymbolManager* sm) override;
598
  Command* clone() const override;
599
  std::string getCommandName() const override;
600
  void toStream(
601
      std::ostream& out,
602
      int toDepth = -1,
603
      size_t dag = 1,
604
      OutputLanguage language = language::output::LANG_AUTO) const override;
605
606
 protected:
607
  /** The location sort */
608
  api::Sort d_locSort;
609
  /** The data sort */
610
  api::Sort d_dataSort;
611
};
612
613
/**
614
 * The command when an attribute is set by a user.  In SMT-LIBv2 this is done
615
 *  via the syntax (! expr :attr)
616
 */
617
404
class CVC5_EXPORT SetUserAttributeCommand : public Command
618
{
619
 public:
620
  SetUserAttributeCommand(const std::string& attr, api::Term term);
621
  SetUserAttributeCommand(const std::string& attr,
622
                          api::Term term,
623
                          const std::vector<api::Term>& values);
624
  SetUserAttributeCommand(const std::string& attr,
625
                          api::Term term,
626
                          const std::string& value);
627
628
  void invoke(api::Solver* solver, SymbolManager* sm) override;
629
  Command* clone() const override;
630
  std::string getCommandName() const override;
631
  void toStream(
632
      std::ostream& out,
633
      int toDepth = -1,
634
      size_t dag = 1,
635
      OutputLanguage language = language::output::LANG_AUTO) const override;
636
637
 private:
638
  SetUserAttributeCommand(const std::string& attr,
639
                          api::Term term,
640
                          const std::vector<api::Term>& termValues,
641
                          const std::string& strValue);
642
643
  const std::string d_attr;
644
  const api::Term d_term;
645
  const std::vector<api::Term> d_termValues;
646
  const std::string d_strValue;
647
}; /* class SetUserAttributeCommand */
648
649
/**
650
 * The command when parsing check-sat.
651
 * This command will check satisfiability of the input formula.
652
 */
653
17732
class CVC5_EXPORT CheckSatCommand : public Command
654
{
655
 public:
656
  CheckSatCommand();
657
  CheckSatCommand(const api::Term& term);
658
659
  api::Term getTerm() const;
660
  api::Result getResult() const;
661
  void invoke(api::Solver* solver, SymbolManager* sm) override;
662
  void printResult(std::ostream& out, uint32_t verbosity = 2) const override;
663
  Command* clone() const override;
664
  std::string getCommandName() const override;
665
  void toStream(
666
      std::ostream& out,
667
      int toDepth = -1,
668
      size_t dag = 1,
669
      OutputLanguage language = language::output::LANG_AUTO) const override;
670
671
 private:
672
  api::Term d_term;
673
  api::Result d_result;
674
}; /* class CheckSatCommand */
675
676
/**
677
 * The command when parsing check-sat-assuming.
678
 * This command will assume a set of formulas and check satisfiability of the
679
 * input formula under these assumptions.
680
 */
681
1980
class CVC5_EXPORT CheckSatAssumingCommand : public Command
682
{
683
 public:
684
  CheckSatAssumingCommand(api::Term term);
685
  CheckSatAssumingCommand(const std::vector<api::Term>& terms);
686
687
  const std::vector<api::Term>& getTerms() const;
688
  api::Result getResult() const;
689
  void invoke(api::Solver* solver, SymbolManager* sm) override;
690
  void printResult(std::ostream& out, uint32_t verbosity = 2) const override;
691
  Command* clone() const override;
692
  std::string getCommandName() const override;
693
  void toStream(
694
      std::ostream& out,
695
      int toDepth = -1,
696
      size_t dag = 1,
697
      OutputLanguage language = language::output::LANG_AUTO) const override;
698
699
 private:
700
  std::vector<api::Term> d_terms;
701
  api::Result d_result;
702
}; /* class CheckSatAssumingCommand */
703
704
1240
class CVC5_EXPORT QueryCommand : public Command
705
{
706
 protected:
707
  api::Term d_term;
708
  api::Result d_result;
709
  bool d_inUnsatCore;
710
711
 public:
712
  QueryCommand(const api::Term& t, bool inUnsatCore = true);
713
714
  api::Term getTerm() const;
715
  api::Result getResult() const;
716
  void invoke(api::Solver* solver, SymbolManager* sm) override;
717
  void printResult(std::ostream& out, uint32_t verbosity = 2) const override;
718
  Command* clone() const override;
719
  std::string getCommandName() const override;
720
  void toStream(
721
      std::ostream& out,
722
      int toDepth = -1,
723
      size_t dag = 1,
724
      OutputLanguage language = language::output::LANG_AUTO) const override;
725
}; /* class QueryCommand */
726
727
/* ------------------- sygus commands  ------------------ */
728
729
/** Declares a sygus universal variable */
730
524
class CVC5_EXPORT DeclareSygusVarCommand : public DeclarationDefinitionCommand
731
{
732
 public:
733
  DeclareSygusVarCommand(const std::string& id, api::Term var, api::Sort sort);
734
  /** returns the declared variable */
735
  api::Term getVar() const;
736
  /** returns the declared variable's sort */
737
  api::Sort getSort() const;
738
  /** invokes this command
739
   *
740
   * The declared sygus variable is communicated to the SMT engine in case a
741
   * synthesis conjecture is built later on.
742
   */
743
  void invoke(api::Solver* solver, SymbolManager* sm) override;
744
  /** creates a copy of this command */
745
  Command* clone() const override;
746
  /** returns this command's name */
747
  std::string getCommandName() const override;
748
  /** prints this command */
749
  void toStream(
750
      std::ostream& out,
751
      int toDepth = -1,
752
      size_t dag = 1,
753
      OutputLanguage language = language::output::LANG_AUTO) const override;
754
755
 protected:
756
  /** the declared variable */
757
  api::Term d_var;
758
  /** the declared variable's sort */
759
  api::Sort d_sort;
760
};
761
762
/** Declares a sygus function-to-synthesize
763
 *
764
 * This command is also used for the special case in which we are declaring an
765
 * invariant-to-synthesize
766
 */
767
564
class CVC5_EXPORT SynthFunCommand : public DeclarationDefinitionCommand
768
{
769
 public:
770
  SynthFunCommand(const std::string& id,
771
                  api::Term fun,
772
                  const std::vector<api::Term>& vars,
773
                  api::Sort sort,
774
                  bool isInv,
775
                  api::Grammar* g);
776
  /** returns the function-to-synthesize */
777
  api::Term getFunction() const;
778
  /** returns the input variables of the function-to-synthesize */
779
  const std::vector<api::Term>& getVars() const;
780
  /** returns the sygus sort of the function-to-synthesize */
781
  api::Sort getSort() const;
782
  /** returns whether the function-to-synthesize should be an invariant */
783
  bool isInv() const;
784
  /** Get the sygus grammar given for the synth fun command */
785
  const api::Grammar* getGrammar() const;
786
787
  /** invokes this command
788
   *
789
   * The declared function-to-synthesize is communicated to the SMT engine in
790
   * case a synthesis conjecture is built later on.
791
   */
792
  void invoke(api::Solver* solver, SymbolManager* sm) override;
793
  /** creates a copy of this command */
794
  Command* clone() const override;
795
  /** returns this command's name */
796
  std::string getCommandName() const override;
797
  /** prints this command */
798
  void toStream(
799
      std::ostream& out,
800
      int toDepth = -1,
801
      size_t dag = 1,
802
      OutputLanguage language = language::output::LANG_AUTO) const override;
803
804
 protected:
805
  /** the function-to-synthesize */
806
  api::Term d_fun;
807
  /** the input variables of the function-to-synthesize */
808
  std::vector<api::Term> d_vars;
809
  /** sort of the function-to-synthesize */
810
  api::Sort d_sort;
811
  /** whether the function-to-synthesize should be an invariant */
812
  bool d_isInv;
813
  /** optional grammar for the possible values of the function-to-sytnhesize */
814
  api::Grammar* d_grammar;
815
};
816
817
/** Declares a sygus constraint */
818
1196
class CVC5_EXPORT SygusConstraintCommand : public Command
819
{
820
 public:
821
  SygusConstraintCommand(const api::Term& t);
822
  /** returns the declared constraint */
823
  api::Term getTerm() const;
824
  /** invokes this command
825
   *
826
   * The declared constraint is communicated to the SMT engine in case a
827
   * synthesis conjecture is built later on.
828
   */
829
  void invoke(api::Solver* solver, SymbolManager* sm) override;
830
  /** creates a copy of this command */
831
  Command* clone() const override;
832
  /** returns this command's name */
833
  std::string getCommandName() const override;
834
  /** prints this command */
835
  void toStream(
836
      std::ostream& out,
837
      int toDepth = -1,
838
      size_t dag = 1,
839
      OutputLanguage language = language::output::LANG_AUTO) const override;
840
841
 protected:
842
  /** the declared constraint */
843
  api::Term d_term;
844
};
845
846
/** Declares a sygus invariant constraint
847
 *
848
 * Invarint constraints are declared in a somewhat implicit manner in the SyGuS
849
 * language: they are declared in terms of the previously declared
850
 * invariant-to-synthesize, precondition, transition relation and condition.
851
 *
852
 * The actual constraint must be built such that the invariant is not stronger
853
 * than the precondition, not weaker than the postcondition and inductive
854
 * w.r.t. the transition relation.
855
 */
856
26
class CVC5_EXPORT SygusInvConstraintCommand : public Command
857
{
858
 public:
859
  SygusInvConstraintCommand(const std::vector<api::Term>& predicates);
860
  SygusInvConstraintCommand(const api::Term& inv,
861
                            const api::Term& pre,
862
                            const api::Term& trans,
863
                            const api::Term& post);
864
  /** returns the place holder predicates */
865
  const std::vector<api::Term>& getPredicates() const;
866
  /** invokes this command
867
   *
868
   * The place holders are communicated to the SMT engine and the actual
869
   * invariant constraint is built, in case an actual synthesis conjecture is
870
   * built later on.
871
   */
872
  void invoke(api::Solver* solver, SymbolManager* sm) override;
873
  /** creates a copy of this command */
874
  Command* clone() const override;
875
  /** returns this command's name */
876
  std::string getCommandName() const override;
877
  /** prints this command */
878
  void toStream(
879
      std::ostream& out,
880
      int toDepth = -1,
881
      size_t dag = 1,
882
      OutputLanguage language = language::output::LANG_AUTO) const override;
883
884
 protected:
885
  /** the place holder predicates with which to build the actual constraint
886
   * (i.e. the invariant, precondition, transition relation and postcondition)
887
   */
888
  std::vector<api::Term> d_predicates;
889
};
890
891
/** Declares a synthesis conjecture */
892
378
class CVC5_EXPORT CheckSynthCommand : public Command
893
{
894
 public:
895
189
  CheckSynthCommand(){};
896
  /** returns the result of the check-synth call */
897
  api::Result getResult() const;
898
  /** prints the result of the check-synth-call */
899
  void printResult(std::ostream& out, uint32_t verbosity = 2) const override;
900
  /** invokes this command
901
   *
902
   * This invocation makes the SMT engine build a synthesis conjecture based on
903
   * previously declared information (such as universal variables,
904
   * functions-to-synthesize and so on), set up attributes to guide the solving,
905
   * and then perform a satisfiability check, whose result is stored in
906
   * d_result.
907
   */
908
  void invoke(api::Solver* solver, SymbolManager* sm) override;
909
  /** creates a copy of this command */
910
  Command* clone() const override;
911
  /** returns this command's name */
912
  std::string getCommandName() const override;
913
  /** prints this command */
914
  void toStream(
915
      std::ostream& out,
916
      int toDepth = -1,
917
      size_t dag = 1,
918
      OutputLanguage language = language::output::LANG_AUTO) const override;
919
920
 protected:
921
  /** result of the check-synth call */
922
  api::Result d_result;
923
  /** string stream that stores the output of the solution */
924
  std::stringstream d_solution;
925
};
926
927
/* ------------------- sygus commands  ------------------ */
928
929
// this is TRANSFORM in the CVC presentation language
930
class CVC5_EXPORT SimplifyCommand : public Command
931
{
932
 protected:
933
  api::Term d_term;
934
  api::Term d_result;
935
936
 public:
937
  SimplifyCommand(api::Term term);
938
939
  api::Term getTerm() const;
940
  api::Term getResult() const;
941
  void invoke(api::Solver* solver, SymbolManager* sm) override;
942
  void printResult(std::ostream& out, uint32_t verbosity = 2) const override;
943
  Command* clone() const override;
944
  std::string getCommandName() const override;
945
  void toStream(
946
      std::ostream& out,
947
      int toDepth = -1,
948
      size_t dag = 1,
949
      OutputLanguage language = language::output::LANG_AUTO) const override;
950
}; /* class SimplifyCommand */
951
952
128
class CVC5_EXPORT GetValueCommand : public Command
953
{
954
 protected:
955
  std::vector<api::Term> d_terms;
956
  api::Term d_result;
957
958
 public:
959
  GetValueCommand(api::Term term);
960
  GetValueCommand(const std::vector<api::Term>& terms);
961
962
  const std::vector<api::Term>& getTerms() const;
963
  api::Term getResult() const;
964
  void invoke(api::Solver* solver, SymbolManager* sm) override;
965
  void printResult(std::ostream& out, uint32_t verbosity = 2) const override;
966
  Command* clone() const override;
967
  std::string getCommandName() const override;
968
  void toStream(
969
      std::ostream& out,
970
      int toDepth = -1,
971
      size_t dag = 1,
972
      OutputLanguage language = language::output::LANG_AUTO) const override;
973
}; /* class GetValueCommand */
974
975
20
class CVC5_EXPORT GetAssignmentCommand : public Command
976
{
977
 protected:
978
  api::Term d_result;
979
980
 public:
981
  GetAssignmentCommand();
982
983
  api::Term getResult() const;
984
  void invoke(api::Solver* solver, SymbolManager* sm) override;
985
  void printResult(std::ostream& out, uint32_t verbosity = 2) const override;
986
  Command* clone() const override;
987
  std::string getCommandName() const override;
988
  void toStream(
989
      std::ostream& out,
990
      int toDepth = -1,
991
      size_t dag = 1,
992
      OutputLanguage language = language::output::LANG_AUTO) const override;
993
}; /* class GetAssignmentCommand */
994
995
60
class CVC5_EXPORT GetModelCommand : public Command
996
{
997
 public:
998
  GetModelCommand();
999
1000
  // Model is private to the library -- for now
1001
  // Model* getResult() const ;
1002
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1003
  void printResult(std::ostream& out, uint32_t verbosity = 2) const override;
1004
  Command* clone() const override;
1005
  std::string getCommandName() const override;
1006
  void toStream(
1007
      std::ostream& out,
1008
      int toDepth = -1,
1009
      size_t dag = 1,
1010
      OutputLanguage language = language::output::LANG_AUTO) const override;
1011
1012
 protected:
1013
  smt::Model* d_result;
1014
}; /* class GetModelCommand */
1015
1016
/** The command to block models. */
1017
28
class CVC5_EXPORT BlockModelCommand : public Command
1018
{
1019
 public:
1020
  BlockModelCommand();
1021
1022
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1023
  Command* clone() const override;
1024
  std::string getCommandName() const override;
1025
  void toStream(
1026
      std::ostream& out,
1027
      int toDepth = -1,
1028
      size_t dag = 1,
1029
      OutputLanguage language = language::output::LANG_AUTO) const override;
1030
}; /* class BlockModelCommand */
1031
1032
/** The command to block model values. */
1033
16
class CVC5_EXPORT BlockModelValuesCommand : public Command
1034
{
1035
 public:
1036
  BlockModelValuesCommand(const std::vector<api::Term>& terms);
1037
1038
  const std::vector<api::Term>& getTerms() const;
1039
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1040
  Command* clone() const override;
1041
  std::string getCommandName() const override;
1042
  void toStream(
1043
      std::ostream& out,
1044
      int toDepth = -1,
1045
      size_t dag = 1,
1046
      OutputLanguage language = language::output::LANG_AUTO) const override;
1047
1048
 protected:
1049
  /** The terms we are blocking */
1050
  std::vector<api::Term> d_terms;
1051
}; /* class BlockModelValuesCommand */
1052
1053
2
class CVC5_EXPORT GetProofCommand : public Command
1054
{
1055
 public:
1056
  GetProofCommand();
1057
1058
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1059
1060
  void printResult(std::ostream& out, uint32_t verbosity = 2) const override;
1061
1062
  Command* clone() const override;
1063
  std::string getCommandName() const override;
1064
  void toStream(
1065
      std::ostream& out,
1066
      int toDepth = -1,
1067
      size_t dag = 1,
1068
      OutputLanguage language = language::output::LANG_AUTO) const override;
1069
1070
 private:
1071
  /** the result of the getProof call */
1072
  std::string d_result;
1073
}; /* class GetProofCommand */
1074
1075
30
class CVC5_EXPORT GetInstantiationsCommand : public Command
1076
{
1077
 public:
1078
  GetInstantiationsCommand();
1079
1080
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1081
  void printResult(std::ostream& out, uint32_t verbosity = 2) const override;
1082
  Command* clone() const override;
1083
  std::string getCommandName() const override;
1084
  void toStream(
1085
      std::ostream& out,
1086
      int toDepth = -1,
1087
      size_t dag = 1,
1088
      OutputLanguage language = language::output::LANG_AUTO) const override;
1089
1090
 protected:
1091
  api::Solver* d_solver;
1092
}; /* class GetInstantiationsCommand */
1093
1094
/** The command (get-interpol s B (G)?)
1095
 *
1096
 * This command asks for an interpolant from the current set of assertions and
1097
 * conjecture (goal) B.
1098
 *
1099
 * The symbol s is the name for the interpolation predicate. If we successfully
1100
 * find a predicate P, then the output response of this command is: (define-fun
1101
 * s () Bool P)
1102
 */
1103
16
class CVC5_EXPORT GetInterpolCommand : public Command
1104
{
1105
 public:
1106
  GetInterpolCommand(const std::string& name, api::Term conj);
1107
  /** The argument g is the grammar of the interpolation query */
1108
  GetInterpolCommand(const std::string& name, api::Term conj, api::Grammar* g);
1109
1110
  /** Get the conjecture of the interpolation query */
1111
  api::Term getConjecture() const;
1112
  /** Get the sygus grammar given for the interpolation query */
1113
  const api::Grammar* getGrammar() const;
1114
  /** Get the result of the query, which is the solution to the interpolation
1115
   * query. */
1116
  api::Term getResult() const;
1117
1118
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1119
  void printResult(std::ostream& out, uint32_t verbosity = 2) const override;
1120
  Command* clone() const override;
1121
  std::string getCommandName() const override;
1122
  void toStream(
1123
      std::ostream& out,
1124
      int toDepth = -1,
1125
      size_t dag = 1,
1126
      OutputLanguage language = language::output::LANG_AUTO) const override;
1127
1128
 protected:
1129
  /** The name of the interpolation predicate */
1130
  std::string d_name;
1131
  /** The conjecture of the interpolation query */
1132
  api::Term d_conj;
1133
  /** The (optional) grammar of the interpolation query */
1134
  api::Grammar* d_sygus_grammar;
1135
  /** the return status of the command */
1136
  bool d_resultStatus;
1137
  /** the return expression of the command */
1138
  api::Term d_result;
1139
}; /* class GetInterpolCommand */
1140
1141
/** The command (get-abduct s B (G)?)
1142
 *
1143
 * This command asks for an abduct from the current set of assertions and
1144
 * conjecture (goal) given by the argument B.
1145
 *
1146
 * The symbol s is the name for the abduction predicate. If we successfully
1147
 * find a predicate P, then the output response of this command is:
1148
 *   (define-fun s () Bool P)
1149
 *
1150
 * A grammar G can be optionally provided to indicate the syntactic restrictions
1151
 * on the possible solutions returned.
1152
 */
1153
22
class CVC5_EXPORT GetAbductCommand : public Command
1154
{
1155
 public:
1156
  GetAbductCommand(const std::string& name, api::Term conj);
1157
  GetAbductCommand(const std::string& name, api::Term conj, api::Grammar* g);
1158
1159
  /** Get the conjecture of the abduction query */
1160
  api::Term getConjecture() const;
1161
  /** Get the grammar given for the abduction query */
1162
  const api::Grammar* getGrammar() const;
1163
  /** Get the name of the abduction predicate for the abduction query */
1164
  std::string getAbductName() const;
1165
  /** Get the result of the query, which is the solution to the abduction query.
1166
   */
1167
  api::Term getResult() const;
1168
1169
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1170
  void printResult(std::ostream& out, uint32_t verbosity = 2) const override;
1171
  Command* clone() const override;
1172
  std::string getCommandName() const override;
1173
  void toStream(
1174
      std::ostream& out,
1175
      int toDepth = -1,
1176
      size_t dag = 1,
1177
      OutputLanguage language = language::output::LANG_AUTO) const override;
1178
1179
 protected:
1180
  /** The name of the abduction predicate */
1181
  std::string d_name;
1182
  /** The conjecture of the abduction query */
1183
  api::Term d_conj;
1184
  /** The (optional) grammar of the abduction query */
1185
  api::Grammar* d_sygus_grammar;
1186
  /** the return status of the command */
1187
  bool d_resultStatus;
1188
  /** the return expression of the command */
1189
  api::Term d_result;
1190
}; /* class GetAbductCommand */
1191
1192
16
class CVC5_EXPORT GetQuantifierEliminationCommand : public Command
1193
{
1194
 protected:
1195
  api::Term d_term;
1196
  bool d_doFull;
1197
  api::Term d_result;
1198
1199
 public:
1200
  GetQuantifierEliminationCommand();
1201
  GetQuantifierEliminationCommand(const api::Term& term, bool doFull);
1202
1203
  api::Term getTerm() const;
1204
  bool getDoFull() const;
1205
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1206
  api::Term getResult() const;
1207
  void printResult(std::ostream& out, uint32_t verbosity = 2) const override;
1208
1209
  Command* clone() const override;
1210
  std::string getCommandName() const override;
1211
  void toStream(
1212
      std::ostream& out,
1213
      int toDepth = -1,
1214
      size_t dag = 1,
1215
      OutputLanguage language = language::output::LANG_AUTO) const override;
1216
}; /* class GetQuantifierEliminationCommand */
1217
1218
22
class CVC5_EXPORT GetUnsatAssumptionsCommand : public Command
1219
{
1220
 public:
1221
  GetUnsatAssumptionsCommand();
1222
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1223
  std::vector<api::Term> getResult() const;
1224
  void printResult(std::ostream& out, uint32_t verbosity = 2) const override;
1225
  Command* clone() const override;
1226
  std::string getCommandName() const override;
1227
  void toStream(
1228
      std::ostream& out,
1229
      int toDepth = -1,
1230
      size_t dag = 1,
1231
      OutputLanguage language = language::output::LANG_AUTO) const override;
1232
1233
 protected:
1234
  std::vector<api::Term> d_result;
1235
}; /* class GetUnsatAssumptionsCommand */
1236
1237
24
class CVC5_EXPORT GetUnsatCoreCommand : public Command
1238
{
1239
 public:
1240
  GetUnsatCoreCommand();
1241
  const std::vector<api::Term>& getUnsatCore() const;
1242
1243
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1244
  void printResult(std::ostream& out, uint32_t verbosity = 2) const override;
1245
1246
  Command* clone() const override;
1247
  std::string getCommandName() const override;
1248
  void toStream(
1249
      std::ostream& out,
1250
      int toDepth = -1,
1251
      size_t dag = 1,
1252
      OutputLanguage language = language::output::LANG_AUTO) const override;
1253
1254
 protected:
1255
  /** The symbol manager we were invoked with */
1256
  SymbolManager* d_sm;
1257
  /** the result of the unsat core call */
1258
  std::vector<api::Term> d_result;
1259
}; /* class GetUnsatCoreCommand */
1260
1261
class CVC5_EXPORT GetAssertionsCommand : public Command
1262
{
1263
 protected:
1264
  std::string d_result;
1265
1266
 public:
1267
  GetAssertionsCommand();
1268
1269
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1270
  std::string getResult() const;
1271
  void printResult(std::ostream& out, uint32_t verbosity = 2) const override;
1272
  Command* clone() const override;
1273
  std::string getCommandName() const override;
1274
  void toStream(
1275
      std::ostream& out,
1276
      int toDepth = -1,
1277
      size_t dag = 1,
1278
      OutputLanguage language = language::output::LANG_AUTO) const override;
1279
}; /* class GetAssertionsCommand */
1280
1281
class CVC5_EXPORT SetBenchmarkStatusCommand : public Command
1282
{
1283
 protected:
1284
  BenchmarkStatus d_status;
1285
1286
 public:
1287
  SetBenchmarkStatusCommand(BenchmarkStatus status);
1288
1289
  BenchmarkStatus getStatus() const;
1290
1291
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1292
  Command* clone() const override;
1293
  std::string getCommandName() const override;
1294
  void toStream(
1295
      std::ostream& out,
1296
      int toDepth = -1,
1297
      size_t dag = 1,
1298
      OutputLanguage language = language::output::LANG_AUTO) const override;
1299
}; /* class SetBenchmarkStatusCommand */
1300
1301
10766
class CVC5_EXPORT SetBenchmarkLogicCommand : public Command
1302
{
1303
 protected:
1304
  std::string d_logic;
1305
1306
 public:
1307
  SetBenchmarkLogicCommand(std::string logic);
1308
1309
  std::string getLogic() const;
1310
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1311
  Command* clone() const override;
1312
  std::string getCommandName() const override;
1313
  void toStream(
1314
      std::ostream& out,
1315
      int toDepth = -1,
1316
      size_t dag = 1,
1317
      OutputLanguage language = language::output::LANG_AUTO) const override;
1318
}; /* class SetBenchmarkLogicCommand */
1319
1320
11128
class CVC5_EXPORT SetInfoCommand : public Command
1321
{
1322
 protected:
1323
  std::string d_flag;
1324
  std::string d_value;
1325
1326
 public:
1327
  SetInfoCommand(const std::string& flag, const std::string& value);
1328
1329
  const std::string& getFlag() const;
1330
  const std::string& getValue() const;
1331
1332
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1333
  Command* clone() const override;
1334
  std::string getCommandName() const override;
1335
  void toStream(
1336
      std::ostream& out,
1337
      int toDepth = -1,
1338
      size_t dag = 1,
1339
      OutputLanguage language = language::output::LANG_AUTO) const override;
1340
}; /* class SetInfoCommand */
1341
1342
40
class CVC5_EXPORT GetInfoCommand : public Command
1343
{
1344
 protected:
1345
  std::string d_flag;
1346
  std::string d_result;
1347
1348
 public:
1349
  GetInfoCommand(std::string flag);
1350
1351
  std::string getFlag() const;
1352
  std::string getResult() const;
1353
1354
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1355
  void printResult(std::ostream& out, uint32_t verbosity = 2) const override;
1356
  Command* clone() const override;
1357
  std::string getCommandName() const override;
1358
  void toStream(
1359
      std::ostream& out,
1360
      int toDepth = -1,
1361
      size_t dag = 1,
1362
      OutputLanguage language = language::output::LANG_AUTO) const override;
1363
}; /* class GetInfoCommand */
1364
1365
14232
class CVC5_EXPORT SetOptionCommand : public Command
1366
{
1367
 protected:
1368
  std::string d_flag;
1369
  std::string d_value;
1370
1371
 public:
1372
  SetOptionCommand(const std::string& flag, const std::string& value);
1373
1374
  const std::string& getFlag() const;
1375
  const std::string& getValue() const;
1376
1377
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1378
  Command* clone() const override;
1379
  std::string getCommandName() const override;
1380
  void toStream(
1381
      std::ostream& out,
1382
      int toDepth = -1,
1383
      size_t dag = 1,
1384
      OutputLanguage language = language::output::LANG_AUTO) const override;
1385
}; /* class SetOptionCommand */
1386
1387
22
class CVC5_EXPORT GetOptionCommand : public Command
1388
{
1389
 protected:
1390
  std::string d_flag;
1391
  std::string d_result;
1392
1393
 public:
1394
  GetOptionCommand(std::string flag);
1395
1396
  std::string getFlag() const;
1397
  std::string getResult() const;
1398
1399
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1400
  void printResult(std::ostream& out, uint32_t verbosity = 2) const override;
1401
  Command* clone() const override;
1402
  std::string getCommandName() const override;
1403
  void toStream(
1404
      std::ostream& out,
1405
      int toDepth = -1,
1406
      size_t dag = 1,
1407
      OutputLanguage language = language::output::LANG_AUTO) const override;
1408
}; /* class GetOptionCommand */
1409
1410
1858
class CVC5_EXPORT DatatypeDeclarationCommand : public Command
1411
{
1412
 private:
1413
  std::vector<api::Sort> d_datatypes;
1414
1415
 public:
1416
  DatatypeDeclarationCommand(const api::Sort& datatype);
1417
1418
  DatatypeDeclarationCommand(const std::vector<api::Sort>& datatypes);
1419
  const std::vector<api::Sort>& getDatatypes() const;
1420
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1421
  Command* clone() const override;
1422
  std::string getCommandName() const override;
1423
  void toStream(
1424
      std::ostream& out,
1425
      int toDepth = -1,
1426
      size_t dag = 1,
1427
      OutputLanguage language = language::output::LANG_AUTO) const override;
1428
}; /* class DatatypeDeclarationCommand */
1429
1430
98
class CVC5_EXPORT ResetCommand : public Command
1431
{
1432
 public:
1433
49
  ResetCommand() {}
1434
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1435
  Command* clone() const override;
1436
  std::string getCommandName() const override;
1437
  void toStream(
1438
      std::ostream& out,
1439
      int toDepth = -1,
1440
      size_t dag = 1,
1441
      OutputLanguage language = language::output::LANG_AUTO) const override;
1442
}; /* class ResetCommand */
1443
1444
64
class CVC5_EXPORT ResetAssertionsCommand : public Command
1445
{
1446
 public:
1447
32
  ResetAssertionsCommand() {}
1448
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1449
  Command* clone() const override;
1450
  std::string getCommandName() const override;
1451
  void toStream(
1452
      std::ostream& out,
1453
      int toDepth = -1,
1454
      size_t dag = 1,
1455
      OutputLanguage language = language::output::LANG_AUTO) const override;
1456
}; /* class ResetAssertionsCommand */
1457
1458
1478
class CVC5_EXPORT QuitCommand : public Command
1459
{
1460
 public:
1461
739
  QuitCommand() {}
1462
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1463
  Command* clone() const override;
1464
  std::string getCommandName() const override;
1465
  void toStream(
1466
      std::ostream& out,
1467
      int toDepth = -1,
1468
      size_t dag = 1,
1469
      OutputLanguage language = language::output::LANG_AUTO) const override;
1470
}; /* class QuitCommand */
1471
1472
class CVC5_EXPORT CommentCommand : public Command
1473
{
1474
  std::string d_comment;
1475
1476
 public:
1477
  CommentCommand(std::string comment);
1478
1479
  std::string getComment() const;
1480
1481
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1482
  Command* clone() const override;
1483
  std::string getCommandName() const override;
1484
  void toStream(
1485
      std::ostream& out,
1486
      int toDepth = -1,
1487
      size_t dag = 1,
1488
      OutputLanguage language = language::output::LANG_AUTO) const override;
1489
}; /* class CommentCommand */
1490
1491
class CVC5_EXPORT CommandSequence : public Command
1492
{
1493
 protected:
1494
  /** All the commands to be executed (in sequence) */
1495
  std::vector<Command*> d_commandSequence;
1496
  /** Next command to be executed */
1497
  unsigned int d_index;
1498
1499
 public:
1500
  CommandSequence();
1501
  ~CommandSequence();
1502
1503
  void addCommand(Command* cmd);
1504
  void clear();
1505
1506
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1507
  void invoke(api::Solver* solver,
1508
              SymbolManager* sm,
1509
              std::ostream& out) override;
1510
1511
  typedef std::vector<Command*>::iterator iterator;
1512
  typedef std::vector<Command*>::const_iterator const_iterator;
1513
1514
  const_iterator begin() const;
1515
  const_iterator end() const;
1516
1517
  iterator begin();
1518
  iterator end();
1519
1520
  Command* clone() const override;
1521
  std::string getCommandName() const override;
1522
  void toStream(
1523
      std::ostream& out,
1524
      int toDepth = -1,
1525
      size_t dag = 1,
1526
      OutputLanguage language = language::output::LANG_AUTO) const override;
1527
}; /* class CommandSequence */
1528
1529
15279
class CVC5_EXPORT DeclarationSequence : public CommandSequence
1530
{
1531
  void toStream(
1532
      std::ostream& out,
1533
      int toDepth = -1,
1534
      size_t dag = 1,
1535
      OutputLanguage language = language::output::LANG_AUTO) const override;
1536
};
1537
1538
}  // namespace cvc5
1539
1540
#endif /* CVC5__COMMAND_H */