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