1. Safety Beyond Types
Writing Correct Software with Leon
Régis Blanc @regbla
EPFL, LARA
型を超えた安全 - Leon で正しいソフトウェアを書く
2. The Leon Verification System
● Verifier for a subset of Scala
● Analyzes code statically
– If issue detected: display an example that can
trigger the problem
– Otherwise, proves the absence of certain errors
● Open source project, developed at EPFL
– Main contributions from LARA group
静的コード解析を行いコードの正しさを証明する
3. def binarySearch(
a: Array[Int], left: Int, right: Int, x: Int
): Int = {
require(left >= 0 && right < a.length)
if(left > right) -1 else {
val m = (left + right)/2
val element = a(m)
if(x < element) {
binarySearch(a, left, m-1, x)
} else if(x > element) {
binarySearch(a, m+1, right, x)
} else {
m
}
}
}
4. def binarySearch(
a: Array[Int], left: Int, right: Int, x: Int
): Int = {
require(left >= 0 && right < a.length)
if(left > right) -1 else {
val m = (left + right)/2
//assert(m >= 0 && m < a.length)
val element = a(m)
if(x < element) {
//assert(left >= 0 && m-1 < a.length)
binarySearch(a, left, m-1, x)
} else if(x > element) {
//assert(m+1 >= 0 && right < a.length)
binarySearch(a, m+1, right, x)
} else {
m
}
}
}
5. Leon's Capabilities
● Static verification of Scala code:
– Validity of assertions
– Ensure absence of some runtime errors
– Ensure contract for each function
● Code synthesis
Automatically generate valid code given some spec
● Termination checker
● Automated program repair
Leon の機能
Scala コードの静的検証、コード合成、終了チェッカ、自動プログラム修復
7. Main Limitations
● Object-oriented programming and subtyping
● Floating-point arithmetic
● Uniqueness constraint for mutable objects
● Custom standard library
● Verification is fundamentally undecidable
8. Get Leon
● Try it online yourself:
https://leon.epfl.ch/
● Open source on GitHub:
https://github.com/epfl-lara/leon
● Get in touch if you want to know more:
– Email: regwblanc@gmail.com
– Twitter: @regbla
– GitHub: regb