NAME
Logic::Expr - logical expression parsing and related routines
SYNOPSIS
use Logic::Expr::Parser;
my $expr = Logic::Expr::Parser->new->from_string('Xv~Y');
use Data::Dumper;
print Dumper $expr->solutions;
my $bools = $expr->bools;
$bools->[1] = 0; # fiddle with Y
print $expr->solve;
DESCRIPTION
Logic::Expr::Parser parses logic expressions of a particular syntax and returns a Logic::Expr
object. This object in turn has various methods for solving all possible solutions, etc.
METHODS
- atoms
-
Hash reference. Atom name (such as
X
) to scalar reference in bools mapping. - bools
-
Array reference. A list of atoms in the logic expression. Set to true by default. atoms and expr contain scalar references to these slots. These values must be updated in-place; a new array will break the references in the other attributes.
- expr
-
The parse tree, which could be a scalar reference or something more complicated involving array references and more.
- new
-
Constructor. Must supply the atoms, bools, and expr parameters, as shown in the code for Logic::Expr::Parser.
- solutions
-
Solves all possible bools states returning an array reference of the results.
- solve
-
Solves the expr using the current state of bools. bools atoms are all set to true by default though could be changed manually.
FUNCTIONS
These are available for export, mostly to the parser module, probably via the :all
tag.
BUGS
None known.
SEE ALSO
There are various other logic modules on CPAN. In particular Math::Logic::Predicate appears to contain section 2 material while this module only has section 1 material from
"A Modern Formal Logic Primer". Paul Teller. 1989.
https://tellerprimer.ucdavis.edu/
COPYRIGHT AND LICENSE
Copyright 2022 Jeremy Mates
This program is distributed under the (Revised) BSD License: https://opensource.org/licenses/BSD-3-Clause