1 /********************* */
4 ** Original author: Andrew Reynolds
5 ** Major contributors: Morgan Deters
6 ** Minor contributors (to current version): none
7 ** This file is part of the CVC4 project.
8 ** Copyright (c) 2009-2014 New York University and The University of Iowa
9 ** See the file COPYING in the top-level source directory for licensing
10 ** information.\endverbatim
12 ** \brief Representative set class and utilities
15 #include "cvc4_private.h"
17 #ifndef __CVC4__THEORY__REP_SET_H
18 #define __CVC4__THEORY__REP_SET_H
20 #include "expr/node.h"
26 class QuantifiersEngine
;
28 /** this class stores a representative set */
33 std::map
< TypeNode
, std::vector
< Node
> > d_type_reps
;
34 std::map
< TypeNode
, bool > d_type_complete
;
35 std::map
< Node
, int > d_tmap
;
39 bool hasType( TypeNode tn
) const { return d_type_reps
.find( tn
)!=d_type_reps
.end(); }
41 bool hasRep( TypeNode tn
, Node n
);
42 /** get cardinality for type */
43 int getNumRepresentatives( TypeNode tn
) const;
44 /** add representative for type */
45 void add( TypeNode tn
, Node n
);
46 /** returns index in d_type_reps for node n */
47 int getIndexFor( Node n
) const;
48 /** complete all values */
49 void complete( TypeNode t
);
51 void toStream(std::ostream
& out
);
54 //representative domain
55 typedef std::vector
< int > RepDomain
;
57 /** this class iterates over a RepSet */
58 class RepSetIterator
{
65 QuantifiersEngine
* d_qe
;
69 std::map
< int, Node
> d_lower_bounds
;
71 int domainSize( int i
);
72 //node this is rep set iterator is for
75 bool resetIndex( int i
, bool initial
= false );
76 /** set index order */
77 void setIndexOrder( std::vector
< int >& indexOrder
);
79 RepSetIterator( QuantifiersEngine
* qe
, RepSet
* rs
);
81 //set that this iterator will be iterating over instantiations for a quantifier
82 bool setQuantifier( Node f
);
83 //set that this iterator will be iterating over the domain of a function
84 bool setFunctionDomain( Node op
);
89 std::vector
< int > d_enum_type
;
90 //index we are considering
91 std::vector
< int > d_index
;
92 //types we are considering
93 std::vector
< TypeNode
> d_types
;
94 //domain we are considering
95 std::vector
< RepDomain
> d_domain
;
96 //are we only considering a strict subset of the domain of the quantifier?
98 //ordering for variables we are indexing over
99 // for example, given reps = { a, b } and quantifier forall( x, y, z ) P( x, y, z ) with d_index_order = { 2, 0, 1 },
100 // then we consider instantiations in this order:
106 std::vector
< int > d_index_order
;
107 //variables to index they are considered at
108 // for example, if d_index_order = { 2, 0, 1 }
109 // then d_var_order = { 0 -> 1, 1 -> 2, 2 -> 0 }
110 std::map
< int, int > d_var_order
;
112 std::map
< int, Node
> d_bounds
[2];
114 /** increment the iterator at index=counter */
115 int increment2( int counter
);
116 /** increment the iterator */
118 /** is the iterator finished? */
120 /** get the i_th term we are considering */
121 Node
getTerm( int i
);
122 /** get the number of terms we are considering */
123 int getNumTerms() { return (int)d_index_order
.size(); }
125 void debugPrint( const char* c
);
126 void debugPrintSmall( const char* c
);
127 };/* class RepSetIterator */
129 }/* CVC4::theory namespace */
130 }/* CVC4 namespace */
132 #endif /* __CVC4__THEORY__REP_SET_H */