True is a bad argument10 is a good argument0fib is an uninterpreted function0averagetakefibfib is an uninterpreted function
Refinement Types = Types + Predicates
0Refinement types via special comments {-@ ... @-}
Q: First, can you fix Pos so poss is rejected?
Q: Next, can you modify poss so it is accepted?
{-@ type Pos = {v:Int | 0 < v} @-}
{-@ poss :: [Pos] @-}
poss = [1, 2, 3]
Type Checking Via Implication Checking.
v = 1 => 0 < v
v = 2 => 0 < v
v = 3 => 0 < v
{-@ type Pos = {v:Int | 0 < v} @-}
Refinements Drawn from Decidable logics.
For automatic, decidable (and thus predictable) SMT type checking.
Goal: Arbitrary (terminating) Haskell expressions into refinements, ...
... while preserving decidable type checking.
A. Farmer et al: Reasoning with the HERMIT
Can we express the above theorems in Liquid Haskell?
Liquid Types express theorems, and
Haskell functions express proofs.
ProofCombinators comes with Liquid Haskell and allows for pretty proofs!
ProofCombinators comes with Liquid Haskell and allows for pretty proofs!
ProofCombinators comes with Liquid Haskell and allows for pretty proofs!
Can we express them in Liquid Haskell?
Reflect terminating fib in the logic.
Now fib can live in the Liquid Types!
fib is an uninterpreted function
For which logic only knows the congruence axiom...
... and nothing else
The type of fib connects logic & Haskell implementation
fib :: i:Nat
-> {v:Nat | v == fib i
&& v == if i == 0 then 0 else
if i == 1 then 1 else
fib (i-1) + fib (i-2)
}
Calling fib i reveals its implementation into the logic!
Q: Can you prove that fib 2 == 1?
Using combinators from ProofCombinators!
Using combinators from ProofCombinators!
fib is increasing
fib is monotonic?
fib is monotonic!
Case Study: MapReduce: Program Properties that matter!