Package org.jakstab.solver

Examples of org.jakstab.solver.Solver


        RTLExpression assumption = stmt.getAssumption();

        // First analysis to use yices, demo implementation
       
        Solver solver = Solver.createSolver();
        solver.addAssertion(s.getStateFormula());
        solver.addAssertion(assumption);

        if (!solver.isSatisfiable()) {
          logger.info("Infeasible CFA edge: " + stmt);
          return Collections.emptySet();
        }
       
        SignState post = new SignState(s);
        for (RTLVariable v : assumption.getUsedVariables()) {
          // Check if we can restrict this variable
          if (s.getValue(v).isTop()) {

            solver.push();
            RTLExpression f = ExpressionFactory.createLessOrEqual(v, ExpressionFactory.createNumber(0, v.getBitWidth()));
            solver.addAssertion(f);
            if (!solver.isSatisfiable()) {
              post.setValue(v, SignElement.POSITIVE);
              logger.debug("Restricting state from " + s + " through " + assumption + " to " + post);
            } else {
              solver.pop();
              solver.push();
              f = ExpressionFactory.createNot(ExpressionFactory.createEqual(v, ExpressionFactory.createNumber(0, v.getBitWidth())));
              solver.addAssertion(f);
              if (!solver.isSatisfiable()) {
                post.setValue(v, SignElement.ZERO);
                logger.debug("Restricting state from " + s + " through " + assumption + " to " + post);
              } else {
                solver.pop();
                solver.push();
                f = ExpressionFactory.createLessOrEqual(ExpressionFactory.createNumber(0, v.getBitWidth()), v);
                solver.addAssertion(f);
                if (!solver.isSatisfiable()) {
                  post.setValue(v, SignElement.NEGATIVE);
                  logger.debug("Restricting state from " + s + " through " + assumption + " to " + post);
                }
              }
            }
            solver.pop();
          }
        }
        return Collections.singleton((AbstractState)post);
       
        /*
 
View Full Code Here


        RTLExpression xprime = ExpressionFactory.createVariable("xprime" + lhs.getBitWidth(), lhs.getBitWidth());

        Context subCtx = new Context();
        subCtx.substitute(lhs, xprime);

        Solver solver = Solver.createSolver();
        RTLExpression stateFormula = s.getStateFormula(prec);
        solver.addAssertion(stateFormula);
        solver.addAssertion(ExpressionFactory.createEqual(xprime,
            stmt.getRightHandSide()));
       
        for (int predIdx = 0; predIdx <= PredicateMap.getMaxIndex(); predIdx++) {
          RTLExpression p = PredicateMap.getPredicate(predIdx);
          if (!p.getUsedVariables().contains(lhs))
            continue;
          // substitute x by xprime
          p = p.evaluate(subCtx);
         
          // Clear variable from predicate BDD
          setVariableDontCare(postPreds, predIdx);
         
          // check if the predicate holds or not
          solver.push();
          solver.addAssertion(ExpressionFactory.createNot(p));

          if (solver.isUnsatisfiable()) {
            postPreds.andWith(bddFactory.ithVar(predIdx));
          } else {
            // Now check whether the negative of the predicate holds
            solver.pop();
            solver.push();
            solver.addAssertion(p);
            if (solver.isUnsatisfiable()) {
              postPreds.andWith(bddFactory.nithVar(predIdx));
            }
          }
          // nothing for don't know, the predicate is already cleared from the BDD

          solver.pop();
        }

        return Collections.singleton((AbstractState)new PredicateAbstractionState(postPreds));
      }
     
      @Override
      public Set<AbstractState> visit(RTLMemoryAssignment stmt) {
        // Memory assignments not supported
        return fallThroughState();
      }

      @Override
      public Set<AbstractState> visit(RTLAssume stmt) {
        Solver solver = Solver.createSolver();
        solver.addAssertion(s.getStateFormula(prec));
        solver.addAssertion(stmt.getAssumption());
        if (solver.isUnsatisfiable())
          return Collections.emptySet();

        // OK? was empty in old impl
        BDD postPreds = s.predicates.id();

        for (int predIdx = 0; predIdx <= PredicateMap.getMaxIndex(); predIdx++) {
          RTLExpression p = PredicateMap.getPredicate(predIdx);
          // check if the predicate holds or not
          solver.push();
          solver.addAssertion(ExpressionFactory.createNot(p));
          if (solver.isUnsatisfiable()) {
            setVariableDontCare(postPreds, predIdx);
            postPreds.andWith(bddFactory.ithVar(predIdx));
          } else {
            // Now check whether the negative of the predicate holds
            solver.pop();
            solver.push();
            solver.addAssertion(p);
            if (solver.isUnsatisfiable()) {
              setVariableDontCare(postPreds, predIdx);
              postPreds.andWith(bddFactory.nithVar(predIdx));
            }
          }
          solver.pop();
        }
       
        return Collections.singleton((AbstractState)new PredicateAbstractionState(postPreds));
      }
View Full Code Here

TOP

Related Classes of org.jakstab.solver.Solver

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.