\section{Quantifiers}

Recall the logical symbols we introduced earlier: $(), \land, \lor, \lnot, \rightarrow$ \par
We will now add two more: $\forall$ (for all) and $\exists$ (exists).

\definition{}
$\forall$ and $\exists$ are \textit{quantifiers}. They allow us to make statements about arbitrary symbols. \par
\note{Quantifiers are aptly named: they tell us \textit{how many} symbols satisfy a certain sentence.}


\vspace{2mm}

Let's look at $\forall$ first. If $\varphi(x)$ is a formula, \par
the formula $\forall x ~ \varphi(x)$ is true only if $\varphi$ is true for all $x$ in our universe.

\vspace{1mm}

For example, take the formula $\forall x ~ (0 < x)$. \par
In English, this means \say{For any $x$, $x$ is bigger than zero,} or simply \say{Any $x$ is positive.}

\vspace{3mm}

$\exists$ is very similar: the formula $\exists x ~ \varphi(x)$ is true if there is at least one $x$ for which $\varphi(x)$ is true. \par
For example, $\exists ~ (0 < x)$ means \say{there is a positive number in our set.}

\vspace{4mm}

\problem{}
Which of the following are true in $\mathbb{Z}$? Which are true in $\mathbb{R}^+_0$? \par
\note{$\mathbb{R}^+_0$ is the set of positive real numbers and zero.}

\begin{itemize}[itemsep = 1mm]
	\item $\forall x ~ (x \geq 0)$
	\item $\lnot (\exists x ~ (x = 0))$
	\item $\forall x ~ [\exists y ~ (y \times y = x)]$
	\item $\forall xy ~ \exists z ~ (x < z < y)$ \tab
	\note{This is a compact way to write $\forall x ~ (\forall y ~ (\exists z ~ (x < z < y)))$}
	\item $\lnot \exists x ~ ( \forall y ~ (x < y) )$
\end{itemize}

\begin{solution}
	\begin{itemize}
		\item \say{all $x$ are positive} \tab $\mathbb{R}^+_0$
		\item \say{zero doesn't exist} \tab neither
		\item \say{square roots exist} \tab $\mathbb{R}^+_0$
		\item \say{this set is dense} \tab\null\tab $\mathbb{R}^+_0$
		\item \say{there is no minimum} \tab $\mathbb{Z}$
	\end{itemize}
\end{solution}

%\begin{examplesolution}
%	Here is a solution to the last part: $\lnot \exists x ~ ( \forall y ~ (x < y) )$ \par
%
%	\vspace{4mm}
%
%	Reading this term-by-term, we get \tab \say{not exists $x$ where (for all $y$ ($x$ smaller than $y$))} \par
%	If we add some grammar, we get \tab \say{There isn't an $x$ where all $y$ are bigger than $x$} \par
%	which we can rephrase as \tab~\tab \say{There isn't a minimum value} \par
%
%	\vspace{4mm}
%
%	Which is true in $\mathbb{Z}$ and false in $\mathbb{R}^+_0$
%\end{examplesolution}


\vfill
\pagebreak










\problem{}
Does the order of $\forall$ and $\exists$ in a formula matter? \par
What's the difference between $\exists x ~ \forall y ~ (x \leq y)$ and $\forall y ~ \exists x ~ (x \leq y)$? \par
\hint{
	Consider $\mathbb{R}^+$\hspace{-1.3ex},\hspace{0.8ex} the set of positive reals. Zero is not positive. \par
	Which of the above formulas is true in $\mathbb{R}^+$\hspace{-1.3ex},\hspace{0.8ex} and which is false?
}

\begin{solution}
	If $\exists x$ is inside $\forall y$, $x$ depends on $y$. We may pick a different value of $x$ for every $y$. \par
	If $\exists x$ is outside, $x$ is fixed \textit{before} we check all $y$.
\end{solution}


\vfill

\problem{}
Define 0 in $\Bigl( \mathbb{Z} ~\big|~ \{\times\} \Bigr)$

\begin{solution}
	$\varphi(x) \coloneqq \bigl[~ \forall y ~ x \times y = x ~\bigr]$
\end{solution}

\vfill


\problem{}
Define 1 in $\Bigl( \mathbb{Z} ~\big|~ \{\times\} \Bigr)$

\begin{solution}
	$\varphi(x) \coloneqq \bigl[~ \forall y ~ x \times y = y ~\bigr]$
\end{solution}


\vfill
\pagebreak


\problem{}
Define $-1$ in $\Bigl( \mathbb{Z} ~\big|~ \{0, <\} \Bigr)$

\begin{solution}
	$\varphi(x) \coloneqq \bigl[~ (x<0) \land \lnot \exists y ~ (x < y < 0) ~\bigr]$
\end{solution}

\vfill

%\problem{}
%Define $2$ in $\Bigl( \mathbb{Z} ~\big|~ \{0, <\} \Bigr)$

%\vfill

\problem{}
Let $\varphi(x)$ be a formula. \par
Write a formula equivalent to $\forall x ~ \varphi(x)$ using only logical symbols and $\exists$.

\begin{solution}
	$\forall x ~ \varphi(x)$ is true if and only if $\lnot \exists x ~ \lnot \varphi(x)$ is true.
\end{solution}

\vfill
\pagebreak