NAME

Logic::Minimizer - The parent class of Boolean minimizers.

SYNOPSIS

This is the base class for logic minimizers that are used by Logic::TruthTable. You do not need to use this class (or indeed read any further) unless you are creating a logic minimizer package.

package Algorithm::SomethingNiftyLikeEspresso;
extends 'Logic::Minimizer';

(Algorithm::SomethingNiftyLikeEspresso has Logic::Minimizer as its base class, which is required if Logic::TruthTable is to use it.)

Then, either use the package directly in your program:

my $fn = Algorithm::SomethingNiftyLikeEspresso->new(
    width => 4,
    minterms => [1, 8, 9, 14, 15],
    dontcares => [2, 3, 11, 12]
);
...

or as a algorithm choice in Logic::TruthTable:

my $tt = Logic::TruthTable->new(
    width => 4,
    algorithm => 'SomethingNiftyLikeEspresso',
    columns => [
        {
            minterms => [1, 8, 9, 14, 15],
            dontcares => [2, 3, 11, 12],
        }
        {
            minterms => [4, 5, 6, 10, 13],
            dontcares => [2, 3, 11, 12],
        }
    ],
);

This class provides the attributes and some of the methods for your minimizer class.

Minimizer Attributes

These are the attributes provided by Logic::Minimizer to create and reduce the object. Some attributes are required to be set from the program, some are optional, and others are generated internally.

The attributes required to create the object are:

'width'

width is absolutely required -- it tells the object how many variables are used in the Boolean equation.

'minterms'
'maxterms'

The set (if using minterms) or unset (if using maxterms) terms in the Boolean equation. The choice affects the output of the equation: using minterms results in a sum-of-products form of the equation, while using maxterms results in a product-of-sums form.

'dontcares'

The terms that don't affect the output of the equation at all; that one literally doesn't care about.

'columnstring'
'columnlist'

Alternate ways of providing minterms, maxterms, and don't-care terms. Position 0 in the string or list represents the 0th row of the column, position 1 represents the next row, and so on. In either case, the output is in sum-of-product form.

Some common sense rules apply. If 'columnstring' or 'columnlist' is provided, 'minterms', 'maxterms', and 'dontcares' can't be used.

Likewise, 'minterms' and 'maxterms' can not be used together, and 'dontcares' can't be used by itself.

Some attributes are optional, and are used to changed the look of the output.

'title'

A name or description of the problem. Useful for tracking which object one is working with, if there's more than one.

'dc'

The don't-care character. May be changed for both aesthetic and inter-program communication purposes. Used in columnstring or columnlist attributes. Also used in output files by Logic::TruthTable, and in 'covers' output (see below). Defaults to the character '-'.

'vars'

The variable names used to output the Boolean equation. By default, uses 'A' to 'Z'. The names do not have to be single characters, e.g.: vars = ['a1', 'a0', 'b1', 'b0']>

The attributes that are set during the minimizing process.

These are all "lazy" attributes, and calculated when asked for in code or by the user. All are created by builder functions that the child class needs to provide.

'primes'

The prime implicants. A hash in the form 'implicant' = [covered terms]>.

'covers'

The covers are the building blocks of the final form of the solution to the equation, and are used to create the text form of the equation.

The terms are listed in an array, but as there may be more than one way to cover the solution, it is an array of cover arrays.

'essentials'

The essential prime implicants (for informational purposes only, algorithms generally don't need it for minimizing).

'algorithm'

The class of the child object. for example, if the class used to solve the set of terms is Algorithm::QuineMcCluskey, then 'algorithm' would be set to 'QuineMcCluskey'.

Minimizer Methods

These are the methods needed for error checking, or to read from or write to the attributes.

Some are provided by Logic::Minimizer, while others (the builder methods of the attributes 'primes', 'covers', and 'essentials') are merely method definitions, and are expected to be provided by the child class.

to_columnstring

Provided by this module. Converts the column into a single string.

to_columnlist

Provided by this module. Converts the column into an array reference.

catch_errors

Provided by this module. Finds basic errors such as empty term arrays, insufficient variables for the width, terms that don't fit within the table size, and so forth.

to_boolean

Provided by this module. Converts a set of covers to a boolean equation.

to_boolean_term

Provided by this module. Converts a cover term into a boolean expression. Called by to_boolean().

generate_primes
generate_covers
generate_essentials

The primes, covers, and essentials attributes need methods to create those attributes. The child module of Logic::Minimizer should provide these.

AUTHOR

John M. Gamble, <jgamble at cpan.org>

BUGS

Please report any bugs or feature requests to bug-logic-minimizer at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Logic-Minimizer. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc Logic::Minimizer

You can also look for information at:

ACKNOWLEDGEMENTS

LICENSE AND COPYRIGHT

Copyright 2015 John M. Gamble.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.