in reply to simplify logical equations

Well, depends on what you're going to be doing with the expressions. If the object is to generate complex expressions and then simplify them as much as possible, not worrying about cycles (maybe the result will be used millions of times in future programs?), then you can divide the expression into sections and test each section for all possible combinations of true / false, replacing sections that are always true or always false with a 1 or 0. If on the other hand you just want to get the results of a complex expression in as efficient a manner as possible, you can do something like the following:
my %vals = ('AND' => '&&', 'OR' => '||', 'XOR' => '^', 'NOT' => '!'); my $logic; while ($logic = <DATA>) { chomp($logic); while(<DATA>) { chomp; last if (!$_); split(/ = /); $vals{@_[0]} = @_[1]; } print "$logic\n"; $logic =~ s/(\w+)/$vals{$1}/g; print "$logic\n"; print eval($logic) . "\n\n"; } __DATA__ a0 OR d1 AND d0 a0 = 1 d1 = 0 d0 = 1 d1 AND e1 AND f0 e1 = 1 f0 = 0