Search in sources :

Example 6 with CompoundTheory

use of com.sri.ai.grinder.theory.compound.CompoundTheory in project aic-expresso by aic-sri-international.

the class BoundsTest method declareTheoryContextAndSetOfFactors.

private void declareTheoryContextAndSetOfFactors() {
    /* That's how we create a empty bound
		 * It is useful for abstracting the kind of bound we are talking about:
		 * 		if you say to a program that one of his attributes is a bound, you can let the user choose
		 * 		between a extensional or intensional representation just by passing the right object as 
		 * 		argument.
		 * 
		 * 		Example:
		 * 		
		 * 		class foo{
		 * 			Bound b
		 * 			...
		 * 			public foo(Bound b, ...) {
		 *				this.b = b;
		 *				...
		 *			} 	 
		 * 		}
		 * 		
		 * 		Use:
		 * 		foo object = new foo(new DefaultExtensionalBound(),...);
		 * 		
		 * */
    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)

Example 7 with CompoundTheory

use of com.sri.ai.grinder.theory.compound.CompoundTheory in project aic-expresso by aic-sri-international.

the class IntensionalSetFalseConditionToEmptySetSimplifierTest 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 IntensionalSetFalseConditionToEmptySetSimplifier();
}
Also used : DifferenceArithmeticTheory(com.sri.ai.grinder.theory.differencearithmetic.DifferenceArithmeticTheory) IntegerInterval(com.sri.ai.expresso.type.IntegerInterval) CompoundTheory(com.sri.ai.grinder.theory.compound.CompoundTheory) TrueContext(com.sri.ai.grinder.core.TrueContext) TupleTheory(com.sri.ai.grinder.theory.tuple.TupleTheory) IntensionalSetFalseConditionToEmptySetSimplifier(com.sri.ai.grinder.library.set.IntensionalSetFalseConditionToEmptySetSimplifier) Before(org.junit.Before)

Example 8 with CompoundTheory

use of com.sri.ai.grinder.theory.compound.CompoundTheory 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();
}
Also used : DifferenceArithmeticTheory(com.sri.ai.grinder.theory.differencearithmetic.DifferenceArithmeticTheory) IntegerInterval(com.sri.ai.expresso.type.IntegerInterval) IntensionalSetToConditionalSimplifier(com.sri.ai.grinder.library.set.invsupport.IntensionalSetToConditionalSimplifier) 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)

Example 9 with CompoundTheory

use of com.sri.ai.grinder.theory.compound.CompoundTheory in project aic-expresso by aic-sri-international.

the class IntersectionExtensionalSetSimplifierTest method setUp.

@Before
public void setUp() {
    context = new TrueContext(new CompoundTheory(new DifferenceArithmeticTheory(false, false), new TupleTheory()));
    IntegerInterval intType = new IntegerInterval(1, 10);
    context = (Context) GrinderUtil.extendRegistryWith(map("M", intType.toString(), "N", intType.toString()), Arrays.asList(intType), context);
    simplifier = new IntersectionExtensionalSetSimplifier();
}
Also used : IntersectionExtensionalSetSimplifier(com.sri.ai.grinder.library.set.invsupport.IntersectionExtensionalSetSimplifier) DifferenceArithmeticTheory(com.sri.ai.grinder.theory.differencearithmetic.DifferenceArithmeticTheory) IntegerInterval(com.sri.ai.expresso.type.IntegerInterval) 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)

Example 10 with CompoundTheory

use of com.sri.ai.grinder.theory.compound.CompoundTheory in project aic-expresso by aic-sri-international.

the class IntersectionIntensionalSetsSimplifierTest 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 IntersectionIntensionalSetsSimplifier();
}
Also used : DifferenceArithmeticTheory(com.sri.ai.grinder.theory.differencearithmetic.DifferenceArithmeticTheory) IntegerInterval(com.sri.ai.expresso.type.IntegerInterval) IntersectionIntensionalSetsSimplifier(com.sri.ai.grinder.library.set.invsupport.IntersectionIntensionalSetsSimplifier) 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

CompoundTheory (com.sri.ai.grinder.theory.compound.CompoundTheory)37 DifferenceArithmeticTheory (com.sri.ai.grinder.theory.differencearithmetic.DifferenceArithmeticTheory)36 PropositionalTheory (com.sri.ai.grinder.theory.propositional.PropositionalTheory)27 TrueContext (com.sri.ai.grinder.core.TrueContext)25 EqualityTheory (com.sri.ai.grinder.theory.equality.EqualityTheory)23 TupleTheory (com.sri.ai.grinder.theory.tuple.TupleTheory)19 Context (com.sri.ai.grinder.api.Context)18 Expression (com.sri.ai.expresso.api.Expression)16 IntegerInterval (com.sri.ai.expresso.type.IntegerInterval)12 LinearRealArithmeticTheory (com.sri.ai.grinder.theory.linearrealarithmetic.LinearRealArithmeticTheory)12 Before (org.junit.Before)12 Test (org.junit.Test)12 TheoryTestingSupport (com.sri.ai.grinder.tester.TheoryTestingSupport)11 Type (com.sri.ai.expresso.api.Type)8 Theory (com.sri.ai.grinder.api.Theory)6 LinkedHashMap (java.util.LinkedHashMap)5 Rewriter (com.sri.ai.grinder.rewriter.api.Rewriter)4 FunctionType (com.sri.ai.expresso.type.FunctionType)3 Recursive (com.sri.ai.grinder.rewriter.core.Recursive)3 BruteForceFunctionTheory (com.sri.ai.grinder.theory.function.BruteForceFunctionTheory)3