{-@ LIQUID "--no-termination" @-} module Repeat where import Prelude hiding (repeat, succ) import Language.Haskell.Liquid.Prelude repeat :: Int -> (a -> a) -> a -> a goal :: Int -> Int {-@ bound step @-} step :: (a -> a -> Bool) -> (Int -> a -> Bool) -> Int -> a -> a -> Bool step pf pr = \ i x x' -> pr (i - 1) x ==> pf x x' ==> pr i x' -- This syntax is not yet supported in liquidhaskell-8 {- repeat :: forall a a -> Bool, r :: Int -> a -> Bool>. (Step a f r) => n:Nat -> (y:a -> a) -> a -> a @-} {-@ repeat :: forall a a -> Bool, r :: Int -> a -> Bool>. {i::Int, x::a|- a <:a } n:Nat -> (y:a -> a) -> a -> a @-} repeat 0 _ x = x repeat n f x = repeat (n - 1) f (f x) {-@ goal :: n:Nat -> {r:Nat | n <= r} @-} goal n = repeat n (+ 1) 0