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