bloder
01/05/2022, 4:55 AMfun average(xs: List<Int>): Int {
pre(xs.isNotEmpty()) { "list not empty" }
TODO()
}
val x = average(listOf(1))
pre-condition `list not empty` is not satisfied in `average(listOf(1))`
-> unsatisfiable constraint: `listOf(1).isNotEmpty`
The curious thing here is, pre / pos conditions with primitive values (like PositiveInt
sample) works but not with collections, I've already tried to create value classes wrappers, Laws, but only works with primitive types, not collections... Am I missing anything? Current using Kotlin 1.6.10 and arrow analysis 2.0-SNAPSHOTraulraja
01/05/2022, 8:08 PMlaws
module to your plugin which includes the laws for the std lib and collections?raulraja
01/05/2022, 8:08 PMraulraja
01/05/2022, 8:08 PMbloder
01/05/2022, 10:24 PMraulraja
01/05/2022, 10:35 PMbloder
01/05/2022, 10:54 PMisNotEmpty
predicate I need to define laws from other std lib type?raulraja
01/05/2022, 11:16 PMraulraja
01/05/2022, 11:17 PMraulraja
01/05/2022, 11:17 PMbloder
01/05/2022, 11:30 PMbloder
01/09/2022, 7:23 PMisNotEmpty
problem, I didn't find out why its axiom is not being declared properly but I found other axioms that is not being declared to smt solver by plugin internal laws like List<E>#isEmpty
and mapOf()
, then if u try to declare pre conditions like this:
fun <K, V> Map<K, V>.x(): Int {
pre(isEmpty()) { "map is not empty" }
return 1
}
val y = mapOf<Int, Int>().x()
and this:
fun <E> List<E>.x(): Int {
pre(isEmpty()) { "list is not empty" }
return 1
}
val y = listOf<Int>().x()
U'll get errors. U guys accepting contributions? I can open a PRraulraja
01/09/2022, 7:25 PMbloder
01/09/2022, 7:27 PM