Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Kernel/Signature.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -693,18 +693,18 @@ class Signature
/** Return the function symbol by its number */
inline Symbol* getFunction(unsigned n)
{
ASS_REP(n < _funs.length(),n);
ASS_L(n, _funs.length());
return _funs[n];
} // getFunction
/** Return the predicate symbol by its number */
inline Symbol* getPredicate(unsigned n)
{
ASS(n < _preds.length());
ASS_L(n, _preds.length());
return _preds[n];
} // getPredicate
inline Symbol* getTypeCon(unsigned n)
{
ASS(n < _typeCons.length());
ASS_L(n, _typeCons.length());
return _typeCons[n];
}

Expand Down
3 changes: 2 additions & 1 deletion Kernel/Theory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1053,7 +1053,8 @@ unsigned Theory::Tuples::getConstructor(unsigned arity)

bool Theory::Tuples::isConstructor(Term* t)
{
return !t->isSpecial() && !t->isSort() && getConstructor(t->numTypeArguments()) == t->functor();
return !t->isSpecial() && !t->isSort() && SortHelper::getResultSort(t).isTupleSort()
&& getConstructor(t->numTypeArguments()) == t->functor();
}

unsigned Theory::Tuples::getProjectionFunctor(unsigned arity, unsigned proj)
Expand Down
16 changes: 14 additions & 2 deletions Parse/SMTLIB2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1499,8 +1499,20 @@ void SMTLIB2::parseLetEnd(LExpr* exp)
}

auto varList = vars.list();
auto args = TermStack::fromIterator(iterTraits(varList->iter()).map(unsignedToVarFn));
auto binder = Formula::createDefinition(Term::create(exprT->functor(), args), SubstHelper::apply(boundExpr,subst), varList);
TermStack args;
if (varList) {
args.loadFromIterator(iterTraits(varList->iter()).map(unsignedToVarFn));
}
Term* lhs;
if (exprSort == AtomicSort::boolSort()) {
// This solution is ugly, but either := has to be special or we have
// to wrap this as a formula to preserve the term-formula boundary.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At some point we can re-consider - I think you're of the opinion that more interpreted symbols and fewer special terms are a good thing, which I agree with. But for now this is a good fix.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I would be happy if the special term wrapper disappeared at some point, but let's see if we can get rid of it.

lhs = Term::createFormula(new AtomicFormula(Literal::create(exprT->functor(), args.size(), true, args.begin())));
} else {
lhs = Term::create(exprT->functor(), args);
}

auto binder = Formula::createDefinition(lhs, SubstHelper::apply(boundExpr,subst), varList);
let = TermList(Term::createLet(binder, let, letSort));
}

Expand Down
10 changes: 9 additions & 1 deletion Shell/FOOLElimination.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -620,9 +620,17 @@ void FOOLElimination::process(Term* term, Context context, TermList& termResult,
auto vars = VList::append(bodyFreeVars, argumentVars);
collectSorts(vars, typeVars, termVars, allVars, termVarSorts);

// this is ugly, but otherwise := would have to be special
if (bindingLhs->isBoolean()) {
ASS(bindingLhs->isFormula());
auto inner = bindingLhs->getSpecialData()->getFormula();
ASS_EQ(inner->connective(), Connective::LITERAL);
bindingLhs = inner->literal();
}

// take the defined function symbol and its result sort
unsigned symbol = bindingLhs->functor();
TermList bindingSort = SortHelper::getResultSort(bindingLhs);
TermList bindingSort = bindingLhs->isLiteral() ? AtomicSort::boolSort() : SortHelper::getResultSort(bindingLhs);

SortHelper::normaliseSort(typeVars, bindingSort);

Expand Down
7 changes: 2 additions & 5 deletions Shell/NewCNF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -763,18 +763,15 @@ TermList NewCNF::nameLetBinding(Term* bindingLhs, TermList bindingRhs, TermList

bool isPredicate = bindingLhs->isBoolean();
// the symbol that we name must be in the form of a literal
if (isPredicate && !bindingLhs->isLiteral()) {
if (isPredicate) {
ASS(bindingLhs->isFormula());
auto inner = bindingLhs->getSpecialData()->getFormula();
ASS_EQ(inner->connective(), Connective::LITERAL);
bindingLhs = inner->literal();
}

unsigned nameArity = VList::length(bindingBoundVars) + bindingFreeVars.size();
TermList nameSort;
if (!isPredicate) {
nameSort = SortHelper::getResultSort(bindingLhs);
}
TermList nameSort = isPredicate ? AtomicSort::boolSort() : SortHelper::getResultSort(bindingLhs);

unsigned freshSymbol = bindingLhs->functor();

Expand Down
2 changes: 0 additions & 2 deletions Shell/SymbolOccurrenceReplacement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ Formula* SymbolOccurrenceReplacement::process(Formula* formula) {
case LITERAL: {
Literal* literal = formula->literal();

Literal* processedLiteral;

if (_isPredicate && (literal->functor() == _oldApplication->functor())) {
Substitution substitution;
for (unsigned i = 0; i < literal->arity(); i++) {
Expand Down
3 changes: 2 additions & 1 deletion Shell/SymbolOccurrenceReplacement.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ class SymbolOccurrenceReplacement {
* freshApplication = g(A1, ..., Am, B1, ..., Bj,X1, ..., Xn, Y1, ..., Yk)
*/
SymbolOccurrenceReplacement(Term* oldApplication, Term* freshApplication)
: _isPredicate(oldApplication->isBoolean()),
: _isPredicate(oldApplication->isLiteral()),
_oldApplication(oldApplication),
_freshApplication(freshApplication)
{
ASS(!oldApplication->isSpecial());
// The implementation of this class doesn't requite argVars to be
// non-empty, however, its use case expects this constraint
//ASS(argVars || !env.signature->getFunction(symbol)->introduced());
Expand Down