Top Banner
1 IC | 28.03.13 School of Computer and Communication Sciences Verifying Scala Programs in Leon Régis Blanc School of Computer and Communication Sciences IC March 30, 2013
12

argo.matf.bg.ac.rsargo.matf.bg.ac.rs/events/2013/pdp2013/slides/RegisBlank.pdf · P. Suter, A.S. K oksal, V. Kuncak, Satis ability Modulo Recursive Programs, SAS’11 R egis Blanc

May 29, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: argo.matf.bg.ac.rsargo.matf.bg.ac.rs/events/2013/pdp2013/slides/RegisBlank.pdf · P. Suter, A.S. K oksal, V. Kuncak, Satis ability Modulo Recursive Programs, SAS’11 R egis Blanc

1IC | 28.03.13School of Computer and Communication Sciences

Verifying Scala Programs in Leon

Régis Blanc

School of Computer andCommunication Sciences IC

March 30, 2013

Page 2: argo.matf.bg.ac.rsargo.matf.bg.ac.rs/events/2013/pdp2013/slides/RegisBlank.pdf · P. Suter, A.S. K oksal, V. Kuncak, Satis ability Modulo Recursive Programs, SAS’11 R egis Blanc

The Leon Verification System

I Verifier for the Scala language.

I Support a well-defined subset of Scala.

I A functional core language.I Many imperative extensions.I Some ways to express non-determinism.

I Complete for finding counterexamples.

I Current team: Regis Blanc, Etienne Kneuss, Viktor Kuncak,Philippe Suter

I Past contributors: Ali Sinan Koksal, Octavian Ganea, RobinSteiger, Utkarsh Upadhyay.

Regis Blanc (EPFL) Verifying Scala Programs in Leon March 30, 2013 2

Page 3: argo.matf.bg.ac.rsargo.matf.bg.ac.rs/events/2013/pdp2013/slides/RegisBlank.pdf · P. Suter, A.S. K oksal, V. Kuncak, Satis ability Modulo Recursive Programs, SAS’11 R egis Blanc

Contracts

Specifications can be defined using contracts.

I Postconditions

def abs(n: Int): Int = {

if(n <= 0) -n else n

} ensuring(res => res >= 0)

I Preconditions

def fact(n: Int): Int = {

require(n >= 0)

if(n == 0) 1 else n * fact(n-1)

}

The implementation and specification languages are the same.

Regis Blanc (EPFL) Verifying Scala Programs in Leon March 30, 2013 3

Page 4: argo.matf.bg.ac.rsargo.matf.bg.ac.rs/events/2013/pdp2013/slides/RegisBlank.pdf · P. Suter, A.S. K oksal, V. Kuncak, Satis ability Modulo Recursive Programs, SAS’11 R egis Blanc

Contracts

Specifications can be defined using contracts.

I Postconditions

def abs(n: Int): Int = {

if(n <= 0) -n else n

} ensuring(res => res >= 0)

I Preconditions

def fact(n: Int): Int = {

require(n >= 0)

if(n == 0) 1 else n * fact(n-1)

}

The implementation and specification languages are the same.

Regis Blanc (EPFL) Verifying Scala Programs in Leon March 30, 2013 3

Page 5: argo.matf.bg.ac.rsargo.matf.bg.ac.rs/events/2013/pdp2013/slides/RegisBlank.pdf · P. Suter, A.S. K oksal, V. Kuncak, Satis ability Modulo Recursive Programs, SAS’11 R egis Blanc

Contracts

Specifications can be defined using contracts.

I Postconditions

def abs(n: Int): Int = {

if(n <= 0) -n else n

} ensuring(res => res >= 0)

I Preconditions

def fact(n: Int): Int = {

require(n >= 0)

if(n == 0) 1 else n * fact(n-1)

}

The implementation and specification languages are the same.

Regis Blanc (EPFL) Verifying Scala Programs in Leon March 30, 2013 3

Page 6: argo.matf.bg.ac.rsargo.matf.bg.ac.rs/events/2013/pdp2013/slides/RegisBlank.pdf · P. Suter, A.S. K oksal, V. Kuncak, Satis ability Modulo Recursive Programs, SAS’11 R egis Blanc

Contracts

Specifications can be defined using contracts.

I Postconditions

def abs(n: Int): Int = {

if(n <= 0) -n else n

} ensuring(res => res >= 0)

I Preconditions

def fact(n: Int): Int = {

require(n >= 0)

if(n == 0) 1 else n * fact(n-1)

}

The implementation and specification languages are the same.

Regis Blanc (EPFL) Verifying Scala Programs in Leon March 30, 2013 3

Page 7: argo.matf.bg.ac.rsargo.matf.bg.ac.rs/events/2013/pdp2013/slides/RegisBlank.pdf · P. Suter, A.S. K oksal, V. Kuncak, Satis ability Modulo Recursive Programs, SAS’11 R egis Blanc

Demo

Regis Blanc (EPFL) Verifying Scala Programs in Leon March 30, 2013 4

Page 8: argo.matf.bg.ac.rsargo.matf.bg.ac.rs/events/2013/pdp2013/slides/RegisBlank.pdf · P. Suter, A.S. K oksal, V. Kuncak, Satis ability Modulo Recursive Programs, SAS’11 R egis Blanc

Our Architecture

Code Transformations

Scala Program

CoreAlgorithm

Report

ScalaCompiler

Regis Blanc (EPFL) Verifying Scala Programs in Leon March 30, 2013 5

Page 9: argo.matf.bg.ac.rsargo.matf.bg.ac.rs/events/2013/pdp2013/slides/RegisBlank.pdf · P. Suter, A.S. K oksal, V. Kuncak, Satis ability Modulo Recursive Programs, SAS’11 R egis Blanc

Our Architecture

Code Transformations

Scala Program

CoreAlgorithm

Report

ScalaCompiler

Imperative toFunctional

ArrayEncoding

FunctionLifting

Regis Blanc (EPFL) Verifying Scala Programs in Leon March 30, 2013 5

Page 10: argo.matf.bg.ac.rsargo.matf.bg.ac.rs/events/2013/pdp2013/slides/RegisBlank.pdf · P. Suter, A.S. K oksal, V. Kuncak, Satis ability Modulo Recursive Programs, SAS’11 R egis Blanc

Our Architecture

Code Transformations

Scala Program

CoreAlgorithm

Report

ScalaCompiler

1. Over-approximate with uninterpreted functions, if UNSAT then return UNSAT.2. Add blocking predicates to block branches containing non-unrolled function invocations, if SAT, return SAT.3. Choose, in some fair way, function invocations to unroll and unroll them, go to step 1.

Reference:

P. Suter, A.S. Koksal, V. Kuncak, Satisfiability ModuloRecursive Programs, SAS’11

Regis Blanc (EPFL) Verifying Scala Programs in Leon March 30, 2013 5

Page 11: argo.matf.bg.ac.rsargo.matf.bg.ac.rs/events/2013/pdp2013/slides/RegisBlank.pdf · P. Suter, A.S. K oksal, V. Kuncak, Satis ability Modulo Recursive Programs, SAS’11 R egis Blanc

Overview of some ResultsBenchmark LOC #VCs Time (s)

V I U

AssociativeList 50 11 0 0 0.23InsertionSort 99 14 1 0 0.42RedBlackTree 117 20 4 0 3.73PropositionalLogic 86 22 1 0 2.36AmortizedQueue 124 32 0 0 3.37Arithmetic 73 10 1 0 0.33ArrayOperations 207 36 0 7 2.37ListOperations 146 21 4 1 4.34Constraints 76 6 3 1 2.41

I Each verification condition (VC) can be Valid, Invalid orUnknown (timeout).

I Different kinds of VCs:I loop invariants, preconditions, postconditions, array accesses,

and exhaustiveness of match expressions.

Regis Blanc (EPFL) Verifying Scala Programs in Leon March 30, 2013 6

Page 12: argo.matf.bg.ac.rsargo.matf.bg.ac.rs/events/2013/pdp2013/slides/RegisBlank.pdf · P. Suter, A.S. K oksal, V. Kuncak, Satis ability Modulo Recursive Programs, SAS’11 R egis Blanc

5IC | 28.03.13School of Computer and Communication Sciences

Thank you for your attention

Régis BlancSchool of Computer andCommunication Sciences IC

ic.epfl.ch