use of com.sri.ai.grinder.core.TrueContext in project aic-expresso by aic-sri-international.
the class LambdaBetaReductionSimplifierTest method testNoReduction.
@Test
public void testNoReduction() {
Type peopleType = new Categorical("People", 4, arrayList(makeSymbol("ann"), makeSymbol("bob"), makeSymbol("tom")));
Context context = new TrueContext();
context = context.makeNewContextWithAddedType(peopleType);
Assert.assertEquals(parse("(lambda X in People : if X = ann then 0 else if X = bob then 0 else 0)()"), simplifier.apply(parse("(lambda X in People : if X = ann then 0 else if X = bob then 0 else 0)()"), context));
Assert.assertEquals(parse("(lambda X in People, Y in People : if X = ann then 0 else if Y = bob then 0 else 0)(ann)"), simplifier.apply(parse("(lambda X in People, Y in People : if X = ann then 0 else if Y = bob then 0 else 0)(ann)"), context));
Assert.assertEquals(parse("(lambda X in People, Y in People : if X = ann then 0 else if Y = bob then 0 else 0)(ann, bob, tom)"), simplifier.apply(parse("(lambda X in People, Y in People : if X = ann then 0 else if Y = bob then 0 else 0)(ann, bob, tom)"), context));
}
use of com.sri.ai.grinder.core.TrueContext in project aic-expresso by aic-sri-international.
the class ProceduralAttachmentsTest method test.
@Test
public void test() {
Context context;
Expression input;
Expression expected;
context = new TrueContext();
Simplifier replaceBy10 = (e, c) -> makeSymbol(10);
registerProceduralAttachment(makeSymbol("ten"), replaceBy10, context);
Simplifier makeHWithFlippedArguments = (e, c) -> apply("h", e.getArguments());
registerProceduralAttachment(makeSymbol("g"), 2, makeHWithFlippedArguments, context);
input = parse("ten + 1 + g(1, 2) + g(1)");
expected = parse("11 + h(1, 2) + g(1)");
runTest(input, expected, context);
}
use of com.sri.ai.grinder.core.TrueContext 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();
}
use of com.sri.ai.grinder.core.TrueContext 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.core.TrueContext 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();
}
Aggregations