summaryrefslogtreecommitdiff
path: root/src/theory/bv/bv_subtheory.h
blob: ed90e0ebeba74123a59365dab11aef0da74cecd0 (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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/*********************                                                        */
/*! \file bv_subtheory.h
 ** \verbatim
 ** Original author: lianah
 ** Major contributors: dejan
 ** Minor contributors (to current version): none
 ** This file is part of the CVC4 prototype.
 ** Copyright (c) 2009-2012  New York University and The University of Iowa
 ** See the file COPYING in the top-level source directory for licensing
 ** information.\endverbatim
 **
 ** \brief Algebraic solver. 
 **
 ** Algebraic solver.
 **/

#include "cvc4_private.h"

#ifndef __CVC4__THEORY__BV__BV_SUBTHEORY_H
#define __CVC4__THEORY__BV__BV_SUBTHEORY_H

#include "context/context.h"
#include "context/cdqueue.h"
#include "theory/uf/equality_engine.h"
#include "theory/theory.h"

namespace CVC4 {
namespace theory {

class TheoryModel;

namespace bv {

enum SubTheory {
  SUB_CORE = 1,
  SUB_BITBLAST = 2,
  SUB_INEQUALITY = 3
};

inline std::ostream& operator << (std::ostream& out, SubTheory subtheory) {
  switch (subtheory) {
  case SUB_BITBLAST:
    out << "BITBLASTER";
    break;
  case SUB_CORE:
    out << "BV_CORE_SUBTHEORY";
    break;
  case SUB_INEQUALITY:
    out << "BV_INEQUALITY_SUBTHEORY"; 
  default:
    Unreachable();
    break;
  }
  return out;
}


const bool d_useEqualityEngine = true;
const bool d_useSatPropagation = true;

// forward declaration 
class TheoryBV; 

typedef context::CDQueue<Node> AssertionQueue; 
/**
 * Abstract base class for bit-vector subtheory solvers
 *
 */
class SubtheorySolver {

protected:

  /** The context we are using */
  context::Context* d_context;

  /** The bit-vector theory */
  TheoryBV* d_bv;
  AssertionQueue d_assertionQueue;
  context::CDO<uint32_t>  d_assertionIndex;
public:
  
  SubtheorySolver(context::Context* c, TheoryBV* bv) :
    d_context(c),
    d_bv(bv),
    d_assertionQueue(c),
    d_assertionIndex(c, 0)
  {}
  virtual ~SubtheorySolver() {}
  virtual bool check(Theory::Effort e) = 0; 
  virtual void explain(TNode literal, std::vector<TNode>& assumptions) = 0;
  virtual void preRegister(TNode node) {}
  virtual void propagate(Theory::Effort e) {}
  virtual void collectModelInfo(TheoryModel* m) = 0;
  virtual Node getModelValue(TNode var) = 0; 
  virtual bool isComplete() = 0;
  virtual EqualityStatus getEqualityStatus(TNode a, TNode b) = 0;
  virtual void addSharedTerm(TNode node) {} 
  bool done() { return d_assertionQueue.size() == d_assertionIndex; }
  TNode get() {
    Assert (!done()); 
    TNode res = d_assertionQueue[d_assertionIndex];
    d_assertionIndex = d_assertionIndex + 1;
    return res; 
  }
  virtual void assertFact(TNode fact) { d_assertionQueue.push_back(fact); }
}; 

}
}
}

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