GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/theory/type_set.h Lines: 4 4 100.0 %
Date: 2021-08-01 Branches: 0 0 0.0 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Andrew Reynolds, Mathias Preiner
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
 * Type set class.
14
 */
15
16
#include "cvc5_private.h"
17
18
#ifndef CVC5__THEORY__TYPE_SET_H
19
#define CVC5__THEORY__TYPE_SET_H
20
21
#include <unordered_map>
22
#include <unordered_set>
23
24
#include "theory/type_enumerator.h"
25
26
namespace cvc5 {
27
namespace theory {
28
29
/* Type set
30
 *
31
 * This class encapsulates a map from types to sets of nodes.
32
 */
33
class TypeSet
34
{
35
 public:
36
  typedef std::unordered_map<TypeNode, std::set<Node>*> TypeSetMap;
37
  typedef std::unordered_map<TypeNode, TypeEnumerator*> TypeToTypeEnumMap;
38
  typedef TypeSetMap::iterator iterator;
39
  typedef TypeSetMap::const_iterator const_iterator;
40
41
 public:
42
54856
  TypeSet() : d_tep(NULL) {}
43
  ~TypeSet();
44
  /** set the properties of the type set
45
   *
46
   * These indicate information such as finite bounds
47
   * on the number of unique uninterpreted constants that can be
48
   * enumerated by this class.
49
   */
50
  void setTypeEnumeratorProperties(TypeEnumeratorProperties* tep);
51
  /** add node n to the set of values of t */
52
  void add(TypeNode t, TNode n);
53
  /** get the set of values of type t */
54
  std::set<Node>* getSet(TypeNode t) const;
55
  /** get the next enumerated term of type t
56
   *
57
   * useBaseType is whether
58
   */
59
  Node nextTypeEnum(TypeNode t, bool useBaseType = false);
60
61
  bool empty() { return d_typeSet.empty(); }
62
33030
  iterator begin() { return d_typeSet.begin(); }
63
58191
  iterator end() { return d_typeSet.end(); }
64
  static TypeNode getType(iterator it) { return (*it).first; }
65
25161
  static std::set<Node>& getSet(iterator it) { return *(*it).second; }
66
 private:
67
  /** sets of values for each type */
68
  TypeSetMap d_typeSet;
69
  /** type enumerators for each type */
70
  TypeToTypeEnumMap d_teMap;
71
  /** pointer the type enumerator properties for this class. */
72
  TypeEnumeratorProperties* d_tep;
73
74
  /* add all sub-terms of n to the sets of this class
75
   *
76
   * If topLevel is true, then we add strict subterms only.
77
   *
78
   * Note that recursive traversal here is over enumerated expressions
79
   * (very low expression depth).
80
   */
81
  void addSubTerms(TNode n,
82
                   std::unordered_set<TNode>& visited,
83
                   bool topLevel = true);
84
}; /* class TypeSet */
85
86
}  // namespace theory
87
}  // namespace cvc5
88
89
#endif /* CVC5__THEORY__TYPE_SET_H */