summaryrefslogtreecommitdiff
path: root/src/preprocessing/preprocessing_pass.h
blob: abb0a6dfe14a55be9e7f7728830e79ac6ae4d3d2 (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
/******************************************************************************
 * Top contributors (to current version):
 *   Justin Xu, Mathias Preiner, Gereon Kremer
 *
 * 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.
 * ****************************************************************************
 *
 * The preprocessing pass super class
 *
 * Implementation of the preprocessing pass super class. Preprocessing passes
 * that inherit from this class, need to pass their name to the constructor to
 * register the pass appropriately. The core of a preprocessing pass lives
 * in applyInternal(), which operates on a list of assertions and is called
 * from apply() in the super class. The apply() method automatically takes
 * care of the following:
 *
 * - Dumping assertions before and after the pass
 * - Initializing the timer
 * - Tracing and chatting
 *
 * Optionally, preprocessing passes can overwrite the initInteral() method to
 * do work that only needs to be done once.
 */

#include "cvc5_private.h"

#ifndef CVC5__PREPROCESSING__PREPROCESSING_PASS_H
#define CVC5__PREPROCESSING__PREPROCESSING_PASS_H

#include <string>

#include "util/statistics_registry.h"
#include "util/stats_timer.h"

namespace cvc5 {
namespace preprocessing {

class AssertionPipeline;
class PreprocessingPassContext;

/**
 * Preprocessing passes return a result which indicates whether a conflict has
 * been detected during preprocessing.
 */
enum PreprocessingPassResult { CONFLICT, NO_CONFLICT };

class PreprocessingPass {
 public:
  /* Preprocesses a list of assertions assertionsToPreprocess */
  PreprocessingPassResult apply(AssertionPipeline* assertionsToPreprocess);

  PreprocessingPass(PreprocessingPassContext* preprocContext,
                    const std::string& name);
  virtual ~PreprocessingPass();

 protected:
  /*
   * Method for dumping assertions within a pass. Also called before and after
   * applying the pass.
   */
  void dumpAssertions(const char* key, const AssertionPipeline& assertionList);

  /*
   * Abstract method that each pass implements to do the actual preprocessing.
   */
  virtual PreprocessingPassResult applyInternal(
      AssertionPipeline* assertionsToPreprocess) = 0;

  /* Context for Preprocessing Passes that initializes necessary variables */
  PreprocessingPassContext* d_preprocContext;

 private:
  /* Name of pass */
  std::string d_name;
  /* Timer for registering the preprocessing time of this pass */
  TimerStat d_timer;
};

}  // namespace preprocessing
}  // namespace cvc5

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