software engineering & automated deduction willem visser stellenbosch university with nikolaj...

23
Software Engineering & Automated Deduction Willem Visser Stellenbosch University With Nikolaj Bjorner (Microsoft Research, Redmond) Natarajan Shankar (SRI Computer Science Lab, Menlo Park)

Upload: milton-hibbitts

Post on 14-Dec-2015

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Software Engineering & Automated Deduction Willem Visser Stellenbosch University With Nikolaj Bjorner (Microsoft Research, Redmond) Natarajan Shankar (SRI

Software Engineering&

Automated Deduction

Willem VisserStellenbosch University

WithNikolaj Bjorner (Microsoft Research, Redmond)

Natarajan Shankar (SRI Computer Science Lab, Menlo Park)

Page 2: Software Engineering & Automated Deduction Willem Visser Stellenbosch University With Nikolaj Bjorner (Microsoft Research, Redmond) Natarajan Shankar (SRI

Stellenbosch?

Page 3: Software Engineering & Automated Deduction Willem Visser Stellenbosch University With Nikolaj Bjorner (Microsoft Research, Redmond) Natarajan Shankar (SRI

Automated DeductionAutomated Deduction

Software Engineering

Software Engineering

VerificationVerification

Page 4: Software Engineering & Automated Deduction Willem Visser Stellenbosch University With Nikolaj Bjorner (Microsoft Research, Redmond) Natarajan Shankar (SRI

Automated deduction uses computation to perform symbolic logical reasoning*

* [101] Shankar. Automated deduction for verification. ACM Computing Surveys. 2009

Is a logical formula φ valid?

or is there a counter-example?in which case !φ is satisfiable

φ valid iff !φ unsatisfiable

Page 5: Software Engineering & Automated Deduction Willem Visser Stellenbosch University With Nikolaj Bjorner (Microsoft Research, Redmond) Natarajan Shankar (SRI

Is a logical formula φ satisfiable?

Is there a Model that satisfies φ?

Satisfiability checking proceduresare the cornerstone of automated deduction

Page 6: Software Engineering & Automated Deduction Willem Visser Stellenbosch University With Nikolaj Bjorner (Microsoft Research, Redmond) Natarajan Shankar (SRI

We tend to want to know about our code …

Given that we have a specification of what is expected

Page 7: Software Engineering & Automated Deduction Willem Visser Stellenbosch University With Nikolaj Bjorner (Microsoft Research, Redmond) Natarajan Shankar (SRI

φ

Program

Specification

Logic Formula

AutomatedDeduction Tool

Page 8: Software Engineering & Automated Deduction Willem Visser Stellenbosch University With Nikolaj Bjorner (Microsoft Research, Redmond) Natarajan Shankar (SRI

Logics Techniques

First-order logic Automated Theorem Proving

Propositional logic SAT SolversExp

ress

iven

ess

Aut

omat

ion

From around the early-mid 1990s SAT solvers improved dramatically

Page 9: Software Engineering & Automated Deduction Willem Visser Stellenbosch University With Nikolaj Bjorner (Microsoft Research, Redmond) Natarajan Shankar (SRI

Program

φLogic Formula

Integer arithmetic

Arrays

BitVectors

Floating point

Strings

Linear integers

Heaps

Machine integers

Features

Floating point

Theories

Strings

+

Satisfiability Modulo Theories (SMT) SolversFully Automated Satisfiability Checkers

Perfect fit for solving Software Engineering problems

Page 10: Software Engineering & Automated Deduction Willem Visser Stellenbosch University With Nikolaj Bjorner (Microsoft Research, Redmond) Natarajan Shankar (SRI

VerificationFull automation is not always possible

Formulas to prove can fall outside

of decidable fragment

Even if it can be provedit might be too slow

or require tricky invariants

Requires human interaction Proof Environments

Page 11: Software Engineering & Automated Deduction Willem Visser Stellenbosch University With Nikolaj Bjorner (Microsoft Research, Redmond) Natarajan Shankar (SRI

Too much manual effort

seL4 microkernel verification took 20 man yearsusing Isabelle/HOL

Program Verifiers are more domain specificthey verify annotations in the code holds

Spec# ESC-Java

Page 12: Software Engineering & Automated Deduction Willem Visser Stellenbosch University With Nikolaj Bjorner (Microsoft Research, Redmond) Natarajan Shankar (SRI

Model Checking

Explicit state Symbolic

PredicateAbstraction

withCEGAR

BDDs SAT

SLAM BLAST (Nu)SMV CBMC

is M a model for φ

Page 13: Software Engineering & Automated Deduction Willem Visser Stellenbosch University With Nikolaj Bjorner (Microsoft Research, Redmond) Natarajan Shankar (SRI

Symbolic Execution

void test(int x, int y) { if (y == x*10) S0; else S1; if (x > 3 && y > 10) S2; else S3;}

[ Y=X*10 ] S0

[ X>3 & 10<Y=X*10] S2

[ true ] test (X,Y)

[ Y!=X*10 & !(X>3 & Y>10) ] S3

[ Y!=X*10 ] S1

[ Y=X*10 & !(X>3 & Y>10) ] S3

[ X>3 & 10<Y!=X*10] S2

SMT solvers check feasibility

Test cases derived from models

Page 14: Software Engineering & Automated Deduction Willem Visser Stellenbosch University With Nikolaj Bjorner (Microsoft Research, Redmond) Natarajan Shankar (SRI

ConcolicDynamic SE

void test(int x, int y) { if (y == x*10) S0; else S1; if (x > 3 && y > 10) S2; else S3;}

[ Y=X*10 ] S0

[ X>3 & 10<Y=X*10] S2

[ true ] test (0,1)

[ Y!=X*10 & !(X>3 & Y>10) ] S3

[ Y!=X*10 ] S1

[ Y=X*10 & !(X>3 & Y>10) ] S3

[ X>3 & 10<Y!=X*10] S2

Pick random inputsCollect PC during executionNegate one of the conditionsIf feasible derive new inputs

[ Y!=X*10 & (X>3 & Y>10) ] => Test(4,11)

Page 15: Software Engineering & Automated Deduction Willem Visser Stellenbosch University With Nikolaj Bjorner (Microsoft Research, Redmond) Natarajan Shankar (SRI

(Dynamic) Symbolic Execution is the poster child

for the positive effect of AD in SE

An idea from the early 1970sthat only sprang to life in late 1990s

due to the advances in SAT/SMT solving

Page 16: Software Engineering & Automated Deduction Willem Visser Stellenbosch University With Nikolaj Bjorner (Microsoft Research, Redmond) Natarajan Shankar (SRI

Automated Deduction

Software Engineering

In the past

currently

Page 17: Software Engineering & Automated Deduction Willem Visser Stellenbosch University With Nikolaj Bjorner (Microsoft Research, Redmond) Natarajan Shankar (SRI

SE drivers for AD

HeapsLocally finite theories

with limited quantification

Data structures Monadic 2nd Order Logic

(Bounded) Software Model Checking Horn Clauses

Security Strings

Reliability andInformation Flow Model Counting (#SAT)

Page 18: Software Engineering & Automated Deduction Willem Visser Stellenbosch University With Nikolaj Bjorner (Microsoft Research, Redmond) Natarajan Shankar (SRI

Not good enough any more

For test case generation we need models

High-integrity code need certifiable proofs

Fault localization and repair need unsatisfiable cores

Reliability analysis need number of solutions

Page 19: Software Engineering & Automated Deduction Willem Visser Stellenbosch University With Nikolaj Bjorner (Microsoft Research, Redmond) Natarajan Shankar (SRI

Informal Survey of SE Researchers

What would you like to see most from an Automated Deduction tool?

Black-box with limited visibility to internals

White-box thatexposes inner workings

Want to know why not just what

Page 20: Software Engineering & Automated Deduction Willem Visser Stellenbosch University With Nikolaj Bjorner (Microsoft Research, Redmond) Natarajan Shankar (SRI

Lessons from Automated Deduction

Competitions/Benchmarking

InteroperabilityTPTP

DIMACS

SMT-LIB2

vs

CASC (1996)

SMT-COMP (2005)vs

SATE (2008)

SV-COMP and RERS (2012)

SyGus-COMP (2014)

Page 21: Software Engineering & Automated Deduction Willem Visser Stellenbosch University With Nikolaj Bjorner (Microsoft Research, Redmond) Natarajan Shankar (SRI

Some New Trends in SE

Synthesis

Education

Sketching*

harness void doubleSketch(int x){ int t = x * ??; assert t == x + x;}

* http://people.csail.mit.edu/asolar/sketch2012/

Learning to Code

Page 22: Software Engineering & Automated Deduction Willem Visser Stellenbosch University With Nikolaj Bjorner (Microsoft Research, Redmond) Natarajan Shankar (SRI

Some More TrendsProbabilistic Analysis

Reliability

[ X>3 & 10<Y=X*10] [ X>3 & 10<Y!=X*10] [ Y!=X*10 & !(X>3 & Y>10) ][ Y=X*10 & !(X>3 & Y>10) ]

y=10xy=10x

x>3 & y>10x>3 & y>10x>3 & y>10x>3 & y>10

1

0.999

0.855

0.001

0.6 0.4 0.145

0.0006 0.0004 0.8538 0.1452

Page 23: Software Engineering & Automated Deduction Willem Visser Stellenbosch University With Nikolaj Bjorner (Microsoft Research, Redmond) Natarajan Shankar (SRI

Automated Deduction

Software Engineering

In the past

currently

Black-box with limited visibility to internals

White-box thatexposes inner workings

Want to know why not just what