9b3bdda07c6df0a29d55531da913dbff135528da
1 /******************************************************************************
2 * Top contributors (to current version):
5 * This file is part of the cvc5 project.
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 * ****************************************************************************
13 * Bitblaster used to bitblast to Boolean Nodes.
15 #include "cvc5_private.h"
17 #ifndef CVC5__THEORY__BV__BITBLAST_NODE_BITBLASTER_H
18 #define CVC5__THEORY__BV__BITBLAST_NODE_BITBLASTER_H
20 #include "theory/bv/bitblast/bitblaster.h"
27 * Implementation of a simple Node-based bit-blaster.
29 * Implements the bare minimum to bit-blast bit-vector atoms/terms.
31 class NodeBitblaster
: public TBitblaster
<Node
>
33 using Bits
= std::vector
<Node
>;
36 NodeBitblaster(TheoryState
* state
);
37 ~NodeBitblaster() = default;
39 /** Bit-blast term 'node' and return bit-blasted 'bits'. */
40 void bbTerm(TNode node
, Bits
& bits
) override
;
41 /** Bit-blast atom 'node'. */
42 void bbAtom(TNode node
) override
;
43 /** Get bit-blasted atom, returns 'atom' itself since it's Boolean. */
44 Node
getBBAtom(TNode atom
) const override
;
45 /** Store Boolean node representing the bit-blasted atom. */
46 void storeBBAtom(TNode atom
, Node atom_bb
) override
;
47 /** Store bits of bit-blasted term. */
48 void storeBBTerm(TNode node
, const Bits
& bits
) override
;
49 /** Check if atom was already bit-blasted. */
50 bool hasBBAtom(TNode atom
) const override
;
51 /** Get bit-blasted node stored for atom. */
52 Node
getStoredBBAtom(TNode node
);
53 /** Create 'bits' for variable 'var'. */
54 void makeVariable(TNode var
, Bits
& bits
) override
;
56 /** Add d_variables to termSet. */
57 void computeRelevantTerms(std::set
<Node
>& termSet
);
58 /** Collect model values for all relevant terms given in 'relevantTerms'. */
59 bool collectModelValues(TheoryModel
* m
, const std::set
<Node
>& relevantTerms
);
61 prop::SatSolver
* getSatSolver() override
{ Unreachable(); }
63 /** Checks whether node is a variable introduced via `makeVariable`.*/
64 bool isVariable(TNode node
);
67 /** Query SAT solver for assignment of node 'a'. */
68 Node
getModelFromSatSolver(TNode a
, bool fullModel
) override
;
70 /** Caches variables for which we already created bits. */
72 /** Stores bit-blasted atoms. */
73 std::unordered_map
<Node
, Node
> d_bbAtoms
;