Boolean Operations

Logical Expressions

Mathematica allows to test various logical expressions:
"Equal", or "= ="
"Unequal", abbreviated "!=",
"<", "<=", ">" and ">=",
"Not", "And", "Or", exclusive or: "Xor",
and "Implies" for =>.

6==3+4

Equal[3+4,7]

6!=3+4

Unequal[3+4,7]

7<-1

4<=Sqrt[16]

Not[3==Sqrt[10]]

And[3+4==6,4==Sqrt[16]]

Or[3+4==6,4==Sqrt[16]]

Xor[3+4==7,4==2^2]

Implies[False,True]

Implies[True,False]

A truth table:

TableForm[{{A=True,B=True,Implies[A,B]},{A=True,B=False,Implies[A,B]},{A=False,B=True,Implies[A,B]},{A=False,B=False,Implies[A,B]}},TableHeadings->{None,{"A","B","A=>B"}}]

Questions

Mathematica has various built-in questions; you will learn later to build your own questions.

PrimeQ[3]

IntegerQ[3/4]

IntegerQ[3/1]

EvenQ[4]

OddQ[4]

{NumberQ[3],NumberQ[3.1],NumberQ[π],NumberQ[3-I]}

(Remember that  π is considered a symbol, not a number.)

{NumericQ[3],NumericQ[3.1],NumericQ[π],NumericQ[3-I],NumericQ[x]}

x=Sqrt[2];
{NumericQ[3],NumericQ[3.1],NumericQ[π],NumericQ[3-I],NumericQ[x]}

VectorQ[1]

VectorQ[{1}]