convert/boolean_operator - Maple Programming Help

Home : Support : Online Help : Programming : Data Types : Conversion : convert/boolean_operator

convert/boolean_operator

convert boolean statements involving {And, Or, Xor, Implies, Not} into equivalent boolean operators using {and, or, xor, implies, not}

 Calling Sequence convert(expr, boolean_operator) convert(expr, boolean_operator, Or, And, ...)

Parameters

 expr - Maple expression possibly containing boolean statements constructed using the operators {And, Or, Xor, Implies, Not}

Description

 • The convert(expr, boolean_operator) command converts, in a given expression, all boolean statements constructed using the functions {And, Or, Xor, Implies, Not} into equivalent boolean constructions using {and, or, xor, implies, not}. If the given expression contains no such boolean functions, it is returned unchanged. To perform the opposite conversion, that is, from the operators {and, or, xor, implies, not} to the corresponding boolean functions expressed using only {And, Or, Not} see convert,boolean_function.
 • To restrict the application of the conversion to boolean functions of only certain type, for instance only to And functions, give the name of these functions after the keyword boolean_operator - see the Examples section.
 • Each of the operator or function representations for boolean statements has its own features, which represent advantages or disadvantages depending on the framework these statements are used. Boolean operators are evaluated inside the Maple kernel and have automatic simplifications carried out; boolean functions are evaluated outside the kernel and no automatic simplifications are performed on them - see details in convert,boolean_function.

Examples

 > $a\wedge b$
 ${a}{\wedge }{b}$ (1)
 > $\mathrm{convert}\left(,\mathrm{boolean_operator}\right)$
 ${a}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{\mathbf{and}}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{b}$ (2)
 > $a\vee \left(b\wedge c\right)$
 ${a}{\vee }\left({b}{\wedge }{c}\right)$ (3)
 > $\mathrm{convert}\left(,\mathrm{boolean_operator}\right)$
 ${a}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{\mathbf{or}}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{b}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{\mathbf{and}}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{c}$ (4)

To reverse these conversions use convert, boolean_function

 > $\mathrm{convert}\left(,\mathrm{boolean_function}\right)$
 ${a}{\vee }\left({b}{\wedge }{c}\right)$ (5)

To restrict the application of the conversion only to one (or some) type of boolean functions use for instance

 > $\mathrm{convert}\left(,\mathrm{boolean_operator},\mathrm{And}\right)$
 ${a}{\vee }{b}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{\mathbf{and}}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{c}$ (6)
 > $\mathrm{convert}\left(,\mathrm{boolean_operator},\mathrm{Or}\right)$
 ${a}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{\mathbf{or}}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{b}{\wedge }{c}$ (7)

Note that, convert, boolean_operator also converts {Xor, Implies}

 > $a⊻\left(b⇒c\right)$
 ${a}{⊻}\left({b}{⇒}{c}\right)$ (8)
 > $\mathrm{convert}\left(,\mathrm{boolean_operator}\right)$
 ${a}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{\mathbf{xor}}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\left({b}{⇒}{c}\right)$ (9)

On the other hand, convert, boolean_function only returns results involving {And, Or, Not}

 > $\mathrm{convert}\left(,\mathrm{boolean_function}\right)$
 $\left({a}{\wedge }{¬}\left({¬}{b}{\vee }{c}\right)\right){\vee }\left({¬}{a}{\wedge }\left({¬}{b}{\vee }{c}\right)\right)$ (10)

To express boolean statements constructed with {xor, implies} using only the operators {and, or, not} you can convert to boolean_function then back to boolean_operator; for instance, the example above involving {xor, implies} is equivalent to the following one that involves only {and, or, not}.

 > $\mathrm{convert}\left(,\mathrm{boolean_operator}\right)$
 ${a}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{\mathbf{and}}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{\mathbf{not}}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\left({\mathbf{not}}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{b}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{\mathbf{or}}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{c}\right)\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{\mathbf{or}}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{\mathbf{not}}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{a}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{\mathbf{and}}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\left({\mathbf{not}}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{b}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{\mathbf{or}}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{c}\right)$ (11)

Note also that Or and And constructions, regardless of the number of operands, can be respectively expressed in terms of each other by using Not and this happens automatically when converting to boolean operators

 > $\left(a\vee b\vee c\right)=\left(¬\left(¬a\wedge ¬b\wedge ¬b\right)\right)$
 $\left({a}{\vee }{b}{\vee }{c}\right){=}\left({¬}\left({¬}{a}{\wedge }{¬}{b}{\wedge }{¬}{b}\right)\right)$ (12)
 > $\mathrm{convert}\left(,\mathrm{boolean_operator}\right)$
 $\left({a}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{\mathbf{or}}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{b}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{\mathbf{or}}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{c}\right){=}\left({a}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{\mathbf{or}}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{b}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{\mathbf{or}}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{b}\right)$ (13)
 > $\left(a\wedge b\wedge c\right)=\left(¬\left(¬a\vee ¬b\vee ¬b\right)\right)$
 $\left({a}{\wedge }{b}{\wedge }{c}\right){=}\left({¬}\left({¬}{a}{\vee }{¬}{b}{\vee }{¬}{b}\right)\right)$ (14)
 > $\mathrm{convert}\left(,\mathrm{boolean_operator}\right)$
 $\left({a}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{\mathbf{and}}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{b}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{\mathbf{and}}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{c}\right){=}\left({a}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{\mathbf{and}}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{b}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{\mathbf{and}}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{b}\right)$ (15)

For information on manipulating and simplifying boolean expressions see the Logic package.