-- Example for a Curry program with contracts (pre/postcondition): -- Sum up all numbers from 0 to n. sum :: Int -> Int sum n = if n==0 then 0 else n + sum (n-1) -- Precondition: the argument is not negative sum'pre :: Int -> Bool sum'pre n = n>=0 -- Postcondition: the result satisfies the Gauss sum formula sum'post :: Int -> Int -> Bool sum'post n f = f == n * (n+1) `div` 2 main :: Int main = sum 100 -- The contract prover for such programs can be installed by -- -- > cypm install contract-prover -- -- If `~/.cpm/bin` is in the path, the contracts in this program -- can be verified (provided that the SMT solver Z3 is installed) by -- -- > curry-contracts Sum -- -- Hence, the contract prover actually verifies the -- (partial) correctness of `sum`.