5f0af60a6387107564a0e96f8c0df52a721bb15c
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 * Entailment check class
16 #include "cvc5_private.h"
18 #ifndef CVC5__THEORY__QUANTIFIERS__ENTAILMENT_CHECK_H
19 #define CVC5__THEORY__QUANTIFIERS__ENTAILMENT_CHECK_H
24 #include "expr/node.h"
25 #include "smt/env_obj.h"
29 namespace quantifiers
{
31 class QuantifiersState
;
35 * Entailment check utility, which determines whether formulas are entailed
36 * in the current context. The main focus of this class is on UF formulas.
37 * It works by looking at the term argument trie data structures in term
38 * database. For details, see e.g. Section 4.1 of Reynolds et al TACAS 2018.
40 class EntailmentCheck
: protected EnvObj
43 EntailmentCheck(Env
& env
, QuantifiersState
& qs
, TermDb
& tdb
);
47 * Returns a term n' such that n = n' is entailed based on the equality
48 * information ee. This function may generate new terms. In particular,
49 * we typically rewrite subterms of n of maximal size to terms that exist in
50 * the equality engine specified by ee.
52 * useEntailmentTests is whether to call the theory engine's entailmentTest
53 * on literals n for which this call fails to find a term n' that is
54 * equivalent to n, for increased precision. This is not frequently used.
56 * The vector exp stores the explanation for why n evaluates to that term,
57 * that is, if this call returns a non-null node n', then:
60 * If reqHasTerm, then we require that the returned term is a Boolean
61 * combination of terms that exist in the equality engine used by this call.
62 * If no such term is constructable, this call returns null. The motivation
63 * for setting this to true is to "fail fast" if we require the return value
64 * of this function to only involve existing terms. This is used e.g. in
65 * the "propagating instances" portion of conflict-based instantiation
66 * (quant_conflict_find.h).
68 Node
evaluateTerm(TNode n
,
69 std::vector
<Node
>& exp
,
70 bool useEntailmentTests
= false,
71 bool reqHasTerm
= false);
72 /** same as above, without exp */
73 Node
evaluateTerm(TNode n
,
74 bool useEntailmentTests
= false,
75 bool reqHasTerm
= false);
78 * If possible, returns a term n' such that:
79 * (1) n' exists in the current equality engine (as specified by the state),
80 * (2) n = n' is entailed in the current context.
81 * It returns null if no such term can be found.
82 * Wrt evaluateTerm, this version does not construct new terms, and
83 * thus is less aggressive.
85 TNode
getEntailedTerm(TNode n
);
88 * If possible, returns a term n' such that:
89 * (1) n' exists in the current equality engine (as specified by the state),
90 * (2) n * subs = n' is entailed in the current context, where * denotes
91 * substitution application.
92 * It returns null if no such term can be found.
93 * subsRep is whether the substitution maps to terms that are representatives
94 * according to the quantifiers state.
95 * Wrt evaluateTerm, this version does not construct new terms, and
96 * thus is less aggressive.
98 TNode
getEntailedTerm(TNode n
, std::map
<TNode
, TNode
>& subs
, bool subsRep
);
100 * Checks whether the current context entails n with polarity pol, based on
101 * the equality information in the quantifiers state. Returns true if the
102 * entailment can be successfully shown.
104 bool isEntailed(TNode n
, bool pol
);
107 * Checks whether the current context entails ( n * subs ) with polarity pol,
108 * based on the equality information in the quantifiers state,
109 * where * denotes substitution application.
110 * subsRep is whether the substitution maps to terms that are representatives
111 * according to in the quantifiers state.
113 bool isEntailed(TNode n
,
114 std::map
<TNode
, TNode
>& subs
,
119 /** helper for evaluate term */
120 Node
evaluateTerm2(TNode n
,
121 std::map
<TNode
, Node
>& visited
,
122 std::vector
<Node
>& exp
,
123 bool useEntailmentTests
,
126 /** helper for get entailed term */
127 TNode
getEntailedTerm2(TNode n
,
128 std::map
<TNode
, TNode
>& subs
,
131 /** helper for is entailed */
132 bool isEntailed2(TNode n
,
133 std::map
<TNode
, TNode
>& subs
,
137 /** The quantifiers state object */
138 QuantifiersState
& d_qstate
;
139 /** Reference to the term database */
144 }; /* class EntailmentCheck */
146 } // namespace quantifiers
147 } // namespace theory
150 #endif /* CVC5__THEORY__QUANTIFIERS__ENTAILMENT_CHECK_H */