cvc4-1.4
type.h
Go to the documentation of this file.
1/********************* */
17#include "cvc4_public.h"
18
19#ifndef __CVC4__TYPE_H
20#define __CVC4__TYPE_H
21
22#include <string>
23#include <vector>
24#include <limits.h>
25#include <stdint.h>
26
27#include "util/cardinality.h"
28#include "util/subrange_bound.h"
29
30namespace CVC4 {
31
32class NodeManager;
34class CVC4_PUBLIC Expr;
35class TypeNode;
36struct CVC4_PUBLIC ExprManagerMapCollection;
37
38class CVC4_PUBLIC SmtEngine;
39
40class CVC4_PUBLIC Datatype;
41class CVC4_PUBLIC Record;
42
43template <bool ref_count>
44class NodeTemplate;
45
46class BooleanType;
47class IntegerType;
48class RealType;
49class StringType;
50class BitVectorType;
51class ArrayType;
52class SetType;
53class DatatypeType;
54class ConstructorType;
55class SelectorType;
56class TesterType;
57class FunctionType;
58class TupleType;
59class RecordType;
60class SExprType;
61class SortType;
62class SortConstructorType;
63// not in release 1.0
64//class PredicateSubtype;
65class SubrangeType;
66class Type;
67
71 size_t operator()(const CVC4::Type& t) const;
72};/* struct TypeHashFunction */
73
80std::ostream& operator<<(std::ostream& out, const Type& t) CVC4_PUBLIC;
81
82namespace expr {
83 TypeNode exportTypeInternal(TypeNode n, NodeManager* from, NodeManager* nm, ExprManagerMapCollection& vmap);
84}/* CVC4::expr namespace */
85
90
91 friend class SmtEngine;
92 friend class ExprManager;
93 friend class NodeManager;
94 friend class TypeNode;
95 friend std::ostream& CVC4::operator<<(std::ostream& out, const Type& t);
96 friend TypeNode expr::exportTypeInternal(TypeNode n, NodeManager* from, NodeManager* nm, ExprManagerMapCollection& vmap);
97
98protected:
99
101 TypeNode* d_typeNode;
102
104 NodeManager* d_nodeManager;
105
111 Type makeType(const TypeNode& typeNode) const;
112
118 Type(NodeManager* em, TypeNode* typeNode);
119
121 static TypeNode* getTypeNode(const Type& t) throw() { return t.d_typeNode; }
122
123public:
124
126 virtual ~Type();
127
130
135 Type(const Type& t);
136
141 bool isNull() const;
142
147
151 bool isWellFounded() const;
152
158
162 bool isSubtypeOf(Type t) const;
163
168 bool isComparableTo(Type t) const;
169
174
178 Type substitute(const Type& type, const Type& replacement) const;
179
183 Type substitute(const std::vector<Type>& types,
184 const std::vector<Type>& replacements) const;
185
190
195
201 Type& operator=(const Type& t);
202
208 bool operator==(const Type& t) const;
209
215 bool operator!=(const Type& t) const;
216
220 bool operator<(const Type& t) const;
221
225 bool operator<=(const Type& t) const;
226
230 bool operator>(const Type& t) const;
231
235 bool operator>=(const Type& t) const;
236
241 bool isBoolean() const;
242
247 bool isInteger() const;
248
253 bool isReal() const;
254
259 bool isString() const;
260
265 bool isBitVector() const;
266
271 bool isFunction() const;
272
278 bool isPredicate() const;
279
284 bool isTuple() const;
285
290 bool isRecord() const;
291
296 bool isSExpr() const;
297
302 bool isArray() const;
303
308 bool isSet() const;
309
314 bool isDatatype() const;
315
320 bool isConstructor() const;
321
326 bool isSelector() const;
327
332 bool isTester() const;
333
338 bool isSort() const;
339
344 bool isSortConstructor() const;
345
350 // not in release 1.0
351 //bool isPredicateSubtype() const;
352
357 bool isSubrange() const;
358
363 void toStream(std::ostream& out) const;
364
368 std::string toString() const;
369};/* class Type */
370
375
376public:
377
380};/* class BooleanType */
381
386
387public:
388
391};/* class IntegerType */
392
396class CVC4_PUBLIC RealType : public Type {
397
398public:
399
402};/* class RealType */
403
408
409public:
410
413};/* class StringType */
414
419
420public:
421
424
426 size_t getArity() const;
427
429 std::vector<Type> getArgTypes() const;
430
432 Type getRangeType() const;
433};/* class FunctionType */
434
438class CVC4_PUBLIC TupleType : public Type {
439
440public:
441
444
446 size_t getLength() const;
447
449 std::vector<Type> getTypes() const;
450
451};/* class TupleType */
452
457
458public:
459
462
464 const Record& getRecord() const;
465};/* class RecordType */
466
470class CVC4_PUBLIC SExprType : public Type {
471
472public:
473
476
478 std::vector<Type> getTypes() const;
479};/* class SExprType */
480
484class CVC4_PUBLIC ArrayType : public Type {
485
486public:
487
490
492 Type getIndexType() const;
493
495 Type getConstituentType() const;
496};/* class ArrayType */
497
501class CVC4_PUBLIC SetType : public Type {
502
503public:
504
506 SetType(const Type& type = Type()) throw(IllegalArgumentException);
507
509 Type getElementType() const;
510};/* class SetType */
511
515class CVC4_PUBLIC SortType : public Type {
516
517public:
518
521
523 std::string getName() const;
524
526 bool isParameterized() const;
527
529 std::vector<Type> getParamTypes() const;
530
531};/* class SortType */
532
537
538public:
539
542
544 std::string getName() const;
545
547 size_t getArity() const;
548
550 SortType instantiate(const std::vector<Type>& params) const;
551
552};/* class SortConstructorType */
553
554// not in release 1.0
555#if 0
559class CVC4_PUBLIC PredicateSubtype : public Type {
560
561public:
562
564 PredicateSubtype(const Type& type = Type()) throw(IllegalArgumentException);
565
567 Expr getPredicate() const;
568
573 Type getParentType() const;
574
575};/* class PredicateSubtype */
576#endif /* 0 */
577
582
583public:
584
587
589 SubrangeBounds getSubrangeBounds() const;
590
591};/* class SubrangeType */
592
597
598public:
599
602
607 unsigned getSize() const;
608
609};/* class BitVectorType */
610
611
616
617public:
618
621
623 const Datatype& getDatatype() const;
624
626 bool isParametric() const;
627
632 Expr getConstructor(std::string name) const;
633
640 bool isInstantiated() const;
641
645 bool isParameterInstantiated(unsigned n) const;
646
648 std::vector<Type> getParamTypes() const;
649
651 size_t getArity() const;
652
654 DatatypeType instantiate(const std::vector<Type>& params) const;
655
656};/* class DatatypeType */
657
662
663public:
664
667
669 DatatypeType getRangeType() const;
670
672 std::vector<Type> getArgTypes() const;
673
675 size_t getArity() const;
676
677};/* class ConstructorType */
678
679
684
685public:
686
689
691 DatatypeType getDomain() const;
692
694 Type getRangeType() const;
695
696};/* class SelectorType */
697
702
703public:
704
707
709 DatatypeType getDomain() const;
710
715 BooleanType getRangeType() const;
716
717};/* class TesterType */
718
719}/* CVC4 namespace */
720
721#endif /* __CVC4__TYPE_H */
void * Expr
void * Type
void * ExprManager
Representation of cardinality.
Class encapsulating an array type.
Definition type.h:484
ArrayType(const Type &type=Type())
Construct from the base type.
Class encapsulating the bit-vector type.
Definition type.h:596
BitVectorType(const Type &type=Type())
Construct from the base type.
Singleton class encapsulating the Boolean type.
Definition type.h:374
BooleanType(const Type &type=Type())
Construct from the base type.
A simple representation of a cardinality.
Definition cardinality.h:65
Class encapsulating the constructor type.
Definition type.h:661
ConstructorType(const Type &type=Type())
Construct from the base type.
Class encapsulating the datatype type.
Definition type.h:615
DatatypeType(const Type &type=Type())
Construct from the base type.
The representation of an inductive datatype.
Definition datatype.h:423
Class encapsulating CVC4 expressions and methods for constructing new expressions.
Definition expr.h:227
Class encapsulating a function type.
Definition type.h:418
FunctionType(const Type &type=Type())
Construct from the base type.
Singleton class encapsulating the integer type.
Definition type.h:385
IntegerType(const Type &type=Type())
Construct from the base type.
Singleton class encapsulating the real type.
Definition type.h:396
RealType(const Type &type=Type())
Construct from the base type.
Class encapsulating a record type.
Definition type.h:456
RecordType(const Type &type=Type())
Construct from the base type.
Class encapsulating a tuple type.
Definition type.h:470
SExprType(const Type &type=Type())
Construct from the base type.
Class encapsulating the Selector type.
Definition type.h:683
SelectorType(const Type &type=Type())
Construct from the base type.
Class encapsulating an set type.
Definition type.h:501
SetType(const Type &type=Type())
Construct from the base type.
Class encapsulating a user-defined sort constructor.
Definition type.h:536
SortConstructorType(const Type &type=Type())
Construct from the base type.
Class encapsulating a user-defined sort.
Definition type.h:515
SortType(const Type &type=Type())
Construct from the base type.
Singleton class encapsulating the string type.
Definition type.h:407
StringType(const Type &type)
Construct from the base type.
Class encapsulating an integer subrange type.
Definition type.h:581
SubrangeType(const Type &type=Type())
Construct from the base type.
Class encapsulating the Tester type.
Definition type.h:701
TesterType(const Type &type=Type())
Construct from the base type.
Class encapsulating a tuple type.
Definition type.h:438
TupleType(const Type &type=Type())
Construct from the base type.
Class encapsulating CVC4 expression types.
Definition type.h:89
Cardinality getCardinality() const
Return the cardinality of this type.
bool operator>(const Type &t) const
An ordering on Types so they can be stored in maps, etc.
ExprManager * getExprManager() const
Get this type's ExprManager.
Type()
Default constructor.
bool isTuple() const
Is this a tuple type?
Type getBaseType() const
Get the most general base type of this type.
bool isSubtypeOf(Type t) const
Is this type a subtype of the given type?
bool isWellFounded() const
Is this a well-founded type?
bool isTester() const
Is this a tester type?
Type substitute(const Type &type, const Type &replacement) const
Substitution of Types.
bool isSet() const
Is this a Set type?
bool isReal() const
Is this the real type?
bool isArray() const
Is this an array type?
bool isBitVector() const
Is this the bit-vector type?
bool isInteger() const
Is this the integer type?
bool operator<=(const Type &t) const
An ordering on Types so they can be stored in maps, etc.
bool isNull() const
Check whether this is a null type.
bool isDatatype() const
Is this a datatype type?
bool operator!=(const Type &t) const
Comparison for structural disequality.
Type substitute(const std::vector< Type > &types, const std::vector< Type > &replacements) const
Simultaneous substitution of Types.
bool operator>=(const Type &t) const
An ordering on Types so they can be stored in maps, etc.
bool isSortConstructor() const
Is this a sort constructor kind?
bool operator==(const Type &t) const
Comparison for structural equality.
static TypeNode * getTypeNode(const Type &t)
Accessor for derived classes.
Definition type.h:121
bool isSelector() const
Is this a selector type?
NodeManager * d_nodeManager
The responsible expression manager.
Definition type.h:104
bool isSubrange() const
Is this a predicate subtype?
bool operator<(const Type &t) const
An ordering on Types so they can be stored in maps, etc.
Type(const Type &t)
Copy constructor.
void toStream(std::ostream &out) const
Outputs a string representation of this type to the stream.
bool isFunction() const
Is this a function type?
bool isRecord() const
Is this a record type?
bool isComparableTo(Type t) const
Is this type comparable to the given type (i.e., do they share a common ancestor in the subtype tree)...
bool isSExpr() const
Is this a symbolic expression type?
bool isString() const
Is this the string type?
bool isPredicate() const
Is this a predicate type, i.e.
Type & operator=(const Type &t)
Assignment operator.
std::string toString() const
Constructs a string representation of this type.
Type makeType(const TypeNode &typeNode) const
Construct a new type given the typeNode, for internal use only.
virtual ~Type()
Force a virtual destructor for safety.
bool isSort() const
Is this a sort kind?
bool isBoolean() const
Is this the Boolean type?
Expr mkGroundTerm() const
Construct and return a ground term for this Type.
Type exportTo(ExprManager *exprManager, ExprManagerMapCollection &vmap) const
Exports this type into a different ExprManager.
bool isConstructor() const
Is this a constructor type?
Type(NodeManager *em, TypeNode *typeNode)
Constructor for internal purposes.
TypeNode * d_typeNode
The internal expression representation.
Definition type.h:101
Macros that should be defined everywhere during the building of the libraries and driver binary,...
#define CVC4_PUBLIC
Definition cvc4_public.h:30
TypeNode exportTypeInternal(TypeNode n, NodeManager *from, NodeManager *nm, ExprManagerMapCollection &vmap)
Definition expr.h:106
std::ostream & operator<<(std::ostream &out, const TypeCheckingException &e)
STL namespace.
Hash function for Types.
Definition type.h:69
size_t operator()(const CVC4::Type &t) const
Return a hash code for type t.
Representation of subrange bounds.