GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/theory/quantifiers/quantifiers_registry.h Lines: 1 1 100.0 %
Date: 2021-05-22 Branches: 0 0 0.0 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Andrew Reynolds, Morgan Deters
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
 * The quantifiers registry.
14
 */
15
16
#include "cvc5_private.h"
17
18
#ifndef CVC5__THEORY__QUANTIFIERS__QUANTIFIERS_REGISTRY_H
19
#define CVC5__THEORY__QUANTIFIERS__QUANTIFIERS_REGISTRY_H
20
21
#include "expr/node.h"
22
#include "theory/quantifiers/quant_bound_inference.h"
23
#include "theory/quantifiers/quant_util.h"
24
#include "theory/quantifiers/quantifiers_attributes.h"
25
26
namespace cvc5 {
27
namespace theory {
28
29
class QuantifiersModule;
30
31
namespace quantifiers {
32
33
class Instantiate;
34
35
/**
36
 * The quantifiers registry, which manages basic information about which
37
 * quantifiers modules have ownership of quantified formulas, and manages
38
 * the allocation of instantiation constants per quantified formula.
39
 */
40
class QuantifiersRegistry : public QuantifiersUtil
41
{
42
  friend class Instantiate;
43
44
 public:
45
  QuantifiersRegistry();
46
9460
  ~QuantifiersRegistry() {}
47
  /**
48
   * Register quantifier, which allocates the instantiation constants for q.
49
   */
50
  void registerQuantifier(Node q) override;
51
  /** reset */
52
  bool reset(Theory::Effort e) override;
53
  /** identify */
54
  std::string identify() const override;
55
  //----------------------------- ownership
56
  /** get the owner of quantified formula q */
57
  QuantifiersModule* getOwner(Node q) const;
58
  /**
59
   * Set owner of quantified formula q to module m with given priority. If
60
   * the quantified formula has previously been assigned an owner with
61
   * lower priority, that owner is overwritten.
62
   */
63
  void setOwner(Node q, QuantifiersModule* m, int32_t priority = 0);
64
  /**
65
   * Return true if module q has no owner registered or if its registered owner is m.
66
   */
67
  bool hasOwnership(Node q, QuantifiersModule* m) const;
68
  //----------------------------- end ownership
69
  //----------------------------- instantiation constants
70
  /** get the i^th instantiation constant of q */
71
  Node getInstantiationConstant(Node q, size_t i) const;
72
  /** get number of instantiation constants for q */
73
  size_t getNumInstantiationConstants(Node q) const;
74
  /** get the ce body q[e/x] */
75
  Node getInstConstantBody(Node q);
76
  /** returns node n with bound vars of q replaced by instantiation constants of
77
     q node n : is the future pattern node q : is the quantifier containing
78
     which bind the variable return a pattern where the variable are replaced by
79
     variable for instantiation.
80
   */
81
  Node substituteBoundVariablesToInstConstants(Node n, Node q);
82
  /** substitute { instantiation constants of q -> bound variables of q } in n
83
   */
84
  Node substituteInstConstantsToBoundVariables(Node n, Node q);
85
  /** substitute { variables of q -> terms } in n */
86
  Node substituteBoundVariables(Node n, Node q, std::vector<Node>& terms);
87
  /** substitute { instantiation constants of q -> terms } in n */
88
  Node substituteInstConstants(Node n, Node q, std::vector<Node>& terms);
89
  //----------------------------- end instantiation constants
90
  /** Get quantifiers attributes utility class */
91
  QuantAttributes& getQuantAttributes();
92
  /** Get quantifiers bound inference utility */
93
  QuantifiersBoundInference& getQuantifiersBoundInference();
94
  /**
95
   * Get quantifiers name, which returns a variable corresponding to the name of
96
   * quantified formula q if q has a name, or otherwise returns q itself.
97
   */
98
  Node getNameForQuant(Node q) const;
99
  /**
100
   * Get name for quantified formula. Returns true if q has a name or if req
101
   * is false. Sets name to the result of the above method.
102
   */
103
  bool getNameForQuant(Node q, Node& name, bool req = true) const;
104
105
 private:
106
  /**
107
   * Maps quantified formulas to the module that owns them, if any module has
108
   * specifically taken ownership of it.
109
   */
110
  std::map<Node, QuantifiersModule*> d_owner;
111
  /**
112
   * The priority value associated with the ownership of quantified formulas
113
   * in the domain of the above map, where higher values take higher
114
   * precendence.
115
   */
116
  std::map<Node, int32_t> d_owner_priority;
117
  /** map from universal quantifiers to the list of variables */
118
  std::map<Node, std::vector<Node> > d_vars;
119
  /** map from universal quantifiers to their inst constant body */
120
  std::map<Node, Node> d_inst_const_body;
121
  /** instantiation constants to universal quantifiers */
122
  std::map<Node, Node> d_inst_constants_map;
123
  /** map from universal quantifiers to the list of instantiation constants */
124
  std::map<Node, std::vector<Node> > d_inst_constants;
125
  /** The quantifiers attributes class */
126
  QuantAttributes d_quantAttr;
127
  /** The quantifiers bound inference class */
128
  QuantifiersBoundInference d_quantBoundInf;
129
};
130
131
}  // namespace quantifiers
132
}  // namespace theory
133
}  // namespace cvc5
134
135
#endif /* CVC5__THEORY__QUANTIFIERS__QUANTIFIERS_REGISTRY_H */