Quantifiers
In a statement like

,
Mathematica treats the variable

as having a definite, though unspecified, value. Sometimes, however, it is useful to be able to make statements about whole collections of possible values for

. You can do this using
quantifiers.
| ForAll[x,expr] | expr holds for all values of x |
| ForAll[{x1,x2,...},expr] | exprholds for all values of all thexi |
| ForAll[{x1,x2,...},cond,expr] | exprholds for allxisatisfyingcond |
| Exists[x,expr] | there exists a value of x for which expr holds |
| Exists[{x1,x2,...},expr] | there exist values of the for which expr holds |
| Exists[{x1,...},cond,expr] | there exist values of the satisfying cond for which expr holds |
The structure of quantifiers.
You can work with quantifiers in
Mathematica much as you work with equations, inequalities or logical connectives. In most cases, the quantifiers will not immediately be changed by evaluation. But they can be simplified or reduced by functions like
FullSimplify and
Reduce.
This asserts that an

exists that makes the inequality true. The output here is just a formatted version of the input.
| Out[1]= |  |
| Out[2]= |  |
This gives
False, since the inequality fails when

is zero.
| Out[3]= |  |
Mathematica supports a version of the standard notation for quantifiers used in predicate logic and pure mathematics. You can input

as \
ForAll
or
Esc
, and you can input

as \
Exists
or
Esc
. To make the notation precise, however,
Mathematica makes the quantified variable a subscript. The conditions on the variable can also be given in the subscript, separated by a comma.
xexpr | ForAll[x,expr] |
{x1,x2,...}expr | ForAll[{x1,x2,...},expr] |
x,condexpr | ForAll[x,cond,expr] |
xexpr | Exists[x,expr] |
{x1,x2,...}expr | Exists[{x1,x2,...},expr] |
x,condexpr | Exists[x,cond,expr] |
Notation for quantifiers.
Given a statement that involves quantifiers, there are certain important cases where it is possible to resolve it into an equivalent statement in which the quantifiers have been eliminated. Somewhat like solving an equation, such quantifier elimination turns an implicit statement about what is true for all
x or for some
x into an explicit statement about the conditions under which this holds.
| Resolve[expr] | attempt to eliminate quantifiers from expr |
| Resolve[expr,dom] | attempt to eliminate quantifiers with all variables assumed to be in domain dom |
Quantifier elimination.
This shows that an

exists that makes the equation true.
| Out[4]= |  |
This shows that the equations can only be satisfied if

obeys a certain condition.
| Out[5]= |  |
Resolve can always eliminate quantifiers from any collection of polynomial equations and inequations over complex numbers, and from any collection of polynomial equations and inequalities over real numbers. It can also eliminate quantifiers from Boolean expressions.
This finds the conditions for a quadratic form over the reals to be positive.
| Out[6]= |  |
This shows that there is a way of assigning truth values to

and

that makes the expression true.
| Out[7]= |  |
You can also use quantifiers with
Reduce. If you give
Reduce a collection of equations or inequalities, then it will try to produce a detailed representation of the complete solution set. But sometimes you may want to address a more global question, such as whether the solution set covers all values of
x, or whether it covers none of these values. Quantifiers provide a convenient way to specify such questions.
This gives the complete structure of the solution set.
| Out[8]= |  |
This instead just gives the condition for a solution to exist.
| Out[9]= |  |
It is possible to formulate a great many mathematical questions in terms of quantifiers.
This finds the conditions for a circle to be contained within an arbitrary conic section.
| Out[10]= |  |
This finds the conditions for a line to intersect a circle.
| Out[11]= |  |
This defines

to be a general monic quartic.
This finds the condition for all pairs of roots to the quartic to be equal.
| Out[13]= |  |
Although quantifier elimination over the integers is in general a computationally impossible problem,
Mathematica can do it in specific cases.
This shows that

cannot be a rational number.
| Out[14]= |  |

is, though.
| Out[15]= |  |