@@ -5,19 +5,19 @@ package com.microsoft.z3
5
5
import kotlin.reflect.KProperty
6
6
7
7
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)
10
10
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)
13
13
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)
16
16
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)
21
21
operator fun BoolExpr.not (): BoolExpr = context.mkNot(this )
22
22
23
23
infix fun BoolExpr .`⇒` (other : BoolExpr ): BoolExpr = this implies other
@@ -27,20 +27,24 @@ infix fun BoolExpr.implies(other: BoolExpr): BoolExpr = context.mkImplies(this,
27
27
infix fun BoolExpr.and (other : BoolExpr ): BoolExpr = context.mkAnd(this , other)
28
28
infix fun BoolExpr.or (other : BoolExpr ): BoolExpr = context.mkOr(this , other)
29
29
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))
32
32
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))
34
34
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)
39
39
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))
42
42
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))
44
48
45
49
class Const <T >(private val ctx : Context , val produce : (Context , name: String ) -> T ) {
46
50
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) ->
49
53
fun Context.declareInt () = Const (this ) { ctx, name -> ctx.mkIntConst(name) }
50
54
fun Context.declareBool () = Const (this ) { ctx, name -> ctx.mkBoolConst(name) }
51
55
fun 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) }
54
58
fun Context.declareIntArray () = Const (this ) { ctx, name -> ctx.mkArrayConst(name, intSort, intSort) }
55
59
56
60
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)
58
62
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