circuits-tools
Safe HaskellNone
LanguageGHC2024

Circuit.Tools.Test

Description

Shared oracle helpers for the circuits-axioma* executables.

This library holds generic test machinery that is useful across multiple executables: assertion printers, finite enumeration, and truth-table helpers. Nothing here depends on circuits.

Synopsis

Assertions

check :: String -> Bool -> IO Bool Source #

Print PASS/FAIL for a named boolean assertion and return the result.

approx :: Double -> Double -> Bool Source #

Approximate equality for floating-point oracles.

Finite enumeration

enumFunctions :: Eq a => [a] -> [b] -> [a -> b] Source #

Enumerate all functions from a finite domain to a finite codomain.

enumCartesian :: [a] -> [b] -> [(a, b)] Source #

Cartesian product of two lists.

allBoolFns :: (Bounded a, Enum a) => [a -> Bool] Source #

All functions from a finite bounded enumerable type to Bool.

pairBoolFns :: Enum b => [b] -> [(b, b) -> Bool] Source #

All functions from a pair of finite bounded enumerable values to Bool.

Pairs do not have an Enum instance in current GHC, so we enumerate the underlying values explicitly and index into the truth table.

pairDoubleFns :: Enum b => [b] -> [(b, b) -> Double] Source #

Boolean-valued pair functions rendered as {0,1}-valued Double functions.