Search in sources :

Example 1 with IndexExpressions

use of com.sri.ai.grinder.library.indexexpression.IndexExpressions in project aic-expresso by aic-sri-international.

the class Expressions method makeDefaultIntensionalMultiSetFromLabelAndSubTrees.

private static Expression makeDefaultIntensionalMultiSetFromLabelAndSubTrees(Object label, Object[] subTreeObjects) {
    if (subTreeObjects.length == 1 && subTreeObjects[0] instanceof Collection) {
        subTreeObjects = ((Collection) subTreeObjects[0]).toArray();
    }
    ArrayList<Expression> subTreeExpressions = Util.mapIntoArrayList(subTreeObjects, Expressions::makeFromObject);
    if (subTreeExpressions.size() == 1) {
        subTreeExpressions = new ArrayList<Expression>(Expressions.ensureListFromKleeneList(subTreeExpressions.get(0)));
    }
    Expression scopingExpression = subTreeExpressions.get(0);
    IndexExpressionsSet indexExpressions = new ExtensionalIndexExpressionsSet((scopingExpression == null || scopingExpression.numberOfArguments() == 0) ? Util.list() : new ArrayList<Expression>(Expressions.ensureListFromKleeneList(scopingExpression.get(0))));
    Expression conditioningSyntaxTree = subTreeExpressions.get(2);
    Expression condition = conditioningSyntaxTree == null ? Expressions.TRUE : conditioningSyntaxTree.get(0);
    Expression result = new DefaultIntensionalMultiSet(indexExpressions, subTreeExpressions.get(1), condition);
    return result;
}
Also used : ExtensionalIndexExpressionsSet(com.sri.ai.expresso.core.ExtensionalIndexExpressionsSet) DefaultLambdaExpression(com.sri.ai.expresso.core.DefaultLambdaExpression) Expression(com.sri.ai.expresso.api.Expression) LambdaExpression(com.sri.ai.expresso.api.LambdaExpression) ArrayList(java.util.ArrayList) Collection(java.util.Collection) IndexExpressions(com.sri.ai.grinder.library.indexexpression.IndexExpressions) ExtensionalIndexExpressionsSet(com.sri.ai.expresso.core.ExtensionalIndexExpressionsSet) IndexExpressionsSet(com.sri.ai.expresso.api.IndexExpressionsSet) DefaultIntensionalMultiSet(com.sri.ai.expresso.core.DefaultIntensionalMultiSet)

Example 2 with IndexExpressions

use of com.sri.ai.grinder.library.indexexpression.IndexExpressions in project aic-expresso by aic-sri-international.

the class Expressions method makeDefaultLambdaExpressionFromLabelAndSubTrees.

private static Expression makeDefaultLambdaExpressionFromLabelAndSubTrees(Object label, Object[] subTreeObjects) {
    ArrayList<Expression> subTreeExpressions = Util.mapIntoArrayList(subTreeObjects, Expressions::makeFromObject);
    Expression indexExpressionsKleeneList = subTreeExpressions.get(0);
    IndexExpressionsSet indexExpressions = new ExtensionalIndexExpressionsSet(ensureListFromKleeneList(indexExpressionsKleeneList));
    Expression body = subTreeExpressions.get(1);
    Expression result = new DefaultLambdaExpression(indexExpressions, body);
    return result;
}
Also used : ExtensionalIndexExpressionsSet(com.sri.ai.expresso.core.ExtensionalIndexExpressionsSet) DefaultLambdaExpression(com.sri.ai.expresso.core.DefaultLambdaExpression) Expression(com.sri.ai.expresso.api.Expression) LambdaExpression(com.sri.ai.expresso.api.LambdaExpression) DefaultLambdaExpression(com.sri.ai.expresso.core.DefaultLambdaExpression) IndexExpressions(com.sri.ai.grinder.library.indexexpression.IndexExpressions) ExtensionalIndexExpressionsSet(com.sri.ai.expresso.core.ExtensionalIndexExpressionsSet) IndexExpressionsSet(com.sri.ai.expresso.api.IndexExpressionsSet)

Example 3 with IndexExpressions

use of com.sri.ai.grinder.library.indexexpression.IndexExpressions in project aic-expresso by aic-sri-international.

the class Expressions method makeDefaultCountingFormulaExpressionFromLabelAndSubTrees.

private static Expression makeDefaultCountingFormulaExpressionFromLabelAndSubTrees(Object label, Object[] subTreeObjects) {
    ArrayList<Expression> subTreeExpressions = Util.mapIntoArrayList(subTreeObjects, Expressions::makeFromObject);
    Expression indexExpressionsKleeneList = subTreeExpressions.get(0);
    IndexExpressionsSet indexExpressions = new ExtensionalIndexExpressionsSet(ensureListFromKleeneList(indexExpressionsKleeneList));
    Expression body = subTreeExpressions.get(1);
    Expression result = new DefaultCountingFormula(indexExpressions, body);
    return result;
}
Also used : ExtensionalIndexExpressionsSet(com.sri.ai.expresso.core.ExtensionalIndexExpressionsSet) DefaultLambdaExpression(com.sri.ai.expresso.core.DefaultLambdaExpression) Expression(com.sri.ai.expresso.api.Expression) LambdaExpression(com.sri.ai.expresso.api.LambdaExpression) IndexExpressions(com.sri.ai.grinder.library.indexexpression.IndexExpressions) ExtensionalIndexExpressionsSet(com.sri.ai.expresso.core.ExtensionalIndexExpressionsSet) IndexExpressionsSet(com.sri.ai.expresso.api.IndexExpressionsSet) DefaultCountingFormula(com.sri.ai.expresso.core.DefaultCountingFormula)

Example 4 with IndexExpressions

use of com.sri.ai.grinder.library.indexexpression.IndexExpressions in project aic-expresso by aic-sri-international.

the class Expressions method makeDefaultExistentiallyQuantifiedFormulaFromLabelAndSubTrees.

private static Expression makeDefaultExistentiallyQuantifiedFormulaFromLabelAndSubTrees(Object label, Object[] subTreeObjects) {
    ArrayList<Expression> subTreeExpressions = Util.mapIntoArrayList(subTreeObjects, Expressions::makeFromObject);
    Expression indexExpressionsKleeneList = subTreeExpressions.get(0);
    IndexExpressionsSet indexExpressions = new ExtensionalIndexExpressionsSet(ensureListFromKleeneList(indexExpressionsKleeneList));
    Expression body = subTreeExpressions.get(1);
    Expression result = new DefaultExistentiallyQuantifiedFormula(indexExpressions, body);
    return result;
}
Also used : ExtensionalIndexExpressionsSet(com.sri.ai.expresso.core.ExtensionalIndexExpressionsSet) DefaultLambdaExpression(com.sri.ai.expresso.core.DefaultLambdaExpression) Expression(com.sri.ai.expresso.api.Expression) LambdaExpression(com.sri.ai.expresso.api.LambdaExpression) DefaultExistentiallyQuantifiedFormula(com.sri.ai.expresso.core.DefaultExistentiallyQuantifiedFormula) IndexExpressions(com.sri.ai.grinder.library.indexexpression.IndexExpressions) ExtensionalIndexExpressionsSet(com.sri.ai.expresso.core.ExtensionalIndexExpressionsSet) IndexExpressionsSet(com.sri.ai.expresso.api.IndexExpressionsSet)

Example 5 with IndexExpressions

use of com.sri.ai.grinder.library.indexexpression.IndexExpressions in project aic-expresso by aic-sri-international.

the class Expressions method makeDefaultIntensionalUniSetFromLabelAndSubTrees.

private static Expression makeDefaultIntensionalUniSetFromLabelAndSubTrees(Object label, Object[] subTreeObjects) {
    if (subTreeObjects.length == 1 && subTreeObjects[0] instanceof Collection) {
        subTreeObjects = ((Collection) subTreeObjects[0]).toArray();
    }
    ArrayList<Expression> subTreeExpressions = Util.mapIntoArrayList(subTreeObjects, Expressions::makeFromObject);
    if (subTreeExpressions.size() == 1) {
        subTreeExpressions = new ArrayList<Expression>(Expressions.ensureListFromKleeneList(subTreeExpressions.get(0)));
    }
    Expression scopingExpression = subTreeExpressions.get(0);
    IndexExpressionsSet indexExpressions = new ExtensionalIndexExpressionsSet((scopingExpression == null || scopingExpression.numberOfArguments() == 0) ? Util.list() : new ArrayList<Expression>(Expressions.ensureListFromKleeneList(scopingExpression.get(0))));
    Expression conditioningSyntaxTree = subTreeExpressions.get(2);
    Expression condition = conditioningSyntaxTree == null ? Expressions.TRUE : conditioningSyntaxTree.get(0);
    Expression result = new DefaultIntensionalUniSet(indexExpressions, subTreeExpressions.get(1), condition);
    return result;
}
Also used : ExtensionalIndexExpressionsSet(com.sri.ai.expresso.core.ExtensionalIndexExpressionsSet) DefaultIntensionalUniSet(com.sri.ai.expresso.core.DefaultIntensionalUniSet) DefaultLambdaExpression(com.sri.ai.expresso.core.DefaultLambdaExpression) Expression(com.sri.ai.expresso.api.Expression) LambdaExpression(com.sri.ai.expresso.api.LambdaExpression) ArrayList(java.util.ArrayList) Collection(java.util.Collection) IndexExpressions(com.sri.ai.grinder.library.indexexpression.IndexExpressions) ExtensionalIndexExpressionsSet(com.sri.ai.expresso.core.ExtensionalIndexExpressionsSet) IndexExpressionsSet(com.sri.ai.expresso.api.IndexExpressionsSet)

Aggregations

Expression (com.sri.ai.expresso.api.Expression)8 IndexExpressionsSet (com.sri.ai.expresso.api.IndexExpressionsSet)8 ExtensionalIndexExpressionsSet (com.sri.ai.expresso.core.ExtensionalIndexExpressionsSet)8 IndexExpressions (com.sri.ai.grinder.library.indexexpression.IndexExpressions)8 LambdaExpression (com.sri.ai.expresso.api.LambdaExpression)7 DefaultLambdaExpression (com.sri.ai.expresso.core.DefaultLambdaExpression)6 ArrayList (java.util.ArrayList)3 Predicate (com.google.common.base.Predicate)2 IntensionalSet (com.sri.ai.expresso.api.IntensionalSet)2 Symbol (com.sri.ai.expresso.api.Symbol)2 DefaultIntensionalMultiSet (com.sri.ai.expresso.core.DefaultIntensionalMultiSet)2 DefaultUniversallyQuantifiedFormula (com.sri.ai.expresso.core.DefaultUniversallyQuantifiedFormula)2 Expressions (com.sri.ai.expresso.helper.Expressions)2 Expressions.apply (com.sri.ai.expresso.helper.Expressions.apply)2 Expressions.makeSymbol (com.sri.ai.expresso.helper.Expressions.makeSymbol)2 Context (com.sri.ai.grinder.api.Context)2 Theory (com.sri.ai.grinder.api.Theory)2 Collection (java.util.Collection)2 Beta (com.google.common.annotations.Beta)1 Function (com.google.common.base.Function)1