Le Lever eragin aging g Rust Types es for Modular lar Speci - - PowerPoint PPT Presentation

le lever eragin aging g rust types es for modular lar
SMART_READER_LITE
LIVE PREVIEW

Le Lever eragin aging g Rust Types es for Modular lar Speci - - PowerPoint PPT Presentation

Le Lever eragin aging g Rust Types es for Modular lar Speci cification and Verification Vytautas Astrauskas Peter Mller Federico Poli Alexander J. Summers Department of Computer Science Analogy with C verification void client(list *


slide-1
SLIDE 1

Le Lever eragin aging g Rust Types es for Modular lar Speci cification and Verification

Vytautas Astrauskas Peter Müller Federico Poli Alexander J. Summers

Department of Computer Science

slide-2
SLIDE 2

Analogy with C verification

1

Data Races Aliasing Memory Errors Functional properties C void client(list *a, list *b) { int old_len = b->len; append(a, 100); assert(b->len == old_len); }

slide-3
SLIDE 3

2

Memory list(a) list(b)

acc(b.len)

Verification Ingredients

*

Predicates Disjointness

  • f memory

Ownership / Permissions Auxiliary annotations

What is this like to use?

slide-4
SLIDE 4

Verification Ingredients at Scale

3

Predicate Owned field Auxiliary annotation Predicate Owned field Owned field Owned field Owned field Predicate Predicate Predicate Predicate Predicate Predicate Disjointness Disjointness Predicate Owned field Predicate Predicate Predicate Predicate Disjointness Auxiliary annotation Auxiliary annotation Auxiliary annotation Auxiliary annotation Auxiliary annotation Auxiliary annotation Auxiliary annotation Auxiliary annotation Auxiliary annotation Auxiliary annotation Auxiliary annotation Auxiliary annotation Auxiliary annotation Disjointness Disjointness Auxiliary annotation Disjointness Disjointness Auxiliary annotation Auxiliary annotation Auxiliary annotation Auxiliary annotation Disjointness Disjointness Auxiliary annotation Auxiliary annotation Auxiliary annotation Auxiliary annotation Auxiliary annotation Disjointness Auxiliary annotation

“Core proof” Requires an expert These steps are mandatory

slide-5
SLIDE 5

Data Races? Aliasing? Memory Errors? No Memory Errors Controlled Aliasing No Data Races

Rust, and its type system

4

Functional properties Can we exploit this type system for verification? Rust fn client(a: &mut List, b: &mut List) { let old_len = b.len(); append(a, 100); assert!(b.len() == old_len); }

slide-6
SLIDE 6

Wha What woul uld d we like?

5

slide-7
SLIDE 7

Prusti: An Overview

6

Specs

https://www.rust-lang.org/logos/rust-logo-blk.svg is licensed under CC BY 4.0

Leveraging Rust Types for Modular Specification and Verification To appear at OOPSLA 2019, Athens, Greece (next week)

slide-8
SLIDE 8

The Prusti Approach

7

Functional specification Auxiliary annotations Pre/postconditions Signature Compiler analyses (e.g. borrow checker) User specifications (optional) Types Predicates and Ownership U s a b l e b y n

  • n
  • e

x p e r t s Rust Verification Ingredients

slide-9
SLIDE 9

Core Proofs: Behind the Scenes

8

Predicate Owned field Auxiliary annotation Predicate Owned field Owned field Owned field Owned field Predicate Predicate Predicate Predicate Predicate Predicate Disjointness Disjointness Predicate Owned field Predicate Predicate Predicate Predicate Disjointness Auxiliary annotation Auxiliary annotation Auxiliary annotation Auxiliary annotation Auxiliary annotation Auxiliary annotation Auxiliary annotation Auxiliary annotation Auxiliary annotation Auxiliary annotation Auxiliary annotation Auxiliary annotation Auxiliary annotation Disjointness Disjointness Auxiliary annotation Disjointness Disjointness Auxiliary annotation Auxiliary annotation Auxiliary annotation Auxiliary annotation Disjointness Disjointness Auxiliary annotation Auxiliary annotation Auxiliary annotation Auxiliary annotation Auxiliary annotation Disjointness Auxiliary annotation

Requires an expert These steps are mandatory Ownership, Predicates, Annotations all generated automatically Users write functional specifications (optionally) Abstraction level: Rust expressions

slide-10
SLIDE 10

Type Encoding

9

struct List { val: i32, next: Option<Box<List>> } predicate List(self: Ref) { acc(self.val) ⁎ acc(self.next) ⁎ i32(self.val) ⁎ OptionBoxList(self.next) }

i32 OptionBoxList

List

val next self

Viper Rust

slide-11
SLIDE 11

*

Signature Encoding

fn client(a: &mut List, b: &mut List) method client(a: Ref, b: Ref) requires List(a) ⁎ List(b) ensures List(a) ⁎ List(b) a: List b: List Rust method client(a: Ref, b: Ref) requires List(a) ⁎ List(b) && a.sorted() && … ensures List(a) ⁎ List(b) && a.sorted()

10

Viper

slide-12
SLIDE 12

fn get(t: &mut BinaryTree) -> &mut BinaryTree { // traverse somehow; return a subtree }

Reborrowing Challenges

11

Rust Frozen Mutable Mutable For the caller:

slide-13
SLIDE 13

fn get(t: &mut BinaryTree) -> &mut BinaryTree { // traverse somehow; return a subtree }

Reborrowing Challenges

12

Rust Combined effect? Permissions?

slide-14
SLIDE 14

s

fn get(t: &mut BinaryTree) -> &mut BinaryTree { // return a subtree }

Reborrowing Challenges

13

fn get(t: &mut BinaryTree) -> &mut BinaryTree { // traverse somehow; return a subtree }

s

* *

) (

Rust Permissions: magic wand Novel specification: pledges (see OOPSLA paper for details…)

slide-15
SLIDE 15

Evaluation (no specifications)

14

11’791 (21%) supported functions

100% of functions:

core proof verifies

Total: 1M lines of Viper Auxiliary annotations: 100K Total: ~40K loc 500 most downloaded packages (crates) No specification

https://www.rust-lang.org/logos/cargo.png is licensed under CC BY 4.0

slide-16
SLIDE 16

Evaluation with specifications

15

+ Specification

rosettacode.org

slide-17
SLIDE 17

VIPER ENCODING AUTOMATION PLEDGES RUST SUBSET

What else is in the paper?

16

Leveraging Rust Types for Modular Specification and Verification To appear at OOPSLA 2019, Athens, Greece (next week)

slide-18
SLIDE 18

Conclusion

17

prusti.ethz.ch

Dramatically simplifies Rust verification Enables verification by developers Plenty more to work on! e.g. closures, unsafe code, reference counting, standard libraries, … On the lookout for Master’s (ETH/UBC) and PhD students (UBC)

  • get in touch!