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