return true;
} //End of TypeCheck function
+ // callback for SIGALRM.
+ void handle_time_out(int parameter){
+ printf("Timed Out.\n");
+
+ abort();
+ // I replaced the exit(0) with an abort().
+ // The exit was sometimes hanging, seemingly because of a bug somewhere else (e.g. loader, glibc).
+ // In strace it output:
+
+ //--- SIGVTALRM (Virtual timer expired) @ 0 (0) ---
+ //fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 5), ...}) = 0
+ //mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fabca622000
+ //write(1, "Timed Out.\n", 11Timed Out.
+ //) = 11
+ //futex(0x7fabc9c54e40, FUTEX_WAIT, 2, NULL
+
+ // Then it would just sit there waiting for the mutex (which never came).
+ //exit(0);
+ }
+
+
+ itimerval timeout;
+ void setHardTimeout(int sec)
+ {
+ signal(SIGVTALRM, handle_time_out);
+ timeout.it_interval.tv_usec = 0;
+ timeout.it_interval.tv_sec = 0;
+ timeout.it_value.tv_usec = 0;
+ timeout.it_value.tv_sec = sec;
+ setitimer(ITIMER_VIRTUAL, &timeout, NULL);
+ }
+
long getCurrentTime()
{
timeval t;
extern int smtlex_destroy(void);
extern int smt2lex_destroy(void);
-// callback for SIGALRM.
-void handle_time_out(int parameter){
- printf("Timed Out.\n");
-
- abort();
- // I replaced the exit(0) with an abort().
- // The exit was sometimes hanging, seemingly because of a bug somewhere else (e.g. loader, glibc).
- // In strace it output:
-
- //--- SIGVTALRM (Virtual timer expired) @ 0 (0) ---
- //fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 5), ...}) = 0
- //mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fabca622000
- //write(1, "Timed Out.\n", 11Timed Out.
- //) = 11
- //futex(0x7fabc9c54e40, FUTEX_WAIT, 2, NULL
-
- // Then it would just sit there waiting for the mutex (which never came).
- //exit(0);
+namespace BEEV
+{
+ void setHardTimeout(int);
}
bool onePrintBack =false;
AbsRefine_CounterExample * Ctr_Example = new AbsRefine_CounterExample(bm, simp, arrayTransformer);
auto_ptr<AbsRefine_CounterExample> ctrCleaner(Ctr_Example);
- itimerval timeout;
-
ParserBM = bm;
GlobalSTP =
new STP(bm,
if (argv[i][1] == 'g')
{
- signal(SIGVTALRM, handle_time_out);
- timeout.it_interval.tv_usec = 0;
- timeout.it_interval.tv_sec = 0;
- timeout.it_value.tv_usec = 0;
- timeout.it_value.tv_sec = atoi(argv[++i]);
- setitimer(ITIMER_VIRTUAL, &timeout, NULL);
+ BEEV::setHardTimeout(atoi(argv[++i]));
}
else if (argv[i][1] == 'i')
{
return lowBits;
}
-Result merge(Result r1, Result r2)
-{
- if (r1 == CONFLICT || r2 == CONFLICT )
- return CONFLICT;
-
- if (r1 == CHANGED || r2 == CHANGED)
- return CHANGED;
-
- if (r1 == NO_CHANGE && r2 == NO_CHANGE)
- return NO_CHANGE;
-
- return NOT_IMPLEMENTED;
-
-}
// The value "b" is in the range [low,high] inclusive.
// Unfortunately it's not idempotent, <....1> [5,6], doesn't completely set it.
bool disabledProp = !beev->UserFlags.bitConstantProp_flag;
bool printOutput = beev->UserFlags.print_output_flag;
+ bool checkCounter = beev->UserFlags.check_counterexample_flag;
beev->UserFlags.bitConstantProp_flag = false;
beev->UserFlags.print_output_flag = false;
+ beev->UserFlags.check_counterexample_flag= false;
ASTVec initialFixing;
for (int i = 0; i < numberOfChildren; i++)
{
std::stringstream out;
- out << "v" << i;
+ out << "v_VERY_SPECIALLY_NAMES" << i;
unsigned valueWidth;
}
unsigned outputWidth = output.isBoolean()? 0: output.getWidth();
- ASTNode outputNode = beev->CreateSymbol("result",0,outputWidth);
+ ASTNode outputNode = beev->CreateSymbol("result_WITH_SPECIAL_NAME",0,outputWidth);
ASTNode expr;
if (output.isBoolean())
if (first)
{
- result = ce.CallSAT_ResultCheck(newS, expr, expr, &tosat,true);
+ beev->AddQuery(beev->ASTUndefined);
+ result = ce.CallSAT_ResultCheck(newS, expr, expr, &tosat,true);
}
else
{
newS.addClause(satSolverClause);
satSolverClause.clear();
+ beev->AddQuery(beev->ASTUndefined);
result = ce.CallSAT_ResultCheck(newS, beev->ASTTrue, beev->ASTTrue, &tosat,true);
}
beev->UserFlags.bitConstantProp_flag = !disabledProp;
beev->UserFlags.print_output_flag = printOutput;
+ beev->UserFlags.check_counterexample_flag= checkCounter;
return first;
}
return CONSTANTBV::BitVector_Compare(lhs,rhs);
}
+Result merge(Result r1, Result r2)
+{
+ if (r1 == CONFLICT || r2 == CONFLICT )
+ return CONFLICT;
+
+ if (r1 == CHANGED || r2 == CHANGED)
+ return CHANGED;
+
+ if (r1 == NO_CHANGE && r2 == NO_CHANGE)
+ return NO_CHANGE;
+
+ return NOT_IMPLEMENTED;
+}
+
int toInt(const BEEV::CBV value)
{
unsigned unfixed;
};
+Result merge(Result r1, Result r2);
+
stats getStats(const vector<FixedBits*>& operands, const unsigned position);
}
}
#include <iostream>
#include <fstream>
#include "ConstantBitP_TransferFunctions.h"
+#include "ConstantBitP_MaxPrecision.h"
using std::endl;
using std::cout;
dispatchToTransferFunctions(const Kind k, vector<FixedBits*>& children,
FixedBits& output, const ASTNode n, MultiplicationStatsMap *msm = NULL);
- Result
- dispatchToMaximallyPrecise(const Kind k, vector<FixedBits*>& children,
- FixedBits& output, const ASTNode n);
-
const bool debug_cBitProp_messages = false;
const bool output_mult_like = false;
const bool debug_print_graph_after = false;
//Determine what must always be true.
ASTNodeMap fromTo = getAllFixed();
+ {
+ ASTNodeMap::iterator it = fromTo.begin();
+ while(it != fromTo.end())
+ {
+ assert(it->getKind() != SYMBOL);
+ it++;
+ }
+ }
+
if (debug_cBitProp_messages)
{
}
#undef MAPTFN
bool mult_like = false;
-
+ const bool lift_to_max = false;
// safe approximation to no overflow multiplication.
if (k == BVMULT)
result = bvMultiplyBothWays(children, output, n.GetSTPMgr(),&ms);
if (CONFLICT != result)
msm->map[n] = ms;
- mult_like=true;
+ mult_like=true;
}
else if (k == BVDIV)
{
mult_like=true;
}
else
+ result = transfer(children, output);
-
- result = transfer(children, output);
+ if (mult_like && lift_to_max)
+ {
+ int bits_before = output.countFixed() + children[0]->countFixed() + children[1]->countFixed();
+ result = merge(result, maxPrecision(children, output, k, n.GetSTPMgr())? CONFLICT :NOT_IMPLEMENTED);
+ int difference = (output.countFixed() + children[0]->countFixed() + children[1]->countFixed()) - bits_before;
+ assert(difference >= 0);
+ cerr << "Bits fixed" << difference << endl;
+ }
if (mult_like && output_mult_like)
{
ASTNode top = nf->CreateTerm(BVEXTRACT, rest, inputterm[0], _bm->CreateBVConst(32,rest-1),_bm->CreateZeroConst(32));
ASTNode bottom = nf->CreateTerm(BVEXTRACT, rest, inputterm[1], _bm->CreateBVConst(32,rest-1),_bm->CreateZeroConst(32));
+ // nb. This differs from the bvdiv case.
ASTNode div = nf->CreateTerm(BVMOD,rest,top,bottom);
div = nf->CreateTerm(BVCONCAT,inputValueWidth,_bm->CreateZeroConst(inputValueWidth-rest),div);
+ // nb. This differs from the bvdiv case.
output = nf->CreateTerm(ITE, inputValueWidth, cond, div, inputterm[0]);
break;
}
found = false;
}
}
+
+ //void setHardTimeout(int sec);
+ //setHardTimeout(500);
+
+
bm->GetRunTimes()->start(RunTimes::Solving);
satSolver.solve();
bm->GetRunTimes()->stop(RunTimes::Solving);