Search in sources :

Example 11 with Context

use of com.sri.ai.grinder.api.Context in project aic-expresso by aic-sri-international.

the class SymbolicShell method main.

public static void main(String[] args) {
    Theory theory = makeTheory();
    Context context = makeContext(theory);
    ConsoleIterator consoleIterator = getConsole(args);
    help(consoleIterator);
    for (String example : EXAMPLES) {
        interpretExample(example, consoleIterator, theory, context);
    }
    while (consoleIterator.hasNext()) {
        context = interpretConsoleInput(consoleIterator, theory, context);
    }
    consoleIterator.getOutputWriter().println("\nGoodbye.");
}
Also used : TrueContext(com.sri.ai.grinder.core.TrueContext) Context(com.sri.ai.grinder.api.Context) PropositionalTheory(com.sri.ai.grinder.theory.propositional.PropositionalTheory) BruteForceFallbackTheory(com.sri.ai.grinder.theory.bruteforce.BruteForceFallbackTheory) BruteForceFunctionTheory(com.sri.ai.grinder.theory.function.BruteForceFunctionTheory) EqualityTheory(com.sri.ai.grinder.theory.equality.EqualityTheory) LinearRealArithmeticTheory(com.sri.ai.grinder.theory.linearrealarithmetic.LinearRealArithmeticTheory) Theory(com.sri.ai.grinder.api.Theory) DifferenceArithmeticTheory(com.sri.ai.grinder.theory.differencearithmetic.DifferenceArithmeticTheory) CompoundTheory(com.sri.ai.grinder.theory.compound.CompoundTheory) TupleTheory(com.sri.ai.grinder.theory.tuple.TupleTheory) GUIConsoleIterator(com.sri.ai.util.console.gui.GUIConsoleIterator) ConsoleIterator(com.sri.ai.util.console.ConsoleIterator) DefaultConsoleIterator(com.sri.ai.util.console.DefaultConsoleIterator)

Example 12 with Context

use of com.sri.ai.grinder.api.Context in project aic-expresso by aic-sri-international.

the class AbstractTheoryTestingSupport method extendWithTestingInformation.

@Override
public Context extendWithTestingInformation(Context context) {
    // we only need to provide the variables types, and not the known constant types, because the latter will be extracted from the already registered types.
    Map<String, String> mapFromSymbolNamesToTypeNames = new LinkedHashMap<String, String>();
    for (Map.Entry<String, Type> symbolAndType : getVariableNamesAndTypesForTesting().entrySet()) {
        mapFromSymbolNamesToTypeNames.put(symbolAndType.getKey(), symbolAndType.getValue().toString());
    }
    for (Map.Entry<String, Type> symbolAndType : getExtendedVariableNamesAndTypesForTesting().entrySet()) {
        mapFromSymbolNamesToTypeNames.put(symbolAndType.getKey(), symbolAndType.getValue().toString());
    }
    Context result = (Context) GrinderUtil.extendRegistryWith(mapFromSymbolNamesToTypeNames, getTypesForTesting(), context);
    return result;
}
Also used : Context(com.sri.ai.grinder.api.Context) Type(com.sri.ai.expresso.api.Type) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap)

Example 13 with Context

use of com.sri.ai.grinder.api.Context in project aic-expresso by aic-sri-international.

the class MultiVariableContextWithCheckedProperty method setIsUniquelyNamedConstantPredicate.

@Override
public MultiVariableContextWithCheckedProperty setIsUniquelyNamedConstantPredicate(Predicate<Expression> isUniquelyNamedConstantPredicate) {
    MultiVariableContextWithCheckedProperty result = clone();
    Context newTail = tail.setIsUniquelyNamedConstantPredicate(isUniquelyNamedConstantPredicate);
    result.tail = newTail;
    return result;
}
Also used : Context(com.sri.ai.grinder.api.Context)

Example 14 with Context

use of com.sri.ai.grinder.api.Context in project aic-expresso by aic-sri-international.

the class MultiVariableContextWithCheckedProperty method makeNewContextWithAddedType.

@Override
public MultiVariableContextWithCheckedProperty makeNewContextWithAddedType(Type type) {
    MultiVariableContextWithCheckedProperty result = clone();
    Context newTail = tail.makeNewContextWithAddedType(type);
    result.tail = newTail;
    return result;
}
Also used : Context(com.sri.ai.grinder.api.Context)

Example 15 with Context

use of com.sri.ai.grinder.api.Context in project aic-expresso by aic-sri-international.

the class MultiVariableContextWithCheckedProperty method putAllGlobalObjects.

@Override
public MultiVariableContextWithCheckedProperty putAllGlobalObjects(Map<Object, Object> objects) {
    MultiVariableContextWithCheckedProperty result = clone();
    Context newTail = tail.putAllGlobalObjects(objects);
    result.tail = newTail;
    return result;
}
Also used : Context(com.sri.ai.grinder.api.Context)

Aggregations

Context (com.sri.ai.grinder.api.Context)132 Expression (com.sri.ai.expresso.api.Expression)100 Test (org.junit.Test)50 TrueContext (com.sri.ai.grinder.core.TrueContext)40 TheoryTestingSupport (com.sri.ai.grinder.tester.TheoryTestingSupport)36 DifferenceArithmeticTheory (com.sri.ai.grinder.theory.differencearithmetic.DifferenceArithmeticTheory)32 Type (com.sri.ai.expresso.api.Type)31 Theory (com.sri.ai.grinder.api.Theory)24 PropositionalTheory (com.sri.ai.grinder.theory.propositional.PropositionalTheory)23 IndexExpressionsSet (com.sri.ai.expresso.api.IndexExpressionsSet)22 EqualityTheory (com.sri.ai.grinder.theory.equality.EqualityTheory)21 Set (java.util.Set)20 IntensionalSet (com.sri.ai.expresso.api.IntensionalSet)19 CompoundTheory (com.sri.ai.grinder.theory.compound.CompoundTheory)19 CompleteMultiVariableContext (com.sri.ai.grinder.core.constraint.CompleteMultiVariableContext)16 Map (java.util.Map)16 Beta (com.google.common.annotations.Beta)15 Constraint (com.sri.ai.grinder.api.Constraint)15 Expressions.parse (com.sri.ai.expresso.helper.Expressions.parse)14 SingleVariableConstraint (com.sri.ai.grinder.api.SingleVariableConstraint)14