Skip to content
Open
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
14 changes: 12 additions & 2 deletions src/api/MainSolver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "MainSolver.h"

#include <common/ApiException.h>
#include <common/NonLinException.h>
#include <itehandler/IteHandler.h>
#include <logics/ArrayTheory.h>
#include <logics/LATheory.h>
Expand Down Expand Up @@ -347,14 +348,23 @@ sstat MainSolver::check() {
StopWatch sw(query_timer);
}
if (isLastFrameUnsat()) { return s_False; }
sstat rval = simplifyFormulas();
sstat rval;
try {
rval = simplifyFormulas();
} catch (NonLinException const & error) {
reasonUnknown = error.what();
return s_Undef;
}

if (config.dump_query()) printCurrentAssertionsAsQuery();

if (rval == s_Undef) {
try {
rval = solve();
} catch (std::overflow_error const & error) { rval = s_Error; }
} catch (std::overflow_error const & error) { rval = s_Error; } catch (NonLinException const & error) {
reasonUnknown = error.what();
return s_Undef;
}
if (rval == s_False) {
assert(not smt_solver->isOK());
rememberUnsatFrame(smt_solver->getConflictFrame());
Expand Down
1 change: 1 addition & 0 deletions src/api/MainSolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ class MainSolver {
vec<PTRef> frameTerms;
std::size_t firstNotSimplifiedFrame = 0;
unsigned int insertedFormulasCount = 0;
std::string reasonUnknown;
};

bool MainSolver::trackPartitions() const {
Expand Down
2 changes: 1 addition & 1 deletion src/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ include(numbers/CMakeLists.txt)
install(FILES
StringMap.h Timer.h inttypes.h IColor.h
TreeOps.h FlaPartitionMap.h PartitionInfo.h Partitions.h ApiException.h TypeUtils.h
NatSet.h ScopedVector.h TermNames.h
NatSet.h ScopedVector.h TermNames.h NonLinException.h
DESTINATION ${INSTALL_HEADERS_DIR}/common)
19 changes: 19 additions & 0 deletions src/common/NonLinException.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright (c) 2024, Konstantin Britikov <britikovki@gmail.com>
*
* SPDX-License-Identifier: MIT
*/

#ifndef OPENSMT_NONLINEXCEPTION_H
#define OPENSMT_NONLINEXCEPTION_H

#include <stdexcept>

namespace opensmt {
class NonLinException : public std::runtime_error {
public:
NonLinException(std::string_view const reason_) : runtime_error("Term " + std::string(reason_) + " is non-linear"){}
};
}

#endif // OPENSMT_NONLINEXCEPTION_H
4 changes: 2 additions & 2 deletions src/common/polynomials/Translations.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ LAPoly ptrefToPoly(PTRef const op, ArithLogic & logic) {
PTRef const polyTerm = lhs == logic.getZeroForSort(logic.getSortRef(lhs)) ? rhs : logic.mkMinus(rhs, lhs);
assert(logic.isLinearTerm(polyTerm));
if (logic.isLinearFactor(polyTerm)) {
auto [var, c] = logic.splitTermToVarAndConst(polyTerm);
auto [var, c] = logic.splitPolyTerm(polyTerm);
poly.addTerm(var, logic.getNumConst(c));
} else {
assert(logic.isPlus(polyTerm));
for (PTRef const factor : logic.getPterm(polyTerm)) {
auto [var, c] = logic.splitTermToVarAndConst(factor);
auto [var, c] = logic.splitPolyTerm(factor);
poly.addTerm(var, logic.getNumConst(c));
}
}
Expand Down
Loading