blob: 88f6001b917dc2231fcfd196cd92d085ff456e15 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
/********************* */
/*! \file scrutinize.h
** \verbatim
** Top contributors (to current version):
** Kshitij Bansal, Tim King
** This file is part of the CVC4 project.
** Copyright (c) 2009-2016 by the authors listed in the file AUTHORS
** in the top-level source directory) and their institutional affiliations.
** All rights reserved. See the file COPYING in the top-level source
** directory for licensing information.\endverbatim
**
** \brief Check consistency of internal data structures.
**
** Some checks are very low-level with respect to TheorySetsPrivate
** implementation, and hence might become outdated pretty quickly.
**/
#pragma once
#include "theory/sets/theory_sets.h"
#include "theory/sets/theory_sets_private.h"
namespace CVC4 {
namespace theory {
namespace sets {
class TheorySetsScrutinize {
/* we don't want to accidentally modify theory data */
const TheorySetsPrivate* d_theory;
public:
TheorySetsScrutinize(TheorySetsPrivate* theory): d_theory(theory) {
Debug("sets") << "[sets] scrunitize enabled" << std::endl;
}
void postCheckInvariants() const {
Debug("sets-scrutinize") << "[sets-scrutinize] postCheckInvariants()" << std::endl;
// assume not in conflict, and complete:
// - try building model
// - check it
TheorySetsPrivate::SettermElementsMap settermElementsMap;
TNode true_atom = NodeManager::currentNM()->mkConst<bool>(true);
std::set<Node> terms;
(d_theory->d_external).computeRelevantTerms(terms);
for(eq::EqClassIterator it_eqclasses(true_atom, &d_theory->d_equalityEngine);
! it_eqclasses.isFinished() ; ++it_eqclasses) {
TNode n = (*it_eqclasses);
if(n.getKind() == kind::MEMBER) {
Assert(d_theory->d_equalityEngine.areEqual(n, true_atom));
TNode x = d_theory->d_equalityEngine.getRepresentative(n[0]);
TNode S = d_theory->d_equalityEngine.getRepresentative(n[1]);
settermElementsMap[S].insert(x);
}
}
bool checkPassed = true;
for (std::set<Node>::const_iterator it = terms.begin(); it != terms.end(); it++){
TNode term = *it;
if( term.getType().isSet() ) {
checkPassed &= d_theory->checkModel(settermElementsMap, term);
}
}
if(Debug.isOn("sets-checkmodel-ignore")) {
Debug("sets-checkmodel-ignore") << "[sets-checkmodel-ignore] checkPassed value was " << checkPassed << std::endl;
} else {
Assert( checkPassed,
"THEORY_SETS check-model failed. Run with -d sets-model for details." );
}
}
};
}/* CVC4::theory::sets namespace */
}/* CVC4::theory namespace */
}/* CVC4 namespace */
|