Liquid Haskell:
Verification of Haskell Code
Niki Vazou
(University of Maryland)
Liquid Haskell: Verification of Haskell Code
Motivation: Why verification?
Liquid Haskell: Verification of Haskell Code
Motivation: Why verification?
In class motivation: programs may diverge or crash.
But the goal is more ambitious ...
Software bugs are Everywhere
“Airbus A400M crashed due to a software bug.”
— May 2015
Software bugs are Everywhere
“Heartbleed: a security bug in the OpenSSL cryptography library.”
— April 2014
How The Heartbleed Bug Works
How The Heartbleed Bug Works
How The Heartbleed Bug Works
Goal: Make Bugs Difficult to Express
Using Modern Programming Languages (e.g., Haskell, Scala, Ocaml, F#).
Because of Strong Types & Lambda Calculus.
Via compile-time sanity checks
Fact Check: Haskell VS. Heartbleed
The Heartbleed Bug in Haskell
True
is a bad argument
But, 10
is a good argument
Reveal 7
extra characters...
More Bugs: Functional Correctness
More Bugs: Program Equivalence
Goal: Extend Type System
To prevent wider class of errors
To enforce program specific properties
Plan
Coming up:
- 4. Termination
- 5. Proving Laws
- 6. Natural Deduction
Installation & Resources
Online Server: http://goto.ucsd.edu:8090/index.html
cabal install liquidhaskell
From github
Recap
- Refinements: Types + Predicates
- Subtyping: SMT Implication
- Measures: Specify Properties of Data
- Termination: Use Logic to Prove Termination
Evaluation
Diverse Code Bases
20KLoc
Memory Safety, Termination, Functional Correctness, Program Equivalence
Specifications: 1 / 10 LOC
Evaluation
Library | LOC | Specs | Time |
---|---|---|---|
XMonad.StackSet |
256 | 74 | 27s |
Data.List |
814 | 46 | 26s |
Data.Set.Splay |
149 | 27 | 27s |
Data.Vector.Algorithms |
1219 | 76 | 89s |
HsColour |
1047 | 19 | 196s |
Data.Map.Base |
1396 | 125 | 174s |
Data.Text |
3128 | 305 | 499s |
Data.Bytestring |
3505 | 307 | 294s |
Total | 11512 | 977 | 1336s |
Conclusion
Liquid Types: Automated Verification via SMT
Properties: | Predicates + Types |
Proofs: | SMT Solvers + Subtyping |
Thank You!
https://github.com/ucsd-progsys/liquidhaskell
http://www.refinement-types.org
online demo @ http://goto.ucsd.edu/liquidhaskell