Skip to content

nikivazou/theorem-proving-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 

Repository files navigation

This is a template repo for structuring and checking Liquid Haskell proofs.

GOAL: Safe map fusion

Haskell's rewrite rules can be use to speed-up your code, e.g., map-fusion:

{-# RULES "mapFusion" forall f g xs. map f (map g xs) = map (f ^ g) xs #-}

Liquid Haskell can now prove such rules safe, e.g., with this:

{-@ mapFusion :: f:_ -> g:_ -> xs:_ 
              -> { map f (map g xs) = map (f ^ g) xs } @-}

Does this proof impose extra run-time overhead? No! Because of another rewrite rule:

{-# RULES "mapFusion/runtime"  forall f g xs. mapFusion f g xs = () #-}

Listing of files in src:

Checking your code

With Travis CI

Your theorems and code are automatically checked with Travis CI at each commit because of .travis.yml

With stack

You can check it locally using stack (or cabal) test that runs liquid on all the files listed here.

cd safe-lists/
stack install 
stack test safe-lists

Check each file

Or type the following commands on your terminal. Attention the ordering of the commands should follow the ordering of your imports.

cd src
stack exec -- liquid Data/Misc.hs
stack exec -- liquid Data/List.hs
stack exec -- liquid Theorems/List.hs
stack exec -- liquid Main.hs

For example, if you update Data/List.hs and you want to check your theorems, you need to run liquid Data/List.hs before you run liquid Theorems/List.hs.

About

Template repo for theorem proving in Liquid Haskell

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published