use of edu.stanford.CVC4.FunctionType in project geotoolkit by Geomatys.
the class FilterToOGC200Converter method convert.
private FunctionType convert(final Expression source) {
List<Expression> parameters = source.getParameters();
final FunctionType function = ogc_factory.createFunctionType();
function.getExpression().add(extract(parameters.get(0)));
function.getExpression().add(extract(parameters.get(1)));
return function;
}
use of edu.stanford.CVC4.FunctionType in project geo-platform by geosdi.
the class BaseBinaryStrategy method createBinaryComparisonTypeForDate.
/**
* @param queryRestrictionDTO
* @return {@link BinaryComparisonOpType}
*/
protected BinaryComparisonOpType createBinaryComparisonTypeForDate(QueryRestrictionDTO queryRestrictionDTO) {
return new BinaryComparisonOpType() {
{
PropertyNameType propertyNameType = new PropertyNameType();
propertyNameType.setContent(asList(queryRestrictionDTO.getAttribute().getName()));
FunctionType functionType = new FunctionType();
functionType.setName("dateParse");
LiteralType literalType = new LiteralType();
literalType.setContent(asList(queryRestrictionDTO.getRestriction()));
LiteralType literalTypeFormat = new LiteralType();
literalTypeFormat.setContent(dateFormatStrategyFinder.findDateFormat(queryRestrictionDTO.getAttribute()));
List<JAXBElement<?>> functionElements = new ArrayList<>(2);
functionElements.add(filterFactory.createLiteral(literalTypeFormat));
functionElements.add(filterFactory.createLiteral(literalType));
functionType.setExpression(functionElements);
List<JAXBElement<?>> elements = new ArrayList<>(2);
elements.add(filterFactory.createPropertyName(propertyNameType));
elements.add(filterFactory.createFunction(functionType));
super.setExpression(elements);
}
};
}
use of edu.stanford.CVC4.FunctionType in project ddf by codice.
the class CswFilterFactory method createPropertyIsEqualTo.
public FilterType createPropertyIsEqualTo(String functionName, List<? extends JAXBElement<?>> expressions, Object literal) {
FunctionType function = new FunctionType();
function.setName(functionName);
function.getExpression().addAll(expressions);
FilterType filter = new FilterType();
BinaryComparisonOpType propertyIsEqualTo = new BinaryComparisonOpType();
propertyIsEqualTo.getExpression().add(filterObjectFactory.createFunction(function));
propertyIsEqualTo.getExpression().add(createLiteralType(literal));
filter.setComparisonOps(filterObjectFactory.createPropertyIsEqualTo(propertyIsEqualTo));
return filter;
}
use of edu.stanford.CVC4.FunctionType in project java-smt by sosy-lab.
the class CVC4FormulaCreator method visit.
@Override
public <R> R visit(FormulaVisitor<R> visitor, Formula formula, final Expr f) {
checkState(!f.isNull());
Type type = f.getType();
if (f.isConst()) {
if (type.isBoolean()) {
return visitor.visitConstant(formula, f.getConstBoolean());
} else if (type.isInteger() || type.isReal()) {
return visitor.visitConstant(formula, f.getConstRational());
} else if (type.isBitVector()) {
// TODO is this correct?
return visitor.visitConstant(formula, f.getConstBitVector().getValue());
} else if (type.isFloatingPoint()) {
// TODO is this correct?
return visitor.visitConstant(formula, f.getConstFloatingPoint());
} else if (type.isRoundingMode()) {
// TODO is this correct?
return visitor.visitConstant(formula, f.getConstRoundingMode());
} else if (type.isString()) {
return visitor.visitConstant(formula, f.getConstString());
} else {
throw new UnsupportedOperationException("Unhandled constant " + f + " with type " + type);
}
} else if (f.getKind() == Kind.BOUND_VARIABLE) {
// BOUND vars are used for all vars that are bound to a quantifier in CVC4.
// We resubstitute them back to the original free.
// CVC4 doesn't give you the de-brujin index
Expr originalVar = variablesCache.get(formula.toString());
return visitor.visitBoundVariable(encapsulate(originalVar), 0);
} else if (f.getKind() == Kind.FORALL || f.getKind() == Kind.EXISTS) {
// QUANTIFIER: replace bound variable with free variable for visitation
assert f.getNumChildren() == 2;
Expr body = f.getChildren().get(1);
List<Formula> freeVars = new ArrayList<>();
for (Expr boundVar : f.getChild(0)) {
// unpack grand-children of f.
String name = getName(boundVar);
Expr freeVar = Preconditions.checkNotNull(variablesCache.get(name));
body = body.substitute(boundVar, freeVar);
freeVars.add(encapsulate(freeVar));
}
BooleanFormula fBody = encapsulateBoolean(body);
Quantifier quant = f.getKind() == Kind.EXISTS ? Quantifier.EXISTS : Quantifier.FORALL;
return visitor.visitQuantifier((BooleanFormula) formula, quant, freeVars, fBody);
} else if (f.isVariable()) {
assert f.getKind() != Kind.BOUND_VARIABLE;
return visitor.visitFreeVariable(formula, getName(f));
} else {
// Expressions like uninterpreted function calls (Kind.APPLY_UF) or operators (e.g. Kind.AND).
// These are all treated like operators, so we can get the declaration by f.getOperator()!
List<Formula> args = ImmutableList.copyOf(Iterables.transform(f, this::encapsulate));
List<FormulaType<?>> argsTypes = new ArrayList<>();
Expr operator = normalize(f.getOperator());
if (operator.getType().isFunction()) {
vectorType argTypes = new FunctionType(operator.getType()).getArgTypes();
for (int i = 0; i < argTypes.size(); i++) {
argsTypes.add(getFormulaTypeFromTermType(argTypes.get(i)));
}
} else {
for (Expr arg : f) {
argsTypes.add(getFormulaType(arg));
}
}
checkState(args.size() == argsTypes.size());
// additional parameters? We do so for some methods of Princess.
return visitor.visitFunction(formula, args, FunctionDeclarationImpl.of(getName(f), getDeclarationKind(f), argsTypes, getFormulaType(f), operator));
}
}
Aggregations