summaryrefslogtreecommitdiff
path: root/src/smt/node_command.h
blob: faef7aca3158f813cfb5f18a4102b81d724bc8fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/*********************                                                        */
/*! \file node_command.h
 ** \verbatim
 ** Top contributors (to current version):
 **   Abdalrhman Mohamed
 ** This file is part of the CVC4 project.
 ** Copyright (c) 2009-2021 by the authors listed in the file AUTHORS
 ** in the top-level source directory and their institutional affiliations.
 ** All rights reserved.  See the file COPYING in the top-level source
 ** directory for licensing information.\endverbatim
 **
 ** \brief Datastructures used for printing commands internally.
 **
 ** Datastructures used for printing commands internally.
 **/

#include "cvc4_private.h"

#ifndef CVC4__SMT__NODE_COMMAND_H
#define CVC4__SMT__NODE_COMMAND_H

#include <string>

#include "expr/node.h"
#include "expr/type_node.h"
#include "options/language.h"

namespace CVC4 {

/**
 * A node version of Command. DO NOT use this version unless there is a need
 * to buffer commands for later use (e.g., printing models).
 */
class NodeCommand
{
 public:
  /** Destructor */
  virtual ~NodeCommand();

  /** Print this NodeCommand to output stream */
  virtual void toStream(
      std::ostream& out,
      int toDepth = -1,
      size_t dag = 1,
      OutputLanguage language = language::output::LANG_AUTO) const = 0;

  /** Get a string representation of this NodeCommand */
  std::string toString() const;

  /** Clone this NodeCommand (make a shallow copy). */
  virtual NodeCommand* clone() const = 0;
};

std::ostream& operator<<(std::ostream& out, const NodeCommand& nc);

/**
 * Declare n-ary function symbol.
 * SMT-LIB: ( declare-fun <id> ( <type.getArgTypes()> ) <type.getRangeType()> )
 */
class DeclareFunctionNodeCommand : public NodeCommand
{
 public:
  DeclareFunctionNodeCommand(const std::string& id, Node fun, TypeNode type);
  void toStream(
      std::ostream& out,
      int toDepth = -1,
      size_t dag = 1,
      OutputLanguage language = language::output::LANG_AUTO) const override;
  NodeCommand* clone() const override;
  const Node& getFunction() const;

 private:
  std::string d_id;
  Node d_fun;
  TypeNode d_type;
};

/**
 * Create datatype sort.
 * SMT-LIB: ( declare-datatypes ( <datatype decls>{n+1} ) ( <datatypes>{n+1} ) )
 */
class DeclareDatatypeNodeCommand : public NodeCommand
{
 public:
  DeclareDatatypeNodeCommand(const std::vector<TypeNode>& datatypes);
  void toStream(
      std::ostream& out,
      int toDepth = -1,
      size_t dag = 1,
      OutputLanguage language = language::output::LANG_AUTO) const override;
  NodeCommand* clone() const override;

 private:
  std::vector<TypeNode> d_datatypes;
};

/**
 * Declare uninterpreted sort.
 * SMT-LIB: ( declare-sort <id> <arity> )
 */
class DeclareTypeNodeCommand : public NodeCommand
{
 public:
  DeclareTypeNodeCommand(const std::string& id, size_t arity, TypeNode type);
  void toStream(
      std::ostream& out,
      int toDepth = -1,
      size_t dag = 1,
      OutputLanguage language = language::output::LANG_AUTO) const override;
  NodeCommand* clone() const override;
  const std::string getSymbol() const;
  const TypeNode& getType() const;

 private:
  std::string d_id;
  size_t d_arity;
  TypeNode d_type;
};

/**
 * Define n-ary function.
 * SMT-LIB: ( define-fun <id> ( <formals> ) <fun.getType()> <formula> )
 */
class DefineFunctionNodeCommand : public NodeCommand
{
 public:
  DefineFunctionNodeCommand(const std::string& id,
                            Node fun,
                            const std::vector<Node>& formals,
                            Node formula);
  void toStream(
      std::ostream& out,
      int toDepth = -1,
      size_t dag = 1,
      OutputLanguage language = language::output::LANG_AUTO) const override;
  NodeCommand* clone() const override;

 private:
  std::string d_id;
  Node d_fun;
  std::vector<Node> d_formals;
  Node d_formula;
};

}  // namespace CVC4

#endif /* CVC4__SMT__NODE_COMMAND_H */
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback