speculate-0.2.5: discovery of properties about Haskell functions

Copyright(c) 2016-2017 Rudy Matela
License3-Clause BSD (see the file LICENSE)
MaintainerRudy Matela <rudy@matela.com.br>
Safe HaskellNone
LanguageHaskell2010

Test.Speculate.Expr.Ground

Description

This module is part of Speculate.

Generate and evaluate ground values of expressions.

Synopsis

Documentation

grounds :: Instances -> Expr -> [Expr] Source #

List all possible valuations of an expression (potentially infinite). In pseudo-Haskell:

take 3 $ grounds preludeInstances ((x + x) + y)
  == [(0 + 0) + 0, (0 + 0) + 1, (1 + 1) + 0]

groundBinds :: Instances -> Expr -> [Binds] Source #

List all possible variable bindings to an expression

take 3 $ groundBinds preludeInstances ((x + x) + y)
  == [ [("x",0),("y",0)]
     , [("x",0),("y",1)]
     , [("x",1),("y",0)] ]

groundAndBinds :: Instances -> Expr -> [(Binds, Expr)] Source #

List all possible variable bindings and valuations to an expression

groundAndBinds ti e == zipWith (,) (grounds ti e) (groundBinds ti e)

equal :: Instances -> Int -> Expr -> Expr -> Bool Source #

Are two expressions equal for a given number of tests?

lessOrEqual :: Instances -> Int -> Expr -> Expr -> Bool Source #

Are two expressions less-than-or-equal for a given number of tests?

less :: Instances -> Int -> Expr -> Expr -> Bool Source #

Are two expressions less-than for a given number of tests?

inequal :: Instances -> Int -> Expr -> Expr -> Bool Source #

Are two expressions inequal for *all* variable assignments? Note this is different than not . equal.

true :: Instances -> Int -> Expr -> Bool Source #

Is a boolean expression true for all variable assignments?

false :: Instances -> Int -> Expr -> Bool Source #

Is an expression ALWAYS false? This is *NOT* the same as not true

condEqual :: Instances -> Int -> Expr -> Expr -> Expr -> Bool Source #

Are two expressions equal under a given condition for a given number of tests?

condEqualM :: Instances -> Int -> Int -> Expr -> Expr -> Expr -> Bool Source #

Are two expressions equal under a given condition for a given number of tests and a minimum amount of tests

trueBinds :: Instances -> Int -> Expr -> [Binds] Source #

List variable bindings for which an expression holds true.

trueRatio :: Instances -> Int -> Expr -> Ratio Int Source #

Under a maximum number of tests, returns the ratio for which an expression holds true.