dep-software-0.1.0.0
Maintainerhapytexeu+gh@gmail.com
Stabilityexperimental
PortabilityPOSIX
Safe HaskellSafe
LanguageHaskell2010

Dep.Data.LogicItem

Description

This module provides utility functions to compress/decompress sums, products, sum-of-products and product-of-sums.

Synopsis

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

evaluateItem, isTrivial, numberOfVariables

Methods

evaluateItem Source #

Arguments

:: (Int -> Bool)

A function to determine the value of the i-th Bool.

-> 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.

evaluateWithBits Source #

Arguments

:: Bits b 
=> b

The given Bits object that holds the values for the Bools.

-> 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.

isTrivial Source #

Arguments

:: a

The given logical item to test.

-> ThreeValue

returns One if the EvaluateItem object always resolves to True; Zero if the object always resolves to False; and DontCare if the function is not trivial.

Check if the given object is trivially True (One); False (Zero), or a non-trivial function (DontCare).

numberOfVariables Source #

Arguments

:: a

The given EvaluateItem.

-> Int

The largest index of the variables the given EvaluateItem is sensitive for.

Determine the largest index of the variables for which the EvaluateItem is sensitive for.

Instances

Instances details
EvaluateItem ProductOfSums Source # 
Instance details

Defined in Dep.Data.Sum

EvaluateItem CompactSum Source # 
Instance details

Defined in Dep.Data.Sum

EvaluateItem Sum Source # 
Instance details

Defined in Dep.Data.Sum

EvaluateItem SumOfProducts Source # 
Instance details

Defined in Dep.Data.Product

EvaluateItem CompactProduct Source # 
Instance details

Defined in Dep.Data.Product

EvaluateItem Product Source # 
Instance details

Defined in Dep.Data.Product

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

toCompact Source #

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.

fromCompact Source #

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.

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

subscriptVariable 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.

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 Bool that is False if the item should be negated; and True otherwise.

-> Text

A Text object that contains the root variable, the subscript, and an accent if necessary.

Convert the given number to a Text objet that contains the "root" variable, name, the index, and based on a given Bool can include a quote mark if the variable should be False.

Alias for ThreeValues

type Item' = ThreeValues Source #

An alias for ThreeValues: an item (Product or Sum) is a sequence of ThreeValues.