GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/theory/sets/theory_sets_rewriter.h Lines: 1 1 100.0 %
Date: 2021-09-07 Branches: 0 0 0.0 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Kshitij Bansal, Andrew Reynolds, Andres Noetzli
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
 * Sets theory rewriter.
14
 */
15
16
#include "cvc5_private.h"
17
18
#ifndef CVC5__THEORY__SETS__THEORY_SETS_REWRITER_H
19
#define CVC5__THEORY__SETS__THEORY_SETS_REWRITER_H
20
21
#include "theory/rewriter.h"
22
23
namespace cvc5 {
24
namespace theory {
25
namespace sets {
26
27
19849
class TheorySetsRewriter : public TheoryRewriter
28
{
29
 public:
30
  /**
31
   * Rewrite a node into the normal form for the theory of sets.
32
   * Called in post-order (really reverse-topological order) when
33
   * traversing the expression DAG during rewriting.  This is the
34
   * main function of the rewriter, and because of the ordering,
35
   * it can assume its children are all rewritten already.
36
   *
37
   * This function can return one of three rewrite response codes
38
   * along with the rewritten node:
39
   *
40
   *   REWRITE_DONE indicates that no more rewriting is needed.
41
   *   REWRITE_AGAIN means that the top-level expression should be
42
   *     rewritten again, but that its children are in final form.
43
   *   REWRITE_AGAIN_FULL means that the entire returned expression
44
   *     should be rewritten again (top-down with preRewrite(), then
45
   *     bottom-up with postRewrite()).
46
   *
47
   * Even if this function returns REWRITE_DONE, if the returned
48
   * expression belongs to a different theory, it will be fully
49
   * rewritten by that theory's rewriter.
50
   */
51
  RewriteResponse postRewrite(TNode node) override;
52
53
  /**
54
   * Rewrite a node into the normal form for the theory of sets
55
   * in pre-order (really topological order)---meaning that the
56
   * children may not be in the normal form.  This is an optimization
57
   * for theories with cancelling terms (e.g., 0 * (big-nasty-expression)
58
   * in arithmetic rewrites to 0 without the need to look at the big
59
   * nasty expression).  Since it's only an optimization, the
60
   * implementation here can do nothing.
61
   */
62
  RewriteResponse preRewrite(TNode node) override;
63
64
  /**
65
   * Rewrite an equality, in case special handling is required.
66
   */
67
  Node rewriteEquality(TNode equality)
68
  {
69
    // often this will suffice
70
    return postRewrite(equality).d_node;
71
  }
72
private:
73
  /**
74
   * Returns true if elementTerm is in setTerm, where both terms are constants.
75
   */
76
  bool checkConstantMembership(TNode elementTerm, TNode setTerm);
77
}; /* class TheorySetsRewriter */
78
79
}  // namespace sets
80
}  // namespace theory
81
}  // namespace cvc5
82
83
#endif /* CVC5__THEORY__SETS__THEORY_SETS_REWRITER_H */