summaryrefslogtreecommitdiff
path: root/src/theory/strings/regexp_elim.h
blob: 5387548de073c6a7292915822e772898de7faba5 (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
79
80
81
82
83
84
85
86
87
88
89
90
/******************************************************************************
 * Top contributors (to current version):
 *   Andrew Reynolds, Mathias Preiner
 *
 * 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.
 * ****************************************************************************
 *
 * Techniques for eliminating regular expressions.
 */

#include "cvc5_private.h"
#ifndef CVC5__THEORY__STRINGS__REGEXP_ELIM_H
#define CVC5__THEORY__STRINGS__REGEXP_ELIM_H

#include "expr/node.h"
#include "theory/eager_proof_generator.h"
#include "theory/trust_node.h"

namespace cvc5 {
namespace theory {
namespace strings {

/** Regular expression membership elimination
 *
 * This class implements techniques for reducing regular expression memberships
 * to bounded integer quantifiers + extended function constraints.
 *
 * It is used by TheoryStrings during ppRewrite.
 */
class RegExpElimination
{
 public:
  /**
   * @param isAgg Whether aggressive eliminations are enabled
   * @param pnm The proof node manager to use (for proofs)
   * @param c The context to use (for proofs)
   */
  RegExpElimination(bool isAgg = false,
                    ProofNodeManager* pnm = nullptr,
                    context::Context* c = nullptr);
  /** eliminate membership
   *
   * This method takes as input a regular expression membership atom of the
   * form (str.in.re x R). If this method returns a non-null node ret, then ret
   * is equivalent to atom.
   *
   * @param atom The node to eliminate
   * @param isAgg Whether we apply aggressive elimination techniques
   * @return The node with regular expressions eliminated, or null if atom
   * was unchanged.
   */
  static Node eliminate(Node atom, bool isAgg);

  /**
   * Return the trust node corresponding to rewriting n based on eliminate
   * above.
   */
  TrustNode eliminateTrusted(Node atom);

 private:
  /** return elimination
   *
   * This method is called when atom is rewritten to atomElim, and returns
   * atomElim. id is an identifier indicating the reason for the elimination.
   */
  static Node returnElim(Node atom, Node atomElim, const char* id);
  /** elimination for regular expression concatenation */
  static Node eliminateConcat(Node atom, bool isAgg);
  /** elimination for regular expression star */
  static Node eliminateStar(Node atom, bool isAgg);
  /** Are proofs enabled? */
  bool isProofEnabled() const;
  /** Are aggressive eliminations enabled? */
  bool d_isAggressive;
  /** Pointer to the proof node manager */
  ProofNodeManager* d_pnm;
  /** An eager proof generator for storing proofs in eliminate trusted above */
  std::unique_ptr<EagerProofGenerator> d_epg;
}; /* class RegExpElimination */

}  // namespace strings
}  // namespace theory
}  // namespace cvc5

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