Functions > Boolean Algebra


For a discussion on Boolean Algebra support in MP, please refer to the Boolean Expressions section.

Working with Truth Tables is made easy through a simple GUI tool. Please refer to Truth Tables Easy Kit section for more details.

Note: Certain functions like first(), last() and count() described in the Array and Data Manipulation section also support Boolean Arrays.

The following functions are described in this Section:

  1. bool
  2. fillbool

bool

Creates a Boolean array. Its format is:

bool (val_1, val_2, ..., val_n )

Here val_1, val_2, ..., val_n are any values that can evaluate to either 'true' or 'false'. The value true can be specified using the string literal 'true', a non-zero number or a Boolean variable or expression that evalulates to true. The value false can be specified using the string literal 'false', the number 0, or a Boolean variable or expression that evalulates to false.

Examples:
>> bool (true, false, true)
>> bool (0, 2, 3)
>> a = 10
>> bool (a > 100, a < 100, a == 100, a != 20, a == 10, a >= 2, a <= 20="" p="">

fillbool

Creates columns of Truth Tables and names them for future reference. This way you can store premises and get the conclusions very conveniently. Its format is:

fillbool (var_1, var_2, var_3, ....., var_n)

var_1, var_2, var_3, ..., var_n are any valid variable names (left-hand side expressions). Each variable is assigned a Boolean array of required size and is initialized with proper values according to the order it appears.

Example:

Suppose you want to create a truth table for the Boolean expression:

(a+b)*(a^b)^(a+b*c+(d^x)*y+z)

Note: Here a,b,c etc. are Boolean variables and +,* and ^ are Boolean operators and not ordinary arithmetic operators.

The expression contains seven (7) Boolean variables. It means that each column of the truth table will have 2^7 = 128 rows! It is not quite convenient to create such a complex truth table manually. The function fillbool can create the required truth table very easily as shown below:

>> fillbool(a,b,c,d,x,y,z)
>> result = (a+b)*(a^b)^(a+b*c+(d^x)*y+z)