GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/smt/node_command.h Lines: 5 5 100.0 %
Date: 2021-09-17 Branches: 0 0 0.0 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Abdalrhman Mohamed
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
 * Datastructures used for printing commands internally.
14
 */
15
16
#include "cvc5_private.h"
17
18
#ifndef CVC5__SMT__NODE_COMMAND_H
19
#define CVC5__SMT__NODE_COMMAND_H
20
21
#include <string>
22
23
#include "expr/node.h"
24
#include "expr/type_node.h"
25
#include "options/language.h"
26
27
namespace cvc5 {
28
29
/**
30
 * A node version of Command. DO NOT use this version unless there is a need
31
 * to buffer commands for later use (e.g., printing models).
32
 */
33
288029
class NodeCommand
34
{
35
 public:
36
  /** Destructor */
37
  virtual ~NodeCommand();
38
39
  /** Print this NodeCommand to output stream */
40
  virtual void toStream(std::ostream& out,
41
                        int toDepth = -1,
42
                        size_t dag = 1,
43
                        Language language = Language::LANG_AUTO) const = 0;
44
45
  /** Get a string representation of this NodeCommand */
46
  std::string toString() const;
47
48
  /** Clone this NodeCommand (make a shallow copy). */
49
  virtual NodeCommand* clone() const = 0;
50
};
51
52
std::ostream& operator<<(std::ostream& out, const NodeCommand& nc);
53
54
/**
55
 * Declare n-ary function symbol.
56
 * SMT-LIB: ( declare-fun <id> ( <type.getArgTypes()> ) <type.getRangeType()> )
57
 */
58
273763
class DeclareFunctionNodeCommand : public NodeCommand
59
{
60
 public:
61
  DeclareFunctionNodeCommand(const std::string& id, Node fun, TypeNode type);
62
  void toStream(std::ostream& out,
63
                int toDepth = -1,
64
                size_t dag = 1,
65
                Language language = Language::LANG_AUTO) const override;
66
  NodeCommand* clone() const override;
67
  const Node& getFunction() const;
68
69
 private:
70
  std::string d_id;
71
  Node d_fun;
72
  TypeNode d_type;
73
};
74
75
/**
76
 * Create datatype sort.
77
 * SMT-LIB: ( declare-datatypes ( <datatype decls>{n+1} ) ( <datatypes>{n+1} ) )
78
 */
79
3368
class DeclareDatatypeNodeCommand : public NodeCommand
80
{
81
 public:
82
  DeclareDatatypeNodeCommand(const std::vector<TypeNode>& datatypes);
83
  void toStream(std::ostream& out,
84
                int toDepth = -1,
85
                size_t dag = 1,
86
                Language language = Language::LANG_AUTO) const override;
87
  NodeCommand* clone() const override;
88
89
 private:
90
  std::vector<TypeNode> d_datatypes;
91
};
92
93
/**
94
 * Declare uninterpreted sort.
95
 * SMT-LIB: ( declare-sort <id> <arity> )
96
 */
97
8625
class DeclareTypeNodeCommand : public NodeCommand
98
{
99
 public:
100
  DeclareTypeNodeCommand(const std::string& id, size_t arity, TypeNode type);
101
  void toStream(std::ostream& out,
102
                int toDepth = -1,
103
                size_t dag = 1,
104
                Language language = Language::LANG_AUTO) const override;
105
  NodeCommand* clone() const override;
106
  const std::string getSymbol() const;
107
  const TypeNode& getType() const;
108
109
 private:
110
  std::string d_id;
111
  size_t d_arity;
112
  TypeNode d_type;
113
};
114
115
/**
116
 * Define n-ary function.
117
 * SMT-LIB: ( define-fun <id> ( <formals> ) <fun.getType()> <formula> )
118
 */
119
2275
class DefineFunctionNodeCommand : public NodeCommand
120
{
121
 public:
122
  DefineFunctionNodeCommand(const std::string& id,
123
                            Node fun,
124
                            const std::vector<Node>& formals,
125
                            Node formula);
126
  void toStream(std::ostream& out,
127
                int toDepth = -1,
128
                size_t dag = 1,
129
                Language language = Language::LANG_AUTO) const override;
130
  NodeCommand* clone() const override;
131
132
 private:
133
  std::string d_id;
134
  Node d_fun;
135
  std::vector<Node> d_formals;
136
  Node d_formula;
137
};
138
139
}  // namespace cvc5
140
141
#endif /* CVC5__SMT__NODE_COMMAND_H */