Search in sources :

Example 6 with EqualityTheory

use of com.sri.ai.grinder.theory.equality.EqualityTheory in project aic-expresso by aic-sri-international.

the class Tests method main.

public void main(String[] args) {
    // Theory initialization
    theory = new CompoundTheory(new EqualityTheory(false, true), new DifferenceArithmeticTheory(false, false), new LinearRealArithmeticTheory(false, false), new TupleTheory(), new PropositionalTheory());
    context = new TrueContext(theory);
    context = context.extendWithSymbolsAndTypes("A", "Boolean");
    // Testing BFS Expander
    println("Testing BFS.");
    testingBFS();
    // // Testing on standard output (output results on screen)
    // println("Testing and printing on screen.");
    // testingAndPrintingOnScreen();
    println("Running main test.");
    runTest();
}
Also used : EqualityTheory(com.sri.ai.grinder.theory.equality.EqualityTheory) DifferenceArithmeticTheory(com.sri.ai.grinder.theory.differencearithmetic.DifferenceArithmeticTheory) LinearRealArithmeticTheory(com.sri.ai.grinder.theory.linearrealarithmetic.LinearRealArithmeticTheory) PropositionalTheory(com.sri.ai.grinder.theory.propositional.PropositionalTheory) CompoundTheory(com.sri.ai.grinder.theory.compound.CompoundTheory) TupleTheory(com.sri.ai.grinder.theory.tuple.TupleTheory) TrueContext(com.sri.ai.grinder.core.TrueContext)

Example 7 with EqualityTheory

use of com.sri.ai.grinder.theory.equality.EqualityTheory in project aic-expresso by aic-sri-international.

the class SampleCommonInterpreterTest method setUp.

@Before
public void setUp() {
    // Make tests repeatable
    random = new Random(1);
    context = new TrueContext(new CompoundTheory(new DifferenceArithmeticTheory(false, false), new LinearRealArithmeticTheory(false, false), new EqualityTheory(false, false), new PropositionalTheory()));
}
Also used : EqualityTheory(com.sri.ai.grinder.theory.equality.EqualityTheory) Random(java.util.Random) DifferenceArithmeticTheory(com.sri.ai.grinder.theory.differencearithmetic.DifferenceArithmeticTheory) LinearRealArithmeticTheory(com.sri.ai.grinder.theory.linearrealarithmetic.LinearRealArithmeticTheory) PropositionalTheory(com.sri.ai.grinder.theory.propositional.PropositionalTheory) CompoundTheory(com.sri.ai.grinder.theory.compound.CompoundTheory) TrueContext(com.sri.ai.grinder.core.TrueContext) Before(org.junit.Before)

Example 8 with EqualityTheory

use of com.sri.ai.grinder.theory.equality.EqualityTheory in project aic-expresso by aic-sri-international.

the class BoundsTest method declareTheoryContextAndSetOfFactors.

@Before
public void declareTheoryContextAndSetOfFactors() {
    ExpressoConfiguration.setDisplayNumericsExactlyForSymbols(true);
    extensionalBound = new DefaultExtensionalBound();
    intensionalBound = new DefaultIntensionalBound();
    theory = new CompoundTheory(new EqualityTheory(false, true), new DifferenceArithmeticTheory(false, false), new LinearRealArithmeticTheory(false, false), new TupleTheory(), new PropositionalTheory());
    context = new TrueContext(theory);
    context = context.extendWithSymbolsAndTypes("X", "Boolean");
    context = context.extendWithSymbolsAndTypes("Y", "Boolean");
    context = context.extendWithSymbolsAndTypes("A", "Boolean");
    context = context.extendWithSymbolsAndTypes("B", "Boolean");
    context = context.extendWithSymbolsAndTypes("C", "1..5");
    // context = context.extendWithSymbolsAndTypes("D","{1,3,4,8}");
    // Set of functions
    Expression phi1 = parse("if X = true then 1 else if Y = true then 2 else 3");
    Expression phi2 = parse("if A = true then if Y = true then 4 else 5 else 6");
    Expression phi3 = parse("if X = true then 7 else if B = true then 8 else 9");
    Expression phi4 = parse("if B = true then 10 else if A = true then 11 else 12");
    Expression phi5 = parse("if C < 4 then 10 else if C = 4 then 11 else 12");
    /*
		 * This is how we create a non empty extensional bound
		 */
    setOfFactors = new DefaultExtensionalBound(arrayList(phi1, phi2, phi3, phi4, phi5));
    // Set of numbers
    setOfNumbers = new DefaultExtensionalBound(arrayList(ONE, TWO));
    Set<Expression> factor = new HashSet<Expression>();
    model = new Model(factor);
    model.context = model.context.extendWithSymbolsAndTypes("A", "Boolean");
    model.context = model.context.extendWithSymbolsAndTypes("B", "Boolean");
    model.context = model.context.extendWithSymbolsAndTypes("Q", "Boolean");
    model.context = model.context.extendWithSymbolsAndTypes("C", "1..4");
    model.context = model.context.extendWithSymbolsAndTypes("D", "6..9");
    intensionalSetOfFactors1 = new DefaultIntensionalBound(arrayList(parse("A' in Boolean"), parse("C' in 1..5")), parse("if C = C' then if A = A' then 1 else 4 else 0"), TRUE);
    intensionalSetOfFactors2 = DefaultIntensionalBound.simplex(arrayList(parse("A")), model);
    intensionalSetOfFactors3 = DefaultIntensionalBound.simplex(arrayList(parse("C"), parse("B")), model);
}
Also used : EqualityTheory(com.sri.ai.grinder.theory.equality.EqualityTheory) DefaultIntensionalBound(com.sri.ai.grinder.library.bounds.DefaultIntensionalBound) DifferenceArithmeticTheory(com.sri.ai.grinder.theory.differencearithmetic.DifferenceArithmeticTheory) LinearRealArithmeticTheory(com.sri.ai.grinder.theory.linearrealarithmetic.LinearRealArithmeticTheory) PropositionalTheory(com.sri.ai.grinder.theory.propositional.PropositionalTheory) CompoundTheory(com.sri.ai.grinder.theory.compound.CompoundTheory) TupleTheory(com.sri.ai.grinder.theory.tuple.TupleTheory) TrueContext(com.sri.ai.grinder.core.TrueContext) Expression(com.sri.ai.expresso.api.Expression) DefaultExtensionalBound(com.sri.ai.grinder.library.bounds.DefaultExtensionalBound) Model(com.sri.ai.grinder.anytime.Model) HashSet(java.util.HashSet) Before(org.junit.Before)

Example 9 with EqualityTheory

use of com.sri.ai.grinder.theory.equality.EqualityTheory in project aic-expresso by aic-sri-international.

the class ExpressionStepSolverToLiteralSplitterStepSolverAdapterTest method testEqualityTheoryWithPropagationOfAllLiteralsWhenBoundWithRandomDisjunctiveFormulas.

@Test
public void testEqualityTheoryWithPropagationOfAllLiteralsWhenBoundWithRandomDisjunctiveFormulas() {
    TheoryTestingSupport theoryTestingSupport = TheoryTestingSupport.make(makeRandom(), new EqualityTheory(true, true));
    extendTestingVariables("X", theoryTestingSupport, "S", "T", "U", "V", "W");
    runRandomDisjunctiveFormulasTest(theoryTestingSupport);
}
Also used : EqualityTheory(com.sri.ai.grinder.theory.equality.EqualityTheory) TheoryTestingSupport(com.sri.ai.grinder.tester.TheoryTestingSupport) Test(org.junit.Test)

Example 10 with EqualityTheory

use of com.sri.ai.grinder.theory.equality.EqualityTheory in project aic-expresso by aic-sri-international.

the class ExpressionStepSolverToLiteralSplitterStepSolverAdapterTest method testEqualityTheoryWithoutPropagationOfAllLiteralsWhenBoundWithRandomDisjunctiveFormulas.

@Test
public void testEqualityTheoryWithoutPropagationOfAllLiteralsWhenBoundWithRandomDisjunctiveFormulas() {
    TheoryTestingSupport theoryTestingSupport = TheoryTestingSupport.make(makeRandom(), new EqualityTheory(true, false));
    extendTestingVariables("X", theoryTestingSupport, "S", "T", "U", "V", "W");
    runRandomDisjunctiveFormulasTest(theoryTestingSupport);
}
Also used : EqualityTheory(com.sri.ai.grinder.theory.equality.EqualityTheory) TheoryTestingSupport(com.sri.ai.grinder.tester.TheoryTestingSupport) Test(org.junit.Test)

Aggregations

EqualityTheory (com.sri.ai.grinder.theory.equality.EqualityTheory)37 PropositionalTheory (com.sri.ai.grinder.theory.propositional.PropositionalTheory)30 CompoundTheory (com.sri.ai.grinder.theory.compound.CompoundTheory)28 DifferenceArithmeticTheory (com.sri.ai.grinder.theory.differencearithmetic.DifferenceArithmeticTheory)27 Context (com.sri.ai.grinder.api.Context)22 Expression (com.sri.ai.expresso.api.Expression)21 TheoryTestingSupport (com.sri.ai.grinder.tester.TheoryTestingSupport)20 Test (org.junit.Test)18 TrueContext (com.sri.ai.grinder.core.TrueContext)15 LinearRealArithmeticTheory (com.sri.ai.grinder.theory.linearrealarithmetic.LinearRealArithmeticTheory)15 TupleTheory (com.sri.ai.grinder.theory.tuple.TupleTheory)11 Theory (com.sri.ai.grinder.api.Theory)10 Type (com.sri.ai.expresso.api.Type)8 LinkedHashMap (java.util.LinkedHashMap)7 Expressions (com.sri.ai.expresso.helper.Expressions)4 FunctionType (com.sri.ai.expresso.type.FunctionType)4 StepSolver (com.sri.ai.grinder.api.StepSolver)4 AbstractTheoryTestingSupport (com.sri.ai.grinder.core.constraint.AbstractTheoryTestingSupport)4 UnificationStepSolver (com.sri.ai.grinder.theory.base.UnificationStepSolver)4 Before (org.junit.Before)4