convert/boolean_function - convert boolean statements involving {and,or,xor,implies,not} into equivalent boolean functions using {And,Or,Not}
|
Calling Sequence
|
|
convert(expr, boolean_function)
convert(expr, boolean_function, `or`, `and`, ...)
|
|
Description
|
|
•
|
The convert(expr, boolean_function) command converts, in a given expression, all boolean statements constructed using the operators {and, or, xor, implies, not} into equivalent boolean function constructions using the functions {And, Or, Not}. If the given expression contains no such boolean operators, it is returned unchanged. To perform the opposite conversion, that is, from the functions {And, Or, Xor, Implies, Not} to the corresponding boolean operators {and, or, xor, implies, not}, see convert,boolean_operator.
|
•
|
To restrict the application of the conversion to boolean operators of only certain type, for instance only to `and` operators, give the name of these operators, surrounded by `` after the keyword boolean_function - see the Examples.
|
•
|
The conversion of boolean statements constructed with operators into boolean statements constructed with functions is of use, among others things, for:
|
|
- avoiding the automatic simplification which happens with boolean operators;
|
|
- allowing the read of the boolean statement with the ordering of execution and precedence of the operations made explicit with parenthesis.
|
|
|
Examples
|
|
>
|
|
| (1) |
>
|
|
| (2) |
>
|
|
| (3) |
>
|
|
| (4) |
>
|
|
| (5) |
>
|
|
| (6) |
To reverse these conversions use convert, boolean_operator
>
|
|
| (7) |
To restrict the application of the conversion only to one (or some) type of boolean operators use for instance
>
|
|
| (8) |
>
|
|
| (9) |
Note that, convert, boolean_function returns using only {And,Or,Not}, so statements using {xor, implies} will not result in statements with {Xor, Implies} in the output (even when convert, boolean_operator knows about them)
>
|
|
| (10) |
>
|
|
| (11) |
>
|
|
| (12) |
>
|
|
| (13) |
Boolean statements constructed with operators have some simplifications performed automatically.
>
|
|
| (14) |
The equivalent boolean function statement is not automatically simplified (quotes around the boolean operator statement are required).
>
|
|
| (15) |
The function representation above permits further manipulations of the boolean statement without having it simplified to 'false'.
The order and precedence of the operations becomes explicit:
>
|
|
| (16) |
>
|
|
| (17) |
>
|
|
| (18) |
>
|
|
| (19) |
To reverse this conversion use
>
|
|
| (20) |
For information on manipulating and simplifying these expressions, see the Logic package.
|
|