(1) Mathematica implements the quantifiers and
as the functions ForAll and Exists.
For example, ForAll[x, x<1] produces the output .
Note that this is simply a quantified statement – it is a statement in the predicate calculus. The predicate “” is not a proposition, because it is not true or false. The variable “
” has to be bound by a quantifier before we can decide the truth or falsity of “
“.
We can check the truth value of ForAll[x, x<1] by applying the Mathematica function Resolve:
Resolve[ForAll[x, x<1] ]
False
Similarly we can quantify the predicate ”” by an existential quantifier:
Exists[x, x<1]
Again we can check the truth of this quantified statement using Resolve:
Resolve[Exists[x, x<1] ]
True
- Experiment with propositions on the one hand and predicates with unbound variables on the other to see the differing Mathematica outputs. Express, in your own words the difference between a proposition and a predicate.
Mathematica
Resolve[Exists[x, x<1] ]
True
For all value of x not be less than one, but x can be less than one or greater than one. In mathematica gives a true because existing value of x can be less than one.
- Construct interesting examples of predicates in which all variables are bound by quantifiers, and check the truth or falsity of these statements using the Resolve function. Note: Resolve will work in general over the complex numbers where possible. So, for example, applying Resolve to the quantified statement ForAll[x,x^2 != -1] yields the truth value “False”. This is because the equation
does in fact have complex solutions. However, if we restrict the domain of Resolve to the real numbers, as follows – Resolve[ForAll[x, x^2 != -1], Reals] – then the result is the truth value “True”.
Mthematica result
Resolve[ForAll[x, x^2 != -1], Reals]
True
The value of x^2 never be a negative value does not matter what value we pass for x we always get out put positive value, because square of x make the positive .
(2) For propositions the truth table for implication
is false when, and only when
is true and
is false. When
are predicates with unbound variables, the situation is more delicate.
For example, let where
are variables ranging over the set
.
The implication is neither true nor false. There are specific values of
for which
is true, and other values for which it is false.
How can we identify such values?
Using the Mathematica function RegionPlot we can visualize the set of points for which
is true:
p=x^2+y^2<1;
RegionPlot[p,{x,-1,1},{y,-1,1}]
Similarly we can visualize the set of points for which
is true:
p=x+y>0;
RegionPlot[p,{x,-1,1},{y,-1,1}]
Using the same function we can visualize the region where is true:
RegionPlot[Implies[p, q], {x, -1, 1}, {y, -1, 1}]
We can check that this gives the same region on which is true:
RegionPlot[! p || q, {x, -1, 1}, {y, -1, 1}]
The function Boole gives us the indicator function of the region on which is true:
b=Boole[Implies[p,q]]
Indicator function of region on which p => q is true
Indicator function of region on which p=>q is false
We can find the area of this region, including a numerical approximation, by integrating the indicator function:
Integrate[b,{x,-1,1},{y,-1,1}]
N[%]
2.4292
- Choose several different examples of regions on which
is true for predicates
defined by inequalities which could be algebraic or involve transcendental functions such as
, and illustrate that these are the same regions for which
is true.