@@ -5,19 +5,19 @@ package com.microsoft.z3
55import kotlin.reflect.KProperty
66
77
8- operator fun ArithExpr.plus (other : ArithExpr ): ArithExpr = context.mkAdd(this , other)
9- operator fun ArithExpr.plus (other : Int ): ArithExpr = this + context.mkInt(other)
8+ operator fun ArithExpr < * > .plus (other : ArithExpr < * > ): ArithExpr < * > = context.mkAdd(this , other)
9+ operator fun ArithExpr < * > .plus (other : Int ): ArithExpr < * > = this + context.mkInt(other)
1010
11- operator fun ArithExpr.minus (other : ArithExpr ): ArithExpr = context.mkSub(this , other)
12- operator fun ArithExpr.minus (other : Int ): ArithExpr = this - context.mkInt(other)
11+ operator fun ArithExpr < * > .minus (other : ArithExpr < * > ): ArithExpr < * > = context.mkSub(this , other)
12+ operator fun ArithExpr < * > .minus (other : Int ): ArithExpr < * > = this - context.mkInt(other)
1313
14- operator fun ArithExpr.times (other : ArithExpr ): ArithExpr = context.mkMul(this , other)
15- operator fun ArithExpr.times (other : Int ): ArithExpr = this * context.mkInt(other)
14+ operator fun ArithExpr < * > .times (other : ArithExpr < * > ): ArithExpr < * > = context.mkMul(this , other)
15+ operator fun ArithExpr < * > .times (other : Int ): ArithExpr < * > = this * context.mkInt(other)
1616
17- infix fun Expr .`=` (other : Int ): BoolExpr = this eq context.mkInt(other)
18- infix fun Expr .`=` (other : Expr ): BoolExpr = this eq other
19- infix fun Expr.eq (other : Expr ): BoolExpr = context.mkEq(this , other)
20- infix fun Expr .`!=` (other : Expr ): BoolExpr = context.mkNot(this `= ` other)
17+ infix fun Expr < * > .`=` (other : Int ): BoolExpr = this eq context.mkInt(other)
18+ infix fun Expr < * > .`=` (other : Expr < * > ): BoolExpr = this eq other
19+ infix fun Expr < * > .eq (other : Expr < * > ): BoolExpr = context.mkEq(this , other)
20+ infix fun Expr < * > .`!=` (other : Expr < * > ): BoolExpr = context.mkNot(this `= ` other)
2121operator fun BoolExpr.not (): BoolExpr = context.mkNot(this )
2222
2323infix fun BoolExpr .`⇒` (other : BoolExpr ): BoolExpr = this implies other
@@ -27,20 +27,24 @@ infix fun BoolExpr.implies(other: BoolExpr): BoolExpr = context.mkImplies(this,
2727infix fun BoolExpr.and (other : BoolExpr ): BoolExpr = context.mkAnd(this , other)
2828infix fun BoolExpr.or (other : BoolExpr ): BoolExpr = context.mkOr(this , other)
2929
30- infix fun ArithExpr.gt (other : ArithExpr ): BoolExpr = context.mkGt(this , other)
31- infix fun ArithExpr.gt (other : Int ): BoolExpr = context.mkGt(this , context.mkInt(other))
30+ infix fun ArithExpr < * > .gt (other : ArithExpr < * > ): BoolExpr = context.mkGt(this , other)
31+ infix fun ArithExpr < * > .gt (other : Int ): BoolExpr = context.mkGt(this , context.mkInt(other))
3232
33- infix fun ArithExpr .`=` (other : Int ): BoolExpr = context.mkEq(this , context.mkInt(other))
33+ infix fun ArithExpr < * > .`=` (other : Int ): BoolExpr = context.mkEq(this , context.mkInt(other))
3434
35- operator fun ArrayExpr.get (index : IntExpr ): Expr = context.mkSelect(this , index)
36- operator fun ArrayExpr.get (index : Int ): Expr = this [context.mkInt(index)]
37- fun ArrayExpr.set (index : IntExpr , value : Expr ): ArrayExpr = context.mkStore(this , index, value)
38- fun ArrayExpr.set (index : Int , value : Expr ): ArrayExpr = set(context.mkInt(index), value)
35+ operator fun ArrayExpr < * , * > .get (index : IntExpr ): Expr < * > = context.mkSelect(this , index.cast() )
36+ operator fun ArrayExpr < * , * > .get (index : Int ): Expr < * > = this [context.mkInt(index)]
37+ fun ArrayExpr < * , * > .set (index : IntExpr , value : Expr < * > ): ArrayExpr < * , * > = context.mkStore(this , index.cast() , value.cast() )
38+ fun ArrayExpr < * , * > .set (index : Int , value : Expr < * > ): ArrayExpr < * , * > = set(context.mkInt(index), value)
3939
40- operator fun SeqExpr.plus (other : SeqExpr ): SeqExpr = context.mkConcat(this , other)
41- operator fun SeqExpr.plus (other : String ): SeqExpr = context.mkConcat(context.mkString(other))
40+ operator fun SeqExpr < * > .plus (other : SeqExpr < * > ): SeqExpr < * > = context.mkConcat(this , other.cast() )
41+ operator fun SeqExpr < * > .plus (other : String ): SeqExpr < * > = context.mkConcat(context.mkString(other))
4242
43- infix fun SeqExpr .`=` (other : String ): BoolExpr = context.mkEq(this , context.mkString(other))
43+ @Suppress(" UNCHECKED_CAST" )
44+ fun <T : Sort , R : Sort > Expr<T>.cast (): Expr <R > = this as Expr <R >
45+
46+
47+ infix fun SeqExpr <* >.`=` (other : String ): BoolExpr = context.mkEq(this , context.mkString(other))
4448
4549class Const <T >(private val ctx : Context , val produce : (Context , name: String ) -> T ) {
4650 operator fun getValue (thisRef : Nothing? , property : KProperty <* >): T = produce(ctx, property.name)
@@ -49,12 +53,12 @@ class Const<T>(private val ctx: Context, val produce: (Context, name: String) ->
4953fun Context.declareInt () = Const (this ) { ctx, name -> ctx.mkIntConst(name) }
5054fun Context.declareBool () = Const (this ) { ctx, name -> ctx.mkBoolConst(name) }
5155fun Context.declareReal () = Const (this ) { ctx, name -> ctx.mkRealConst(name) }
52- fun Context.declareString () = Const (this ) { ctx, name -> ctx.mkConst(name, stringSort) as SeqExpr }
53- fun Context.declareList (sort : ListSort ) = Const (this ) { ctx, name -> ctx.mkConst(name, sort) }
56+ fun Context.declareString () = Const (this ) { ctx, name -> ctx.mkConst(name, stringSort) as SeqExpr < * > }
57+ fun Context.declareList (sort : ListSort < * > ) = Const (this ) { ctx, name -> ctx.mkConst(name, sort) }
5458fun Context.declareIntArray () = Const (this ) { ctx, name -> ctx.mkArrayConst(name, intSort, intSort) }
5559
5660
57- operator fun FuncDecl.invoke (vararg expr : Expr ): Expr = context.mkApp(this , * expr)
61+ operator fun FuncDecl < * > .invoke (vararg expr : Expr < * > ): Expr < * > = context.mkApp(this , * expr)
5862
59- fun Model.eval (expr : Expr ): Expr = this .eval(expr, true )
60- fun Model.eval (vararg exprs : Expr ): List <Expr > = exprs.map { this .eval(it, true ) }
63+ fun Model.eval (expr : Expr < * > ): Expr < * > = this .eval(expr, true )
64+ fun Model.eval (vararg exprs : Expr < * > ): List <Expr < * > > = exprs.map { this .eval(it, true ) }
0 commit comments