mathlib documentation

testing.slim_check.gen

gen Monad

This monad is used to formulate randomized computations with a parameter to specify the desired size of the result.

This is a port of the Haskell QuickCheck library.

Main definitions

Local notation

Tags

random testing

References

def slim_check.gen (α : Type u) :
Type u

Monad to generate random examples to test properties with. It has a nat parameter so that the caller can decide on the size of the examples.

Equations
def slim_check.io.run_gen {α : Type} (x : slim_check.gen α) (i : ) :
io α

Execute a gen inside the io monad using i as the example size and with a fresh random number generator.

Equations
def slim_check.gen.choose_any (α : Type u) [preorder α] [random α] :

Lift random.random to the gen monad.

Equations
def slim_check.gen.choose {α : Type u} [preorder α] [bounded_random α] (x y : α) (p : x y) :

Lift random.random_r to the gen monad.

Equations
def slim_check.gen.choose_nat (x y : ) (p : x y) :

Generate a nat example between x and y.

Equations
def slim_check.gen.sized {α : Type u} (cmd : slim_check.gen α) :

Get access to the size parameter of the gen monad. For reasons of universe polymorphism, it is specified in continuation passing style.

Equations
def slim_check.gen.vector_of {α : Type u} (n : ) (cmd : slim_check.gen α) :

Create n examples using cmd.

Equations
def slim_check.gen.list_of {α : Type u} (cmd : slim_check.gen α) :

Create a list of examples using cmd. The size is controlled by the size parameter of gen.

Equations
def slim_check.gen.one_of_aux {α : Type u} (xs : list (slim_check.gen α)) (pos : fact (0 < xs.length)) :

Given a list of example generators, choose one to create an example. This definition is needed for to provide a local fact $ 0 < xs.length instance to the type resolution system.

Equations
def slim_check.gen.one_of {α : Type u} (xs : list (slim_check.gen α)) (pos : 0 < xs.length) :

Given a list of example generators, choose one to create an example.

Equations
def slim_check.gen.permutation_of {α : Type u} (xs : list α) :

Generate a random permutation of a given list.

Equations