use of com.sri.ai.expresso.api.IndexExpressionsSet in project aic-expresso by aic-sri-international.
the class DefaultExtensionalBound method summingBound.
private DefaultExtensionalBound summingBound(Expression variablesToBeSummedOut, Bound bound, Context context, Theory theory) {
List<Expression> listOfBound = getElements(bound);
ArrayList<Expression> BoundSummedOut = new ArrayList<>(listOfBound.size());
for (Expression phi : listOfBound) {
IndexExpressionsSet indices = getIndexExpressionsOfFreeVariablesIn(variablesToBeSummedOut, context);
Expression setOfFactorInstantiations = IntensionalSet.makeMultiSet(indices, // head
phi, // No Condition
makeSymbol(true));
Expression sumOnPhi = apply(SUM, setOfFactorInstantiations);
Expression evaluation = theory.evaluate(sumOnPhi, context);
BoundSummedOut.add(evaluation);
}
DefaultExtensionalBound SetOfBoundSummedOut = new DefaultExtensionalBound(BoundSummedOut);
// Updating extreme points
DefaultExtensionalBound result = updateExtremes(SetOfBoundSummedOut, 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 Bounds method normalizeSingleExpression.
/**
* Does not work for sets or bounds. Aims at normalizing a sing expression phi
* @param phi
* @param theory
* @param context
* @return
*/
public static Expression normalizeSingleExpression(Expression phi, Theory theory, Context context) {
IndexExpressionsSet indices = getIndexExpressionsOfFreeVariablesIn(phi, context);
Expression setOfFactorInstantiations = IntensionalSet.makeMultiSet(indices, // head
phi, // No Condition
makeSymbol(true));
Expression sumOnPhi = apply(SUM, setOfFactorInstantiations);
Expression f = apply("/", phi, sumOnPhi);
Expression evaluation = theory.evaluate(f, context);
return evaluation;
}
use of com.sri.ai.expresso.api.IndexExpressionsSet in project aic-expresso by aic-sri-international.
the class DefaultIntensionalBound method applyFunctionToBound.
protected DefaultIntensionalBound applyFunctionToBound(Expression f, Expression variableName, Bound bound, Theory theory, Context context) {
if (!bound.isIntensionalBound()) {
return null;
}
IntensionalSet intensionalBound = (IntensionalSet) bound;
IndexExpressionsSet indexExpressions = intensionalBound.getIndexExpressions();
Expression Head = intensionalBound.getHead();
Expression condition = intensionalBound.getCondition();
Expression fOfHead = f.replaceAllOccurrences(variableName, Head, context);
Expression evaluation = theory.evaluate(fOfHead, context);
DefaultIntensionalBound result = new DefaultIntensionalBound(indexExpressions, evaluation, condition);
return result;
}
use of com.sri.ai.expresso.api.IndexExpressionsSet in project aic-praise by aic-sri-international.
the class HOGMModelValidator method getQuantifiedExpressionScope.
public Map<Expression, HOGMConstantDeclaration> getQuantifiedExpressionScope(Expression quantifiedExpression) {
Map<Expression, HOGMConstantDeclaration> result = new LinkedHashMap<>();
IndexExpressionsSet indexExpressionSet = ((QuantifiedExpression) quantifiedExpression).getIndexExpressions();
IndexExpressions.getIndexToTypeMapWithDefaultNull(indexExpressionSet).forEach((name, type) -> {
HOGMSortDeclaration localSort = getSort(type);
if (localSort != null) {
result.put(name, new HOGMConstantDeclaration(name, Expressions.ZERO, localSort.getName()));
}
});
return result;
}
Aggregations