use of com.sri.ai.expresso.api.IndexExpressionsSet in project aic-expresso by aic-sri-international.
the class TupleQuantifierSimplifier method rewriteThereExists.
private static Expression rewriteThereExists(Expression quantifiedExpression, Map<Expression, Expression> indexToTypeMap, Map<Expression, Expression> indexToTupleOfVars, Context context) {
if (indexToTypeMap.size() > 1) {
throw new IllegalStateException("We have an Existential Quantifier with > 1 index : " + quantifiedExpression);
}
Pair<IndexExpressionsSet, Expression> updatePair = update(ThereExists.getBody(quantifiedExpression), indexToTypeMap, indexToTupleOfVars, context);
Expression result = ThereExists.make(updatePair.first, updatePair.second);
return result;
}
use of com.sri.ai.expresso.api.IndexExpressionsSet in project aic-expresso by aic-sri-international.
the class TupleQuantifierSimplifier method rewriteForAll.
private static Expression rewriteForAll(Expression quantifiedExpression, Map<Expression, Expression> indexToTypeMap, Map<Expression, Expression> indexToTupleOfVars, Context context) {
if (indexToTypeMap.size() > 1) {
throw new IllegalStateException("We have a Universal Quantifier with > 1 index : " + quantifiedExpression);
}
Pair<IndexExpressionsSet, Expression> updatePair = update(ForAll.getBody(quantifiedExpression), indexToTypeMap, indexToTupleOfVars, context);
Expression result = ForAll.make(updatePair.first, updatePair.second);
return result;
}
use of com.sri.ai.expresso.api.IndexExpressionsSet in project aic-expresso by aic-sri-international.
the class DefaultIntensionalBound method summingBound.
private DefaultIntensionalBound summingBound(Expression variablesToBeSummedOut, Bound bound, Context context, Theory theory) {
if (!bound.isIntensionalBound()) {
return null;
}
DefaultIntensionalBound intensionalBound = (DefaultIntensionalBound) bound;
ExtensionalIndexExpressionsSet indexExpressions = (ExtensionalIndexExpressionsSet) intensionalBound.getIndexExpressions();
for (Expression indexExpression : indexExpressions.getList()) {
Expression index = indexExpression.get(0);
Expression type = indexExpression.get(1);
context = context.extendWithSymbolsAndTypes(index, type);
}
Expression x = makeSymbol("variableX");
IndexExpressionsSet indices = getIndexExpressionsOfFreeVariablesIn(variablesToBeSummedOut, context);
Expression setOfFactorInstantiations = IntensionalSet.makeMultiSet(indices, // head
x, // No Condition
makeSymbol(true));
Expression f = apply(SUM, setOfFactorInstantiations);
DefaultIntensionalBound result = applyFunctionToBound(f, x, bound, theory, context);
result = normalize(result, theory, context);
return result;
}
use of com.sri.ai.expresso.api.IndexExpressionsSet in project aic-expresso by aic-sri-international.
the class Sets method intensionalMultiSet.
public static Expression intensionalMultiSet(List<? extends Expression> indices, Expression body, Context context) {
IndexExpressionsSet indexExpressions = context.getIndexExpressions(indices);
Expression result = new DefaultIntensionalMultiSet(indexExpressions, body, TRUE);
return result;
}
use of com.sri.ai.expresso.api.IndexExpressionsSet in project aic-expresso by aic-sri-international.
the class IntensionalSetConditionSimplifier method simplify.
public static Expression simplify(Expression expression, Context context) {
Expression result = expression;
if (Sets.isIntensionalSet(expression)) {
IntensionalSet intensionalSet = (IntensionalSet) expression;
Expression condition = intensionalSet.getCondition();
if (!(condition.equals(Expressions.TRUE) || condition.equals(Expressions.FALSE))) {
IndexExpressionsSet indexExpressionsSet = intensionalSet.getIndexExpressions();
Context extendedContext = context.extendWith(indexExpressionsSet);
Expression evaluatedCondition = context.getTheory().evaluate(condition, extendedContext);
if (!evaluatedCondition.equals(condition)) {
result = IntensionalSet.make(Sets.isIntensionalMultiSet(expression) ? IntensionalSet.MULTI_SET_LABEL : IntensionalSet.UNI_SET_LABEL, indexExpressionsSet, intensionalSet.getHead(), evaluatedCondition);
}
}
}
return result;
}
Aggregations