| Maintainer | hapytexeu+gh@gmail.com |
|---|---|
| Stability | experimental |
| Portability | POSIX |
| Safe Haskell | Safe |
| Language | Haskell2010 |
Dep.Data.LogicItem
Description
This module provides utility functions to compress/decompress sums, products, sum-of-products and product-of-sums.
Synopsis
- class EvaluateItem a where
- evaluateItem :: (Int -> Bool) -> a -> Bool
- evaluateWithBits :: Bits b => b -> a -> Bool
- isTrivial :: a -> ThreeValue
- numberOfVariables :: a -> Int
- class ToCompact a b | a -> b where
- toCompact :: a -> b
- fromCompact :: b -> a
- getThreeList :: Get ThreeValues
- putThreeList :: ThreeValues -> Put
- subscriptVariable :: Char -> Int -> Text
- subscriptNegatedVariable :: Char -> Int -> Text
- subscriptConditionVariable :: Char -> Int -> Bool -> Text
- type Item' = ThreeValues
Evaluating logical items
class EvaluateItem a where Source #
A typeclass for objects that can be evaluated to a Bool
based on multiple variables. Numbering of the bits starts by
one because a CompactSum and CompactProduct
start indexes by one, due to the fact that 0 and -0 are equal.
Minimal complete definition
Methods
Arguments
| :: (Int -> Bool) | A function to determine the value of the i-th |
| -> a | The given binary function to evaluate. |
| -> Bool | The result after evaluating the object. |
Evaluate the given item with a function that derives the value
for the given i-th Bool.
Arguments
| :: Bits b | |
| => b | |
| -> a | The given binary function to evaluate. |
| -> Bool | The result after evluating the given object. |
Determine the outcome of the given EvaluateItem based on the values
specified in a Bits object where the i-th Bool is the i-1-th bit
of the data.
Arguments
| :: a | The given logical item to test. |
| -> ThreeValue | returns |
Check if the given object is trivially True (One); False (Zero),
or a non-trivial function (DontCare).
Arguments
| :: a | The given |
| -> Int | The largest index of the variables the given |
Determine the largest index of the variables for which the EvaluateItem is sensitive for.
Instances
Convert from and to a compact format
class ToCompact a b | a -> b where Source #
A class that specifies that a given logic item can be made more compact, or from a compact form to its original form. The two functions are not per se fully each others inverse.
Methods
Arguments
| :: a | The given item to turn in a compact form. |
| -> b | The corresponding compact form. |
Convert the given item to a more compact representation.
Arguments
| :: b | The given compact form that should be represented to the normal form. |
| -> a | The corresponding normal form. |
Convert the given item from a compact representation to its normal presentation.
Instances
| ToCompact Sum CompactSum Source # | |
Defined in Dep.Data.Sum | |
| ToCompact Product CompactProduct Source # | |
Defined in Dep.Data.Product Methods toCompact :: Product -> CompactProduct Source # fromCompact :: CompactProduct -> Product Source # | |
| ToCompact [ThreeValue] [Int] Source # | |
Defined in Dep.Data.LogicItem | |
Binary encode/decode ThreeValues in an efficient way.
getThreeList :: Get ThreeValues Source #
Read a list o ThreeValues from a binary stream where each byte represents
(up to) four ThreeValues.
putThreeList :: ThreeValues -> Put Source #
Convert the given list of ThreeValues to a writer for a binary stream that
encodes four ThreeValues on one byte.
Typesetting variables
Arguments
| :: Char | The "root" variable that we will use with a subscript. |
| -> Int | The subscript that will be added to the character. |
| -> Text | A text object that contains the "root" variable with the subscript. |
Convert the given number to a Text object containing the "root" variable
name and the index as subscript.
subscriptNegatedVariable Source #
Arguments
| :: Char | The "root" variable that we will use with a subscript. |
| -> Int | The subscript that will be added to the character. |
| -> Text | A text object that contains the "root" variable with the subscript and an accent to mark its negation. |
Convert the given number to a Text object containing the "root" variable
name and the index as subscript.
subscriptConditionVariable Source #
Arguments
| :: Char | The "root" variable that will be used with a subscript. |
| -> Int | The subscript that will be added to the variable. |
| -> Bool | A |
| -> Text | A |
Alias for ThreeValues
type Item' = ThreeValues Source #
An alias for ThreeValues: an item (Product or Sum) is a sequence of ThreeValues.