I'm having a trouble with the understanding of how to derive logical identities of the following form:
- $(1) \ \forall x \forall y, P \Leftrightarrow \forall y \forall x, P$
- $(2)$ if $x$ is not free in $P$, then $$Q \wedge (\forall x, P(x)) \Leftrightarrow \forall x, (Q \wedge P(x))$$
I'm not very well-versed in logic, my motivation is pragmatic: to shorten proofs in "ordinary" mathematics. So far, I've been using them as axiom, but I wish to put and end to this.
The problem is, I've tried browsing introduction to logic and in particular to first-order logic, but they all seem to have a different focus, the one with is unhelpful to me and goes contrary to my goals.
In particular, we take $\neg, \vee$ and $\forall$ as our basic logical symbols, and define the rest of them as follows:
- $P \wedge Q$ stands for $\neg (\neg P \vee \neg Q)$
- $P \Rightarrow Q$ stands for $\neg P \vee Q$
- $P \Leftrightarrow Q$ stands for $(P \Rightarrow Q) \wedge (Q \Rightarrow P)$
- $\exists x, P$ stands for $\neg (\forall x, \neg P)$
There are various ways to prove these two equivalences, formally or semantically. But given the purpose of your question, let me give a somewhat informal proof that I think is fairly easy to follow conceptually yet is clear enough for your purposes:
A universal can be seen as kind of conjunction, that is, if $a,b,c,...$ denote the objects in your domain, then you can think of a universal like this:
$$\forall x \: P(x) \approx P(a) \land P(b) \land P(c) \land ...$$
So, if we have two universal quantifiers, we would get:
$$\forall x \forall y \ P(x,y) \approx$$
$$ \forall y \ P(a,y) \land \forall y \ P(b,y) \land \forall y \ P(c,y) \land ... \approx$$
$$(P(a,a) \land P(a,b) \land P(a,c) ..) \land (P(b,a) \land P(b,b) \land P(b,c) ..) \land (P(c,a) \land P(c,b) \land P(c,c) ..) \Leftrightarrow \text{(Reorder)}$$
$$(P(a,a) \land P(b,a) \land P(c,a) ..) \land (P(a,b) \land P(b,b) \land P(c,b) ..) \land (P(a,c) \land P(b,c) \land P(c,c) ..) \land ... \approx$$
$$\forall x \ P(x,a) \land \forall x \ P(x,b) \land \forall x \ P(x,c) \land ... \approx$$
$$\forall y \forall x \ P(x,y)$$
Again, it's a little informal, but you see that the equivalence $\forall x \forall y \ P(x,y) \Leftrightarrow \forall y \forall x \ P(x,y)$ follows from the fact that the conjunction is associative and commutative. Similarly, you can regard an existential as a disjunction, and by the associativity and commutativity of the disjunction prove $\exists x \exists y \ P(x,y) \Leftrightarrow \exists y \exists x \ P(x,y)$
So, we have as a general equivalence principle:
Swapping Quantifiers of the Same Type That Are Next to Each Other
Where $Q$ is some quantifier:
$Q x Q y \ P(x,y) \Leftrightarrow Q y Q x \ P(x,y)$
And yes, they really need to be of the same type, since $\forall x \exists y \ P(x,y) \not \Leftrightarrow \exists y \forall x \ P(x,y)$. If you write out the quantifiers as conjunctions and disjunctions as suggested, you'll see why the equivalence does not hold, but as a simple counterexample: everyone loves someone is not the same as there is someone who loves everyone.
And yes, they also need to be right next to each other, e.g. $\forall x \exists y \forall z \ P(x,y,z) \not \Leftrightarrow \forall z \exists y \forall x \ P(x,y,z)$
By the way, I was assuming that both $x$ and $y$ occur in the formula $P$, which is why I wrote it as $P(x,y)$. If any of them do not occur in $P$, then you can simply drop the quantifier. That is, we can also prove the principle of:
Null Quantification
Where $Q$ is some quantifier and where $x$ does not occur free in $P$:
$Qx P \Leftrightarrow P$
Which makes sense from the conjunction/disjunction point of view as well: If we have $\forall x P$, and if $P$ does not have $x$ as a free variable, we basically just get $P \land P \land P \land ...$, and that is of course just $P$. For the existential we would get $P \lor P \lor P \lor ...$, which is also just $P$.
Finally, we can show your 2). Now, I think you meant to say 'If $x$ is not free in $Q$ ...', but actually in your case it doesn't matter, since if $x$ is free in $Q$ we have the following equivalence principles:
Distribution Universal over Conjunction, and Existential over Disjunction
$\forall x (P(x) \land Q(x)) \Leftrightarrow \forall x \ P(x) \land \forall x \ Q(x)$
$\exists x (P(x) \lor Q(x)) \Leftrightarrow \exists x \ P(x) \lor \exists x \ Q(x)$
'Proof':
$$\forall x (P(x) \land Q(x)) \approx$$
$$(P(a) \land Q(a)) \land (P(b) \land Q(b)) \land (P(c) \land Q(c)) \land ... \Leftrightarrow \text{(Reorder)}$$
$$(P(a) \land P(b) \land P(c) \land ...) \land (Q(a) \land Q(b) \land Q(c) \land ... \approx$$
$$\forall x \ P(x) \land \forall x \ Q(x)$$
(Similar for $\exists x (P(x) \lor Q(x)) \Leftrightarrow \exists x \ P(x) \lor \exists x \ Q(x)$)
And if $x$ is not free in $Q$, we simply do:
$$\forall x (P(x) \land Q) \approx$$
$$(P(a) \land Q) \land (P(b) \land Q) \land (P(c) \land Q) \land ... \Leftrightarrow \text{(Reorder)}$$
$$(P(a) \land P(b) \land P(c) \land ...) \land (Q \land Q \land Q \land ... \Leftrightarrow$$
$$(P(a) \land P(b) \land P(c) \land ...) \land Q \approx$$
$$\forall x \ P(x) \land Q$$
Or, using the earlier established equivalences:
$$\forall x (P(x) \land Q) \Leftrightarrow \text{(Distribution } \forall \text{ over } \land )$$
$$\forall x P(x) \land \forall Q \Leftrightarrow \text{( Null Quantification)}$$
$$\forall x \ P(x) \land Q$$
Note that we do not have that the universal distributes over the $\lor$ or that the Existential distributes over the $\land$, and again, if you rewrite in terms of conjunctions and disjunctions, you'll see why. As a simple counterexample though: Saying that every natural number is even or odd is not the same as saying that either every natural numbers is even, or every natural number is odd. So, in general, $\forall x (P(x) \lor Q(x)) \not \Leftrightarrow \forall x \ P(x) \lor \forall x \ Q(x)$ and $\exists x (P(x) \land Q(x)) \not \Leftrightarrow \exists x \ P(x) \land \exists x \ Q(x)$
However, if $x$ is not free in $Q(x)$, then the following does hold:
Prenex Laws (well, some of them)
Where $x$ is not a free variable in $Q$:
$\forall x (P(x) \lor Q) \Leftrightarrow \forall x \ P(x) \lor Q$
$\exists x (P(x) \land Q)\Leftrightarrow \exists x \ P(x) \land Q$
'Proof':
$$\forall x (P(x) \lor Q) \approx$$
$$(P(a) \lor Q) \land (P(b) \lor Q) \land (P(c) \lor Q) \land ... \Leftrightarrow \text{(Distribution } \lor \text{ over } \land)$$
$$(P(a) \land P(b) \land P(c) \land ...) \lor Q \approx$$
$$\forall x \ P(x) \lor Q$$