GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/smt/command.h Lines: 62 79 78.5 %
Date: 2021-05-21 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
155
  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
18547
  CommandStatus() {}
129
130
 public:
131
53
  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
9247
class CVC5_EXPORT CommandSuccess : public CommandStatus
138
{
139
  static const CommandSuccess* s_instance;
140
141
 public:
142
589255
  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
9247
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
70
class CVC5_EXPORT CommandFailure : public CommandStatus
171
{
172
  std::string d_message;
173
174
 public:
175
35
  CommandFailure(std::string message) : d_message(message) {}
176
  CommandFailure& clone() const override { return *new CommandFailure(*this); }
177
35
  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
10605
  void setMuted(bool muted) { d_muted = muted; }
235
  /**
236
   * Determine whether this Command will print a success message.
237
   */
238
294732
  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
846
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
157328
class CVC5_EXPORT AssertCommand : public Command
348
{
349
 protected:
350
  api::Term d_term;
351
  bool d_inUnsatCore;
352
353
 public:
354
  AssertCommand(const api::Term& t, bool inUnsatCore = true);
355
356
  api::Term getTerm() const;
357
358
  void invoke(api::Solver* solver, SymbolManager* sm) override;
359
360
  Command* clone() const override;
361
  std::string getCommandName() const override;
362
  void toStream(
363
      std::ostream& out,
364
      int toDepth = -1,
365
      size_t dag = 1,
366
      OutputLanguage language = language::output::LANG_AUTO) const override;
367
}; /* class AssertCommand */
368
369
7698
class CVC5_EXPORT PushCommand : public Command
370
{
371
 public:
372
  void invoke(api::Solver* solver, SymbolManager* sm) override;
373
  Command* clone() const override;
374
  std::string getCommandName() const override;
375
  void toStream(
376
      std::ostream& out,
377
      int toDepth = -1,
378
      size_t dag = 1,
379
      OutputLanguage language = language::output::LANG_AUTO) const override;
380
}; /* class PushCommand */
381
382
6444
class CVC5_EXPORT PopCommand : public Command
383
{
384
 public:
385
  void invoke(api::Solver* solver, SymbolManager* sm) override;
386
  Command* clone() const override;
387
  std::string getCommandName() const override;
388
  void toStream(
389
      std::ostream& out,
390
      int toDepth = -1,
391
      size_t dag = 1,
392
      OutputLanguage language = language::output::LANG_AUTO) const override;
393
}; /* class PopCommand */
394
395
181068
class CVC5_EXPORT DeclarationDefinitionCommand : public Command
396
{
397
 protected:
398
  std::string d_symbol;
399
400
 public:
401
  DeclarationDefinitionCommand(const std::string& id);
402
403
  void invoke(api::Solver* solver, SymbolManager* sm) override = 0;
404
  std::string getSymbol() const;
405
}; /* class DeclarationDefinitionCommand */
406
407
348128
class CVC5_EXPORT DeclareFunctionCommand : public DeclarationDefinitionCommand
408
{
409
 protected:
410
  api::Term d_func;
411
  api::Sort d_sort;
412
413
 public:
414
  DeclareFunctionCommand(const std::string& id, api::Term func, api::Sort sort);
415
  api::Term getFunction() const;
416
  api::Sort getSort() const;
417
418
  void invoke(api::Solver* solver, SymbolManager* sm) override;
419
  Command* clone() const override;
420
  std::string getCommandName() const override;
421
  void toStream(
422
      std::ostream& out,
423
      int toDepth = -1,
424
      size_t dag = 1,
425
      OutputLanguage language = language::output::LANG_AUTO) const override;
426
}; /* class DeclareFunctionCommand */
427
428
6
class CVC5_EXPORT DeclarePoolCommand : public DeclarationDefinitionCommand
429
{
430
 protected:
431
  api::Term d_func;
432
  api::Sort d_sort;
433
  std::vector<api::Term> d_initValue;
434
435
 public:
436
  DeclarePoolCommand(const std::string& id,
437
                     api::Term func,
438
                     api::Sort sort,
439
                     const std::vector<api::Term>& initValue);
440
  api::Term getFunction() const;
441
  api::Sort getSort() const;
442
  const std::vector<api::Term>& getInitialValue() const;
443
444
  void invoke(api::Solver* solver, SymbolManager* sm) override;
445
  Command* clone() const override;
446
  std::string getCommandName() const override;
447
  void toStream(
448
      std::ostream& out,
449
      int toDepth = -1,
450
      size_t dag = 1,
451
      OutputLanguage language = language::output::LANG_AUTO) const override;
452
}; /* class DeclarePoolCommand */
453
454
8054
class CVC5_EXPORT DeclareSortCommand : public DeclarationDefinitionCommand
455
{
456
 protected:
457
  size_t d_arity;
458
  api::Sort d_sort;
459
460
 public:
461
  DeclareSortCommand(const std::string& id, size_t arity, api::Sort sort);
462
463
  size_t getArity() const;
464
  api::Sort getSort() const;
465
466
  void invoke(api::Solver* solver, SymbolManager* sm) override;
467
  Command* clone() const override;
468
  std::string getCommandName() const override;
469
  void toStream(
470
      std::ostream& out,
471
      int toDepth = -1,
472
      size_t dag = 1,
473
      OutputLanguage language = language::output::LANG_AUTO) const override;
474
}; /* class DeclareSortCommand */
475
476
400
class CVC5_EXPORT DefineSortCommand : public DeclarationDefinitionCommand
477
{
478
 protected:
479
  std::vector<api::Sort> d_params;
480
  api::Sort d_sort;
481
482
 public:
483
  DefineSortCommand(const std::string& id, api::Sort sort);
484
  DefineSortCommand(const std::string& id,
485
                    const std::vector<api::Sort>& params,
486
                    api::Sort sort);
487
488
  const std::vector<api::Sort>& getParameters() const;
489
  api::Sort getSort() const;
490
491
  void invoke(api::Solver* solver, SymbolManager* sm) override;
492
  Command* clone() const override;
493
  std::string getCommandName() const override;
494
  void toStream(
495
      std::ostream& out,
496
      int toDepth = -1,
497
      size_t dag = 1,
498
      OutputLanguage language = language::output::LANG_AUTO) const override;
499
}; /* class DefineSortCommand */
500
501
4460
class CVC5_EXPORT DefineFunctionCommand : public DeclarationDefinitionCommand
502
{
503
 public:
504
  DefineFunctionCommand(const std::string& id,
505
                        api::Term func,
506
                        api::Term formula,
507
                        bool global);
508
  DefineFunctionCommand(const std::string& id,
509
                        api::Term func,
510
                        const std::vector<api::Term>& formals,
511
                        api::Term formula,
512
                        bool global);
513
514
  api::Term getFunction() const;
515
  const std::vector<api::Term>& getFormals() const;
516
  api::Term getFormula() const;
517
518
  void invoke(api::Solver* solver, SymbolManager* sm) override;
519
  Command* clone() const override;
520
  std::string getCommandName() const override;
521
  void toStream(
522
      std::ostream& out,
523
      int toDepth = -1,
524
      size_t dag = 1,
525
      OutputLanguage language = language::output::LANG_AUTO) const override;
526
527
 protected:
528
  /** The function we are defining */
529
  api::Term d_func;
530
  /** The formal arguments for the function we are defining */
531
  std::vector<api::Term> d_formals;
532
  /** The formula corresponding to the body of the function we are defining */
533
  api::Term d_formula;
534
  /**
535
   * Stores whether this definition is global (i.e. should persist when
536
   * popping the user context.
537
   */
538
  bool d_global;
539
}; /* class DefineFunctionCommand */
540
541
/**
542
 * The command when parsing define-fun-rec or define-funs-rec.
543
 * This command will assert a set of quantified formulas that specify
544
 * the (mutually recursive) function definitions provided to it.
545
 */
546
224
class CVC5_EXPORT DefineFunctionRecCommand : public Command
547
{
548
 public:
549
  DefineFunctionRecCommand(api::Term func,
550
                           const std::vector<api::Term>& formals,
551
                           api::Term formula,
552
                           bool global);
553
  DefineFunctionRecCommand(const std::vector<api::Term>& funcs,
554
                           const std::vector<std::vector<api::Term> >& formals,
555
                           const std::vector<api::Term>& formula,
556
                           bool global);
557
558
  const std::vector<api::Term>& getFunctions() const;
559
  const std::vector<std::vector<api::Term> >& getFormals() const;
560
  const std::vector<api::Term>& getFormulas() const;
561
562
  void invoke(api::Solver* solver, SymbolManager* sm) override;
563
  Command* clone() const override;
564
  std::string getCommandName() const override;
565
  void toStream(
566
      std::ostream& out,
567
      int toDepth = -1,
568
      size_t dag = 1,
569
      OutputLanguage language = language::output::LANG_AUTO) const override;
570
571
 protected:
572
  /** functions we are defining */
573
  std::vector<api::Term> d_funcs;
574
  /** formal arguments for each of the functions we are defining */
575
  std::vector<std::vector<api::Term> > d_formals;
576
  /** formulas corresponding to the bodies of the functions we are defining */
577
  std::vector<api::Term> d_formulas;
578
  /**
579
   * Stores whether this definition is global (i.e. should persist when
580
   * popping the user context.
581
   */
582
  bool d_global;
583
}; /* class DefineFunctionRecCommand */
584
585
/**
586
 * In separation logic inputs, which is an extension of smt2 inputs, this
587
 * corresponds to the command:
588
 *   (declare-heap (T U))
589
 * where T is the location sort and U is the data sort.
590
 */
591
174
class CVC5_EXPORT DeclareHeapCommand : public Command
592
{
593
 public:
594
  DeclareHeapCommand(api::Sort locSort, api::Sort dataSort);
595
  api::Sort getLocationSort() const;
596
  api::Sort getDataSort() const;
597
  void invoke(api::Solver* solver, SymbolManager* sm) override;
598
  Command* clone() const override;
599
  std::string getCommandName() const override;
600
  void toStream(
601
      std::ostream& out,
602
      int toDepth = -1,
603
      size_t dag = 1,
604
      OutputLanguage language = language::output::LANG_AUTO) const override;
605
606
 protected:
607
  /** The location sort */
608
  api::Sort d_locSort;
609
  /** The data sort */
610
  api::Sort d_dataSort;
611
};
612
613
/**
614
 * The command when an attribute is set by a user.  In SMT-LIBv2 this is done
615
 *  via the syntax (! expr :attr)
616
 */
617
404
class CVC5_EXPORT SetUserAttributeCommand : public Command
618
{
619
 public:
620
  SetUserAttributeCommand(const std::string& attr, api::Term term);
621
  SetUserAttributeCommand(const std::string& attr,
622
                          api::Term term,
623
                          const std::vector<api::Term>& values);
624
  SetUserAttributeCommand(const std::string& attr,
625
                          api::Term term,
626
                          const std::string& value);
627
628
  void invoke(api::Solver* solver, SymbolManager* sm) override;
629
  Command* clone() const override;
630
  std::string getCommandName() const override;
631
  void toStream(
632
      std::ostream& out,
633
      int toDepth = -1,
634
      size_t dag = 1,
635
      OutputLanguage language = language::output::LANG_AUTO) const override;
636
637
 private:
638
  SetUserAttributeCommand(const std::string& attr,
639
                          api::Term term,
640
                          const std::vector<api::Term>& termValues,
641
                          const std::string& strValue);
642
643
  const std::string d_attr;
644
  const api::Term d_term;
645
  const std::vector<api::Term> d_termValues;
646
  const std::string d_strValue;
647
}; /* class SetUserAttributeCommand */
648
649
/**
650
 * The command when parsing check-sat.
651
 * This command will check satisfiability of the input formula.
652
 */
653
15438
class CVC5_EXPORT CheckSatCommand : public Command
654
{
655
 public:
656
  CheckSatCommand();
657
  CheckSatCommand(const api::Term& term);
658
659
  api::Term getTerm() const;
660
  api::Result getResult() const;
661
  void invoke(api::Solver* solver, SymbolManager* sm) override;
662
  void printResult(std::ostream& out, uint32_t verbosity = 2) const override;
663
  Command* clone() const override;
664
  std::string getCommandName() const override;
665
  void toStream(
666
      std::ostream& out,
667
      int toDepth = -1,
668
      size_t dag = 1,
669
      OutputLanguage language = language::output::LANG_AUTO) const override;
670
671
 private:
672
  api::Term d_term;
673
  api::Result d_result;
674
}; /* class CheckSatCommand */
675
676
/**
677
 * The command when parsing check-sat-assuming.
678
 * This command will assume a set of formulas and check satisfiability of the
679
 * input formula under these assumptions.
680
 */
681
1970
class CVC5_EXPORT CheckSatAssumingCommand : public Command
682
{
683
 public:
684
  CheckSatAssumingCommand(api::Term term);
685
  CheckSatAssumingCommand(const std::vector<api::Term>& terms);
686
687
  const std::vector<api::Term>& getTerms() const;
688
  api::Result getResult() const;
689
  void invoke(api::Solver* solver, SymbolManager* sm) override;
690
  void printResult(std::ostream& out, uint32_t verbosity = 2) const override;
691
  Command* clone() const override;
692
  std::string getCommandName() const override;
693
  void toStream(
694
      std::ostream& out,
695
      int toDepth = -1,
696
      size_t dag = 1,
697
      OutputLanguage language = language::output::LANG_AUTO) const override;
698
699
 private:
700
  std::vector<api::Term> d_terms;
701
  api::Result d_result;
702
}; /* class CheckSatAssumingCommand */
703
704
1122
class CVC5_EXPORT QueryCommand : public Command
705
{
706
 protected:
707
  api::Term d_term;
708
  api::Result d_result;
709
  bool d_inUnsatCore;
710
711
 public:
712
  QueryCommand(const api::Term& t, bool inUnsatCore = true);
713
714
  api::Term getTerm() const;
715
  api::Result getResult() const;
716
  void invoke(api::Solver* solver, SymbolManager* sm) override;
717
  void printResult(std::ostream& out, uint32_t verbosity = 2) const override;
718
  Command* clone() const override;
719
  std::string getCommandName() const override;
720
  void toStream(
721
      std::ostream& out,
722
      int toDepth = -1,
723
      size_t dag = 1,
724
      OutputLanguage language = language::output::LANG_AUTO) const override;
725
}; /* class QueryCommand */
726
727
/* ------------------- sygus commands  ------------------ */
728
729
/** Declares a sygus universal variable */
730
524
class CVC5_EXPORT DeclareSygusVarCommand : public DeclarationDefinitionCommand
731
{
732
 public:
733
  DeclareSygusVarCommand(const std::string& id, api::Term var, api::Sort sort);
734
  /** returns the declared variable */
735
  api::Term getVar() const;
736
  /** returns the declared variable's sort */
737
  api::Sort getSort() const;
738
  /** invokes this command
739
   *
740
   * The declared sygus variable is communicated to the SMT engine in case a
741
   * synthesis conjecture is built later on.
742
   */
743
  void invoke(api::Solver* solver, SymbolManager* sm) override;
744
  /** creates a copy of this command */
745
  Command* clone() const override;
746
  /** returns this command's name */
747
  std::string getCommandName() const override;
748
  /** prints this command */
749
  void toStream(
750
      std::ostream& out,
751
      int toDepth = -1,
752
      size_t dag = 1,
753
      OutputLanguage language = language::output::LANG_AUTO) const override;
754
755
 protected:
756
  /** the declared variable */
757
  api::Term d_var;
758
  /** the declared variable's sort */
759
  api::Sort d_sort;
760
};
761
762
/** Declares a sygus function-to-synthesize
763
 *
764
 * This command is also used for the special case in which we are declaring an
765
 * invariant-to-synthesize
766
 */
767
564
class CVC5_EXPORT SynthFunCommand : public DeclarationDefinitionCommand
768
{
769
 public:
770
  SynthFunCommand(const std::string& id,
771
                  api::Term fun,
772
                  const std::vector<api::Term>& vars,
773
                  api::Sort sort,
774
                  bool isInv,
775
                  api::Grammar* g);
776
  /** returns the function-to-synthesize */
777
  api::Term getFunction() const;
778
  /** returns the input variables of the function-to-synthesize */
779
  const std::vector<api::Term>& getVars() const;
780
  /** returns the sygus sort of the function-to-synthesize */
781
  api::Sort getSort() const;
782
  /** returns whether the function-to-synthesize should be an invariant */
783
  bool isInv() const;
784
  /** Get the sygus grammar given for the synth fun command */
785
  const api::Grammar* getGrammar() const;
786
787
  /** invokes this command
788
   *
789
   * The declared function-to-synthesize is communicated to the SMT engine in
790
   * case a synthesis conjecture is built later on.
791
   */
792
  void invoke(api::Solver* solver, SymbolManager* sm) override;
793
  /** creates a copy of this command */
794
  Command* clone() const override;
795
  /** returns this command's name */
796
  std::string getCommandName() const override;
797
  /** prints this command */
798
  void toStream(
799
      std::ostream& out,
800
      int toDepth = -1,
801
      size_t dag = 1,
802
      OutputLanguage language = language::output::LANG_AUTO) const override;
803
804
 protected:
805
  /** the function-to-synthesize */
806
  api::Term d_fun;
807
  /** the input variables of the function-to-synthesize */
808
  std::vector<api::Term> d_vars;
809
  /** sort of the function-to-synthesize */
810
  api::Sort d_sort;
811
  /** whether the function-to-synthesize should be an invariant */
812
  bool d_isInv;
813
  /** optional grammar for the possible values of the function-to-sytnhesize */
814
  api::Grammar* d_grammar;
815
};
816
817
/** Declares a sygus constraint */
818
1196
class CVC5_EXPORT SygusConstraintCommand : public Command
819
{
820
 public:
821
  SygusConstraintCommand(const api::Term& t);
822
  /** returns the declared constraint */
823
  api::Term getTerm() const;
824
  /** invokes this command
825
   *
826
   * The declared constraint is communicated to the SMT engine in case a
827
   * synthesis conjecture is built later on.
828
   */
829
  void invoke(api::Solver* solver, SymbolManager* sm) override;
830
  /** creates a copy of this command */
831
  Command* clone() const override;
832
  /** returns this command's name */
833
  std::string getCommandName() const override;
834
  /** prints this command */
835
  void toStream(
836
      std::ostream& out,
837
      int toDepth = -1,
838
      size_t dag = 1,
839
      OutputLanguage language = language::output::LANG_AUTO) const override;
840
841
 protected:
842
  /** the declared constraint */
843
  api::Term d_term;
844
};
845
846
/** Declares a sygus invariant constraint
847
 *
848
 * Invarint constraints are declared in a somewhat implicit manner in the SyGuS
849
 * language: they are declared in terms of the previously declared
850
 * invariant-to-synthesize, precondition, transition relation and condition.
851
 *
852
 * The actual constraint must be built such that the invariant is not stronger
853
 * than the precondition, not weaker than the postcondition and inductive
854
 * w.r.t. the transition relation.
855
 */
856
26
class CVC5_EXPORT SygusInvConstraintCommand : public Command
857
{
858
 public:
859
  SygusInvConstraintCommand(const std::vector<api::Term>& predicates);
860
  SygusInvConstraintCommand(const api::Term& inv,
861
                            const api::Term& pre,
862
                            const api::Term& trans,
863
                            const api::Term& post);
864
  /** returns the place holder predicates */
865
  const std::vector<api::Term>& getPredicates() const;
866
  /** invokes this command
867
   *
868
   * The place holders are communicated to the SMT engine and the actual
869
   * invariant constraint is built, in case an actual synthesis conjecture is
870
   * built later on.
871
   */
872
  void invoke(api::Solver* solver, SymbolManager* sm) override;
873
  /** creates a copy of this command */
874
  Command* clone() const override;
875
  /** returns this command's name */
876
  std::string getCommandName() const override;
877
  /** prints this command */
878
  void toStream(
879
      std::ostream& out,
880
      int toDepth = -1,
881
      size_t dag = 1,
882
      OutputLanguage language = language::output::LANG_AUTO) const override;
883
884
 protected:
885
  /** the place holder predicates with which to build the actual constraint
886
   * (i.e. the invariant, precondition, transition relation and postcondition)
887
   */
888
  std::vector<api::Term> d_predicates;
889
};
890
891
/** Declares a synthesis conjecture */
892
378
class CVC5_EXPORT CheckSynthCommand : public Command
893
{
894
 public:
895
189
  CheckSynthCommand(){};
896
  /** returns the result of the check-synth call */
897
  api::Result getResult() const;
898
  /** prints the result of the check-synth-call */
899
  void printResult(std::ostream& out, uint32_t verbosity = 2) const override;
900
  /** invokes this command
901
   *
902
   * This invocation makes the SMT engine build a synthesis conjecture based on
903
   * previously declared information (such as universal variables,
904
   * functions-to-synthesize and so on), set up attributes to guide the solving,
905
   * and then perform a satisfiability check, whose result is stored in
906
   * d_result.
907
   */
908
  void invoke(api::Solver* solver, SymbolManager* sm) override;
909
  /** creates a copy of this command */
910
  Command* clone() const override;
911
  /** returns this command's name */
912
  std::string getCommandName() const override;
913
  /** prints this command */
914
  void toStream(
915
      std::ostream& out,
916
      int toDepth = -1,
917
      size_t dag = 1,
918
      OutputLanguage language = language::output::LANG_AUTO) const override;
919
920
 protected:
921
  /** result of the check-synth call */
922
  api::Result d_result;
923
  /** string stream that stores the output of the solution */
924
  std::stringstream d_solution;
925
};
926
927
/* ------------------- sygus commands  ------------------ */
928
929
// this is TRANSFORM in the CVC presentation language
930
class CVC5_EXPORT SimplifyCommand : public Command
931
{
932
 protected:
933
  api::Term d_term;
934
  api::Term d_result;
935
936
 public:
937
  SimplifyCommand(api::Term term);
938
939
  api::Term getTerm() const;
940
  api::Term getResult() const;
941
  void invoke(api::Solver* solver, SymbolManager* sm) override;
942
  void printResult(std::ostream& out, uint32_t verbosity = 2) const override;
943
  Command* clone() const override;
944
  std::string getCommandName() const override;
945
  void toStream(
946
      std::ostream& out,
947
      int toDepth = -1,
948
      size_t dag = 1,
949
      OutputLanguage language = language::output::LANG_AUTO) const override;
950
}; /* class SimplifyCommand */
951
952
128
class CVC5_EXPORT GetValueCommand : public Command
953
{
954
 protected:
955
  std::vector<api::Term> d_terms;
956
  api::Term d_result;
957
958
 public:
959
  GetValueCommand(api::Term term);
960
  GetValueCommand(const std::vector<api::Term>& terms);
961
962
  const std::vector<api::Term>& getTerms() const;
963
  api::Term getResult() const;
964
  void invoke(api::Solver* solver, SymbolManager* sm) override;
965
  void printResult(std::ostream& out, uint32_t verbosity = 2) const override;
966
  Command* clone() const override;
967
  std::string getCommandName() const override;
968
  void toStream(
969
      std::ostream& out,
970
      int toDepth = -1,
971
      size_t dag = 1,
972
      OutputLanguage language = language::output::LANG_AUTO) const override;
973
}; /* class GetValueCommand */
974
975
20
class CVC5_EXPORT GetAssignmentCommand : public Command
976
{
977
 protected:
978
  api::Term d_result;
979
980
 public:
981
  GetAssignmentCommand();
982
983
  api::Term getResult() const;
984
  void invoke(api::Solver* solver, SymbolManager* sm) override;
985
  void printResult(std::ostream& out, uint32_t verbosity = 2) const override;
986
  Command* clone() const override;
987
  std::string getCommandName() const override;
988
  void toStream(
989
      std::ostream& out,
990
      int toDepth = -1,
991
      size_t dag = 1,
992
      OutputLanguage language = language::output::LANG_AUTO) const override;
993
}; /* class GetAssignmentCommand */
994
995
60
class CVC5_EXPORT GetModelCommand : public Command
996
{
997
 public:
998
  GetModelCommand();
999
1000
  // Model is private to the library -- for now
1001
  // Model* getResult() const ;
1002
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1003
  void printResult(std::ostream& out, uint32_t verbosity = 2) const override;
1004
  Command* clone() const override;
1005
  std::string getCommandName() const override;
1006
  void toStream(
1007
      std::ostream& out,
1008
      int toDepth = -1,
1009
      size_t dag = 1,
1010
      OutputLanguage language = language::output::LANG_AUTO) const override;
1011
1012
 protected:
1013
  smt::Model* d_result;
1014
}; /* class GetModelCommand */
1015
1016
/** The command to block models. */
1017
24
class CVC5_EXPORT BlockModelCommand : public Command
1018
{
1019
 public:
1020
  BlockModelCommand();
1021
1022
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1023
  Command* clone() const override;
1024
  std::string getCommandName() const override;
1025
  void toStream(
1026
      std::ostream& out,
1027
      int toDepth = -1,
1028
      size_t dag = 1,
1029
      OutputLanguage language = language::output::LANG_AUTO) const override;
1030
}; /* class BlockModelCommand */
1031
1032
/** The command to block model values. */
1033
12
class CVC5_EXPORT BlockModelValuesCommand : public Command
1034
{
1035
 public:
1036
  BlockModelValuesCommand(const std::vector<api::Term>& terms);
1037
1038
  const std::vector<api::Term>& getTerms() const;
1039
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1040
  Command* clone() const override;
1041
  std::string getCommandName() const override;
1042
  void toStream(
1043
      std::ostream& out,
1044
      int toDepth = -1,
1045
      size_t dag = 1,
1046
      OutputLanguage language = language::output::LANG_AUTO) const override;
1047
1048
 protected:
1049
  /** The terms we are blocking */
1050
  std::vector<api::Term> d_terms;
1051
}; /* class BlockModelValuesCommand */
1052
1053
2
class CVC5_EXPORT GetProofCommand : public Command
1054
{
1055
 public:
1056
  GetProofCommand();
1057
1058
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1059
1060
  void printResult(std::ostream& out, uint32_t verbosity = 2) const override;
1061
1062
  Command* clone() const override;
1063
  std::string getCommandName() const override;
1064
  void toStream(
1065
      std::ostream& out,
1066
      int toDepth = -1,
1067
      size_t dag = 1,
1068
      OutputLanguage language = language::output::LANG_AUTO) const override;
1069
1070
 private:
1071
  /** the result of the getProof call */
1072
  std::string d_result;
1073
}; /* class GetProofCommand */
1074
1075
24
class CVC5_EXPORT GetInstantiationsCommand : public Command
1076
{
1077
 public:
1078
  GetInstantiationsCommand();
1079
1080
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1081
  void printResult(std::ostream& out, uint32_t verbosity = 2) const override;
1082
  Command* clone() const override;
1083
  std::string getCommandName() const override;
1084
  void toStream(
1085
      std::ostream& out,
1086
      int toDepth = -1,
1087
      size_t dag = 1,
1088
      OutputLanguage language = language::output::LANG_AUTO) const override;
1089
1090
 protected:
1091
  api::Solver* d_solver;
1092
}; /* class GetInstantiationsCommand */
1093
1094
class CVC5_EXPORT GetSynthSolutionCommand : public Command
1095
{
1096
 public:
1097
  GetSynthSolutionCommand();
1098
1099
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1100
  void printResult(std::ostream& out, uint32_t verbosity = 2) const override;
1101
  Command* clone() const override;
1102
  std::string getCommandName() const override;
1103
  void toStream(
1104
      std::ostream& out,
1105
      int toDepth = -1,
1106
      size_t dag = 1,
1107
      OutputLanguage language = language::output::LANG_AUTO) const override;
1108
1109
 protected:
1110
  api::Solver* d_solver;
1111
}; /* class GetSynthSolutionCommand */
1112
1113
/** The command (get-interpol s B (G)?)
1114
 *
1115
 * This command asks for an interpolant from the current set of assertions and
1116
 * conjecture (goal) B.
1117
 *
1118
 * The symbol s is the name for the interpolation predicate. If we successfully
1119
 * find a predicate P, then the output response of this command is: (define-fun
1120
 * s () Bool P)
1121
 */
1122
16
class CVC5_EXPORT GetInterpolCommand : public Command
1123
{
1124
 public:
1125
  GetInterpolCommand(const std::string& name, api::Term conj);
1126
  /** The argument g is the grammar of the interpolation query */
1127
  GetInterpolCommand(const std::string& name, api::Term conj, api::Grammar* g);
1128
1129
  /** Get the conjecture of the interpolation query */
1130
  api::Term getConjecture() const;
1131
  /** Get the sygus grammar given for the interpolation query */
1132
  const api::Grammar* getGrammar() const;
1133
  /** Get the result of the query, which is the solution to the interpolation
1134
   * query. */
1135
  api::Term getResult() const;
1136
1137
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1138
  void printResult(std::ostream& out, uint32_t verbosity = 2) const override;
1139
  Command* clone() const override;
1140
  std::string getCommandName() const override;
1141
  void toStream(
1142
      std::ostream& out,
1143
      int toDepth = -1,
1144
      size_t dag = 1,
1145
      OutputLanguage language = language::output::LANG_AUTO) const override;
1146
1147
 protected:
1148
  /** The name of the interpolation predicate */
1149
  std::string d_name;
1150
  /** The conjecture of the interpolation query */
1151
  api::Term d_conj;
1152
  /** The (optional) grammar of the interpolation query */
1153
  api::Grammar* d_sygus_grammar;
1154
  /** the return status of the command */
1155
  bool d_resultStatus;
1156
  /** the return expression of the command */
1157
  api::Term d_result;
1158
}; /* class GetInterpolCommand */
1159
1160
/** The command (get-abduct s B (G)?)
1161
 *
1162
 * This command asks for an abduct from the current set of assertions and
1163
 * conjecture (goal) given by the argument B.
1164
 *
1165
 * The symbol s is the name for the abduction predicate. If we successfully
1166
 * find a predicate P, then the output response of this command is:
1167
 *   (define-fun s () Bool P)
1168
 *
1169
 * A grammar G can be optionally provided to indicate the syntactic restrictions
1170
 * on the possible solutions returned.
1171
 */
1172
22
class CVC5_EXPORT GetAbductCommand : public Command
1173
{
1174
 public:
1175
  GetAbductCommand(const std::string& name, api::Term conj);
1176
  GetAbductCommand(const std::string& name, api::Term conj, api::Grammar* g);
1177
1178
  /** Get the conjecture of the abduction query */
1179
  api::Term getConjecture() const;
1180
  /** Get the grammar given for the abduction query */
1181
  const api::Grammar* getGrammar() const;
1182
  /** Get the name of the abduction predicate for the abduction query */
1183
  std::string getAbductName() const;
1184
  /** Get the result of the query, which is the solution to the abduction query.
1185
   */
1186
  api::Term getResult() const;
1187
1188
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1189
  void printResult(std::ostream& out, uint32_t verbosity = 2) const override;
1190
  Command* clone() const override;
1191
  std::string getCommandName() const override;
1192
  void toStream(
1193
      std::ostream& out,
1194
      int toDepth = -1,
1195
      size_t dag = 1,
1196
      OutputLanguage language = language::output::LANG_AUTO) const override;
1197
1198
 protected:
1199
  /** The name of the abduction predicate */
1200
  std::string d_name;
1201
  /** The conjecture of the abduction query */
1202
  api::Term d_conj;
1203
  /** The (optional) grammar of the abduction query */
1204
  api::Grammar* d_sygus_grammar;
1205
  /** the return status of the command */
1206
  bool d_resultStatus;
1207
  /** the return expression of the command */
1208
  api::Term d_result;
1209
}; /* class GetAbductCommand */
1210
1211
16
class CVC5_EXPORT GetQuantifierEliminationCommand : public Command
1212
{
1213
 protected:
1214
  api::Term d_term;
1215
  bool d_doFull;
1216
  api::Term d_result;
1217
1218
 public:
1219
  GetQuantifierEliminationCommand();
1220
  GetQuantifierEliminationCommand(const api::Term& term, bool doFull);
1221
1222
  api::Term getTerm() const;
1223
  bool getDoFull() const;
1224
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1225
  api::Term getResult() const;
1226
  void printResult(std::ostream& out, uint32_t verbosity = 2) const override;
1227
1228
  Command* clone() const override;
1229
  std::string getCommandName() const override;
1230
  void toStream(
1231
      std::ostream& out,
1232
      int toDepth = -1,
1233
      size_t dag = 1,
1234
      OutputLanguage language = language::output::LANG_AUTO) const override;
1235
}; /* class GetQuantifierEliminationCommand */
1236
1237
16
class CVC5_EXPORT GetUnsatAssumptionsCommand : public Command
1238
{
1239
 public:
1240
  GetUnsatAssumptionsCommand();
1241
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1242
  std::vector<api::Term> getResult() const;
1243
  void printResult(std::ostream& out, uint32_t verbosity = 2) const override;
1244
  Command* clone() const override;
1245
  std::string getCommandName() const override;
1246
  void toStream(
1247
      std::ostream& out,
1248
      int toDepth = -1,
1249
      size_t dag = 1,
1250
      OutputLanguage language = language::output::LANG_AUTO) const override;
1251
1252
 protected:
1253
  std::vector<api::Term> d_result;
1254
}; /* class GetUnsatAssumptionsCommand */
1255
1256
24
class CVC5_EXPORT GetUnsatCoreCommand : public Command
1257
{
1258
 public:
1259
  GetUnsatCoreCommand();
1260
  const std::vector<api::Term>& getUnsatCore() const;
1261
1262
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1263
  void printResult(std::ostream& out, uint32_t verbosity = 2) const override;
1264
1265
  Command* clone() const override;
1266
  std::string getCommandName() const override;
1267
  void toStream(
1268
      std::ostream& out,
1269
      int toDepth = -1,
1270
      size_t dag = 1,
1271
      OutputLanguage language = language::output::LANG_AUTO) const override;
1272
1273
 protected:
1274
  /** The symbol manager we were invoked with */
1275
  SymbolManager* d_sm;
1276
  /** the result of the unsat core call */
1277
  std::vector<api::Term> d_result;
1278
}; /* class GetUnsatCoreCommand */
1279
1280
class CVC5_EXPORT GetAssertionsCommand : public Command
1281
{
1282
 protected:
1283
  std::string d_result;
1284
1285
 public:
1286
  GetAssertionsCommand();
1287
1288
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1289
  std::string getResult() const;
1290
  void printResult(std::ostream& out, uint32_t verbosity = 2) const 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 GetAssertionsCommand */
1299
1300
class CVC5_EXPORT SetBenchmarkStatusCommand : public Command
1301
{
1302
 protected:
1303
  BenchmarkStatus d_status;
1304
1305
 public:
1306
  SetBenchmarkStatusCommand(BenchmarkStatus status);
1307
1308
  BenchmarkStatus getStatus() const;
1309
1310
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1311
  Command* clone() const override;
1312
  std::string getCommandName() const override;
1313
  void toStream(
1314
      std::ostream& out,
1315
      int toDepth = -1,
1316
      size_t dag = 1,
1317
      OutputLanguage language = language::output::LANG_AUTO) const override;
1318
}; /* class SetBenchmarkStatusCommand */
1319
1320
10478
class CVC5_EXPORT SetBenchmarkLogicCommand : public Command
1321
{
1322
 protected:
1323
  std::string d_logic;
1324
1325
 public:
1326
  SetBenchmarkLogicCommand(std::string logic);
1327
1328
  std::string getLogic() const;
1329
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1330
  Command* clone() const override;
1331
  std::string getCommandName() const override;
1332
  void toStream(
1333
      std::ostream& out,
1334
      int toDepth = -1,
1335
      size_t dag = 1,
1336
      OutputLanguage language = language::output::LANG_AUTO) const override;
1337
}; /* class SetBenchmarkLogicCommand */
1338
1339
11074
class CVC5_EXPORT SetInfoCommand : public Command
1340
{
1341
 protected:
1342
  std::string d_flag;
1343
  std::string d_value;
1344
1345
 public:
1346
  SetInfoCommand(const std::string& flag, const std::string& value);
1347
1348
  const std::string& getFlag() const;
1349
  const std::string& getValue() const;
1350
1351
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1352
  Command* clone() const override;
1353
  std::string getCommandName() const override;
1354
  void toStream(
1355
      std::ostream& out,
1356
      int toDepth = -1,
1357
      size_t dag = 1,
1358
      OutputLanguage language = language::output::LANG_AUTO) const override;
1359
}; /* class SetInfoCommand */
1360
1361
40
class CVC5_EXPORT GetInfoCommand : public Command
1362
{
1363
 protected:
1364
  std::string d_flag;
1365
  std::string d_result;
1366
1367
 public:
1368
  GetInfoCommand(std::string flag);
1369
1370
  std::string getFlag() const;
1371
  std::string getResult() const;
1372
1373
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1374
  void printResult(std::ostream& out, uint32_t verbosity = 2) const override;
1375
  Command* clone() const override;
1376
  std::string getCommandName() const override;
1377
  void toStream(
1378
      std::ostream& out,
1379
      int toDepth = -1,
1380
      size_t dag = 1,
1381
      OutputLanguage language = language::output::LANG_AUTO) const override;
1382
}; /* class GetInfoCommand */
1383
1384
14144
class CVC5_EXPORT SetOptionCommand : public Command
1385
{
1386
 protected:
1387
  std::string d_flag;
1388
  std::string d_value;
1389
1390
 public:
1391
  SetOptionCommand(const std::string& flag, const std::string& value);
1392
1393
  const std::string& getFlag() const;
1394
  const std::string& getValue() const;
1395
1396
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1397
  Command* clone() const override;
1398
  std::string getCommandName() const override;
1399
  void toStream(
1400
      std::ostream& out,
1401
      int toDepth = -1,
1402
      size_t dag = 1,
1403
      OutputLanguage language = language::output::LANG_AUTO) const override;
1404
}; /* class SetOptionCommand */
1405
1406
22
class CVC5_EXPORT GetOptionCommand : public Command
1407
{
1408
 protected:
1409
  std::string d_flag;
1410
  std::string d_result;
1411
1412
 public:
1413
  GetOptionCommand(std::string flag);
1414
1415
  std::string getFlag() const;
1416
  std::string getResult() const;
1417
1418
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1419
  void printResult(std::ostream& out, uint32_t verbosity = 2) const 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 GetOptionCommand */
1428
1429
1846
class CVC5_EXPORT DatatypeDeclarationCommand : public Command
1430
{
1431
 private:
1432
  std::vector<api::Sort> d_datatypes;
1433
1434
 public:
1435
  DatatypeDeclarationCommand(const api::Sort& datatype);
1436
1437
  DatatypeDeclarationCommand(const std::vector<api::Sort>& datatypes);
1438
  const std::vector<api::Sort>& getDatatypes() const;
1439
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1440
  Command* clone() const override;
1441
  std::string getCommandName() const override;
1442
  void toStream(
1443
      std::ostream& out,
1444
      int toDepth = -1,
1445
      size_t dag = 1,
1446
      OutputLanguage language = language::output::LANG_AUTO) const override;
1447
}; /* class DatatypeDeclarationCommand */
1448
1449
94
class CVC5_EXPORT ResetCommand : public Command
1450
{
1451
 public:
1452
47
  ResetCommand() {}
1453
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1454
  Command* clone() const override;
1455
  std::string getCommandName() const override;
1456
  void toStream(
1457
      std::ostream& out,
1458
      int toDepth = -1,
1459
      size_t dag = 1,
1460
      OutputLanguage language = language::output::LANG_AUTO) const override;
1461
}; /* class ResetCommand */
1462
1463
62
class CVC5_EXPORT ResetAssertionsCommand : public Command
1464
{
1465
 public:
1466
31
  ResetAssertionsCommand() {}
1467
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1468
  Command* clone() const override;
1469
  std::string getCommandName() const override;
1470
  void toStream(
1471
      std::ostream& out,
1472
      int toDepth = -1,
1473
      size_t dag = 1,
1474
      OutputLanguage language = language::output::LANG_AUTO) const override;
1475
}; /* class ResetAssertionsCommand */
1476
1477
1432
class CVC5_EXPORT QuitCommand : public Command
1478
{
1479
 public:
1480
716
  QuitCommand() {}
1481
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1482
  Command* clone() const override;
1483
  std::string getCommandName() const override;
1484
  void toStream(
1485
      std::ostream& out,
1486
      int toDepth = -1,
1487
      size_t dag = 1,
1488
      OutputLanguage language = language::output::LANG_AUTO) const override;
1489
}; /* class QuitCommand */
1490
1491
class CVC5_EXPORT CommentCommand : public Command
1492
{
1493
  std::string d_comment;
1494
1495
 public:
1496
  CommentCommand(std::string comment);
1497
1498
  std::string getComment() const;
1499
1500
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1501
  Command* clone() const override;
1502
  std::string getCommandName() const override;
1503
  void toStream(
1504
      std::ostream& out,
1505
      int toDepth = -1,
1506
      size_t dag = 1,
1507
      OutputLanguage language = language::output::LANG_AUTO) const override;
1508
}; /* class CommentCommand */
1509
1510
class CVC5_EXPORT CommandSequence : public Command
1511
{
1512
 protected:
1513
  /** All the commands to be executed (in sequence) */
1514
  std::vector<Command*> d_commandSequence;
1515
  /** Next command to be executed */
1516
  unsigned int d_index;
1517
1518
 public:
1519
  CommandSequence();
1520
  ~CommandSequence();
1521
1522
  void addCommand(Command* cmd);
1523
  void clear();
1524
1525
  void invoke(api::Solver* solver, SymbolManager* sm) override;
1526
  void invoke(api::Solver* solver,
1527
              SymbolManager* sm,
1528
              std::ostream& out) override;
1529
1530
  typedef std::vector<Command*>::iterator iterator;
1531
  typedef std::vector<Command*>::const_iterator const_iterator;
1532
1533
  const_iterator begin() const;
1534
  const_iterator end() const;
1535
1536
  iterator begin();
1537
  iterator end();
1538
1539
  Command* clone() const override;
1540
  std::string getCommandName() const override;
1541
  void toStream(
1542
      std::ostream& out,
1543
      int toDepth = -1,
1544
      size_t dag = 1,
1545
      OutputLanguage language = language::output::LANG_AUTO) const override;
1546
}; /* class CommandSequence */
1547
1548
15135
class CVC5_EXPORT DeclarationSequence : public CommandSequence
1549
{
1550
  void toStream(
1551
      std::ostream& out,
1552
      int toDepth = -1,
1553
      size_t dag = 1,
1554
      OutputLanguage language = language::output::LANG_AUTO) const override;
1555
};
1556
1557
}  // namespace cvc5
1558
1559
#endif /* CVC5__COMMAND_H */