convert/boolean_function - Maple Programming Help

Online Help

All Products    Maple    MapleSim


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

convert/boolean_function

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

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

convert(expr, boolean_function)

convert(expr, boolean_function, `or`, `and`, ...)

Parameters

expr

-

Maple expression possibly containing boolean statements constructed using the operators and, or, xor, implies, not

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

aandb

aandb

(1)

convert,boolean_function

Anda,b

(2)

aorb

aorb

(3)

convert,boolean_function

Ora,b

(4)

aorbandc

aorbandc

(5)

convert,boolean_function

Ora,Andb,c

(6)

To reverse these conversions use convert, boolean_operator

convert,boolean_operator

aorbandc

(7)

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

convert,boolean_function,`and`

aorAndb,c

(8)

convert,boolean_function,`or`

Ora,bandc

(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)

axorb

axorb

(10)

convert,boolean_function

OrAnda,Notb,AndNota,b

(11)

ab

ab

(12)

convert,boolean_function

OrNota,b

(13)

Boolean statements constructed with operators have some simplifications performed automatically.

z0andb2a2=0orb2a=0

false

(14)

The equivalent boolean function statement is not automatically simplified (quotes around the boolean operator statement are required).

convert'z0andb2a2=0orb2a=0',boolean_function

Andz0,Orb2a2=0,b2a=0

(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:

aandborcanddore

aandborcanddore

(16)

convert,boolean_function

OrAnda,b,Andc,d,e

(17)

axorbcandd

axorbcandd

(18)

convert,boolean_function

OrNotOrAnda,Notb,AndNota,b,Andc,d

(19)

To reverse this conversion use

convert,boolean_operator

notaandnotbornotaandborcandd

(20)

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

See Also

convert

convert/and

convert/boolean_operator

Logic

type/And