<=>, _equiv

Logical equivalence

MuPAD® notebooks will be removed in a future release. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.


b1 <=> b2
_equiv(b1, b2)


b1 <=> b2 represents the logical equivalence of the Boolean expressions b1, b2.

a <=> b is equivalent to (a ==> b) and (b ==> a), where a ==> b is equivalent to not a or b.

_equiv(a, b) is equivalent to a <=> b.

MuPAD® uses a three state logic with the Boolean constants TRUE, FALSE, and UNKNOWN. These are processed as follows:


Boolean expressions can be composed of these constants as well as of arbitrary arithmetical expressions. Typically, equations, such as x = y, and inequalities, such as x <> y, x < y, x <= y, are used to construct Boolean expressions.

Combinations of the constants TRUE, FALSE, UNKNOWN inside a Boolean expression are simplified automatically. However, symbolic Boolean subexpressions, equalities, and inequalities are not evaluated and simplified by logical operators. Use bool to evaluate such expressions to one of the Boolean constants. Note, however, that bool can evaluate inequalities x < y, x <= y and so on, only if they are composed of numbers of type Type::Real.

Use simplify with the option logic to simplify expressions involving symbolic Boolean subexpressions. See Example 1.

The precedences of the logical operators are as follows. If in doubt, use parentheses to ensure that the expression is parsed as desired.

  • The operator not is stronger binding than and, that is, not b1 and b2 = (not b1) and b2.

  • The operator and is stronger binding than xor, that is, b1 and b2 or b3 = (b1 and b2) xor b3.

  • The operator xor is stronger binding than or, that is, b1 xor b2 or b3 = (b1 xor b2) or b3.

  • The operator or is stronger binding than ==>, that is, b1 or b2 ==> b3 = (b1 or b2) ==> b3.

  • The operator ==> is stronger binding than <=>, that is, b1 ==> b2 <=> b3 = (b1 ==> b2) <=> b3.

In the conditional context of if, repeat, and while statements, Boolean expressions are evaluated via “lazy evaluation” (see _lazy_and, _lazy_or). In any other context, all operands are evaluated.


Example 1

a <=> b is equivalent to (a ==> b) and (b ==> a), where a ==> b is equivalent to not a or b.

simplify((a <=> b), logic)

simplify((a ==> b) and (b ==> a), logic)


b1, b2

Boolean expressions

Return Values

Boolean expression.

Overloaded By

b, b_1, b_2

See Also

MuPAD Functions