summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Reynolds <andrew.j.reynolds@gmail.com>2018-09-04 15:18:12 -0500
committerGitHub <noreply@github.com>2018-09-04 15:18:12 -0500
commita635120676d265b27fa7c49d86d16a3e6d96174e (patch)
tree978e5e4c8a688fde4a5b152937caea864bedba53
parentd367c9f9b299a15fb970d62df04d3df22b7ca08d (diff)
Minor improvements to theory model builder interface. (#2408)
-rw-r--r--src/theory/theory_engine.cpp11
-rw-r--r--src/theory/theory_model_builder.cpp24
-rw-r--r--src/theory/theory_model_builder.h18
3 files changed, 35 insertions, 18 deletions
diff --git a/src/theory/theory_engine.cpp b/src/theory/theory_engine.cpp
index d75f7843d..41ab45170 100644
--- a/src/theory/theory_engine.cpp
+++ b/src/theory/theory_engine.cpp
@@ -636,17 +636,12 @@ void TheoryEngine::check(Theory::Effort effort) {
AlwaysAssert(d_curr_model->isBuiltSuccess());
if (options::produceModels())
{
- // if we are incomplete, there is no guarantee on the model.
- // thus, we do not check the model here. (related to #1693)
- // we also don't debug-check the model if the checkModels()
- // is not enabled.
- if (!d_incomplete && options::checkModels())
- {
- d_curr_model_builder->debugCheckModel(d_curr_model);
- }
// Do post-processing of model from the theories (used for THEORY_SEP
// to construct heap model)
postProcessModel(d_curr_model);
+ // also call the model builder's post-process model
+ d_curr_model_builder->postProcessModel(d_incomplete.get(),
+ d_curr_model);
}
}
}
diff --git a/src/theory/theory_model_builder.cpp b/src/theory/theory_model_builder.cpp
index bcc4f7eaf..a9742b2ba 100644
--- a/src/theory/theory_model_builder.cpp
+++ b/src/theory/theory_model_builder.cpp
@@ -808,16 +808,30 @@ bool TheoryEngineModelBuilder::buildModel(Model* m)
{
return false;
}
- else
+
+ tm->d_modelBuiltSuccess = true;
+ return true;
+}
+
+void TheoryEngineModelBuilder::postProcessModel(bool incomplete, Model* m)
+{
+ // if we are incomplete, there is no guarantee on the model.
+ // thus, we do not check the model here. (related to #1693).
+ if (incomplete)
{
- tm->d_modelBuiltSuccess = true;
- return true;
+ return;
+ }
+ TheoryModel* tm = static_cast<TheoryModel*>(m);
+ Assert(tm != nullptr);
+ // debug-check the model if the checkModels() is enabled.
+ if (options::checkModels())
+ {
+ debugCheckModel(tm);
}
}
-void TheoryEngineModelBuilder::debugCheckModel(Model* m)
+void TheoryEngineModelBuilder::debugCheckModel(TheoryModel* tm)
{
- TheoryModel* tm = (TheoryModel*)m;
#ifdef CVC4_ASSERTIONS
Assert(tm->isBuilt());
eq::EqClassesIterator eqcs_i = eq::EqClassesIterator(tm->d_equalityEngine);
diff --git a/src/theory/theory_model_builder.h b/src/theory/theory_model_builder.h
index 68e8c6b49..bff230b5c 100644
--- a/src/theory/theory_model_builder.h
+++ b/src/theory/theory_model_builder.h
@@ -68,13 +68,14 @@ class TheoryEngineModelBuilder : public ModelBuilder
* are building fails to satisfy a quantified formula.
*/
bool buildModel(Model* m) override;
- /** Debug check model.
+
+ /** postprocess model
*
- * This throws an assertion failure if the model
- * contains an equivalence class with two terms t1 and t2
- * such that t1^M != t2^M.
+ * This is called when m is a model that will be returned to the user. This
+ * method checks the internal consistency of the model if we are in a debug
+ * build.
*/
- void debugCheckModel(Model* m);
+ void postProcessModel(bool incomplete, Model* m);
protected:
/** pointer to theory engine */
@@ -102,6 +103,13 @@ class TheoryEngineModelBuilder : public ModelBuilder
virtual void debugModel(TheoryModel* m) {}
//-----------------------------------end virtual functions
+ /** Debug check model.
+ *
+ * This throws an assertion failure if the model contains an equivalence
+ * class with two terms t1 and t2 such that t1^M != t2^M.
+ */
+ void debugCheckModel(TheoryModel* m);
+
/** is n assignable?
*
* A term n is assignable if its value
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback