Courtney May
06/11/2026, 2:21 PM@JvmInline
value class Score(val value: Int) { init { require(value in 1..101) } } // a bug - should be 1..100
fun gradeBand(score: Score): String {
val labels = arrayOf("F", "E", "D", "C-", "C", "C+", "B", "B+", "A-", "A")
return labels[(score.value - 1) / 10]
}
class GradeBandProofs {
@BmcProof
fun `gradeBand never throws for any valid Score`() {
val score = assumeValid { Score(anyInt()) } // require(...) gets folded into the domain
gradeBand(score) // we want to prove that gradeBand never throws for any valid score
// refuted! ArrayIndexOutOfBoundsException, counterexample: score = 101
}
}
We are pre-1.0.0 so actively looking for people to try it out and provide feedback/report issues!
https://bmc4j.github.io/docs/
https://github.com/bmc4j/bmc4jBernd Prünster
06/11/2026, 3:00 PMCourtney May
06/12/2026, 12:37 AM