summaryrefslogtreecommitdiff
path: root/src/theory/strings/theory_strings_preprocess.h
blob: a947c6da69225f7fb75ed2cc69c9f46cf47a70a2 (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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/*********************                                                        */
/*! \file theory_strings_preprocess.h
 ** \verbatim
 ** Top contributors (to current version):
 **   Andrew Reynolds, Tianyi Liang, Mathias Preiner
 ** This file is part of the CVC4 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.\endverbatim
 **
 ** \brief Strings Preprocess
 **
 ** Strings Preprocess.
 **/

#include "cvc4_private.h"

#ifndef CVC4__THEORY__STRINGS__PREPROCESS_H
#define CVC4__THEORY__STRINGS__PREPROCESS_H

#include <vector>
#include "context/cdhashmap.h"
#include "theory/rewriter.h"
#include "theory/strings/sequences_stats.h"
#include "theory/strings/skolem_cache.h"
#include "theory/theory.h"
#include "util/hash.h"

namespace CVC4 {
namespace theory {
namespace strings {

/** Strings preprocessor
 *
 * This class is responsible for extended function reductions. It is used as
 * a preprocessor when --no-strings-lazy-pp is enabled. By default, it is
 * used for reducing extended functions on-demand during the "extended function
 * reductions" inference schema of TheoryStrings.
 */
class StringsPreprocess {
 public:
  StringsPreprocess(SkolemCache* sc,
                    IntegralHistogramStat<Kind>* statReductions = nullptr);
  ~StringsPreprocess();
  /** The reduce routine
   *
   * This is the main routine for constructing the reduction lemma for
   * an extended function t. It returns the simplified form of t, as well
   * as assertions for t, interpeted conjunctively.  The reduction lemma
   * for t is:
   *   asserts[0] ^ ... ^ asserts[n] ^ t = t'
   * where t' is the term returned by this method.
   * The argument sc defines the methods for generating new Skolem variables.
   * The return value is t itself if it is not reduced by this class.
   *
   * The reduction lemma for t is a way of specifying the complete semantics
   * of t. In other words, any model satisfying the reduction lemma of t
   * correctly interprets t.
   *
   * @param t The node to reduce,
   * @param asserts The vector for storing the assertions that correspond to
   * the reduction of t,
   * @param sc The skolem cache for generating new variables,
   * @return The reduced form of t.
   */
  static Node reduce(Node t, std::vector<Node>& asserts, SkolemCache* sc);
  /**
   * Calls the above method for the skolem cache owned by this class, and
   * records statistics.
   */
  Node simplify(Node t, std::vector<Node>& asserts);
  /**
   * Applies simplifyRec on t until a fixed point is reached, and returns
   * the resulting term t', which is such that
   *   (exists k) asserts => t = t'
   * is valid, where k are the free skolems introduced when constructing
   * asserts.
   */
  Node processAssertion(Node t, std::vector<Node>& asserts);

 private:
  /** pointer to the skolem cache used by this class */
  SkolemCache* d_sc;
  /** Reference to the statistics for the theory of strings/sequences. */
  IntegralHistogramStat<Kind>* d_statReductions;
  /** visited cache */
  std::map<Node, Node> d_visited;
  /**
   * Applies simplify to all top-level extended function subterms of t. New
   * assertions created in this reduction are added to asserts. The argument
   * visited stores a cache of previous results.
   */
  Node simplifyRec(Node t, std::vector<Node>& asserts);
  /**
   * Make internal quantified formula with bound variable list bvl and body.
   * Internally, we get a node corresponding to marking a quantified formula as
   * an "internal" one. This node is provided as the third argument of the
   * FORALL returned by this method. This ensures that E-matching is not applied
   * to the quantified formula.
   */
  static Node mkForallInternal(Node bvl, Node body);
};

}/* CVC4::theory::strings namespace */
}/* CVC4::theory namespace */
}/* CVC4 namespace */

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