True
is a bad argument10
is a good argumenttake
and drop
reconstruction0
fib
is an uninterpreted function0
average
take
fib
fib
is an uninterpreted functionList
s Elementsappend
take
and drop
reconstructiontake
and drop
reconstructionLets prove that f x == mconcat (pmap f (chunk i x))
in Haskell!
For parallelism we use Control.Parallel.Strategies.withStrategy
encoded in the logic as an identity.
What about the rest of the recursive functions?
Example: reflecting take
.
Our first recursive proof using combinators from Language.Haskell.Liquid.ProofCombinators
.
This proof is boring! Please automate it!
Let's define type aliases for morphism
and a proof for append right identity.
The proof is simply a recursive Haskell function!
We start with the classic list definition, ...
refined with a length
termination annotation.
List chunking
uses the standard take
and drop
functions.
STAY
Note: We need to make take
total!
Similarly we define a total drop
function.
We use take
and drop
to define chunk
.
Appending take
and drop
exactly reconstuct the list.
take
and drop
reconstructionDefine an inductive proof term, ... following the structure of take
and drop
.
GOAL: f x == mconcat (pmap f (chunk i x))
First, we define list mapping.
We parallelize mapping using Control.Parallel.Strategies
Where withStrategy
is assumed to be identity.
Runtime parallelization does not affect the proof and is the classic haskell code.
GOAL: f x == mconcat (pmap f (chunk i x))
Finally, lets concatenate the result!