forked from ucsd-progsys/liquidhaskell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
meas5.hs
43 lines (30 loc) · 870 Bytes
/
meas5.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
module Meas () where
import Language.Haskell.Liquid.Prelude
{-@ include <len.hquals> @-}
mylen :: [a] -> Int
mylen [] = 0
mylen (_:xs) = 1 + mylen xs
mymap f [] = []
mymap f (x:xs) = (f x) : (mymap f xs)
{-@ decrease go 2 @-}
myreverse = go []
where go acc (x:xs) = go (x:acc) xs
go acc [] = acc
myapp [] ys = ys
myapp (x:xs) ys = x:(myapp xs ys)
zs :: [Int]
zs = [1..100]
zs' :: [Int]
zs' = [500..1000]
prop2 = liquidAssertB (n1 == n2)
where n1 = mylen zs
n2 = mylen $ mymap (+ 1) zs
prop3 = liquidAssertB (n1 == n2)
where n1 = mylen zs
n2 = mylen $ myreverse zs
prop4 = liquidAssertB ((n1 + n2) == n3)
where n1 = mylen zs
n2 = mylen zs'
n3 = mylen $ myapp zs zs'
prop5 = liquidAssertB (length zs'' == length zs)
where zs'' = safeZipWith (+) zs (myreverse zs)