GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/decision/decision_engine.h Lines: 4 4 100.0 %
Date: 2021-08-01 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
26
namespace cvc5 {
27
namespace decision {
28
29
class DecisionEngine
30
{
31
 public:
32
  /** Constructor */
33
  DecisionEngine(context::Context* sc,
34
                 ResourceManager* rm);
35
9905
  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
5477
  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) = 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) = 0;
63
  /**
64
   * Notify this class that the literal n has been asserted, possibly
65
   * propagated by the SAT solver.
66
   */
67
5638057
  virtual void notifyAsserted(TNode n) {}
68
69
 protected:
70
  /** Get next internal, the engine-specific implementation of getNext */
71
  virtual prop::SatLiteral getNextInternal(bool& stopSearch) = 0;
72
  /** Pointer to the SAT context */
73
  context::Context* d_context;
74
  /** Pointer to resource manager for associated SmtEngine */
75
  ResourceManager* d_resourceManager;
76
  /** Pointer to the CNF stream */
77
  prop::CnfStream* d_cnfStream;
78
  /** Pointer to the SAT solver */
79
  prop::CDCLTSatSolverInterface* d_satSolver;
80
};
81
82
/**
83
 * Instance of the above class which does nothing. This is used when
84
 * the decision mode is set to internal.
85
 */
86
4356
class DecisionEngineEmpty : public DecisionEngine
87
{
88
 public:
89
  DecisionEngineEmpty(context::Context* sc, ResourceManager* rm);
90
  bool isDone() override;
91
  void addAssertion(TNode assertion) override;
92
  void addSkolemDefinition(TNode lem, TNode skolem) override;
93
94
 protected:
95
  prop::SatLiteral getNextInternal(bool& stopSearch) override;
96
};
97
98
}  // namespace decision
99
}  // namespace cvc5
100
101
#endif /* CVC5__DECISION__DECISION_ENGINE_H */