GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/preprocessing/passes/unconstrained_simplifier.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
 *   Clark Barrett, Andres Noetzli, Andrew Reynolds
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
 * Simplifications based on unconstrained variables
14
 *
15
 * This module implements a preprocessing phase which replaces certain
16
 * "unconstrained" expressions by variables.  Based on Roberto
17
 * Bruttomesso's PhD thesis.
18
 */
19
20
#include "cvc5_private.h"
21
22
#ifndef CVC5__PREPROCESSING_PASSES_UNCONSTRAINED_SIMPLIFIER_H
23
#define CVC5__PREPROCESSING_PASSES_UNCONSTRAINED_SIMPLIFIER_H
24
25
#include <unordered_map>
26
#include <unordered_set>
27
28
#include "expr/node.h"
29
#include "preprocessing/preprocessing_pass.h"
30
#include "theory/substitutions.h"
31
#include "util/statistics_stats.h"
32
33
namespace cvc5 {
34
namespace context {
35
class Context;
36
}
37
namespace preprocessing {
38
namespace passes {
39
40
19846
class UnconstrainedSimplifier : public PreprocessingPass
41
{
42
 public:
43
  UnconstrainedSimplifier(PreprocessingPassContext* preprocContext);
44
45
  PreprocessingPassResult applyInternal(
46
      AssertionPipeline* assertionsToPreprocess) override;
47
48
 private:
49
  /** number of expressions eliminated due to unconstrained simplification */
50
  IntStat d_numUnconstrainedElim;
51
52
  using TNodeCountMap = std::unordered_map<TNode, unsigned>;
53
  using TNodeMap = std::unordered_map<TNode, TNode>;
54
  using TNodeSet = std::unordered_set<TNode>;
55
56
  TNodeCountMap d_visited;
57
  TNodeMap d_visitedOnce;
58
  TNodeSet d_unconstrained;
59
60
  context::Context* d_context;
61
  theory::SubstitutionMap d_substitutions;
62
63
  /**
64
   * Visit all subterms in assertion. This method throws a LogicException if
65
   * there is a subterm that is unhandled by this preprocessing pass (e.g. a
66
   * quantified formula).
67
   */
68
  void visitAll(TNode assertion);
69
  Node newUnconstrainedVar(TypeNode t, TNode var);
70
  void processUnconstrained();
71
};
72
73
}  // namespace passes
74
}  // namespace preprocessing
75
}  // namespace cvc5
76
77
#endif