Search in sources :

Example 1 with IndexExpressions

use of com.sri.ai.grinder.sgdpllt.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.sgdpllt.library.indexexpression.IndexExpressions) ExtensionalIndexExpressionsSet(com.sri.ai.expresso.core.ExtensionalIndexExpressionsSet) IndexExpressionsSet(com.sri.ai.expresso.api.IndexExpressionsSet)

Example 2 with IndexExpressions

use of com.sri.ai.grinder.sgdpllt.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.sgdpllt.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.sgdpllt.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.sgdpllt.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.sgdpllt.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.sgdpllt.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.sgdpllt.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.sgdpllt.library.indexexpression.IndexExpressions) ExtensionalIndexExpressionsSet(com.sri.ai.expresso.core.ExtensionalIndexExpressionsSet) IndexExpressionsSet(com.sri.ai.expresso.api.IndexExpressionsSet) DefaultIntensionalMultiSet(com.sri.ai.expresso.core.DefaultIntensionalMultiSet)

Aggregations

Expression (com.sri.ai.expresso.api.Expression)7 IndexExpressionsSet (com.sri.ai.expresso.api.IndexExpressionsSet)7 LambdaExpression (com.sri.ai.expresso.api.LambdaExpression)7 ExtensionalIndexExpressionsSet (com.sri.ai.expresso.core.ExtensionalIndexExpressionsSet)7 IndexExpressions (com.sri.ai.grinder.sgdpllt.library.indexexpression.IndexExpressions)7 DefaultLambdaExpression (com.sri.ai.expresso.core.DefaultLambdaExpression)6 DefaultIntensionalMultiSet (com.sri.ai.expresso.core.DefaultIntensionalMultiSet)2 DefaultUniversallyQuantifiedFormula (com.sri.ai.expresso.core.DefaultUniversallyQuantifiedFormula)2 ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)2 Beta (com.google.common.annotations.Beta)1 Function (com.google.common.base.Function)1 Predicate (com.google.common.base.Predicate)1 CountingFormula (com.sri.ai.expresso.api.CountingFormula)1 FunctionApplication (com.sri.ai.expresso.api.FunctionApplication)1 IntensionalSet (com.sri.ai.expresso.api.IntensionalSet)1 QuantifiedExpressionWithABody (com.sri.ai.expresso.api.QuantifiedExpressionWithABody)1 Symbol (com.sri.ai.expresso.api.Symbol)1 Tuple (com.sri.ai.expresso.api.Tuple)1 EMPTY_TUPLE (com.sri.ai.expresso.api.Tuple.EMPTY_TUPLE)1