diff --git a/ksmt-core/src/main/kotlin/org/ksmt/expr/rewrite/simplify/ArithSimplification.kt b/ksmt-core/src/main/kotlin/org/ksmt/expr/rewrite/simplify/ArithSimplification.kt index 858fb40b2..e2d25da31 100644 --- a/ksmt-core/src/main/kotlin/org/ksmt/expr/rewrite/simplify/ArithSimplification.kt +++ b/ksmt-core/src/main/kotlin/org/ksmt/expr/rewrite/simplify/ArithSimplification.kt @@ -40,6 +40,10 @@ fun KContext.simplifyArithUnaryMinus(arg: KExpr): KExpr { } fun KContext.simplifyArithAdd(args: List>): KExpr { + require(args.isNotEmpty()) { + "Arith add requires at least a single argument" + } + val simplifiedArgs = ArrayList>(args.size) var constantTerm = RealValue.zero @@ -54,7 +58,6 @@ fun KContext.simplifyArithAdd(args: List>): KExpr { } } - // If all args are constants we have no simplifiedArgs and a single constant value if (simplifiedArgs.isEmpty()) { return numericValue(constantTerm, args.first().sort) } @@ -77,6 +80,10 @@ fun KContext.simplifyArithSub(args: List>): KExpr = if (args.size == 1) { args.single() } else { + require(args.isNotEmpty()) { + "Arith sub requires at least a single argument" + } + val simplifiedArgs = arrayListOf(args.first()) for (arg in args.drop(1)) { simplifiedArgs += simplifyArithUnaryMinus(arg) @@ -85,6 +92,10 @@ fun KContext.simplifyArithSub(args: List>): KExpr = } fun KContext.simplifyArithMul(args: List>): KExpr { + require(args.isNotEmpty()) { + "Arith mul requires at least a single argument" + } + val simplifiedArgs = ArrayList>(args.size) var constantTerm = RealValue.one