in reply to simplify logical equations
This really depends on what you consider "simplified". If you mean just the basic eliminations of a OR a, then you can easily approach that with a two step algorithm:
If you want a more thourough reduction of terms, for example, a reduction of a AND b OR NOT a AND b to b (assuming standard precedence of AND like * and OR like +), then you will have to employ some less braindead techniques, like bringing the expression into conjunctive (AND terms connected by OR) or disjunctive (OR terms connected by AND) normal form, sorting the terms and then reading off the truth table and eliminating the variables that have no bearing on the result.
b OR a AND b OR c AND a # first, add parentheses for better disambiguation: (b) OR (a AND b) OR (c AND a) # now, sort the AND terms alphabetically, exploiting # the commutativity of AND (b) OR (a AND b) OR (a AND c) # sort the outer terms alphabetically, exploiting # the commutativity of OR (a AND b) OR (a AND c) OR (b) # this is the conjunctive normal form (I think)
The above term has a true value if any of the AND terms have a true value. To get at the disjunctive normal form, do the same thing except that you want to have the OR inside and the AND on the outside - beware of the precedence though!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: simplify logical equations
by ysth (Canon) on Oct 19, 2004 at 10:30 UTC | |
by Corion (Patriarch) on Oct 19, 2004 at 10:48 UTC | |
|
Re^2: simplify logical equations
by thealienz1 (Pilgrim) on Oct 19, 2004 at 09:07 UTC |