use of org.sosy_lab.java_smt.api.FormulaType.ArrayFormulaType in project java-smt by sosy-lab.
the class PrincessFormulaCreator method getFormulaType.
@SuppressWarnings("unchecked")
@Override
public <T extends Formula> FormulaType<T> getFormulaType(final T pFormula) {
if (pFormula instanceof BitvectorFormula) {
ITerm input = (ITerm) extractInfo(pFormula);
Sort sort = Sort$.MODULE$.sortOf(input);
scala.Option<Object> bitWidth = PrincessEnvironment.getBitWidth(sort);
checkArgument(bitWidth.isDefined(), "BitvectorFormula with actual type %s: %s", sort, pFormula);
return (FormulaType<T>) FormulaType.getBitvectorTypeWithSize((Integer) bitWidth.get());
} else if (pFormula instanceof ArrayFormula<?, ?>) {
final FormulaType<?> arrayIndexType = getArrayFormulaIndexType((ArrayFormula<?, ?>) pFormula);
final FormulaType<?> arrayElementType = getArrayFormulaElementType((ArrayFormula<?, ?>) pFormula);
return (FormulaType<T>) new ArrayFormulaType<>(arrayIndexType, arrayElementType);
}
return super.getFormulaType(pFormula);
}
use of org.sosy_lab.java_smt.api.FormulaType.ArrayFormulaType in project java-smt by sosy-lab.
the class PrincessEnvironment method getFormulaTypeFromSort.
private static FormulaType<?> getFormulaTypeFromSort(final Sort sort) {
if (sort == PrincessEnvironment.BOOL_SORT) {
return FormulaType.BooleanType;
} else if (sort == PrincessEnvironment.INTEGER_SORT) {
return FormulaType.IntegerType;
} else if (sort instanceof ExtArray.ArraySort) {
Seq<Sort> indexSorts = ((ExtArray.ArraySort) sort).theory().indexSorts();
Sort elementSort = ((ExtArray.ArraySort) sort).theory().objSort();
assert indexSorts.iterator().size() == 1 : "unexpected index type in Array type:" + sort;
// assert indexSorts.size() == 1; // TODO Eclipse does not like simpler code.
return new ArrayFormulaType<>(// get single index-sort
getFormulaTypeFromSort(indexSorts.iterator().next()), getFormulaTypeFromSort(elementSort));
} else if (sort instanceof MultipleValueBool$) {
return FormulaType.BooleanType;
} else {
scala.Option<Object> bitWidth = getBitWidth(sort);
if (bitWidth.isDefined()) {
return FormulaType.getBitvectorTypeWithSize((Integer) bitWidth.get());
}
}
throw new IllegalArgumentException(String.format("Unknown formula type '%s' for sort '%s'.", sort.getClass(), sort));
}
use of org.sosy_lab.java_smt.api.FormulaType.ArrayFormulaType in project java-smt by sosy-lab.
the class AbstractFormulaManager method makeVariable.
@Override
public <T extends Formula> T makeVariable(FormulaType<T> formulaType, String name) {
checkVariableName(name);
Formula t;
if (formulaType.isBooleanType()) {
t = booleanManager.makeVariable(name);
} else if (formulaType.isIntegerType()) {
assert integerManager != null;
t = integerManager.makeVariable(name);
} else if (formulaType.isRationalType()) {
assert rationalManager != null;
t = rationalManager.makeVariable(name);
} else if (formulaType.isStringType()) {
assert strManager != null;
t = strManager.makeVariable(name);
} else if (formulaType.isBitvectorType()) {
assert bitvectorManager != null;
t = bitvectorManager.makeVariable((BitvectorType) formulaType, name);
} else if (formulaType.isFloatingPointType()) {
assert floatingPointManager != null;
t = floatingPointManager.makeVariable(name, (FloatingPointType) formulaType);
} else if (formulaType.isArrayType()) {
assert arrayManager != null;
t = arrayManager.makeArray(name, (ArrayFormulaType<?, ?>) formulaType);
} else {
throw new IllegalArgumentException("Unknown formula type");
}
@SuppressWarnings("unchecked") T out = (T) t;
return out;
}
use of org.sosy_lab.java_smt.api.FormulaType.ArrayFormulaType in project java-smt by sosy-lab.
the class CVC4ArrayFormulaManager method internalMakeArray.
@Override
@SuppressWarnings("MethodTypeParameterName")
protected <TI extends Formula, TE extends Formula> Expr internalMakeArray(String pName, FormulaType<TI> pIndexType, FormulaType<TE> pElementType) {
final ArrayFormulaType<TI, TE> arrayFormulaType = FormulaType.getArrayType(pIndexType, pElementType);
final Type cvc4ArrayType = toSolverType(arrayFormulaType);
return getFormulaCreator().makeVariable(cvc4ArrayType, pName);
}
Aggregations