intro · automated theorem provers •z3: microsoft started shipping with device driver...

18
CS 4160 Formal Verification Prof. Clarkson Spring 2020

Upload: others

Post on 10-Jul-2020

10 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: intro · Automated theorem provers •Z3: Microsoft started shipping with device driver developer's kit in Windows 7 •ACL2: used to verify AMD chip compliance with IEEE floating-point

CS 4160Formal Verification

Prof. ClarksonSpring 2020

Page 2: intro · Automated theorem provers •Z3: Microsoft started shipping with device driver developer's kit in Windows 7 •ACL2: used to verify AMD chip compliance with IEEE floating-point
Page 3: intro · Automated theorem provers •Z3: Microsoft started shipping with device driver developer's kit in Windows 7 •ACL2: used to verify AMD chip compliance with IEEE floating-point

Approaches to validation• Social

– Code reviews– Extreme/Pair programming

• Methodological– Design patterns– Test-driven development– Version control– Bug tracking

• Technological– Static analysis

(“lint” tools, FindBugs, …)– Fuzzers

• Mathematical– Sound type systems– “Formal” verification

More formal: eliminate with certainty as many problems as possible.

Less formal: Techniques may miss problems in programs

All of these methods should be used!

Even the most formal can stillhave holes:• did you prove the right thing?• do your assumptions match reality?

Slide credit: Benjamin C. Pierce (UPenn)

Page 4: intro · Automated theorem provers •Z3: Microsoft started shipping with device driver developer's kit in Windows 7 •ACL2: used to verify AMD chip compliance with IEEE floating-point

Verification

• In the 1970s, scaled to about tens of LOC

• Now, research projects scale to real software:– CompCert: verified C compiler– seL4: verified microkernel OS– Ynot: verified DBMS, web services– Four color theorem– Project Everest: verified HTTPS stack [in progress]– Etc.

• In another 40 years?

Page 5: intro · Automated theorem provers •Z3: Microsoft started shipping with device driver developer's kit in Windows 7 •ACL2: used to verify AMD chip compliance with IEEE floating-point

Automated theorem provers

theorem

proof

counter-example

timeout

prover

Page 6: intro · Automated theorem provers •Z3: Microsoft started shipping with device driver developer's kit in Windows 7 •ACL2: used to verify AMD chip compliance with IEEE floating-point

Automated theorem provers

• Z3: Microsoft started shipping with device driver developer's kit in Windows 7

• ACL2: used to verify AMD chip compliance with IEEE floating-point specification, as well as parts of the Java virtual machine

Page 7: intro · Automated theorem provers •Z3: Microsoft started shipping with device driver developer's kit in Windows 7 •ACL2: used to verify AMD chip compliance with IEEE floating-point

Proof assistant

theorem

proofassistant

human guidance

Page 8: intro · Automated theorem provers •Z3: Microsoft started shipping with device driver developer's kit in Windows 7 •ACL2: used to verify AMD chip compliance with IEEE floating-point

Proof assistants

• NuPRL [Prof. Constable]: Formalization of mathematics, distributed protocols, security

• Coq: CompCert, Ynot [Dean Morrisett]

Page 9: intro · Automated theorem provers •Z3: Microsoft started shipping with device driver developer's kit in Windows 7 •ACL2: used to verify AMD chip compliance with IEEE floating-point

COQ

Page 10: intro · Automated theorem provers •Z3: Microsoft started shipping with device driver developer's kit in Windows 7 •ACL2: used to verify AMD chip compliance with IEEE floating-point

Coq

• 1984: Coquand and Huet implement Coq based on calculus of inductive constructions

• 1992: Coq ported to Caml• Now implemented in OCaml

Thierry Coquand1961 –

Page 11: intro · Automated theorem provers •Z3: Microsoft started shipping with device driver developer's kit in Windows 7 •ACL2: used to verify AMD chip compliance with IEEE floating-point

Coq for program verification

Coq program

Coq theorem

guidance with tactics

Proof of theorem

Verified OCaml

program

Page 12: intro · Automated theorem provers •Z3: Microsoft started shipping with device driver developer's kit in Windows 7 •ACL2: used to verify AMD chip compliance with IEEE floating-point

Coq's full system

Page 13: intro · Automated theorem provers •Z3: Microsoft started shipping with device driver developer's kit in Windows 7 •ACL2: used to verify AMD chip compliance with IEEE floating-point

Subset of Coq we'll use

Page 14: intro · Automated theorem provers •Z3: Microsoft started shipping with device driver developer's kit in Windows 7 •ACL2: used to verify AMD chip compliance with IEEE floating-point
Page 15: intro · Automated theorem provers •Z3: Microsoft started shipping with device driver developer's kit in Windows 7 •ACL2: used to verify AMD chip compliance with IEEE floating-point

LOGISTICS

Page 16: intro · Automated theorem provers •Z3: Microsoft started shipping with device driver developer's kit in Windows 7 •ACL2: used to verify AMD chip compliance with IEEE floating-point

Prof. Michael Clarkson

• PhD 2010 Cornell University• BS (CS) & BM (piano) 1999 Miami University• Regularly teach: CS 2110, CS 3110

• Ugrad senior project: verification of some Space Shuttle specs with NASA/JPL

• PhD dissertation: verified in Isabelle/HOL• [Hirsch and Clarkson, CCS 2013]: verified in Coq

Page 17: intro · Automated theorem provers •Z3: Microsoft started shipping with device driver developer's kit in Windows 7 •ACL2: used to verify AMD chip compliance with IEEE floating-point

Course website

https://www.cs.cornell.edu/courses/cs4160/2020sp/

Page 18: intro · Automated theorem provers •Z3: Microsoft started shipping with device driver developer's kit in Windows 7 •ACL2: used to verify AMD chip compliance with IEEE floating-point

Acknowledgment

CS 4160 is based on the online textbook Software Foundations and especially on the work of Prof. Benjamin C. Pierce at the University of Pennsylvania and Prof. Andrew Appel at Princeton University in courses they teach.