How to | Use Logical Operators
The Wolfram Language supports logical operators not only for programming, but for mathematical operations as well.
The infix operators && and || stand for conjunction (And) and disjunction (Or), while ! is the prefix operator for negation (Not). The next two inputs are equivalent:
(True && False) || !TrueOr[And[True, False], Not[True]]You can use symbols instead of True and False. BooleanConvert symbolically evaluates many logical expressions. We expect
to be
:
BooleanConvert[(a && b) || (!a && b)]Use Resolve to find truth values of quantified logical statements:
Resolve[ForAll[{a, b}, Equivalent[(a && b) || (!a && b), b]], {a, b}, Booleans]You can also use the existential quantifier to check that
:
Resolve[ForAll[a, Exists[b, (a && b) || (!a && b)]], {a, b}, Booleans]The Wolfram Language also recognizes the logical operator Implies; you can use it to show
:
Resolve[ForAll[{a, b}, Implies[a && b, b]], {a, b}, Booleans]Use SatisfiableQ to check if a and b satisfy
:
SatisfiableQ[(a && b) && (!a || !b), {a, b}]