Skip to content

Commit

Permalink
Merge pull request #584 from vprover/martin-fix-fmb
Browse files Browse the repository at this point in the history
Fixes several model printing bugs (and more)
  • Loading branch information
quickbeam123 authored Sep 2, 2024
2 parents e5a912c + 740f67a commit 2d67dfb
Show file tree
Hide file tree
Showing 44 changed files with 1,535 additions and 1,207 deletions.
2 changes: 2 additions & 0 deletions Debug/Assertion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ template <typename T>
catch (Exception& e) { e.cry(std::cout); ASSERTION_VIOLATION } \
catch (...) { ASSERTION_VIOLATION } \

#define RELEASE_CODE(X) {}
#define DEBUG_CODE(X) X
#define ALWAYS(Cond) ASS(Cond)
#define NEVER(Cond) ASS(!(Cond))
Expand Down Expand Up @@ -192,6 +193,7 @@ template <typename T>
}
#endif

#define RELEASE_CODE(X) X
#define DEBUG_CODE(X) {}

#define ASS(Cond) {}
Expand Down
11 changes: 5 additions & 6 deletions Debug/RuntimeStatistics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ using namespace std;

void RSMultiCounter::print(ostream& out)
{
out << name() << ":"<< endl;
out << "% " << name() << ":"<< endl;
for(size_t i=0;i<_counters.size();i++) {
if(_counters[i]) {
out << " " << i << ": " << _counters[i] <<endl;
Expand All @@ -45,7 +45,7 @@ RSMultiStatistic::~RSMultiStatistic()

void RSMultiStatistic::print(ostream& out)
{
out << name() << ":"<< endl;
out << "% " << name() << ":"<< endl;
for(size_t i=0;i<_values.size();i++) {
if(_values[i]) {

Expand All @@ -67,8 +67,7 @@ void RSMultiStatistic::print(ostream& out)
max=val;
}
}

out << " " << i << ": " <<
out << " " << i << ": " <<
"cnt: "+Int::toString(cnt)+
", avg: "+Int::toString(static_cast<float>(sum)/cnt)+
", min: "+Int::toString(min)+
Expand Down Expand Up @@ -98,14 +97,14 @@ RuntimeStatistics::~RuntimeStatistics()

void RuntimeStatistics::print(ostream& out)
{
out<<"---- Runtime statistics ----"<<endl;
out<<"% ---- Runtime statistics ----"<<endl;

ObjSkipList::Iterator it(_objs);
while(it.hasNext()) {
it.next()->print(out);
}

out<<"-----------------------------"<<endl;
out<<"% -----------------------------"<<endl;
}


Expand Down
2 changes: 1 addition & 1 deletion Debug/RuntimeStatistics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class RSCounter
public:
RSCounter(const char* name) : RSObject(name), _counter(0) {}

void print(std::ostream& out) { out << name() << ": " << _counter << std::endl; }
void print(std::ostream& out) { out << "% " << name() << ": " << _counter << std::endl; }
void inc() { _counter++; }
void inc(size_t num) { _counter+=num; }
private:
Expand Down
14 changes: 7 additions & 7 deletions FMB/FiniteModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ bool FiniteModel::evaluate(Unit* unit)
formula = fu->getFormula();
}

formula = partialEvaluate(formula);
formula = partialEvaluate(formula,0);
formula = SimplifyFalseTrue::simplify(formula);
return evaluate(formula);
}
Expand Down Expand Up @@ -549,7 +549,7 @@ bool FiniteModel::evaluate(Formula* formula,unsigned depth)
* TODO: This is recursive, which could be problematic in the long run
*
*/
Formula* FiniteModel::partialEvaluate(Formula* formula)
Formula* FiniteModel::partialEvaluate(Formula* formula,unsigned depth)
{
#if DEBUG_MODEL
for(unsigned i=0;i<depth;i++){ cout << "."; }
Expand All @@ -572,7 +572,7 @@ bool FiniteModel::evaluate(Formula* formula,unsigned depth)
return formula;
case NOT:
{
Formula* inner = partialEvaluate(formula->uarg());
Formula* inner = partialEvaluate(formula->uarg(),depth+1);
return new NegatedFormula(inner);
}
case AND:
Expand All @@ -582,7 +582,7 @@ bool FiniteModel::evaluate(Formula* formula,unsigned depth)
FormulaList* newArgs = 0;
FormulaList::Iterator fit(args);
while(fit.hasNext()){
Formula* newArg = partialEvaluate(fit.next());
Formula* newArg = partialEvaluate(fit.next(),depth+1);
FormulaList::push(newArg,newArgs);
}
return new JunctionFormula(formula->connective(),newArgs);
Expand All @@ -594,8 +594,8 @@ bool FiniteModel::evaluate(Formula* formula,unsigned depth)
{
Formula* left = formula->left();
Formula* right = formula->right();
Formula* newLeft = partialEvaluate(left);
Formula* newRight = partialEvaluate(right);
Formula* newLeft = partialEvaluate(left,depth+1);
Formula* newRight = partialEvaluate(right,depth+1);

return new BinaryFormula(formula->connective(),newLeft,newRight);
}
Expand All @@ -605,7 +605,7 @@ bool FiniteModel::evaluate(Formula* formula,unsigned depth)
{
VList* vs = formula->vars();
Formula* inner = formula->qarg();
Formula* newInner = partialEvaluate(inner);
Formula* newInner = partialEvaluate(inner,depth+1);
return new QuantifiedFormula(formula->connective(),vs,0,newInner);
}
default:
Expand Down
4 changes: 3 additions & 1 deletion FMB/FiniteModel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class FiniteModel {

private:

Formula* partialEvaluate(Formula* formula);
Formula* partialEvaluate(Formula* formula,unsigned depth);
// currently private as requires formula to be rectified
bool evaluate(Formula* formula,unsigned depth=0);

Expand All @@ -82,6 +82,8 @@ class FiniteModel {
if(_domainConstants.find(c,t)) return t;
std::string name = "domainConstant";//+Lib::Int::toString(c);
unsigned f = env.signature->addFreshFunction(0,name.c_str());
Signature::Symbol* fSym = env.signature->getFunction(f);
fSym->setType(OperatorType::getConstantsType(AtomicSort::defaultSort()));
t = Term::createConstant(f);
_domainConstants.insert(c,t);
_domainConstantsRev.insert(t,c);
Expand Down
Loading

0 comments on commit 2d67dfb

Please sign in to comment.