Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
fb0adca
Draft: model synthesis
Jun 20, 2022
11c47d9
m
AbdullinAM Jun 20, 2022
4aaa8e5
first prototype, needs debugging and tuning
AbdullinAM Jun 22, 2022
9c63ba0
prototype
AbdullinAM Jun 28, 2022
707fa6d
refactor
AbdullinAM Jun 29, 2022
10c4193
very early prototype
AbdullinAM Jul 8, 2022
4285a5c
UtConstraintModel implemented
AbdullinAM Jul 12, 2022
22e2266
partial UtConstraint to UtExpression convertion
AbdullinAM Jul 14, 2022
6b47a9a
working prototypes
AbdullinAM Jul 19, 2022
a75a840
bugfixes + expression support in constraints
AbdullinAM Jul 21, 2022
fb392f6
m
AbdullinAM Jul 26, 2022
5f35311
everything kind of works, but some constraints need to be added
AbdullinAM Jul 27, 2022
ba9bb62
first working protoype with arrays
AbdullinAM Aug 1, 2022
065924f
renaming
AbdullinAM Aug 1, 2022
8cc7515
first tests and fixes
AbdullinAM Aug 2, 2022
4a14606
more expressions supported
AbdullinAM Aug 3, 2022
bbf525b
some cleanup + more expressions supported
AbdullinAM Aug 8, 2022
850b530
cleanup
AbdullinAM Aug 8, 2022
8799691
support for multidimensional arrays + fix for array generation
AbdullinAM Aug 9, 2022
60df4a4
first support of lists
AbdullinAM Aug 10, 2022
8963a7e
support sets
AbdullinAM Aug 10, 2022
1578c96
small refactorings
AbdullinAM Aug 11, 2022
1dd4b25
maps
AbdullinAM Aug 12, 2022
313757d
some cleanup and parameters
AbdullinAM Aug 12, 2022
faa0047
test write fix
AbdullinAM Aug 12, 2022
94740c9
m
AbdullinAM Aug 22, 2022
9920283
Merge branch 'main' into abdullin/constraint-model-synthesis
AbdullinAM Aug 22, 2022
fd22077
merge with master
AbdullinAM Aug 24, 2022
4e97b5f
first prototype of constraint scoring selector
AbdullinAM Aug 26, 2022
2544b31
m
AbdullinAM Aug 30, 2022
e585371
fixes
AbdullinAM Aug 31, 2022
d2564e9
Merge branch 'main' into abdullin/constraint-model-synthesis
AbdullinAM Sep 7, 2022
bb1acbc
Merge branch 'main' into abdullin/constraint-model-synthesis
AbdullinAM Sep 7, 2022
c6fbeb0
Split constraint models into a set of non-intersecting subsets before…
AbdullinAM Sep 12, 2022
2553ef7
m
AbdullinAM Sep 12, 2022
e943a16
some cleanup
AbdullinAM Sep 13, 2022
cd5fff8
more cleanup
AbdullinAM Sep 13, 2022
c2a7d31
order models in the subsets
AbdullinAM Sep 13, 2022
d1b09c8
simple caching of synthesis unit contexts
AbdullinAM Sep 13, 2022
eedccb9
option to enable/disable caching of synthesis contexts
AbdullinAM Sep 14, 2022
11eea4d
m
AbdullinAM Sep 14, 2022
9712e70
tests
AbdullinAM Sep 14, 2022
1c6b679
unit tests fixed
AbdullinAM Sep 19, 2022
4e37763
Merge branch 'main' into abdullin/constraint-model-synthesis
AbdullinAM Sep 28, 2022
34ed6fe
merge with main
AbdullinAM Sep 28, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
more expressions supported
  • Loading branch information
AbdullinAM committed Aug 3, 2022
commit 4a14606d099cf5c918aef66522a5dc9f2cb244df
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ import org.utbot.framework.plugin.api.util.*

sealed class UtConstraintVariable {
abstract val classId: ClassId
val isPrimitive get() = classId.isPrimitive
val isPrimitive get() = try {
classId.isPrimitive
} catch (e: Throwable) {
throw e
}
val isArray get() = classId.isArray

abstract fun <T> accept(visitor: UtConstraintVariableVisitor<T>): T
Expand Down Expand Up @@ -288,6 +292,26 @@ data class UtConstraintNot(
}
}

data class UtConstraintNeg(
val operand: UtConstraintVariable
) : UtConstraintExpr() {
override val classId: ClassId
get() = operand.classId

override fun <T> accept(visitor: UtConstraintVariableVisitor<T>): T {
return visitor.visitUtConstraintNeg(this)
}
}

data class UtConstraintCast(
val operand: UtConstraintVariable,
override val classId: ClassId
) : UtConstraintExpr() {
override fun <T> accept(visitor: UtConstraintVariableVisitor<T>): T {
return visitor.visitUtConstraintCast(this)
}
}

sealed class UtConstraint {
abstract fun negated(): UtConstraint
abstract fun <T> accept(visitor: UtConstraintVisitor<T>): T
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ interface UtConstraintVariableVisitor<T> {
fun visitUtConstraintUshr(expr: UtConstraintUshr): T
fun visitUtConstraintXor(expr: UtConstraintXor): T
fun visitUtConstraintNot(expr: UtConstraintNot): T

fun visitUtConstraintNeg(expr: UtConstraintNeg): T

fun visitUtConstraintCast(expr: UtConstraintCast): T
}

interface UtConstraintVisitor<T> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ class ConstraintResolver(
}.toSet()
val lengthVariable = UtConstraintArrayLength(variable)
val lengthModel = buildModel(atoms, lengthVariable, lengths)
val concreteLength = holder.eval(lengths.first().expr).value() as Int
val concreteLength = lengths.firstOrNull()?.let { holder.eval(it.expr).value() as Int } ?: 100

val indexMap = atoms
.flatMap {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,19 @@ class UtConstraintTransformer(
)
}

override fun visitUtConstraintNeg(expr: UtConstraintNeg) = replace(expr) {
UtConstraintNeg(
operand.accept(this@UtConstraintTransformer)
)
}

override fun visitUtConstraintCast(expr: UtConstraintCast) = replace(expr) {
UtConstraintCast(
operand.accept(this@UtConstraintTransformer),
classId
)
}

override fun visitUtRefEqConstraint(expr: UtRefEqConstraint) = with(expr) {
UtRefEqConstraint(
lhv.accept(this@UtConstraintTransformer),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,14 @@ class UtConstraintVariableCollector(
expr.operand.accept(this)
}

override fun visitUtConstraintNeg(expr: UtConstraintNeg) = visitVar(expr) {
expr.operand.accept(this)
}

override fun visitUtConstraintCast(expr: UtConstraintCast) = visitVar(expr) {
expr.operand.accept(this)
}

override fun visitUtRefEqConstraint(expr: UtRefEqConstraint) = visitConstraint(expr) {
expr.lhv.accept(this)
expr.rhv.accept(this)
Expand Down
39 changes: 23 additions & 16 deletions utbot-framework/src/main/kotlin/org/utbot/engine/pc/UtVarBuilder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,19 @@ class UtVarBuilder(
val instance = expr.index.accept(this)
UtConstraintArrayLength(instance)
}
"RefValues_Arrays" -> {
val instance = expr.index.accept(this)
instance
}
"char_Arrays" -> {
val instance = expr.index.accept(this)
instance
}
"int_Arrays" -> {
val instance = expr.index.accept(this)
instance
}
"RefValues_Arrays" -> expr.index.accept(this)
"boolean_Arrays" -> expr.index.accept(this)
"char_Arrays" -> expr.index.accept(this)
"int_Arrays" -> expr.index.accept(this)
"long_Arrays" -> expr.index.accept(this)
"byte_Arrays" -> expr.index.accept(this)
"short_Arrays" -> expr.index.accept(this)
"float_Arrays" -> expr.index.accept(this)
"double_Arrays" -> expr.index.accept(this)
else -> {
val instance = expr.index.accept(this)
try {
val (type, field) = base.name.split("_")
val (type, field) = base.name.split("_", limit = 2)
UtConstraintFieldAccess(instance, FieldId(ClassId(type), field))
} catch (e: Throwable) {
arrayAccess(base, instance)
Expand All @@ -55,6 +52,7 @@ class UtVarBuilder(
val index = expr.index.accept(this)
arrayAccess(base, index)
}
is UtConstraintNumericConstant -> expr.index.accept(this)
is UtConstraintNull -> UtConstraintArrayAccess(base, expr.index.accept(this), objectClassId)
else -> error("Unexpected: $base")
}
Expand All @@ -77,7 +75,7 @@ class UtVarBuilder(
System.err.println(base.classId)
System.err.println(index)
System.err.println(index.classId)
TODO()
index
}
}

Expand Down Expand Up @@ -217,11 +215,20 @@ class UtVarBuilder(
}

override fun visit(expr: UtNegExpression): UtConstraintVariable {
TODO("Not yet implemented")
return UtConstraintNeg(
expr.variable.expr.accept(this)
).also {
backMapping[it] = expr.variable.expr
}
}

override fun visit(expr: UtCastExpression): UtConstraintVariable {
TODO("Not yet implemented")
return UtConstraintCast(
expr.variable.expr.accept(this),
expr.type.classId
).also {
backMapping[it] = expr.variable.expr
}
}

override fun visit(expr: UtBoolOpExpression): UtConstraintVariable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Synthesizer(
private val queueIterator = SynthesisUnitContextQueue(parameters, statementStorage, depth)
private val unitChecker = SynthesisUnitChecker(objectClassId.toSoot())

fun synthesize(timeLimit: Long = 10000L): List<UtModel>? {
fun synthesize(timeLimit: Long = 100000L): List<UtModel>? {
val currentTime = { System.currentTimeMillis() }
val startTime = currentTime()
while (queueIterator.hasNext() && ((currentTime() - startTime) < timeLimit)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ private class UtConstraintBuilder(
}
}
isArray -> {
val sootType = classId.toSootType().arrayType
val sootType = classId.toSootType() as ArrayType
val addr = UtAddrExpression(mkBVConst("post_condition_${name}", UtIntSort))
engine.createArray(addr, sootType, useConcreteType = addr.isThisAddr)
}
Expand Down Expand Up @@ -341,6 +341,20 @@ private class UtConstraintBuilder(
PrimitiveValue(oper.type, mkNot(oper.expr as UtBoolExpression))
}

override fun visitUtConstraintNeg(expr: UtConstraintNeg): SymbolicValue = with(expr) {
val oper = operand.accept(this@UtConstraintBuilder) as PrimitiveValue
PrimitiveValue(
oper.type, UtNegExpression(oper)
)
}

override fun visitUtConstraintCast(expr: UtConstraintCast): SymbolicValue = with(expr) {
val oper = operand.accept(this@UtConstraintBuilder) as PrimitiveValue
PrimitiveValue(
oper.type, UtCastExpression(oper, classId.toSootType())
)
}

override fun visitUtRefEqConstraint(expr: UtRefEqConstraint): UtBoolExpression = with(expr) {
val lhvVal = lhv.accept(this@UtConstraintBuilder)
val rhvVal = rhv.accept(this@UtConstraintBuilder)
Expand Down