@Test public void testConditionals() { RTLExpression c = ExpressionFactory.createConditionalExpression( ExpressionFactory.createGreaterThan(esp, ExpressionFactory.createNumber(10, 32)), ExpressionFactory.createNumber(10, 32), ExpressionFactory.createNumber(5, 32)); RTLExpression f = ExpressionFactory.createEqual(ExpressionFactory.createVariable("x", 32), c); solver.addAssertion(f); assertTrue(solver.isSatisfiable()); }
/** Test method for {@link org.jakstab.solver.yices.YicesSolver#isSatisfiable()}. */ @Test public void testMemoryLocations() { solver.push(); RTLExpression f = ExpressionFactory.createEqual(m1, ExpressionFactory.createNumber(254823, 32)); solver.addAssertion(f); f = ExpressionFactory.createEqual(m2, ExpressionFactory.createNumber(53223, 32)); solver.addAssertion(f); assertTrue(solver.isSatisfiable()); f = ExpressionFactory.createEqual(m3, ExpressionFactory.createNumber(53223, 32)); solver.addAssertion(f); assertFalse(solver.isSatisfiable()); solver.pop(); solver.push(); f = ExpressionFactory.createNotEqual(m1, m2); solver.addAssertion(f); assertTrue(solver.isSatisfiable()); f = ExpressionFactory.createEqual(m1, m2); solver.addAssertion(f); assertFalse(solver.isSatisfiable()); solver.pop(); }
public RTLExpression getStateFormula(ValuationState state) { RTLExpression result = null; for (Iterator<Map.Entry<RTLVariable, AbstractDomainElement>> entryIt = state.variableIterator(); entryIt.hasNext(); ) { Map.Entry<RTLVariable, AbstractDomainElement> entry = entryIt.next(); RTLVariable var = entry.getKey(); IntervalElement interval = (IntervalElement) entry.getValue(); if (interval.size() == 1) { result = addClause( result, ExpressionFactory.createEqual( var, ExpressionFactory.createNumber(interval.getLeft(), var.getBitWidth()))); } else { if (!interval.leftOpen()) { result = addClause( result, ExpressionFactory.createLessOrEqual( ExpressionFactory.createNumber(interval.getLeft(), var.getBitWidth()), var)); } if (!interval.rightOpen()) { result = addClause( result, ExpressionFactory.createLessOrEqual( var, ExpressionFactory.createNumber(interval.getRight(), var.getBitWidth()))); } } } if (result == null) { result = ExpressionFactory.TRUE; } return result; }