use of com.sri.ai.grinder.sgdpllt.theory.differencearithmetic.DifferenceArithmeticTheory in project aic-expresso by aic-sri-international.
the class BoundTest method testApplyFunctionToBound.
@Test
public void testApplyFunctionToBound() {
Theory theory = new CompoundTheory(new EqualityTheory(false, true), new DifferenceArithmeticTheory(false, false), new LinearRealArithmeticTheory(false, false), new TupleTheory(), new PropositionalTheory());
Context context = new TrueContext(theory);
context = context.extendWithSymbolsAndTypes("X", "Boolean");
context = context.extendWithSymbolsAndTypes("Y", "Boolean");
//Set of numbers
Expression one = DefaultSymbol.createSymbol(1);
Expression two = DefaultSymbol.createSymbol(2);
Expression three = DefaultSymbol.createSymbol(3);
Expression setOFNumbers = ExtensionalSets.makeUniSet(one, two, three);
//Set of functions
Expression phi1 = parse("if X = true then 1 else if Y = true then 2 else 3");
Expression phi2 = parse("if X = true then if Y = true then 4 else 5 else 6");
Expression phi3 = parse("if X = true then 7 else if Y = true then 8 else 9");
Expression phi4 = parse("if X = true then 10 else if Y = true then 11 else 12");
Expression setOfFactors = ExtensionalSets.makeUniSet(phi1, phi2, phi3, phi4);
Expression phi = DefaultSymbol.createSymbol("phi");
Expression f = parse("13*phi");
println("f: " + f);
assertEquals(parse("{ 13, 26, 39 }"), Bounds.applyFunctionToBound(f, phi, setOFNumbers, theory, context));
assertEquals(parse("{ if X then 13 else if Y then 26 else 39, " + "if X then if Y then 52 else 65 else 78, " + "if X then 91 else if Y then 104 else 117, " + "if X then 130 else if Y then 143 else 156 }"), Bounds.applyFunctionToBound(f, phi, setOfFactors, theory, context));
println("f(setfac): " + Bounds.applyFunctionToBound(f, phi, setOfFactors, theory, context));
}
use of com.sri.ai.grinder.sgdpllt.theory.differencearithmetic.DifferenceArithmeticTheory in project aic-expresso by aic-sri-international.
the class IntensionalSetToConditionalSimplifierTest method setUp.
@Before
public void setUp() {
context = new TrueContext(new CompoundTheory(new DifferenceArithmeticTheory(false, false), new TupleTheory()));
IntegerInterval nType = new IntegerInterval(1, 10);
context = (Context) GrinderUtil.extendRegistryWith(map("N", nType.toString()), Arrays.asList(nType), context);
simplifier = new IntensionalSetToConditionalSimplifier();
}
use of com.sri.ai.grinder.sgdpllt.theory.differencearithmetic.DifferenceArithmeticTheory in project aic-expresso by aic-sri-international.
the class InversionPerformanceEvaluationTest method setUp.
@Before
public void setUp() {
context = new TrueContext(new CompoundTheory(new DifferenceArithmeticTheory(false, false), new EqualityTheory(false, false), new PropositionalTheory(), new TupleTheory()));
updateContextWithIndexAndType("R", GrinderUtil.INTEGER_TYPE);
context.conjoin(parse("R = 1"), context);
}
use of com.sri.ai.grinder.sgdpllt.theory.differencearithmetic.DifferenceArithmeticTheory in project aic-expresso by aic-sri-international.
the class ExpressionStepSolverToLiteralSplitterStepSolverAdapterTest method testDifferenceArithmeticTheoryWithoutPropagationOfAllLiteralsWhenBoundWithRandomDisjunctiveFormulas.
@Test
public void testDifferenceArithmeticTheoryWithoutPropagationOfAllLiteralsWhenBoundWithRandomDisjunctiveFormulas() {
TheoryTestingSupport theoryTestingSupport = TheoryTestingSupport.make(makeRandom(), new DifferenceArithmeticTheory(true, false));
extendTestingVaribles("K", theoryTestingSupport, "L", "M", "N", "O", "P");
runRandomDisjunctiveFormulasTest(theoryTestingSupport);
}
use of com.sri.ai.grinder.sgdpllt.theory.differencearithmetic.DifferenceArithmeticTheory in project aic-expresso by aic-sri-international.
the class UnificationStepSolverTest method advancedCompositeTest.
@Ignore("TODO - context implementation currently does not support these more advanced/indirect comparisons")
@Test
public void advancedCompositeTest() {
TheoryTestingSupport theoryTestingSupport = TheoryTestingSupport.make(seededRandom, new CompoundTheory(new EqualityTheory(false, true), new DifferenceArithmeticTheory(false, true), new LinearRealArithmeticTheory(false, true), new PropositionalTheory()));
// NOTE: passing explicit FunctionTypes will prevent the general variables' argument types being randomly changed.
theoryTestingSupport.setVariableNamesAndTypesForTesting(map("P", BOOLEAN_TYPE, "Q", BOOLEAN_TYPE, "R", BOOLEAN_TYPE, "unary_prop/1", new FunctionType(BOOLEAN_TYPE, BOOLEAN_TYPE), "binary_prop/2", new FunctionType(BOOLEAN_TYPE, BOOLEAN_TYPE, BOOLEAN_TYPE), "S", TESTING_CATEGORICAL_TYPE, "T", TESTING_CATEGORICAL_TYPE, "U", TESTING_CATEGORICAL_TYPE, "unary_eq/1", new FunctionType(TESTING_CATEGORICAL_TYPE, TESTING_CATEGORICAL_TYPE), "binary_eq/2", new FunctionType(TESTING_CATEGORICAL_TYPE, TESTING_CATEGORICAL_TYPE, TESTING_CATEGORICAL_TYPE), "I", TESTING_INTEGER_INTERVAL_TYPE, "J", TESTING_INTEGER_INTERVAL_TYPE, "K", TESTING_INTEGER_INTERVAL_TYPE, "unary_dar/1", new FunctionType(TESTING_INTEGER_INTERVAL_TYPE, TESTING_INTEGER_INTERVAL_TYPE), "binary_dar/2", new FunctionType(TESTING_INTEGER_INTERVAL_TYPE, TESTING_INTEGER_INTERVAL_TYPE, TESTING_INTEGER_INTERVAL_TYPE), "X", TESTING_REAL_INTERVAL_TYPE, "Y", TESTING_REAL_INTERVAL_TYPE, "Z", TESTING_REAL_INTERVAL_TYPE, "unary_lra/1", new FunctionType(TESTING_REAL_INTERVAL_TYPE, TESTING_REAL_INTERVAL_TYPE), "binary_lra/2", new FunctionType(TESTING_REAL_INTERVAL_TYPE, TESTING_REAL_INTERVAL_TYPE, TESTING_REAL_INTERVAL_TYPE)));
Context rootContext = theoryTestingSupport.makeContextWithTestingInformation();
UnificationStepSolver unificationStepSolver = new UnificationStepSolver(parse("binary_prop(P, unary_prop(P))"), parse("binary_prop(unary_prop(Q), Q)"));
Context localTestContext = rootContext.conjoinWithConjunctiveClause(parse("not P and Q and not unary_prop(Q) and unary_prop(P)"), rootContext);
StepSolver.Step<Boolean> step = unificationStepSolver.step(localTestContext);
Assert.assertEquals(false, step.itDepends());
Assert.assertEquals(true, step.getValue());
localTestContext = rootContext.conjoinWithConjunctiveClause(parse("P and Q and not unary_prop(Q) and unary_prop(P)"), rootContext);
step = unificationStepSolver.step(localTestContext);
Assert.assertEquals(false, step.itDepends());
Assert.assertEquals(false, step.getValue());
}
Aggregations