Skip to content

Commit

Permalink
Merge pull request #301 from vprover/ahmed-fix-kboforepr-bug
Browse files Browse the repository at this point in the history
Fix KBOForEPR polymorphism bug
  • Loading branch information
quickbeam123 committed Nov 30, 2021
2 parents 1128390 + 1bec8ad commit 106b95b
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 17 deletions.
2 changes: 2 additions & 0 deletions Kernel/Ordering.cpp
Expand Up @@ -130,6 +130,7 @@ Ordering* Ordering::create(Problem& prb, const Options& opt)
// - user specified symbol weights
// TODO fix this!
if(prb.getProperty()->maxFunArity()==0
&& prb.getProperty()->maxTypeConArity() == 0
&& !env.colorUsed
&& env.options->predicateWeights() == ""
&& env.options->functionWeights() == ""
Expand All @@ -145,6 +146,7 @@ Ordering* Ordering::create(Problem& prb, const Options& opt)
default:
ASSERTION_VIOLATION;
}
//TODO currently do not show SKIKBO
if (opt.showSimplOrdering()) {
env.beginOutput();
out->show(env.out());
Expand Down
6 changes: 3 additions & 3 deletions SAT/Z3Interfacing.hpp
Expand Up @@ -169,7 +169,7 @@ class Z3Interfacing : public PrimitiveProofRecordingSATSolver
return true;

// compare sort arguments
for(int i = 0; i < l.forSorts->numTypeArguments(); i++)
for(unsigned i = 0; i < l.forSorts->numTypeArguments(); i++)
// sorts are perfectly shared
if(!l.forSorts->nthArgument(i)->sameContent(r.forSorts->nthArgument(i)))
return false;
Expand All @@ -185,7 +185,7 @@ class Z3Interfacing : public PrimitiveProofRecordingSATSolver
: env.signature->getFunction(self.id)->name()
);
if(self.forSorts)
for(int i = 0; i < self.forSorts->numTypeArguments(); i++)
for(unsigned i = 0; i < self.forSorts->numTypeArguments(); i++)
out << " " << self.forSorts->nthArgument(i)->toString();
return out;
}
Expand Down Expand Up @@ -281,7 +281,7 @@ namespace std {
size_t operator()(SAT::Z3Interfacing::FuncOrPredId const& self) {
unsigned hash = Lib::HashUtils::combine(self.id, self.isPredicate);
if(self.forSorts)
for(int i = 0; i < self.forSorts->numTypeArguments(); i++)
for(unsigned i = 0; i < self.forSorts->numTypeArguments(); i++)
hash = Lib::HashUtils::combine(hash, self.forSorts->nthArgument(i)->content());
return hash;
}
Expand Down
24 changes: 14 additions & 10 deletions Shell/Property.cpp
Expand Up @@ -66,6 +66,7 @@ Property::Property()
_groundGoals(0),
_maxFunArity(0),
_maxPredArity(0),
_maxTypeConArity(0),
_totalNumberOfVariables(0),
_maxVariablesInClause(0),
_props(0),
Expand Down Expand Up @@ -656,10 +657,6 @@ void Property::scan(TermList ts,bool unit,bool goal)
return;
}

if(ts.term()->isSort()){
return;
}

ASS(ts.isTerm());
Term* t = ts.term();

Expand Down Expand Up @@ -687,6 +684,13 @@ void Property::scan(TermList ts,bool unit,bool goal)
break;
}
} else {
if(t->isSort()){
if(t->arity() > _maxTypeConArity){
_maxTypeConArity = t->arity();
}
return;
}

scanForInterpreted(t);

_symbolsInFormula.insert(t->functor());
Expand Down Expand Up @@ -719,20 +723,20 @@ void Property::scan(TermList ts,bool unit,bool goal)
_hasLogicalProxy = true;
}

OperatorType* type = func->fnType();
if(!t->isApplication() && type->typeArgsArity()){
if(!t->isApplication() && t->numTypeArguments() > 0){
_hasPolymorphicSym = true;
}

int arity = t->arity();
for (int i = 0; i < arity; i++) {
scanSort(SortHelper::getArgSort(t, i));
}
scanSort(SortHelper::getResultSort(t));

if (arity > _maxFunArity) {
_maxFunArity = arity;
}

for (int i = 0; i < arity; i++) {
scanSort(SortHelper::getArgSort(t, i));
}
scanSort(SortHelper::getResultSort(t));
}
}

Expand Down
3 changes: 3 additions & 0 deletions Shell/Property.hpp
Expand Up @@ -187,6 +187,8 @@ class Property
bool hasFormulas() const { return _axiomFormulas || _goalFormulas; }
/** Maximal arity of a function in the problem */
int maxFunArity() const { return _maxFunArity; }
/** Maximal arity of a type con in the problem */
unsigned maxTypeConArity() const { return _maxTypeConArity; }
/** Total number of variables in problem */
int totalNumberOfVariables() const { return _totalNumberOfVariables;}

Expand Down Expand Up @@ -303,6 +305,7 @@ class Property
int _groundGoals;
int _maxFunArity;
int _maxPredArity;
unsigned _maxTypeConArity;

/** Number of variables in this clause, used during counting */
int _variablesInThisClause;
Expand Down
6 changes: 2 additions & 4 deletions Shell/SubexpressionIterator.hpp
Expand Up @@ -52,10 +52,8 @@ namespace Shell {
* we first propagate the negative polarity from the formula to its underlying
* boolean term, and then from the boolean terms to their underlying formulas.
*
* NOTE: this iterator returns sort terms as well. As of 08/07/2021, the only
* use of this iterator is in Property.cpp where sorts are NOT required.
* However, sorts are sub-expressions, so to keep the iterator intuitive we
* leave the code as is.
* NOTE: this iterator returns sort terms as well. As of 25/11/2021, the only
* use of this iterator is in Property.cpp.
*/
class Expression {
public:
Expand Down

0 comments on commit 106b95b

Please sign in to comment.