GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/preprocessing/passes/foreign_theory_rewrite.h Lines: 2 2 100.0 %
Date: 2021-09-29 Branches: 0 0 0.0 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Yoni Zohar, Gereon Kremer
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 foreign_theory_rewrite preprocessing pass.
14
 *
15
 * Simplifies nodes of one theory using rewrites from another.
16
 */
17
18
#include "cvc5_private.h"
19
20
#ifndef CVC5__PREPROCESSING__PASSES__FOREIGN_THEORY_REWRITE_H
21
#define CVC5__PREPROCESSING__PASSES__FOREIGN_THEORY_REWRITE_H
22
23
#include "context/cdhashmap.h"
24
#include "expr/node.h"
25
#include "preprocessing/preprocessing_pass.h"
26
#include "smt/env_obj.h"
27
28
namespace cvc5 {
29
namespace preprocessing {
30
namespace passes {
31
32
using CDNodeMap = context::CDHashMap<Node, Node>;
33
34
6270
class ForeignTheoryRewriter : protected EnvObj
35
{
36
 public:
37
  ForeignTheoryRewriter(Env& env);
38
  /** the main function that simplifies n.
39
   * does a traversal on n and call rewriting fucntions.
40
   */
41
  Node simplify(Node n);
42
  /** A specific simplification function specific for GEQ
43
   * constraints in strings.
44
   */
45
  Node rewriteStringsGeq(Node n);
46
  /** invoke rewrite functions for n.
47
   * based on the structure of n (typically its kind)
48
   * we invoke rewrites from other theories.
49
   * For example: when encountering a `>=` node,
50
   * we invoke rewrites from the theory of strings.
51
   */
52
  Node foreignRewrite(Node n);
53
  /** construct a node with the same operator as originalNode whose children are
54
   * processedChildren
55
   */
56
  static Node reconstructNode(Node originalNode, std::vector<Node> newChildren);
57
  /** A cache to store the simplified nodes */
58
  CDNodeMap d_cache;
59
};
60
61
12536
class ForeignTheoryRewrite : public PreprocessingPass
62
{
63
 public:
64
  ForeignTheoryRewrite(PreprocessingPassContext* preprocContext);
65
66
 protected:
67
  PreprocessingPassResult applyInternal(
68
      AssertionPipeline* assertionsToPreprocess) override;
69
  /** Foreign theory rewriter */
70
  ForeignTheoryRewriter d_ftr;
71
};
72
73
}  // namespace passes
74
}  // namespace preprocessing
75
}  // namespace cvc5
76
77
#endif /* CVC5__PREPROCESSING__PASSES__FOREIGN_THEORY_REWRITE_H */