This adds the expr-level sequence datatypes. This is required for further progress on sequences. However, note that this class may be deleted in the further when the Expr level is replaced.
expr/datatype.h
expr/emptyset.h
expr/expr_iomanip.h
+ expr/expr_sequence.h
expr/record.h
expr/symbol_table.h
expr/type.h
${CMAKE_CURRENT_BINARY_DIR}/ExprHashFunction.java
${CMAKE_CURRENT_BINARY_DIR}/ExprManager.java
${CMAKE_CURRENT_BINARY_DIR}/ExprManagerMapCollection.java
+ ${CMAKE_CURRENT_BINARY_DIR}/ExprSequence.java
${CMAKE_CURRENT_BINARY_DIR}/FloatingPoint.java
${CMAKE_CURRENT_BINARY_DIR}/FloatingPointConvertSort.java
${CMAKE_CURRENT_BINARY_DIR}/FloatingPointSize.java
%include "expr/array_store_all.i"
%include "expr/ascription_type.i"
%include "expr/emptyset.i"
+%include "expr/expr_sequence.i"
%include "expr/datatype.i"
%include "expr/record.i"
%include "proof/unsat_core.i"
expr_iomanip.cpp
expr_iomanip.h
expr_manager_scope.h
+ expr_sequence.cpp
+ expr_sequence.h
kind_map.h
match_trie.cpp
match_trie.h
node_traversal.h
node_value.cpp
node_value.h
+ sequence.cpp
+ sequence.h
node_visitor.h
proof.cpp
proof.h
%template(getConstBoolean) CVC4::Expr::getConst<bool>;
%template(getConstDatatypeIndexConstant) CVC4::Expr::getConst<CVC4::DatatypeIndexConstant>;
%template(getConstEmptySet) CVC4::Expr::getConst<CVC4::EmptySet>;
+%template(getConstExprSequence) CVC4::Expr::getConst<CVC4::ExprSequence>;
%template(getConstFloatingPoint) CVC4::Expr::getConst<CVC4::FloatingPoint>;
%template(getConstKind) CVC4::Expr::getConst<CVC4::kind::Kind_t>;
%template(getConstRational) CVC4::Expr::getConst<CVC4::Rational>;
%template(mkConst) CVC4::ExprManager::mkConst<CVC4::Rational>;
%template(mkConst) CVC4::ExprManager::mkConst<CVC4::BitVector>;
%template(mkConst) CVC4::ExprManager::mkConst<CVC4::EmptySet>;
+%template(mkConst) CVC4::ExprManager::mkConst<CVC4::ExprSequence>;
%template(mkConst) CVC4::ExprManager::mkConst<CVC4::String>;
#ifdef SWIGPYTHON
/* The python bindings cannot differentiate between bool and other basic
--- /dev/null
+/********************* */
+/*! \file expr_sequence.cpp
+ ** \verbatim
+ ** Top contributors (to current version):
+ ** Andrew Reynolds
+ ** This file is part of the CVC4 project.
+ ** Copyright (c) 2009-2019 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 Implementation of the sequence data type.
+ **/
+
+#include "expr/expr_sequence.h"
+
+#include "expr/expr.h"
+#include "expr/node.h"
+#include "expr/sequence.h"
+#include "expr/type.h"
+#include "expr/type_node.h"
+
+namespace CVC4 {
+
+ExprSequence::ExprSequence(const Type& t, const std::vector<Expr>& seq)
+{
+ d_type.reset(new Type(t));
+ std::vector<Node> nseq;
+ for (const Expr& e : seq)
+ {
+ nseq.push_back(Node::fromExpr(e));
+ }
+ d_sequence.reset(new Sequence(TypeNode::fromType(t), nseq));
+}
+ExprSequence::~ExprSequence() {}
+
+ExprSequence::ExprSequence(const ExprSequence& other)
+ : d_type(new Type(other.getType())),
+ d_sequence(new Sequence(other.getSequence()))
+{
+}
+
+ExprSequence& ExprSequence::operator=(const ExprSequence& other)
+{
+ (*d_type) = other.getType();
+ (*d_sequence) = other.getSequence();
+ return *this;
+}
+
+const Type& ExprSequence::getType() const { return *d_type; }
+
+const Sequence& ExprSequence::getSequence() const { return *d_sequence; }
+
+bool ExprSequence::operator==(const ExprSequence& es) const
+{
+ return getType() == es.getType() && getSequence() == es.getSequence();
+}
+
+bool ExprSequence::operator!=(const ExprSequence& es) const
+{
+ return !(*this == es);
+}
+
+bool ExprSequence::operator<(const ExprSequence& es) const
+{
+ return (getType() < es.getType())
+ || (getType() == es.getType() && getSequence() < es.getSequence());
+}
+
+bool ExprSequence::operator<=(const ExprSequence& es) const
+{
+ return (getType() < es.getType())
+ || (getType() == es.getType() && getSequence() <= es.getSequence());
+}
+
+bool ExprSequence::operator>(const ExprSequence& es) const
+{
+ return !(*this <= es);
+}
+
+bool ExprSequence::operator>=(const ExprSequence& es) const
+{
+ return !(*this < es);
+}
+
+std::ostream& operator<<(std::ostream& os, const ExprSequence& s)
+{
+ return os << "__expr_sequence__(" << s.getType() << ", " << s.getSequence()
+ << ")";
+}
+
+size_t ExprSequenceHashFunction::operator()(const ExprSequence& es) const
+{
+ uint64_t hash = fnv1a::fnv1a_64(TypeHashFunction()(es.getType()));
+ return static_cast<size_t>(SequenceHashFunction()(es.getSequence()), hash);
+}
+
+} // namespace CVC4
--- /dev/null
+/********************* */
+/*! \file expr_sequence.h
+ ** \verbatim
+ ** Top contributors (to current version):
+ ** Andrew Reynolds
+ ** This file is part of the CVC4 project.
+ ** Copyright (c) 2009-2019 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 The sequence data type.
+ **/
+
+#include "cvc4_public.h"
+
+#ifndef CVC4__EXPR__EXPR_SEQUENCE_H
+#define CVC4__EXPR__EXPR_SEQUENCE_H
+
+#include <iosfwd>
+#include <memory>
+#include <vector>
+
+namespace CVC4 {
+
+// messy; Expr needs ExprSequence (because it's the payload of a
+// CONSTANT-kinded expression), and ExprSequence needs Expr.
+class Type;
+class Expr;
+class Sequence;
+
+/** The CVC4 sequence class
+ *
+ * This data structure is the domain of values for the sequence type.
+ */
+class CVC4_PUBLIC ExprSequence
+{
+ public:
+ /** constructors for ExprSequence
+ *
+ * Internally, a CVC4::ExprSequence is represented by a vector of Nodes
+ * (d_seq), where each Node in this vector must be a constant.
+ */
+ ExprSequence(const Type& type, const std::vector<Expr>& seq);
+ ~ExprSequence();
+
+ ExprSequence(const ExprSequence& other);
+ ExprSequence& operator=(const ExprSequence& other);
+
+ bool operator==(const ExprSequence& es) const;
+ bool operator!=(const ExprSequence& es) const;
+ bool operator<(const ExprSequence& es) const;
+ bool operator<=(const ExprSequence& es) const;
+ bool operator>(const ExprSequence& es) const;
+ bool operator>=(const ExprSequence& es) const;
+
+ const Type& getType() const;
+ const Sequence& getSequence() const;
+
+ private:
+ /** The element type of the sequence */
+ std::unique_ptr<Type> d_type;
+ /** The data of the sequence */
+ std::unique_ptr<Sequence> d_sequence;
+}; /* class ExprSequence */
+
+struct CVC4_PUBLIC ExprSequenceHashFunction
+{
+ size_t operator()(const ::CVC4::ExprSequence& s) const;
+}; /* struct ExprSequenceHashFunction */
+
+std::ostream& operator<<(std::ostream& os, const ExprSequence& s) CVC4_PUBLIC;
+
+} // namespace CVC4
+
+#endif /* CVC4__EXPR__SEQUENCE_H */
--- /dev/null
+%{
+#include "expr/expr_sequence.h"
+%}
+
+%rename(equals) CVC4::ExprSequence::operator==(const ExprSequence&) const;
+%ignore CVC4::ExprSequence::operator!=(const ExprSequence&) const;
+%ignore CVC4::ExprSequence::getSequence() const;
+
+%rename(less) CVC4::ExprSequence::operator<(const ExprSequence&) const;
+%rename(lessEqual) CVC4::ExprSequence::operator<=(const ExprSequence&) const;
+%rename(greater) CVC4::ExprSequence::operator>(const ExprSequence&) const;
+%rename(greaterEqual) CVC4::ExprSequence::operator>=(const ExprSequence&) const;
+
+%rename(apply) CVC4::ExprSequenceHashFunction::operator()(const ExprSequence&) const;
+
+%ignore CVC4::operator<<(std::ostream& out, const ExprSequence& es);
+
+%include "expr/expr_sequence.h"
#include "expr/sequence.h"
+#include "expr/expr_sequence.h"
+
using namespace std;
namespace CVC4 {
size_t Sequence::maxSize() { return std::numeric_limits<uint32_t>::max(); }
+ExprSequence Sequence::toExprSequence()
+{
+ std::vector<Expr> seq;
+ for (const Node& n : d_seq)
+ {
+ seq.push_back(n.toExpr());
+ }
+ return ExprSequence(d_type.toType(), seq);
+}
+
std::ostream& operator<<(std::ostream& os, const Sequence& s)
{
const std::vector<Node>& vec = s.getVec();
*/
static size_t maxSize();
+ //!!!!!!!!!!!!!!! temporary
+ ExprSequence toExprSequence();
+ //!!!!!!!!!!!!!!! end temporary
+
private:
/**
* Returns a negative number if *this < y, 0 if *this and y are equal and a
"util/string.h" \
"a string of characters"
+constant CONST_SEQUENCE \
+ ::CVC4::ExprSequence \
+ ::CVC4::ExprSequenceHashFunction \
+ "expr/expr_sequence.h" \
+ "a sequence of characters"
+
# equal equal / less than / output
operator STRING_TO_REGEXP 1 "convert string to regexp"
operator REGEXP_CONCAT 2: "regexp concat"