summaryrefslogtreecommitdiff
path: root/src/theory/quantifiers/quantifiers_preprocess.h
blob: 45b7ad07a538714199a04777d7906bd7481d4eb4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/******************************************************************************
 * Top contributors (to current version):
 *   Andrew Reynolds
 *
 * This file is part of the cvc5 project.
 *
 * Copyright (c) 2009-2021 by the authors listed in the file AUTHORS
 * in the top-level source directory and their institutional affiliations.
 * All rights reserved.  See the file COPYING in the top-level source
 * directory for licensing information.
 * ****************************************************************************
 *
 * Preprocessor for the theory of quantifiers.
 */

#include "cvc5_private.h"

#ifndef CVC5__THEORY__QUANTIFIERS__QUANTIFIERS_PREPROCESS_H
#define CVC5__THEORY__QUANTIFIERS__QUANTIFIERS_PREPROCESS_H

#include "proof/trust_node.h"
#include "smt/env_obj.h"

namespace cvc5 {
namespace theory {
namespace quantifiers {

/**
 * Module for doing preprocessing that is pertinent to quantifiers. These
 * operations cannot be done in the rewriter since e.g. preskolemization
 * depends on knowing the polarity of the position in which quantifiers occur.
 */
class QuantifiersPreprocess : protected EnvObj
{
 public:
  QuantifiersPreprocess(Env& env);
  /** preprocess
   *
   * This returns the result of applying simple quantifiers-specific
   * pre-processing to n, including but not limited to:
   * - pre-skolemization,
   * - aggressive prenexing.
   * The argument isInst is set to true if n is an instance of a previously
   * registered quantified formula. If this flag is true, we do not apply
   * certain steps like pre-skolemization since we know they will have no
   * effect.
   *
   * The result is wrapped in a trust node of kind TrustNodeKind::REWRITE.
   */
  TrustNode preprocess(Node n, bool isInst = false) const;

 private:
  using NodePolPairHashFunction = PairHashFunction<Node, bool, std::hash<Node>>;
  /**
   * Pre-skolemize quantifiers. Return the pre-skolemized form of n.
   *
   * @param n The formula to preskolemize.
   * @param polarity The polarity of n in the input.
   * @param fvs The free variables
   * @param visited Cache of visited (node, polarity) pairs.
   */
  Node preSkolemizeQuantifiers(
      Node n,
      bool polarity,
      std::vector<TNode>& fvs,
      std::unordered_map<std::pair<Node, bool>, Node, NodePolPairHashFunction>&
          visited) const;
  /**
   * Apply prenexing aggressively. Returns the prenex normal form of n.
   */
  Node computePrenexAgg(Node n, std::map<Node, Node>& visited) const;
};

}  // namespace quantifiers
}  // namespace theory
}  // namespace cvc5

#endif /* CVC5__THEORY__QUANTIFIERS__QUANTIFIERS_REWRITER_H */
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback