summaryrefslogtreecommitdiff
path: root/src/theory/theory_inference_manager.h
diff options
context:
space:
mode:
authorAndrew Reynolds <andrew.j.reynolds@gmail.com>2020-08-31 06:46:42 -0500
committerGitHub <noreply@github.com>2020-08-31 06:46:42 -0500
commitfc784f0273099b84581862b8587940c6db3459ed (patch)
treef8eb682b426b14f01d349983d0e40f2bcbfcb8b1 /src/theory/theory_inference_manager.h
parent0675545dde7ed679b7045a37470148c7e1bdfd25 (diff)
Basic proof support in inference manager (#4975)
This adds basic support for asserting internal facts with proofs in the inference manager class. The purpose of this PR is twofold: (1) From the point of view of proofs, this PR standardizes the management of proof equality engine within inference manager. Theories no longer have to manually construct proof equality engines, and instead are recommended to create inference managers. (2) From the point of view of the new approach to theory combination, this PR ensures standard theory callbacks (preNotifyFact / notifyFact) are used for internal facts, regardless of whether proofs are enabled. This will simplify several of the current (unmerged) changes for proof production in theory solvers on proof-new. Notice this PR adds the utility method NodeManager::mkAnd, which is arguably long overdue. Also notice this code is not yet active, but will be used on proof-new after this PR is merged.
Diffstat (limited to 'src/theory/theory_inference_manager.h')
-rw-r--r--src/theory/theory_inference_manager.h68
1 files changed, 67 insertions, 1 deletions
diff --git a/src/theory/theory_inference_manager.h b/src/theory/theory_inference_manager.h
index e52afe124..af8e817b4 100644
--- a/src/theory/theory_inference_manager.h
+++ b/src/theory/theory_inference_manager.h
@@ -17,11 +17,14 @@
#ifndef CVC4__THEORY__THEORY_INFERENCE_MANAGER_H
#define CVC4__THEORY__THEORY_INFERENCE_MANAGER_H
+#include <memory>
+
#include "context/cdhashset.h"
#include "expr/node.h"
#include "theory/output_channel.h"
#include "theory/theory_state.h"
#include "theory/trust_node.h"
+#include "theory/uf/proof_equality_engine.h"
namespace CVC4 {
@@ -51,6 +54,12 @@ class EqualityEngine;
* (with isInternal = true) whenever we assert internal facts using
* assertFactInernal below, mirroring what is done for facts from the fact
* queue (where isInternal = false).
+ *
+ * (3) The proof equality engine is used whenever proofs are enabled (when
+ * the proof node manager provided to this class is non-null). Notice this
+ * class automatically will construct a proof equality engine during
+ * setEqualityEngine, and use it for handling variants of assertInternalFact
+ * below that involve proofs.
*/
class TheoryInferenceManager
{
@@ -117,17 +126,72 @@ class TheoryInferenceManager
* output channel as a propagation or lemma. This method ensures that the
* Theory's preNotifyFact and notifyFact method have been called with
* isInternal = true.
+ *
+ * @param atom The atom of the fact to assert
+ * @param pol Its polarity
+ * @param exp Its explanation, i.e. ( exp => (~) atom ) is valid.
+ */
+ void assertInternalFact(TNode atom, bool pol, TNode exp);
+ /**
+ * Assert internal fact, with a proof step justification. Notice that if
+ * proofs are not enabled in this inference manager, then this asserts
+ * a fact to the equality engine in the normal way.
+ *
+ * @param atom The atom of the fact to assert
+ * @param pol Its polarity
+ * @param id The proof rule identifier of the proof step
+ * @param exp Its explanation, interpreted as a conjunction
+ * @param args The arguments of the proof step
*/
- void assertInternalFact(TNode atom, bool pol, TNode fact);
+ void assertInternalFact(TNode atom,
+ bool pol,
+ PfRule id,
+ const std::vector<Node>& exp,
+ const std::vector<Node>& args);
+ /**
+ * Assert internal fact, with a proof generator justification. Same as above,
+ * but with a proof generator instead of an explicit step.
+ *
+ * @param atom The atom of the fact to assert
+ * @param pol Its polarity
+ * @param exp Its explanation, interpreted as a conjunction
+ * @param pg The proof generator for this step. It must be the case that pf
+ * can provide a proof concluding (~) atom from free asumptions in exp in
+ * the remainder of the current SAT context.
+ */
+ void assertInternalFact(TNode atom,
+ bool pol,
+ const std::vector<Node>& exp,
+ ProofGenerator* pg);
protected:
/**
+ * Process internal fact. This is a common helper method for the
+ * assertInternalFact variants above.
+ */
+ void processInternalFact(TNode atom,
+ bool pol,
+ PfRule id,
+ const std::vector<Node>& exp,
+ const std::vector<Node>& args,
+ ProofGenerator* pg);
+ /**
* Explain conflict from constants merging in the equality engine. This
* method is called by conflictEqConstantMerge. By default, it returns
* the explanation of the official equality engine of the theory, if it
* exists.
*/
virtual TrustNode explainConflictEqConstantMerge(TNode a, TNode b);
+ /**
+ * Explain formula n (which is possibly a conjunction with no nested
+ * conjunctions), add its explanation to assumptions.
+ */
+ void explain(TNode n, std::vector<TNode>& assumptions);
+ /**
+ * Explain formula n (which is possibly a conjunction with no nested
+ * conjunctions), return the explanation as a conjunction.
+ */
+ Node mkExplain(TNode n);
/** The theory object */
Theory& d_theory;
/** Reference to the state of theory */
@@ -136,6 +200,8 @@ class TheoryInferenceManager
OutputChannel& d_out;
/** Pointer to equality engine of the theory. */
eq::EqualityEngine* d_ee;
+ /** A proof equality engine */
+ std::unique_ptr<eq::ProofEqEngine> d_pfee;
/** The proof node manager of the theory */
ProofNodeManager* d_pnm;
/**
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback