3 Acme::Test::LogicalEquivalence - Test if expressions are logically
13 use Acme::Test::LogicalEquivalence qw(is_logically_equivalent);
15 # test two expressions with 2 variables using the special vars $a and $b
16 is_logically_equivalent(2, sub { $a && $b }, sub { $b && $a });
19 is_logically_equivalent(2, sub { $_[0] && $_[1] }, sub { $_[1] && $_[0] });
21 # you can do as many vars as you like
22 is_logically_equivalent(3, sub { $_[0] || ($_[1] && $_[2]) },
23 sub { ($_[0] || $_[1]) && ($_[0] || $_[2]) });
29 Some expressions are "logically equivalent" to other expressions, but
30 it may not be easy to tell if one or both of the expressions are
31 reasonably complicated. Or maybe you're like many other people and are
32 too lazy to go through the effort... Either way, why not let your
33 computer prove logical equivalence for you?
37 is_logically_equivalent
39 Test logical equivalence of two subroutines.
41 my $is_equivalent = is_logically_equivalent($numvars, &sub1, &sub2);
43 This will execute both of the subroutines one or more times (depending
44 on how many variables you specify) with different inputs. The
45 subroutines shall be considered logically equivalent if, for all
46 combinations of inputs, they both return the same thing.
48 Returns true if the subroutines are logically equivalent, false
53 * What is logical equivalence? Start here:
54 https://en.wikipedia.org/wiki/Logical_equivalence
58 Charles McGarvey <chazmcgarvey@brokenzipper.com>
62 This software is copyright (c) 2016 by Charles McGarvey.
64 This is free software; you can redistribute it and/or modify it under
65 the same terms as the Perl 5 programming language system itself.