Search in sources :

Example 46 with ExtensionalIndexExpressionsSet

use of com.sri.ai.expresso.core.ExtensionalIndexExpressionsSet in project aic-expresso by aic-sri-international.

the class IndexExpressions method makeExtensionalIndexExpressionsSetFromSymbolsAndTypesStrings.

public static ExtensionalIndexExpressionsSet makeExtensionalIndexExpressionsSetFromSymbolsAndTypesStrings(String... symbolsAndTypes) {
    Expression[] symbolsAndTypesExpressions = GrinderUtil.makeListOfSymbolsAndTypesExpressionsFromSymbolsAndTypesStrings(symbolsAndTypes);
    List<Expression> indexExpressions = GrinderUtil.makeIndexExpressionsFromSymbolsAndTypes(symbolsAndTypesExpressions);
    ExtensionalIndexExpressionsSet result = new ExtensionalIndexExpressionsSet(indexExpressions);
    return result;
}
Also used : ExtensionalIndexExpressionsSet(com.sri.ai.expresso.core.ExtensionalIndexExpressionsSet) Expression(com.sri.ai.expresso.api.Expression) QuantifiedExpression(com.sri.ai.expresso.api.QuantifiedExpression)

Example 47 with ExtensionalIndexExpressionsSet

use of com.sri.ai.expresso.core.ExtensionalIndexExpressionsSet in project aic-expresso by aic-sri-international.

the class ThereExists method make.

public static Expression make(IndexExpressionsSet indexExpressions, Expression body) {
    Expression current = body;
    List<Expression> indexExpressionsList = ((ExtensionalIndexExpressionsSet) indexExpressions).getList();
    for (int i = indexExpressionsList.size() - 1; i >= 0; i--) {
        current = make(indexExpressionsList.get(i), current);
    }
    return current;
}
Also used : ExtensionalIndexExpressionsSet(com.sri.ai.expresso.core.ExtensionalIndexExpressionsSet) Expression(com.sri.ai.expresso.api.Expression)

Example 48 with ExtensionalIndexExpressionsSet

use of com.sri.ai.expresso.core.ExtensionalIndexExpressionsSet in project aic-expresso by aic-sri-international.

the class GrinderUtil method makeIndexExpressionsForIndicesInListAndTypesInRegistry.

/**
 * Returns a list of index expressions corresponding to the given indices and their types per the registry, if any.
 */
public static ExtensionalIndexExpressionsSet makeIndexExpressionsForIndicesInListAndTypesInRegistry(Collection<Expression> indices, Registry registry) {
    List<Expression> indexExpressions = new LinkedList<Expression>();
    for (Expression index : indices) {
        Expression type = registry.getTypeExpressionOfRegisteredSymbol(index);
        Expression indexExpression = IndexExpressions.makeIndexExpression(index, type);
        indexExpressions.add(indexExpression);
    }
    return new ExtensionalIndexExpressionsSet(indexExpressions);
}
Also used : ExtensionalIndexExpressionsSet(com.sri.ai.expresso.core.ExtensionalIndexExpressionsSet) Expression(com.sri.ai.expresso.api.Expression) LambdaExpression(com.sri.ai.expresso.api.LambdaExpression) LinkedList(java.util.LinkedList)

Example 49 with ExtensionalIndexExpressionsSet

use of com.sri.ai.expresso.core.ExtensionalIndexExpressionsSet in project aic-expresso by aic-sri-international.

the class AbstractFunctionBasedGroup method makeProblemExpression.

public Expression makeProblemExpression(List<Expression> indices, List<Expression> indicesTypes, Expression constraint, Expression body) {
    List<Expression> indexExpressions = makeIndexExpressions(indices, indicesTypes);
    IndexExpressionsSet indexExpressionsSet = new ExtensionalIndexExpressionsSet(indexExpressions);
    DefaultIntensionalMultiSet set = new DefaultIntensionalMultiSet(indexExpressionsSet, body, constraint);
    Expression problem = apply(getQuantifierFunctionString(), set);
    return problem;
}
Also used : ExtensionalIndexExpressionsSet(com.sri.ai.expresso.core.ExtensionalIndexExpressionsSet) Expression(com.sri.ai.expresso.api.Expression) ExtensionalIndexExpressionsSet(com.sri.ai.expresso.core.ExtensionalIndexExpressionsSet) IndexExpressionsSet(com.sri.ai.expresso.api.IndexExpressionsSet) DefaultIntensionalMultiSet(com.sri.ai.expresso.core.DefaultIntensionalMultiSet)

Example 50 with ExtensionalIndexExpressionsSet

use of com.sri.ai.expresso.core.ExtensionalIndexExpressionsSet in project aic-expresso by aic-sri-international.

the class SimplifierForQuantificationOn method applySimplifier.

@Override
public Expression applySimplifier(Expression expression, Context context) {
    Expression result;
    try {
        QuantifiedExpressionWithABody quantifiedExpression = (QuantifiedExpressionWithABody) expression;
        Expression body = quantifiedExpression.getBody();
        ExtensionalIndexExpressionsSet indexExpressions = (ExtensionalIndexExpressionsSet) quantifiedExpression.getIndexExpressions();
        // the set is intensional, but not the set of index expressions!
        result = quantifierEliminator.extendContextAndSolve(group, indexExpressions, TRUE, body, context);
    } catch (IllegalArgumentException exception) {
        result = expression;
    }
    return result;
}
Also used : ExtensionalIndexExpressionsSet(com.sri.ai.expresso.core.ExtensionalIndexExpressionsSet) QuantifiedExpressionWithABody(com.sri.ai.expresso.api.QuantifiedExpressionWithABody) Expression(com.sri.ai.expresso.api.Expression)

Aggregations

Expression (com.sri.ai.expresso.api.Expression)56 ExtensionalIndexExpressionsSet (com.sri.ai.expresso.core.ExtensionalIndexExpressionsSet)56 IndexExpressionsSet (com.sri.ai.expresso.api.IndexExpressionsSet)24 ArrayList (java.util.ArrayList)14 LambdaExpression (com.sri.ai.expresso.api.LambdaExpression)12 IntensionalSet (com.sri.ai.expresso.api.IntensionalSet)10 DefaultLambdaExpression (com.sri.ai.expresso.core.DefaultLambdaExpression)10 IndexExpressions (com.sri.ai.grinder.library.indexexpression.IndexExpressions)8 Type (com.sri.ai.expresso.api.Type)7 Context (com.sri.ai.grinder.api.Context)7 Expressions (com.sri.ai.expresso.helper.Expressions)5 Theory (com.sri.ai.grinder.api.Theory)5 Util (com.sri.ai.util.Util)5 QuantifiedExpression (com.sri.ai.expresso.api.QuantifiedExpression)4 Pair (com.sri.ai.util.base.Pair)4 Collection (java.util.Collection)4 Map (java.util.Map)4 Set (java.util.Set)4 Predicate (com.google.common.base.Predicate)3 Symbol (com.sri.ai.expresso.api.Symbol)3