GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/decision/decision_engine.h Lines: 4 5 80.0 %
Date: 2021-11-07 Branches: 0 0 0.0 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Kshitij Bansal, Andrew Reynolds, Aina Niemetz
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
 * Decision engine.
14
 */
15
16
#include "cvc5_private.h"
17
18
#ifndef CVC5__DECISION__DECISION_ENGINE_H
19
#define CVC5__DECISION__DECISION_ENGINE_H
20
21
#include "expr/node.h"
22
#include "prop/cnf_stream.h"
23
#include "prop/sat_solver.h"
24
#include "prop/sat_solver_types.h"
25
#include "smt/env_obj.h"
26
27
namespace cvc5 {
28
namespace decision {
29
30
class DecisionEngine : protected EnvObj
31
{
32
 public:
33
  /** Constructor */
34
  DecisionEngine(Env& env);
35
15335
  virtual ~DecisionEngine() {}
36
37
  /** Finish initialize */
38
  void finishInit(prop::CDCLTSatSolverInterface* ss, prop::CnfStream* cs);
39
40
  /** Presolve, called at the beginning of each check-sat call */
41
5852
  virtual void presolve() {}
42
43
  /**
44
   * Gets the next decision based on strategies that are enabled. This sets
45
   * stopSearch to true if no further SAT variables need to be assigned in
46
   * this SAT context.
47
   */
48
  prop::SatLiteral getNext(bool& stopSearch);
49
50
  /** Is the DecisionEngine in a state where it has solved everything? */
51
  virtual bool isDone() = 0;
52
53
  /**
54
   * Notify this class that assertion is an (input) assertion, not corresponding
55
   * to a skolem definition.
56
   */
57
  virtual void addAssertion(TNode assertion, bool isLemma) = 0;
58
  /**
59
   * Notify this class that lem is the skolem definition for skolem, which is
60
   * a part of the current assertions.
61
   */
62
  virtual void addSkolemDefinition(TNode lem, TNode skolem, bool isLemma) = 0;
63
  /**
64
   * Notify this class that the list of lemmas defs are now active in the
65
   * current SAT context.
66
   */
67
  virtual void notifyActiveSkolemDefs(std::vector<TNode>& defs) {}
68
  /**
69
   * Track active skolem defs, whether we need to call the above method
70
   * when appropriate.
71
   */
72
2586
  virtual bool needsActiveSkolemDefs() const { return false; }
73
74
 protected:
75
  /** Get next internal, the engine-specific implementation of getNext */
76
  virtual prop::SatLiteral getNextInternal(bool& stopSearch) = 0;
77
  /** Pointer to the SAT context */
78
  context::Context* d_context;
79
  /** Pointer to resource manager for associated SolverEngine */
80
  ResourceManager* d_resourceManager;
81
  /** Pointer to the CNF stream */
82
  prop::CnfStream* d_cnfStream;
83
  /** Pointer to the SAT solver */
84
  prop::CDCLTSatSolverInterface* d_satSolver;
85
};
86
87
/**
88
 * Instance of the above class which does nothing. This is used when
89
 * the decision mode is set to internal.
90
 */
91
5158
class DecisionEngineEmpty : public DecisionEngine
92
{
93
 public:
94
  DecisionEngineEmpty(Env& env);
95
  bool isDone() override;
96
  void addAssertion(TNode assertion, bool isLemma) override;
97
  void addSkolemDefinition(TNode lem, TNode skolem, bool isLemma) override;
98
99
 protected:
100
  prop::SatLiteral getNextInternal(bool& stopSearch) override;
101
};
102
103
}  // namespace decision
104
}  // namespace cvc5
105
106
#endif /* CVC5__DECISION__DECISION_ENGINE_H */