This is a template repo for structuring and checking Liquid Haskell proofs.
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 = () #-}
Main.hs
contains your main code that uses user-defined lists,Data/List.hs
contains the definition of the list data type,Data/Misc.hs
contains helper functions, andTheorems/List.hs
contains some theorems that lists satisfy.
Your theorems and code are automatically checked with Travis CI at each commit because of .travis.yml
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
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
.