Search in sources :

Example 1 with RegexFormula

use of org.sosy_lab.java_smt.api.RegexFormula in project java-smt by sosy-lab.

the class SolverVisitorTest method stringInBooleanFormulaIdVisit.

@Test
public void stringInBooleanFormulaIdVisit() throws SolverException, InterruptedException {
    requireStrings();
    StringFormula x = smgr.makeVariable("xVariable");
    StringFormula y = smgr.makeVariable("yVariable");
    RegexFormula r = smgr.makeRegex("regex1");
    for (BooleanFormula f : ImmutableList.of(smgr.equal(x, y), smgr.contains(x, y), smgr.lessThan(x, y), smgr.lessOrEquals(x, y), smgr.greaterOrEquals(x, y), smgr.greaterThan(x, y), smgr.prefix(x, y), smgr.suffix(x, y), smgr.in(x, r))) {
        mgr.visit(f, new FunctionDeclarationVisitorNoUF());
        mgr.visit(f, new FunctionDeclarationVisitorNoOther());
        BooleanFormula f2 = mgr.transformRecursively(f, new FormulaTransformationVisitor(mgr) {
        });
        assertThat(f2).isEqualTo(f);
        assertThatFormula(f).isEquivalentTo(f2);
    }
}
Also used : BooleanFormulaTransformationVisitor(org.sosy_lab.java_smt.api.visitors.BooleanFormulaTransformationVisitor) FormulaTransformationVisitor(org.sosy_lab.java_smt.api.visitors.FormulaTransformationVisitor) StringFormula(org.sosy_lab.java_smt.api.StringFormula) RegexFormula(org.sosy_lab.java_smt.api.RegexFormula) BooleanFormula(org.sosy_lab.java_smt.api.BooleanFormula) Test(org.junit.Test)

Example 2 with RegexFormula

use of org.sosy_lab.java_smt.api.RegexFormula in project java-smt by sosy-lab.

the class StringFormulaManagerTest method testRegexAll.

// Tests
@Test
public void testRegexAll() throws SolverException, InterruptedException {
    RegexFormula regex = smgr.all();
    assertThatFormula(smgr.in(hello, regex)).isSatisfiable();
}
Also used : RegexFormula(org.sosy_lab.java_smt.api.RegexFormula) Test(org.junit.Test)

Example 3 with RegexFormula

use of org.sosy_lab.java_smt.api.RegexFormula in project java-smt by sosy-lab.

the class StringFormulaManagerTest method testStringRegex2.

@Test
public void testStringRegex2() throws SolverException, InterruptedException {
    RegexFormula regex = smgr.concat(smgr.closure(a2z), smgr.makeRegex("ll"), smgr.closure(a2z));
    assertThatFormula(smgr.in(hello, regex)).isSatisfiable();
}
Also used : RegexFormula(org.sosy_lab.java_smt.api.RegexFormula) Test(org.junit.Test)

Example 4 with RegexFormula

use of org.sosy_lab.java_smt.api.RegexFormula in project java-smt by sosy-lab.

the class SolverVisitorTest method stringInRegexFormulaVisit.

@Test
public void stringInRegexFormulaVisit() {
    requireStrings();
    RegexFormula r = smgr.makeRegex("regex1");
    RegexFormula s = smgr.makeRegex("regex2");
    ImmutableList.Builder<RegexFormula> formulas = ImmutableList.<RegexFormula>builder().add(smgr.union(r, s)).add(smgr.closure(r)).add(smgr.concat(r, r, r, s, s, s)).add(smgr.cross(r));
    if (solverToUse() != Solvers.Z3) {
        formulas.add(smgr.difference(r, s)).add(smgr.complement(r));
    // invalid function OTHER/INTERNAL in visitor, bug in Z3?
    }
    for (RegexFormula f : formulas.build()) {
        mgr.visit(f, new FunctionDeclarationVisitorNoUF());
        mgr.visit(f, new FunctionDeclarationVisitorNoOther());
        RegexFormula f2 = mgr.transformRecursively(f, new FormulaTransformationVisitor(mgr) {
        });
        assertThat(f2).isEqualTo(f);
    }
}
Also used : BooleanFormulaTransformationVisitor(org.sosy_lab.java_smt.api.visitors.BooleanFormulaTransformationVisitor) FormulaTransformationVisitor(org.sosy_lab.java_smt.api.visitors.FormulaTransformationVisitor) ImmutableList(com.google.common.collect.ImmutableList) RegexFormula(org.sosy_lab.java_smt.api.RegexFormula) Test(org.junit.Test)

Example 5 with RegexFormula

use of org.sosy_lab.java_smt.api.RegexFormula in project java-smt by sosy-lab.

the class StringFormulaManagerTest method testStringRegex3.

@Test
public void testStringRegex3() throws SolverException, InterruptedException {
    RegexFormula regex = smgr.makeRegex(".*ll.*");
    assertThatFormula(smgr.in(hello, regex)).isUnsatisfiable();
}
Also used : RegexFormula(org.sosy_lab.java_smt.api.RegexFormula) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)7 RegexFormula (org.sosy_lab.java_smt.api.RegexFormula)7 BooleanFormulaTransformationVisitor (org.sosy_lab.java_smt.api.visitors.BooleanFormulaTransformationVisitor)2 FormulaTransformationVisitor (org.sosy_lab.java_smt.api.visitors.FormulaTransformationVisitor)2 ImmutableList (com.google.common.collect.ImmutableList)1 BooleanFormula (org.sosy_lab.java_smt.api.BooleanFormula)1 StringFormula (org.sosy_lab.java_smt.api.StringFormula)1