GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/smt/command.h Lines: 61 77 79.2 %
Date: 2021-09-10 Branches: 4 16 25.0 %

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