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