GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/theory/sets/skolem_cache.h Lines: 1 1 100.0 %
Date: 2021-11-07 Branches: 0 0 0.0 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Andrew Reynolds
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
 * A cache of skolems for theory of sets.
14
 */
15
16
#include "cvc5_private.h"
17
18
#ifndef CVC5__THEORY__SETS__SKOLEM_CACHE_H
19
#define CVC5__THEORY__SETS__SKOLEM_CACHE_H
20
21
#include <map>
22
#include <unordered_set>
23
24
#include "expr/node.h"
25
26
namespace cvc5 {
27
namespace theory {
28
29
class Rewriter;
30
31
namespace sets {
32
33
/**
34
 * A cache of all set skolems generated by the TheorySets class. This
35
 * cache is used to ensure that duplicate skolems are not generated when
36
 * possible, and helps identify what skolems were allocated in the current run.
37
 */
38
15268
class SkolemCache
39
{
40
 public:
41
  SkolemCache(Rewriter* rr);
42
  /** Identifiers for skolem types
43
   *
44
   * The comments below document the properties of each skolem introduced by
45
   * inference in the sets solver, where by skolem we mean the fresh
46
   * set variable that witnesses each of "exists k".
47
   */
48
  enum SkolemId
49
  {
50
    // exists k. k = a
51
    SK_PURIFY,
52
    // a != b => exists k. ( k in a != k in b )
53
    SK_DISEQUAL,
54
    // a in tclosure(b) => exists k1 k2. ( a.1, k1 ) in b ^ ( k2, a.2 ) in b ^
55
    //                                   ( k1 = k2 V ( k1, k2 ) in tclosure(b) )
56
    SK_TCLOSURE_DOWN1,
57
    SK_TCLOSURE_DOWN2,
58
    // (a,b) in join(A,B) => exists k. (a,k) in A ^ (k,b) in B
59
    // This is cached by the nodes corresponding to (a,b) and join(A,B).
60
    SK_JOIN,
61
  };
62
63
  /**
64
   * Makes a skolem of type tn that is cached based on the key (a,b,id).
65
   * Argument c is the variable name of the skolem.
66
   */
67
  Node mkTypedSkolemCached(
68
      TypeNode tn, Node a, Node b, SkolemId id, const char* c);
69
  /** same as above, cached based on key (a,null,id) */
70
  Node mkTypedSkolemCached(TypeNode tn, Node a, SkolemId id, const char* c);
71
  /** Same as above, but without caching. */
72
  Node mkTypedSkolem(TypeNode tn, const char* c);
73
  /** Returns true if n is a skolem allocated by this class */
74
  bool isSkolem(Node n) const;
75
76
 private:
77
  /** map from node pairs and identifiers to skolems */
78
  std::map<Node, std::map<Node, std::map<SkolemId, Node> > > d_skolemCache;
79
  /** the set of all skolems we have generated */
80
  std::unordered_set<Node> d_allSkolems;
81
  /** the optional rewriter */
82
  Rewriter* d_rewriter;
83
};
84
85
}  // namespace sets
86
}  // namespace theory
87
}  // namespace cvc5
88
89
#endif /* CVC5__THEORY__STRINGS__SKOLEM_CACHE_H */