1 /********************* */
2 /*! \file bv_inverter.h
4 ** Top contributors (to current version):
6 ** This file is part of the CVC4 project.
7 ** Copyright (c) 2009-2017 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.\endverbatim
12 ** \brief inverse rules for bit-vector operators
15 #include "cvc4_private.h"
17 #ifndef __CVC4__BV_INVERTER_H
18 #define __CVC4__BV_INVERTER_H
21 #include <unordered_map>
22 #include <unordered_set>
25 #include "expr/node.h"
29 namespace quantifiers
{
33 * This is a virtual class for queries
34 * required by the BvInverter class.
41 /** returns the current model value of n */
42 virtual Node
getModelValue(Node n
) = 0;
43 /** returns a bound variable of type tn */
44 virtual Node
getBoundVariable(TypeNode tn
) = 0;
48 // TODO : move to theory/bv/ if generally useful?
54 /** get dummy fresh variable of type tn, used as argument for sv */
55 Node
getSolveVariable(TypeNode tn
);
57 /** Get path to pv in lit, replace that occurrence by sv and all others by
58 * pvs. If return value R is non-null, then : lit.path = pv R.path = sv
59 * R.path' = pvs for all lit.path' = pv, where path' != path
62 Node lit
, Node pv
, Node sv
, Node pvs
, std::vector
<unsigned>& path
);
65 * solve for sv in lit, where lit.path = sv
66 * status accumulates side conditions
68 Node
solveBvLit(Node sv
,
70 std::vector
<unsigned>& path
,
74 /** Dummy variables for each type */
75 std::map
<TypeNode
, Node
> d_solve_var
;
77 /** Helper function for getPathToPv */
78 Node
getPathToPv(Node lit
,
81 std::vector
<unsigned>& path
,
82 std::unordered_set
<TNode
, TNodeHashFunction
>& visited
);
84 /** Helper function for getInv.
86 * This expects a condition cond where:
88 * is a BV tautology where x is getSolveVariable( tn ).
90 * It returns a term of the form:
91 * (choice y. cond { x -> y })
92 * where y is a bound variable and x is getSolveVariable( tn ).
94 * In some cases, we may return a term t if cond implies an equality on
95 * the solve variable. For example, if cond is x = t where x is
96 * getSolveVariable(tn), then we return t instead of introducing the choice
99 Node
getInversionNode(Node cond
, TypeNode tn
, BvInverterQuery
* m
);
102 } // namespace quantifiers
103 } // namespace theory
106 #endif /* __CVC4__BV_INVERTER_H */