Search in sources :

Example 36 with PropositionalTheory

use of com.sri.ai.grinder.theory.propositional.PropositionalTheory in project aic-expresso by aic-sri-international.

the class CompoundTheoryWithoutDifferenceArithmeticTest method runCompleteSatisfiabilityTest.

/**
 * @param conjunction
 * @param expected
 */
private void runCompleteSatisfiabilityTest(String conjunction, Expression expected, Map<String, Type> variableNamesAndTypesForTesting) {
    TheoryTestingSupport equalityTheoryTestingSupport = TheoryTestingSupport.make(makeRandom(), new EqualityTheory(true, true));
    equalityTheoryTestingSupport.setVariableNamesAndTypesForTesting(variableNamesAndTypesForTesting);
    TheoryTestingSupport theoryTestingSupport = TheoryTestingSupport.make(makeRandom(), equalityTheoryTestingSupport, TheoryTestingSupport.make(makeRandom(), new PropositionalTheory()));
    Context context = theoryTestingSupport.makeContextWithTestingInformation();
    for (Expression literal : And.getConjuncts(parse(conjunction))) {
        context = context.conjoin(literal, context);
    }
    assertEquals(expected, context);
}
Also used : TrueContext(com.sri.ai.grinder.core.TrueContext) Context(com.sri.ai.grinder.api.Context) EqualityTheory(com.sri.ai.grinder.theory.equality.EqualityTheory) Expression(com.sri.ai.expresso.api.Expression) AbstractTheoryTestingSupport(com.sri.ai.grinder.core.constraint.AbstractTheoryTestingSupport) TheoryTestingSupport(com.sri.ai.grinder.tester.TheoryTestingSupport) PropositionalTheory(com.sri.ai.grinder.theory.propositional.PropositionalTheory)

Example 37 with PropositionalTheory

use of com.sri.ai.grinder.theory.propositional.PropositionalTheory in project aic-expresso by aic-sri-international.

the class FirstOfTest method runTest.

private void runTest(List<Rewriter> rewriters, Expression initial, Expression expected, Map<Expression, Expression> symbolsAndTypes) {
    CompoundTheory theory = new CompoundTheory(new PropositionalTheory(), new DifferenceArithmeticTheory(false, true));
    Context context = new TrueContext(theory);
    context = context.makeCloneWithAdditionalRegisteredSymbolsAndTypes(symbolsAndTypes);
    Rewriter firstOf = new FirstOf(rewriters);
    Expression solution = firstOf.apply(initial, context);
    System.out.println("Solution: " + solution);
    assertEquals(expected, solution);
}
Also used : TrueContext(com.sri.ai.grinder.core.TrueContext) Context(com.sri.ai.grinder.api.Context) Expression(com.sri.ai.expresso.api.Expression) DifferenceArithmeticTheory(com.sri.ai.grinder.theory.differencearithmetic.DifferenceArithmeticTheory) Rewriter(com.sri.ai.grinder.rewriter.api.Rewriter) PropositionalTheory(com.sri.ai.grinder.theory.propositional.PropositionalTheory) FirstOf(com.sri.ai.grinder.rewriter.core.FirstOf) CompoundTheory(com.sri.ai.grinder.theory.compound.CompoundTheory) TrueContext(com.sri.ai.grinder.core.TrueContext)

Example 38 with PropositionalTheory

use of com.sri.ai.grinder.theory.propositional.PropositionalTheory in project aic-expresso by aic-sri-international.

the class SwitchTest method runTest.

private void runTest(Rewriter rewriter, Expression initial, Expression expected, Map<Expression, Expression> symbolsAndTypes) {
    CompoundTheory theory = new CompoundTheory(new PropositionalTheory(), new DifferenceArithmeticTheory(false, true));
    Context context = new TrueContext(theory);
    context = context.makeCloneWithAdditionalRegisteredSymbolsAndTypes(symbolsAndTypes);
    Rewriter recursive = new Recursive(rewriter);
    Expression solution = recursive.apply(initial, context);
    System.out.println("Solution: " + solution);
    assertEquals(expected, solution);
}
Also used : TrueContext(com.sri.ai.grinder.core.TrueContext) Context(com.sri.ai.grinder.api.Context) Expression(com.sri.ai.expresso.api.Expression) DifferenceArithmeticTheory(com.sri.ai.grinder.theory.differencearithmetic.DifferenceArithmeticTheory) CombiningTopRewriter(com.sri.ai.grinder.rewriter.core.CombiningTopRewriter) Rewriter(com.sri.ai.grinder.rewriter.api.Rewriter) TopRewriter(com.sri.ai.grinder.rewriter.api.TopRewriter) PropositionalTheory(com.sri.ai.grinder.theory.propositional.PropositionalTheory) CompoundTheory(com.sri.ai.grinder.theory.compound.CompoundTheory) Recursive(com.sri.ai.grinder.rewriter.core.Recursive) TrueContext(com.sri.ai.grinder.core.TrueContext)

Example 39 with PropositionalTheory

use of com.sri.ai.grinder.theory.propositional.PropositionalTheory 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);
}
Also used : EqualityTheory(com.sri.ai.grinder.theory.equality.EqualityTheory) DifferenceArithmeticTheory(com.sri.ai.grinder.theory.differencearithmetic.DifferenceArithmeticTheory) PropositionalTheory(com.sri.ai.grinder.theory.propositional.PropositionalTheory) CompoundTheory(com.sri.ai.grinder.theory.compound.CompoundTheory) TrueContext(com.sri.ai.grinder.core.TrueContext) TupleTheory(com.sri.ai.grinder.theory.tuple.TupleTheory) Before(org.junit.Before)

Aggregations

PropositionalTheory (com.sri.ai.grinder.theory.propositional.PropositionalTheory)39 CompoundTheory (com.sri.ai.grinder.theory.compound.CompoundTheory)33 DifferenceArithmeticTheory (com.sri.ai.grinder.theory.differencearithmetic.DifferenceArithmeticTheory)32 EqualityTheory (com.sri.ai.grinder.theory.equality.EqualityTheory)30 Context (com.sri.ai.grinder.api.Context)25 Expression (com.sri.ai.expresso.api.Expression)23 TrueContext (com.sri.ai.grinder.core.TrueContext)19 TheoryTestingSupport (com.sri.ai.grinder.tester.TheoryTestingSupport)18 Test (org.junit.Test)17 LinearRealArithmeticTheory (com.sri.ai.grinder.theory.linearrealarithmetic.LinearRealArithmeticTheory)16 Theory (com.sri.ai.grinder.api.Theory)11 TupleTheory (com.sri.ai.grinder.theory.tuple.TupleTheory)11 Type (com.sri.ai.expresso.api.Type)8 LinkedHashMap (java.util.LinkedHashMap)6 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 Rewriter (com.sri.ai.grinder.rewriter.api.Rewriter)4 UnificationStepSolver (com.sri.ai.grinder.theory.base.UnificationStepSolver)4 Before (org.junit.Before)4