GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/smt/command.h Lines: 61 76 80.3 %
Date: 2021-11-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 SolverEngines.
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
20830
  CommandStatus() {}
129
130
 public:
131
68
  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
10379
class CVC5_EXPORT CommandSuccess : public CommandStatus
138
{
139
  static const CommandSuccess* s_instance;
140
141
 public:
142
484638
  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
10381
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
12
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
96
class CVC5_EXPORT CommandFailure : public CommandStatus
171
{
172
  std::string d_message;
173
174
 public:
175
48
  CommandFailure(std::string message) : d_message(message) {}
176
  CommandFailure& clone() const override { return *new CommandFailure(*this); }
177
48
  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
32
class CVC5_EXPORT CommandRecoverableFailure : public CommandStatus
187
{
188
  std::string d_message;
189
190
 public:
191
16
  CommandRecoverableFailure(std::string message) : d_message(message) {}
192
  CommandRecoverableFailure& clone() const override
193
  {
194
    return *new CommandRecoverableFailure(*this);
195
  }
196
16
  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
6169
  void setMuted(bool muted) { d_muted = muted; }
233
  /**
234
   * Determine whether this Command will print a success message.
235
   */
236
242430
  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
168
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
162238
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
10254
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
8628
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
118826
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
211756
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
6
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
7916
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
434
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
14940
class CVC5_EXPORT DefineFunctionCommand : public DeclarationDefinitionCommand
494
{
495
 public:
496
  DefineFunctionCommand(const std::string& id,
497
                        api::Sort sort,
498
                        api::Term formula);
499
  DefineFunctionCommand(const std::string& id,
500
                        const std::vector<api::Term>& formals,
501
                        api::Sort sort,
502
                        api::Term formula);
503
504
  const std::vector<api::Term>& getFormals() const;
505
  api::Sort getSort() const;
506
  api::Term getFormula() const;
507
508
  void invoke(api::Solver* solver, SymbolManager* sm) override;
509
  Command* clone() const override;
510
  std::string getCommandName() const override;
511
  void toStream(std::ostream& out,
512
                int toDepth = -1,
513
                size_t dag = 1,
514
                Language language = Language::LANG_AUTO) const override;
515
516
 protected:
517
  /** The formal arguments for the function we are defining */
518
  std::vector<api::Term> d_formals;
519
  /** The co-domain sort of the function we are defining */
520
  api::Sort d_sort;
521
  /** The formula corresponding to the body of the function we are defining */
522
  api::Term d_formula;
523
}; /* class DefineFunctionCommand */
524
525
/**
526
 * The command when parsing define-fun-rec or define-funs-rec.
527
 * This command will assert a set of quantified formulas that specify
528
 * the (mutually recursive) function definitions provided to it.
529
 */
530
252
class CVC5_EXPORT DefineFunctionRecCommand : public Command
531
{
532
 public:
533
  DefineFunctionRecCommand(api::Term func,
534
                           const std::vector<api::Term>& formals,
535
                           api::Term formula);
536
  DefineFunctionRecCommand(const std::vector<api::Term>& funcs,
537
                           const std::vector<std::vector<api::Term> >& formals,
538
                           const std::vector<api::Term>& formula);
539
540
  const std::vector<api::Term>& getFunctions() const;
541
  const std::vector<std::vector<api::Term> >& getFormals() const;
542
  const std::vector<api::Term>& getFormulas() const;
543
544
  void invoke(api::Solver* solver, SymbolManager* sm) override;
545
  Command* clone() const override;
546
  std::string getCommandName() const override;
547
  void toStream(std::ostream& out,
548
                int toDepth = -1,
549
                size_t dag = 1,
550
                Language language = Language::LANG_AUTO) const override;
551
552
 protected:
553
  /** functions we are defining */
554
  std::vector<api::Term> d_funcs;
555
  /** formal arguments for each of the functions we are defining */
556
  std::vector<std::vector<api::Term> > d_formals;
557
  /** formulas corresponding to the bodies of the functions we are defining */
558
  std::vector<api::Term> d_formulas;
559
}; /* class DefineFunctionRecCommand */
560
561
/**
562
 * In separation logic inputs, which is an extension of smt2 inputs, this
563
 * corresponds to the command:
564
 *   (declare-heap (T U))
565
 * where T is the location sort and U is the data sort.
566
 */
567
172
class CVC5_EXPORT DeclareHeapCommand : public Command
568
{
569
 public:
570
  DeclareHeapCommand(api::Sort locSort, api::Sort dataSort);
571
  api::Sort getLocationSort() const;
572
  api::Sort getDataSort() const;
573
  void invoke(api::Solver* solver, SymbolManager* sm) override;
574
  Command* clone() const override;
575
  std::string getCommandName() const override;
576
  void toStream(std::ostream& out,
577
                int toDepth = -1,
578
                size_t dag = 1,
579
                Language language = Language::LANG_AUTO) const override;
580
581
 protected:
582
  /** The location sort */
583
  api::Sort d_locSort;
584
  /** The data sort */
585
  api::Sort d_dataSort;
586
};
587
588
/**
589
 * The command when parsing check-sat.
590
 * This command will check satisfiability of the input formula.
591
 */
592
18902
class CVC5_EXPORT CheckSatCommand : public Command
593
{
594
 public:
595
  CheckSatCommand();
596
  api::Result getResult() const;
597
  void invoke(api::Solver* solver, SymbolManager* sm) override;
598
  void printResult(std::ostream& out, uint32_t verbosity = 2) const override;
599
  Command* clone() const override;
600
  std::string getCommandName() const override;
601
  void toStream(std::ostream& out,
602
                int toDepth = -1,
603
                size_t dag = 1,
604
                Language language = Language::LANG_AUTO) const override;
605
606
 private:
607
  api::Result d_result;
608
}; /* class CheckSatCommand */
609
610
/**
611
 * The command when parsing check-sat-assuming.
612
 * This command will assume a set of formulas and check satisfiability of the
613
 * input formula under these assumptions.
614
 */
615
3126
class CVC5_EXPORT CheckSatAssumingCommand : public Command
616
{
617
 public:
618
  CheckSatAssumingCommand(api::Term term);
619
  CheckSatAssumingCommand(const std::vector<api::Term>& terms);
620
621
  const std::vector<api::Term>& getTerms() const;
622
  api::Result getResult() const;
623
  void invoke(api::Solver* solver, SymbolManager* sm) override;
624
  void printResult(std::ostream& out, uint32_t verbosity = 2) const override;
625
  Command* clone() const override;
626
  std::string getCommandName() const override;
627
  void toStream(std::ostream& out,
628
                int toDepth = -1,
629
                size_t dag = 1,
630
                Language language = Language::LANG_AUTO) const override;
631
632
 private:
633
  std::vector<api::Term> d_terms;
634
  api::Result d_result;
635
}; /* class CheckSatAssumingCommand */
636
637
46
class CVC5_EXPORT QueryCommand : public Command
638
{
639
 protected:
640
  api::Term d_term;
641
  api::Result d_result;
642
643
 public:
644
  QueryCommand(const api::Term& t);
645
646
  api::Term getTerm() const;
647
  api::Result getResult() const;
648
  void invoke(api::Solver* solver, SymbolManager* sm) override;
649
  void printResult(std::ostream& out, uint32_t verbosity = 2) const override;
650
  Command* clone() const override;
651
  std::string getCommandName() const override;
652
  void toStream(std::ostream& out,
653
                int toDepth = -1,
654
                size_t dag = 1,
655
                Language language = Language::LANG_AUTO) const override;
656
}; /* class QueryCommand */
657
658
/* ------------------- sygus commands  ------------------ */
659
660
/** Declares a sygus universal variable */
661
1238
class CVC5_EXPORT DeclareSygusVarCommand : public DeclarationDefinitionCommand
662
{
663
 public:
664
  DeclareSygusVarCommand(const std::string& id, api::Term var, api::Sort sort);
665
  /** returns the declared variable */
666
  api::Term getVar() const;
667
  /** returns the declared variable's sort */
668
  api::Sort getSort() const;
669
  /** invokes this command
670
   *
671
   * The declared sygus variable is communicated to the SMT engine in case a
672
   * synthesis conjecture is built later on.
673
   */
674
  void invoke(api::Solver* solver, SymbolManager* sm) override;
675
  /** creates a copy of this command */
676
  Command* clone() const override;
677
  /** returns this command's name */
678
  std::string getCommandName() const override;
679
  /** prints this command */
680
  void toStream(std::ostream& out,
681
                int toDepth = -1,
682
                size_t dag = 1,
683
                Language language = Language::LANG_AUTO) const override;
684
685
 protected:
686
  /** the declared variable */
687
  api::Term d_var;
688
  /** the declared variable's sort */
689
  api::Sort d_sort;
690
};
691
692
/** Declares a sygus function-to-synthesize
693
 *
694
 * This command is also used for the special case in which we are declaring an
695
 * invariant-to-synthesize
696
 */
697
1362
class CVC5_EXPORT SynthFunCommand : public DeclarationDefinitionCommand
698
{
699
 public:
700
  SynthFunCommand(const std::string& id,
701
                  api::Term fun,
702
                  const std::vector<api::Term>& vars,
703
                  api::Sort sort,
704
                  bool isInv,
705
                  api::Grammar* g);
706
  /** returns the function-to-synthesize */
707
  api::Term getFunction() const;
708
  /** returns the input variables of the function-to-synthesize */
709
  const std::vector<api::Term>& getVars() const;
710
  /** returns the sygus sort of the function-to-synthesize */
711
  api::Sort getSort() const;
712
  /** returns whether the function-to-synthesize should be an invariant */
713
  bool isInv() const;
714
  /** Get the sygus grammar given for the synth fun command */
715
  const api::Grammar* getGrammar() const;
716
717
  /** invokes this command
718
   *
719
   * The declared function-to-synthesize is communicated to the SMT engine in
720
   * case a synthesis conjecture is built later on.
721
   */
722
  void invoke(api::Solver* solver, SymbolManager* sm) override;
723
  /** creates a copy of this command */
724
  Command* clone() const override;
725
  /** returns this command's name */
726
  std::string getCommandName() const override;
727
  /** prints this command */
728
  void toStream(std::ostream& out,
729
                int toDepth = -1,
730
                size_t dag = 1,
731
                Language language = Language::LANG_AUTO) const override;
732
733
 protected:
734
  /** the function-to-synthesize */
735
  api::Term d_fun;
736
  /** the input variables of the function-to-synthesize */
737
  std::vector<api::Term> d_vars;
738
  /** sort of the function-to-synthesize */
739
  api::Sort d_sort;
740
  /** whether the function-to-synthesize should be an invariant */
741
  bool d_isInv;
742
  /** optional grammar for the possible values of the function-to-sytnhesize */
743
  api::Grammar* d_grammar;
744
};
745
746
/** Declares a sygus constraint */
747
2500
class CVC5_EXPORT SygusConstraintCommand : public Command
748
{
749
 public:
750
  SygusConstraintCommand(const api::Term& t, bool isAssume = false);
751
  /** returns the declared constraint */
752
  api::Term getTerm() const;
753
  /** invokes this command
754
   *
755
   * The declared constraint is communicated to the SMT engine in case a
756
   * synthesis conjecture is built later on.
757
   */
758
  void invoke(api::Solver* solver, SymbolManager* sm) override;
759
  /** creates a copy of this command */
760
  Command* clone() const override;
761
  /** returns this command's name */
762
  std::string getCommandName() const override;
763
  /** prints this command */
764
  void toStream(std::ostream& out,
765
                int toDepth = -1,
766
                size_t dag = 1,
767
                Language language = Language::LANG_AUTO) const override;
768
769
 protected:
770
  /** the declared constraint */
771
  api::Term d_term;
772
  /** true if this is a sygus assumption */
773
  bool d_isAssume;
774
};
775
776
/** Declares a sygus invariant constraint
777
 *
778
 * Invarint constraints are declared in a somewhat implicit manner in the SyGuS
779
 * language: they are declared in terms of the previously declared
780
 * invariant-to-synthesize, precondition, transition relation and condition.
781
 *
782
 * The actual constraint must be built such that the invariant is not stronger
783
 * than the precondition, not weaker than the postcondition and inductive
784
 * w.r.t. the transition relation.
785
 */
786
54
class CVC5_EXPORT SygusInvConstraintCommand : public Command
787
{
788
 public:
789
  SygusInvConstraintCommand(const std::vector<api::Term>& predicates);
790
  SygusInvConstraintCommand(const api::Term& inv,
791
                            const api::Term& pre,
792
                            const api::Term& trans,
793
                            const api::Term& post);
794
  /** returns the place holder predicates */
795
  const std::vector<api::Term>& getPredicates() const;
796
  /** invokes this command
797
   *
798
   * The place holders are communicated to the SMT engine and the actual
799
   * invariant constraint is built, in case an actual synthesis conjecture is
800
   * built later on.
801
   */
802
  void invoke(api::Solver* solver, SymbolManager* sm) override;
803
  /** creates a copy of this command */
804
  Command* clone() const override;
805
  /** returns this command's name */
806
  std::string getCommandName() const override;
807
  /** prints this command */
808
  void toStream(std::ostream& out,
809
                int toDepth = -1,
810
                size_t dag = 1,
811
                Language language = Language::LANG_AUTO) const override;
812
813
 protected:
814
  /** the place holder predicates with which to build the actual constraint
815
   * (i.e. the invariant, precondition, transition relation and postcondition)
816
   */
817
  std::vector<api::Term> d_predicates;
818
};
819
820
/** Declares a synthesis conjecture */
821
756
class CVC5_EXPORT CheckSynthCommand : public Command
822
{
823
 public:
824
378
  CheckSynthCommand(){};
825
  /** returns the result of the check-synth call */
826
  api::Result getResult() const;
827
  /** prints the result of the check-synth-call */
828
  void printResult(std::ostream& out, uint32_t verbosity = 2) const override;
829
  /** invokes this command
830
   *
831
   * This invocation makes the SMT engine build a synthesis conjecture based on
832
   * previously declared information (such as universal variables,
833
   * functions-to-synthesize and so on), set up attributes to guide the solving,
834
   * and then perform a satisfiability check, whose result is stored in
835
   * d_result.
836
   */
837
  void invoke(api::Solver* solver, SymbolManager* sm) override;
838
  /** creates a copy of this command */
839
  Command* clone() const override;
840
  /** returns this command's name */
841
  std::string getCommandName() const override;
842
  /** prints this command */
843
  void toStream(std::ostream& out,
844
                int toDepth = -1,
845
                size_t dag = 1,
846
                Language language = Language::LANG_AUTO) const override;
847
848
 protected:
849
  /** result of the check-synth call */
850
  api::Result d_result;
851
  /** string stream that stores the output of the solution */
852
  std::stringstream d_solution;
853
};
854
855
/* ------------------- sygus commands  ------------------ */
856
857
// this is TRANSFORM in the CVC presentation language
858
class CVC5_EXPORT SimplifyCommand : public Command
859
{
860
 protected:
861
  api::Term d_term;
862
  api::Term d_result;
863
864
 public:
865
  SimplifyCommand(api::Term term);
866
867
  api::Term getTerm() const;
868
  api::Term getResult() const;
869
  void invoke(api::Solver* solver, SymbolManager* sm) override;
870
  void printResult(std::ostream& out, uint32_t verbosity = 2) const override;
871
  Command* clone() const override;
872
  std::string getCommandName() const override;
873
  void toStream(std::ostream& out,
874
                int toDepth = -1,
875
                size_t dag = 1,
876
                Language language = Language::LANG_AUTO) const override;
877
}; /* class SimplifyCommand */
878
879
136
class CVC5_EXPORT GetValueCommand : public Command
880
{
881
 protected:
882
  std::vector<api::Term> d_terms;
883
  api::Term d_result;
884
885
 public:
886
  GetValueCommand(api::Term term);
887
  GetValueCommand(const std::vector<api::Term>& terms);
888
889
  const std::vector<api::Term>& getTerms() const;
890
  api::Term getResult() const;
891
  void invoke(api::Solver* solver, SymbolManager* sm) override;
892
  void printResult(std::ostream& out, uint32_t verbosity = 2) const override;
893
  Command* clone() const override;
894
  std::string getCommandName() const override;
895
  void toStream(std::ostream& out,
896
                int toDepth = -1,
897
                size_t dag = 1,
898
                Language language = Language::LANG_AUTO) const override;
899
}; /* class GetValueCommand */
900
901
20
class CVC5_EXPORT GetAssignmentCommand : public Command
902
{
903
 protected:
904
  api::Term d_result;
905
906
 public:
907
  GetAssignmentCommand();
908
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 GetAssignmentCommand */
919
920
60
class CVC5_EXPORT GetModelCommand : public Command
921
{
922
 public:
923
  GetModelCommand();
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
933
 protected:
934
  /** Result of printing the model */
935
  std::string d_result;
936
}; /* class GetModelCommand */
937
938
/** The command to block models. */
939
28
class CVC5_EXPORT BlockModelCommand : public Command
940
{
941
 public:
942
  BlockModelCommand();
943
944
  void invoke(api::Solver* solver, SymbolManager* sm) 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
}; /* class BlockModelCommand */
952
953
/** The command to block model values. */
954
16
class CVC5_EXPORT BlockModelValuesCommand : public Command
955
{
956
 public:
957
  BlockModelValuesCommand(const std::vector<api::Term>& terms);
958
959
  const std::vector<api::Term>& getTerms() const;
960
  void invoke(api::Solver* solver, SymbolManager* sm) override;
961
  Command* clone() const override;
962
  std::string getCommandName() const override;
963
  void toStream(std::ostream& out,
964
                int toDepth = -1,
965
                size_t dag = 1,
966
                Language language = Language::LANG_AUTO) const override;
967
968
 protected:
969
  /** The terms we are blocking */
970
  std::vector<api::Term> d_terms;
971
}; /* class BlockModelValuesCommand */
972
973
4
class CVC5_EXPORT GetProofCommand : public Command
974
{
975
 public:
976
  GetProofCommand();
977
978
  void invoke(api::Solver* solver, SymbolManager* sm) override;
979
980
  void printResult(std::ostream& out, uint32_t verbosity = 2) const override;
981
982
  Command* clone() const override;
983
  std::string getCommandName() const override;
984
  void toStream(std::ostream& out,
985
                int toDepth = -1,
986
                size_t dag = 1,
987
                Language language = Language::LANG_AUTO) const override;
988
989
 private:
990
  /** the result of the getProof call */
991
  std::string d_result;
992
}; /* class GetProofCommand */
993
994
30
class CVC5_EXPORT GetInstantiationsCommand : public Command
995
{
996
 public:
997
  GetInstantiationsCommand();
998
999
  static bool isEnabled(api::Solver* solver, const api::Result& res);
1000
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1001
  void printResult(std::ostream& out, uint32_t verbosity = 2) const override;
1002
  Command* clone() const override;
1003
  std::string getCommandName() const override;
1004
  void toStream(std::ostream& out,
1005
                int toDepth = -1,
1006
                size_t dag = 1,
1007
                Language language = Language::LANG_AUTO) const override;
1008
1009
 protected:
1010
  api::Solver* d_solver;
1011
}; /* class GetInstantiationsCommand */
1012
1013
/** The command (get-interpol s B (G)?)
1014
 *
1015
 * This command asks for an interpolant from the current set of assertions and
1016
 * conjecture (goal) B.
1017
 *
1018
 * The symbol s is the name for the interpolation predicate. If we successfully
1019
 * find a predicate P, then the output response of this command is: (define-fun
1020
 * s () Bool P)
1021
 */
1022
16
class CVC5_EXPORT GetInterpolCommand : public Command
1023
{
1024
 public:
1025
  GetInterpolCommand(const std::string& name, api::Term conj);
1026
  /** The argument g is the grammar of the interpolation query */
1027
  GetInterpolCommand(const std::string& name, api::Term conj, api::Grammar* g);
1028
1029
  /** Get the conjecture of the interpolation query */
1030
  api::Term getConjecture() const;
1031
  /** Get the sygus grammar given for the interpolation query */
1032
  const api::Grammar* getGrammar() const;
1033
  /** Get the result of the query, which is the solution to the interpolation
1034
   * query. */
1035
  api::Term getResult() const;
1036
1037
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1038
  void printResult(std::ostream& out, uint32_t verbosity = 2) const override;
1039
  Command* clone() const override;
1040
  std::string getCommandName() const override;
1041
  void toStream(std::ostream& out,
1042
                int toDepth = -1,
1043
                size_t dag = 1,
1044
                Language language = Language::LANG_AUTO) const override;
1045
1046
 protected:
1047
  /** The name of the interpolation predicate */
1048
  std::string d_name;
1049
  /** The conjecture of the interpolation query */
1050
  api::Term d_conj;
1051
  /** The (optional) grammar of the interpolation query */
1052
  api::Grammar* d_sygus_grammar;
1053
  /** the return status of the command */
1054
  bool d_resultStatus;
1055
  /** the return expression of the command */
1056
  api::Term d_result;
1057
}; /* class GetInterpolCommand */
1058
1059
/** The command (get-abduct s B (G)?)
1060
 *
1061
 * This command asks for an abduct from the current set of assertions and
1062
 * conjecture (goal) given by the argument B.
1063
 *
1064
 * The symbol s is the name for the abduction predicate. If we successfully
1065
 * find a predicate P, then the output response of this command is:
1066
 *   (define-fun s () Bool P)
1067
 *
1068
 * A grammar G can be optionally provided to indicate the syntactic restrictions
1069
 * on the possible solutions returned.
1070
 */
1071
76
class CVC5_EXPORT GetAbductCommand : public Command
1072
{
1073
 public:
1074
  GetAbductCommand(const std::string& name, api::Term conj);
1075
  GetAbductCommand(const std::string& name, api::Term conj, api::Grammar* g);
1076
1077
  /** Get the conjecture of the abduction query */
1078
  api::Term getConjecture() const;
1079
  /** Get the grammar given for the abduction query */
1080
  const api::Grammar* getGrammar() const;
1081
  /** Get the name of the abduction predicate for the abduction query */
1082
  std::string getAbductName() const;
1083
  /** Get the result of the query, which is the solution to the abduction query.
1084
   */
1085
  api::Term getResult() const;
1086
1087
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1088
  void printResult(std::ostream& out, uint32_t verbosity = 2) const override;
1089
  Command* clone() const override;
1090
  std::string getCommandName() const override;
1091
  void toStream(std::ostream& out,
1092
                int toDepth = -1,
1093
                size_t dag = 1,
1094
                Language language = Language::LANG_AUTO) const override;
1095
1096
 protected:
1097
  /** The name of the abduction predicate */
1098
  std::string d_name;
1099
  /** The conjecture of the abduction query */
1100
  api::Term d_conj;
1101
  /** The (optional) grammar of the abduction query */
1102
  api::Grammar* d_sygus_grammar;
1103
  /** the return status of the command */
1104
  bool d_resultStatus;
1105
  /** the return expression of the command */
1106
  api::Term d_result;
1107
}; /* class GetAbductCommand */
1108
1109
18
class CVC5_EXPORT GetQuantifierEliminationCommand : public Command
1110
{
1111
 protected:
1112
  api::Term d_term;
1113
  bool d_doFull;
1114
  api::Term d_result;
1115
1116
 public:
1117
  GetQuantifierEliminationCommand();
1118
  GetQuantifierEliminationCommand(const api::Term& term, bool doFull);
1119
1120
  api::Term getTerm() const;
1121
  bool getDoFull() const;
1122
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1123
  api::Term getResult() const;
1124
  void printResult(std::ostream& out, uint32_t verbosity = 2) const override;
1125
1126
  Command* clone() const override;
1127
  std::string getCommandName() const override;
1128
  void toStream(std::ostream& out,
1129
                int toDepth = -1,
1130
                size_t dag = 1,
1131
                Language language = Language::LANG_AUTO) const override;
1132
}; /* class GetQuantifierEliminationCommand */
1133
1134
28
class CVC5_EXPORT GetUnsatAssumptionsCommand : public Command
1135
{
1136
 public:
1137
  GetUnsatAssumptionsCommand();
1138
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1139
  std::vector<api::Term> getResult() const;
1140
  void printResult(std::ostream& out, uint32_t verbosity = 2) const override;
1141
  Command* clone() const override;
1142
  std::string getCommandName() const override;
1143
  void toStream(std::ostream& out,
1144
                int toDepth = -1,
1145
                size_t dag = 1,
1146
                Language language = Language::LANG_AUTO) const override;
1147
1148
 protected:
1149
  std::vector<api::Term> d_result;
1150
}; /* class GetUnsatAssumptionsCommand */
1151
1152
28
class CVC5_EXPORT GetUnsatCoreCommand : public Command
1153
{
1154
 public:
1155
  GetUnsatCoreCommand();
1156
  const std::vector<api::Term>& getUnsatCore() const;
1157
1158
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1159
  void printResult(std::ostream& out, uint32_t verbosity = 2) const override;
1160
1161
  Command* clone() const override;
1162
  std::string getCommandName() const override;
1163
  void toStream(std::ostream& out,
1164
                int toDepth = -1,
1165
                size_t dag = 1,
1166
                Language language = Language::LANG_AUTO) const override;
1167
1168
 protected:
1169
  /** The symbol manager we were invoked with */
1170
  SymbolManager* d_sm;
1171
  /** the result of the unsat core call */
1172
  std::vector<api::Term> d_result;
1173
}; /* class GetUnsatCoreCommand */
1174
1175
class CVC5_EXPORT GetDifficultyCommand : public Command
1176
{
1177
 public:
1178
  GetDifficultyCommand();
1179
  const std::map<api::Term, api::Term>& getDifficultyMap() const;
1180
1181
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1182
  void printResult(std::ostream& out, uint32_t verbosity = 2) const override;
1183
1184
  Command* clone() const override;
1185
  std::string getCommandName() const override;
1186
  void toStream(std::ostream& out,
1187
                int toDepth = -1,
1188
                size_t dag = 1,
1189
                Language language = Language::LANG_AUTO) const override;
1190
1191
 protected:
1192
  /** The symbol manager we were invoked with */
1193
  SymbolManager* d_sm;
1194
  /** the result of the get difficulty call */
1195
  std::map<api::Term, api::Term> d_result;
1196
};
1197
1198
class CVC5_EXPORT GetAssertionsCommand : public Command
1199
{
1200
 protected:
1201
  std::string d_result;
1202
1203
 public:
1204
  GetAssertionsCommand();
1205
1206
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1207
  std::string getResult() const;
1208
  void printResult(std::ostream& out, uint32_t verbosity = 2) const override;
1209
  Command* clone() const override;
1210
  std::string getCommandName() const override;
1211
  void toStream(std::ostream& out,
1212
                int toDepth = -1,
1213
                size_t dag = 1,
1214
                Language language = Language::LANG_AUTO) const override;
1215
}; /* class GetAssertionsCommand */
1216
1217
13128
class CVC5_EXPORT SetBenchmarkLogicCommand : public Command
1218
{
1219
 protected:
1220
  std::string d_logic;
1221
1222
 public:
1223
  SetBenchmarkLogicCommand(std::string logic);
1224
1225
  std::string getLogic() const;
1226
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1227
  Command* clone() const override;
1228
  std::string getCommandName() const override;
1229
  void toStream(std::ostream& out,
1230
                int toDepth = -1,
1231
                size_t dag = 1,
1232
                Language language = Language::LANG_AUTO) const override;
1233
}; /* class SetBenchmarkLogicCommand */
1234
1235
11752
class CVC5_EXPORT SetInfoCommand : public Command
1236
{
1237
 protected:
1238
  std::string d_flag;
1239
  std::string d_value;
1240
1241
 public:
1242
  SetInfoCommand(const std::string& flag, const std::string& value);
1243
1244
  const std::string& getFlag() const;
1245
  const std::string& getValue() const;
1246
1247
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1248
  Command* clone() const override;
1249
  std::string getCommandName() const override;
1250
  void toStream(std::ostream& out,
1251
                int toDepth = -1,
1252
                size_t dag = 1,
1253
                Language language = Language::LANG_AUTO) const override;
1254
}; /* class SetInfoCommand */
1255
1256
40
class CVC5_EXPORT GetInfoCommand : public Command
1257
{
1258
 protected:
1259
  std::string d_flag;
1260
  std::string d_result;
1261
1262
 public:
1263
  GetInfoCommand(std::string flag);
1264
1265
  std::string getFlag() const;
1266
  std::string getResult() const;
1267
1268
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1269
  void printResult(std::ostream& out, uint32_t verbosity = 2) const override;
1270
  Command* clone() const override;
1271
  std::string getCommandName() const override;
1272
  void toStream(std::ostream& out,
1273
                int toDepth = -1,
1274
                size_t dag = 1,
1275
                Language language = Language::LANG_AUTO) const override;
1276
}; /* class GetInfoCommand */
1277
1278
17306
class CVC5_EXPORT SetOptionCommand : public Command
1279
{
1280
 protected:
1281
  std::string d_flag;
1282
  std::string d_value;
1283
1284
 public:
1285
  SetOptionCommand(const std::string& flag, const std::string& value);
1286
1287
  const std::string& getFlag() const;
1288
  const std::string& getValue() const;
1289
1290
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1291
  Command* clone() const override;
1292
  std::string getCommandName() const override;
1293
  void toStream(std::ostream& out,
1294
                int toDepth = -1,
1295
                size_t dag = 1,
1296
                Language language = Language::LANG_AUTO) const override;
1297
}; /* class SetOptionCommand */
1298
1299
102
class CVC5_EXPORT GetOptionCommand : public Command
1300
{
1301
 protected:
1302
  std::string d_flag;
1303
  std::string d_result;
1304
1305
 public:
1306
  GetOptionCommand(std::string flag);
1307
1308
  std::string getFlag() const;
1309
  std::string getResult() const;
1310
1311
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1312
  void printResult(std::ostream& out, uint32_t verbosity = 2) const override;
1313
  Command* clone() const override;
1314
  std::string getCommandName() const override;
1315
  void toStream(std::ostream& out,
1316
                int toDepth = -1,
1317
                size_t dag = 1,
1318
                Language language = Language::LANG_AUTO) const override;
1319
}; /* class GetOptionCommand */
1320
1321
2336
class CVC5_EXPORT DatatypeDeclarationCommand : public Command
1322
{
1323
 private:
1324
  std::vector<api::Sort> d_datatypes;
1325
1326
 public:
1327
  DatatypeDeclarationCommand(const api::Sort& datatype);
1328
1329
  DatatypeDeclarationCommand(const std::vector<api::Sort>& datatypes);
1330
  const std::vector<api::Sort>& getDatatypes() const;
1331
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1332
  Command* clone() const override;
1333
  std::string getCommandName() const override;
1334
  void toStream(std::ostream& out,
1335
                int toDepth = -1,
1336
                size_t dag = 1,
1337
                Language language = Language::LANG_AUTO) const override;
1338
}; /* class DatatypeDeclarationCommand */
1339
1340
86
class CVC5_EXPORT ResetCommand : public Command
1341
{
1342
 public:
1343
43
  ResetCommand() {}
1344
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1345
  Command* clone() const override;
1346
  std::string getCommandName() const override;
1347
  void toStream(std::ostream& out,
1348
                int toDepth = -1,
1349
                size_t dag = 1,
1350
                Language language = Language::LANG_AUTO) const override;
1351
}; /* class ResetCommand */
1352
1353
72
class CVC5_EXPORT ResetAssertionsCommand : public Command
1354
{
1355
 public:
1356
36
  ResetAssertionsCommand() {}
1357
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1358
  Command* clone() const override;
1359
  std::string getCommandName() const override;
1360
  void toStream(std::ostream& out,
1361
                int toDepth = -1,
1362
                size_t dag = 1,
1363
                Language language = Language::LANG_AUTO) const override;
1364
}; /* class ResetAssertionsCommand */
1365
1366
1482
class CVC5_EXPORT QuitCommand : public Command
1367
{
1368
 public:
1369
741
  QuitCommand() {}
1370
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1371
  Command* clone() const override;
1372
  std::string getCommandName() const override;
1373
  void toStream(std::ostream& out,
1374
                int toDepth = -1,
1375
                size_t dag = 1,
1376
                Language language = Language::LANG_AUTO) const override;
1377
}; /* class QuitCommand */
1378
1379
class CVC5_EXPORT CommandSequence : public Command
1380
{
1381
 protected:
1382
  /** All the commands to be executed (in sequence) */
1383
  std::vector<Command*> d_commandSequence;
1384
  /** Next command to be executed */
1385
  unsigned int d_index;
1386
1387
 public:
1388
  CommandSequence();
1389
  ~CommandSequence();
1390
1391
  void addCommand(Command* cmd);
1392
  void clear();
1393
1394
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1395
  void invoke(api::Solver* solver,
1396
              SymbolManager* sm,
1397
              std::ostream& out) override;
1398
1399
  typedef std::vector<Command*>::iterator iterator;
1400
  typedef std::vector<Command*>::const_iterator const_iterator;
1401
1402
  const_iterator begin() const;
1403
  const_iterator end() const;
1404
1405
  iterator begin();
1406
  iterator end();
1407
1408
  Command* clone() const override;
1409
  std::string getCommandName() const override;
1410
  void toStream(std::ostream& out,
1411
                int toDepth = -1,
1412
                size_t dag = 1,
1413
                Language language = Language::LANG_AUTO) const override;
1414
}; /* class CommandSequence */
1415
1416
class CVC5_EXPORT DeclarationSequence : public CommandSequence
1417
{
1418
  void toStream(std::ostream& out,
1419
                int toDepth = -1,
1420
                size_t dag = 1,
1421
                Language language = Language::LANG_AUTO) const override;
1422
};
1423
1424
}  // namespace cvc5
1425
1426
#endif /* CVC5__COMMAND_H */