All-Path Reachability Logic Andrei Stefanescu 1, Stefan Ciobaca 2, Radu Mereuta 1,2, Brandon Moore...

36
All-Path Reachability Logic Andrei Stefanescu 1 , Stefan Ciobaca 2 , Radu Mereuta 1,2 , Brandon Moore 1 , Traian Serbanuta 3 , Grigore Rosu 1 1 University of Illinois, USA 2 University of Iasi, Romania 3 University of Bucharest, Romania

description

Overview State-of-the-art in Certifiable Verification All-Path Reachability Specifying State Properties Specifying Reachability Properties Reasoning about Reachability

Transcript of All-Path Reachability Logic Andrei Stefanescu 1, Stefan Ciobaca 2, Radu Mereuta 1,2, Brandon Moore...

Page 1: All-Path Reachability Logic Andrei Stefanescu 1, Stefan Ciobaca 2, Radu Mereuta 1,2, Brandon Moore 1, Traian Serbanuta 3, Grigore Rosu 1 1 University of.

All-Path Reachability LogicAndrei Stefanescu1, Stefan Ciobaca2, Radu Mereuta1,2,

Brandon Moore1, Traian Serbanuta3, Grigore Rosu1

1 University of Illinois, USA2 University of Iasi, Romania

3 University of Bucharest, Romania

Page 2: All-Path Reachability Logic Andrei Stefanescu 1, Stefan Ciobaca 2, Radu Mereuta 1,2, Brandon Moore 1, Traian Serbanuta 3, Grigore Rosu 1 1 University of.

2

Main GoalLanguage-independent program verification

framework

Prove program properties from operational semantics

Proof systemOperational semantics ⊢ program properties

Page 3: All-Path Reachability Logic Andrei Stefanescu 1, Stefan Ciobaca 2, Radu Mereuta 1,2, Brandon Moore 1, Traian Serbanuta 3, Grigore Rosu 1 1 University of.

Overview

State-of-the-art in Certifiable Verification

All-Path ReachabilitySpecifying State PropertiesSpecifying Reachability PropertiesReasoning about Reachability

Page 4: All-Path Reachability Logic Andrei Stefanescu 1, Stefan Ciobaca 2, Radu Mereuta 1,2, Brandon Moore 1, Traian Serbanuta 3, Grigore Rosu 1 1 University of.

4

Operational SemanticsEasy to define and understand

Can be regarded as formal “implementations”Require little mathematical knowledge

Great introductory topics in PL coursesExecutable, so testable

Can be tested against real benchmarks

Page 5: All-Path Reachability Logic Andrei Stefanescu 1, Stefan Ciobaca 2, Radu Mereuta 1,2, Brandon Moore 1, Traian Serbanuta 3, Grigore Rosu 1 1 University of.

5

Operational SemanticsFrameworks

PLT-Redex/Racket (Findler et al.)Raskal (Klint et al.)RLS-Maude (Meseguer et al.)PLanComps (Mosses et al.)K (Rosu et al.)OTT (Sewell et al.)

Page 6: All-Path Reachability Logic Andrei Stefanescu 1, Stefan Ciobaca 2, Radu Mereuta 1,2, Brandon Moore 1, Traian Serbanuta 3, Grigore Rosu 1 1 University of.

6

Operational SemanticsScale

C (Ellison and Rosu, POPL’12)GCC torture test suite

JavaScript (Bodin et al., POPL’14)ECMA test262 suite

Python (Politz et al., OOPSLA’13)CPython test suite

PHP (Filaretti and Maffeis, ECOOP’14)Zend test suite

Page 7: All-Path Reachability Logic Andrei Stefanescu 1, Stefan Ciobaca 2, Radu Mereuta 1,2, Brandon Moore 1, Traian Serbanuta 3, Grigore Rosu 1 1 University of.

7

Operational SemanticsSample rule (may require a configuration

context)

Define languages only with rules of the form

l, r are configuration termsb is a Boolean side condition

Page 8: All-Path Reachability Logic Andrei Stefanescu 1, Stefan Ciobaca 2, Radu Mereuta 1,2, Brandon Moore 1, Traian Serbanuta 3, Grigore Rosu 1 1 University of.

8

Unfortunately …Operational semantics considered inappropriate

for program verification; proofs are low-level and tedious:Formalization of and working with transition systemTypically by induction

on the structure of the programon the number of execution stepsetc.

Done in ACL2 before

Page 9: All-Path Reachability Logic Andrei Stefanescu 1, Stefan Ciobaca 2, Radu Mereuta 1,2, Brandon Moore 1, Traian Serbanuta 3, Grigore Rosu 1 1 University of.

9

Axiomatic Semantics(Hoare Logic)

Emphasis on program verificationProgramming language captured as a formal proof

system deriving Hoare triples

precondition postcondition

Page 10: All-Path Reachability Logic Andrei Stefanescu 1, Stefan Ciobaca 2, Radu Mereuta 1,2, Brandon Moore 1, Traian Serbanuta 3, Grigore Rosu 1 1 University of.

10

Axiomatic SemanticsNot easy to define and understand, error-prone

Not executable, hard to testRequire program transformations, behavior loss

Write e = 1 and you’ve got a wrong semantics!

Page 11: All-Path Reachability Logic Andrei Stefanescu 1, Stefan Ciobaca 2, Radu Mereuta 1,2, Brandon Moore 1, Traian Serbanuta 3, Grigore Rosu 1 1 University of.

11

State-of-the-art inCertifiable Verification

Languages C (Appel et al.) – CompCert operational semantics Java (Jacobs et al.)

Approach Define an operational semantics: trusted language model Define an axiomatic semantics: for verification purposes Prove axiomatic semantics sound for operational semantics

Now we have trusted verification … BUT Requires two semantics of the same language

C operational semantics took more than 2 years! Must be done individually for each language

Page 12: All-Path Reachability Logic Andrei Stefanescu 1, Stefan Ciobaca 2, Radu Mereuta 1,2, Brandon Moore 1, Traian Serbanuta 3, Grigore Rosu 1 1 University of.

Overview

State-of-the-art in Certifiable Verification

All-Path ReachabilitySpecifying State PropertiesSpecifying Reachability PropertiesReasoning about Reachability

Page 13: All-Path Reachability Logic Andrei Stefanescu 1, Stefan Ciobaca 2, Radu Mereuta 1,2, Brandon Moore 1, Traian Serbanuta 3, Grigore Rosu 1 1 University of.

13

Our ApproachUnderlying belief: one semantics for each

language! Executable (testable), easy to define and understand Suitable for program verification, “as is”

Approach: language-independent proof system Takes operational semantics unchanged Derives program properties Both operational semantics rules and program

specifications stated as reachability rules Sound and relatively complete

Page 14: All-Path Reachability Logic Andrei Stefanescu 1, Stefan Ciobaca 2, Radu Mereuta 1,2, Brandon Moore 1, Traian Serbanuta 3, Grigore Rosu 1 1 University of.

Overview

State-of-the-art in Certifiable Verification

All-Path ReachabilitySpecifying State PropertiesSpecifying Reachability PropertiesReasoning about Reachability

Page 15: All-Path Reachability Logic Andrei Stefanescu 1, Stefan Ciobaca 2, Radu Mereuta 1,2, Brandon Moore 1, Traian Serbanuta 3, Grigore Rosu 1 1 University of.

15

Matching LogicLogic for specifying static properties about

program configurations and reasoning about them

Key insight:Configuration terms with variables are allowed to

be used as predicates, called patternsSemantically, their satisfaction means matching

Matching logic is parametric in a (first-order) configuration model: typically the underlying model of the operational semantics

[Rosu, Ellison, Schulte 2010]

Page 16: All-Path Reachability Logic Andrei Stefanescu 1, Stefan Ciobaca 2, Radu Mereuta 1,2, Brandon Moore 1, Traian Serbanuta 3, Grigore Rosu 1 1 University of.

16

PatternsC configurations

Example of a pattern

Extra 70 cells

Page 17: All-Path Reachability Logic Andrei Stefanescu 1, Stefan Ciobaca 2, Radu Mereuta 1,2, Brandon Moore 1, Traian Serbanuta 3, Grigore Rosu 1 1 University of.

17

Model of Configurations- Properties -

Configuration abstraction (list)“Separation” achieved at term level

Operations (reverse)

Page 18: All-Path Reachability Logic Andrei Stefanescu 1, Stefan Ciobaca 2, Radu Mereuta 1,2, Brandon Moore 1, Traian Serbanuta 3, Grigore Rosu 1 1 University of.

18

Separation Logic =Matching Logic Instance

Separation logic: popular logic for heap propertiesMechanical translation to matching logic

Configuration: Separation encoded using different sub-terms

Example SL ML

No expressiveness loss from using matching logicMatching logic gives “structural separation” anywhere

in the configuration, not only in the heap

[OOPSLA’12]

Page 19: All-Path Reachability Logic Andrei Stefanescu 1, Stefan Ciobaca 2, Radu Mereuta 1,2, Brandon Moore 1, Traian Serbanuta 3, Grigore Rosu 1 1 University of.

Overview

State-of-the-art in Certifiable Verification

All-Path ReachabilitySpecifying State PropertiesSpecifying Reachability PropertiesReasoning about Reachability

Page 20: All-Path Reachability Logic Andrei Stefanescu 1, Stefan Ciobaca 2, Radu Mereuta 1,2, Brandon Moore 1, Traian Serbanuta 3, Grigore Rosu 1 1 University of.

20

One-Path Reachability Rules

Pairs of matching logic patterns

One-Path Reachability: Any terminating concrete configuration satisfying reaches, on some execution path, some configuration satisfying , in the transition system induced by the operational semantics .

Page 21: All-Path Reachability Logic Andrei Stefanescu 1, Stefan Ciobaca 2, Radu Mereuta 1,2, Brandon Moore 1, Traian Serbanuta 3, Grigore Rosu 1 1 University of.

21

All-Path Reachability RulesPairs of matching logic patterns

All-Path Reachability: Any concrete configuration satisfying reaches, on any terminating execution path, some configuration satisfying , in the transition system induced by the operational semantics .

Page 22: All-Path Reachability Logic Andrei Stefanescu 1, Stefan Ciobaca 2, Radu Mereuta 1,2, Brandon Moore 1, Traian Serbanuta 3, Grigore Rosu 1 1 University of.

22

Reachability Rules- Operational + Axiomatic

-Operational flavor

Axiomatic flavor

Page 23: All-Path Reachability Logic Andrei Stefanescu 1, Stefan Ciobaca 2, Radu Mereuta 1,2, Brandon Moore 1, Traian Serbanuta 3, Grigore Rosu 1 1 University of.

23

Hoare Triple = Syntactic Sugar

Page 24: All-Path Reachability Logic Andrei Stefanescu 1, Stefan Ciobaca 2, Radu Mereuta 1,2, Brandon Moore 1, Traian Serbanuta 3, Grigore Rosu 1 1 University of.

24

Operational and Axiomatic Semantics Rules as Reachability

RulesReachability rules generalize

Operational semantics rulesHoare triples

Operational semantics rule is syntactic sugar for reachability rule

Hoare triple encoded in a reachability rule with the empty code in the right-hand-side

Page 25: All-Path Reachability Logic Andrei Stefanescu 1, Stefan Ciobaca 2, Radu Mereuta 1,2, Brandon Moore 1, Traian Serbanuta 3, Grigore Rosu 1 1 University of.

Overview

State-of-the-art in Certifiable Verification

All-Path ReachabilitySpecifying State PropertiesSpecifying Reachability PropertiesReasoning about Reachability

Page 26: All-Path Reachability Logic Andrei Stefanescu 1, Stefan Ciobaca 2, Radu Mereuta 1,2, Brandon Moore 1, Traian Serbanuta 3, Grigore Rosu 1 1 University of.

26

Reasoning aboutAll-Path Reachability

The main result of this section is a proof system deriving reachability rules from reachability rules:

Operational semantics

Target reachability rule

Claimed reachability rules

(Coinductively) trusted reachability rules

Page 27: All-Path Reachability Logic Andrei Stefanescu 1, Stefan Ciobaca 2, Radu Mereuta 1,2, Brandon Moore 1, Traian Serbanuta 3, Grigore Rosu 1 1 University of.

27

Reachability Proof System- In Two Sentences -

Symbolic execution based on operational semantics

Coinductive proof rule for repetitive behaviorGeneralizes invariant rules from Hoare logicSound and (relatively) complete

Page 28: All-Path Reachability Logic Andrei Stefanescu 1, Stefan Ciobaca 2, Radu Mereuta 1,2, Brandon Moore 1, Traian Serbanuta 3, Grigore Rosu 1 1 University of.

28

Reachability Proof System- 8 Rules -

Symbolic execution (multiple steps)Code with circular behaviorCode with circular behavior

Page 29: All-Path Reachability Logic Andrei Stefanescu 1, Stefan Ciobaca 2, Radu Mereuta 1,2, Brandon Moore 1, Traian Serbanuta 3, Grigore Rosu 1 1 University of.

29

Reachability Proof System

Each configuration has some successorEach successor of a configuration satisfies

Page 30: All-Path Reachability Logic Andrei Stefanescu 1, Stefan Ciobaca 2, Radu Mereuta 1,2, Brandon Moore 1, Traian Serbanuta 3, Grigore Rosu 1 1 University of.

30

Circular behaviorsCircularity, Transitivity and Axiom proof rules

Hoare logic rule for while loops

Language-independent

Language-specific

Claim (cannot use yet)!

Enable!

Use!

Page 31: All-Path Reachability Logic Andrei Stefanescu 1, Stefan Ciobaca 2, Radu Mereuta 1,2, Brandon Moore 1, Traian Serbanuta 3, Grigore Rosu 1 1 University of.

31

Reachability Proof System

Page 32: All-Path Reachability Logic Andrei Stefanescu 1, Stefan Ciobaca 2, Radu Mereuta 1,2, Brandon Moore 1, Traian Serbanuta 3, Grigore Rosu 1 1 University of.

32

Soundness

Theorem: If is derivable by the proof system, then is semantically valid.

Page 33: All-Path Reachability Logic Andrei Stefanescu 1, Stefan Ciobaca 2, Radu Mereuta 1,2, Brandon Moore 1, Traian Serbanuta 3, Grigore Rosu 1 1 University of.

33

Relative Completeness

RelativityValidity oracle for static configuration properties

Language-independent result, unlike Hoare logics

Theorem: If is semantically valid, then is derivable by the proof system, with the operational semantics of a language.

Page 34: All-Path Reachability Logic Andrei Stefanescu 1, Stefan Ciobaca 2, Radu Mereuta 1,2, Brandon Moore 1, Traian Serbanuta 3, Grigore Rosu 1 1 University of.

34

ImplementationPart of the K framework (k-framework.org)Operational semantics and program properties

represented as K rules

Automatic prover (user specified properties) symbolic execution based on the K semantics Circularity for repetitive behaviors custom prover for matching logic implications

Java (mostly) and Z3 (for theory reasoning)

Page 35: All-Path Reachability Logic Andrei Stefanescu 1, Stefan Ciobaca 2, Radu Mereuta 1,2, Brandon Moore 1, Traian Serbanuta 3, Grigore Rosu 1 1 University of.

35

NarrowingConcrete execution

ground configuration rewritingSymbolic execution

symbolic configuration narrowingunification modulo theories

Narrowing generalizes control flow proof rulescode sample

construct operational semantics

Page 36: All-Path Reachability Logic Andrei Stefanescu 1, Stefan Ciobaca 2, Radu Mereuta 1,2, Brandon Moore 1, Traian Serbanuta 3, Grigore Rosu 1 1 University of.

36

ConclusionSound and relatively complete proof system

Circularity generalizes language specific proof rules for repetitive behaviors (loops, recursive functions, …)

Implemented as part of the K frameworkLanguage independent program verification

based solely on operational semantics is possible