What are the rules for negating quantifiers in propositional logic in general, is the "NOT" distributive? I was wondering what the general rules for negating quantifiers was.
I was reading that they follow this rule holds:
$$NOT(\forall x. P(x)) \iff \exists x. NOT(P(x))$$
Which makes sense to me. However, I was worried that if there are more and more predicates and quantifiers involved in the negation, that we have to be extra careful about negating the statement and that its not as simple as just "distributing" the NOT.
For example is just "distributing" the NOT over all predicates and quantifiers really negates a statement correct?
Consider this example:
$$NOT( \exists x. P(x). \forall y. P(x,y). \exists z \exists k. P(z,k)) \iff \forall x. NOT(P(x)). \exists y. NOT(P(x,y)). \forall z \forall k. NOT(P(z,k))$$
Basically, is it safe to just distribute the NOT across all quantifiers and predicates when trying to negate a more general proposition? The order of the statements in the proposition never change when we negate, right? Is there some intuitive proof that distribution of not works for negating a proposition? Why is "distributing" the not correct? Or maybe someone could make the rule precise to me, its not clear to me how to do it for an arbitrary proposition with crazy mixtures of quantifiers and predicates.
 A: The formula :

$NOT(∃x.P(x).∀y.P(x,y).∃z∃k.P(z,k))$

is not correctly written; the issue is not with the dots after the quantifiers; we can delete them and we have still an "un-grammatical" formuala :

$NOT(∃xP(x).∀yP(x,y).∃z∃kP(z,k))$.

The formula is meaningless exactly as is meaningless the natural language expression :

"there exist a prime number all prime numbers are ..."

$∃xP(x)$ is a formula correctly written; thus it can be part of a more complex formula containing also the formula $∀yP(x,y)$ only if there is a connective : $\land, \lor, \rightarrow, \leftrightarrow$ "joining" them.

Having said that, the basic rules for managing the quantifiers are :

$\forall \lnot$ is equivalent to : $\lnot \exists$
$\lnot \forall$ is equivalent to : $\exists \lnot$.

Thus, your example :

$NOT(∀xP(x)) \leftrightarrow ∃x NOT(P(x))$

is correct.
With more "complex" formulae, like e.g. :

$NOT (∀xP(x) \lor ∃y Q(y))$

we have, by De Morgan's laws :

$NOT (∀xP(x)) \land NOT (∃y Q(y)) \leftrightarrow \exists x NOT P(x) \land \forall y NOT Q(y)$.



Examples from your courseware are :

$∀n ∈ Evens ∃p ∈ Primes ∃q ∈ Primes (n = p + q)$ [page 75]

all the quantifers prefix a formula (a "matrix") and the scope of all three quantifiers is the formula : $(n = p + q)$.
Thus, its negation will be :

$\lnot (∀n ∃p ∃q (n = p + q)) \leftrightarrow ∃n \lnot (∃p ∃q (n = p + q)) \leftrightarrow \ldots \leftrightarrow ∃n ∀p ∀q \lnot (n = p + q)$.

In the case of :

$∃x∀yP(x, y) \rightarrow ∀y∃xP(x, y)$ [page 77]

we have two sub-formulae : $∃x∀yP(x, y)$ and $∀y∃xP(x, y)$ "joined" by the connective : $\rightarrow$ (IMPLIES).
Here we have to apply first the rule for the negation of a formula with $\rightarrow$, i.e. : $\lnot (p \rightarrow q)$ is equivalent to : $p \land \lnot q$, in order to "move inside" the negation sign, followed by the rules for the negation of quantifiers.
Thus :

$\lnot (∃x∀yP(x, y) \rightarrow ∀y∃xP(x, y)) \leftrightarrow ((∃x∀yP(x, y) \land \lnot ∀y∃xP(x, y)) \leftrightarrow ((∃x∀yP(x, y) \land ∃y∀x \lnot P(x, y))$

A: The "rules for negating quantifiers" you mention above are regarded as generalizations of De Morgan's laws, despite there seem to have no name in common usage (see this post):

The universal quantifier in $\varphi$ is equivalent to a conjunction of $[\overline{a}/x]\varphi$ of all elements $a$ of the universe $U$ (and the same holds for the existential quantifier in terms of disjunctions), they are regarded to be generalizations of De Morgan's laws, as others answered already:
$$\begin{align} \neg \forall x (\varphi) & \equiv \neg \bigwedge_{ a \in U} [\overline{a}/x]\varphi \tag{1} \\
&\equiv \bigvee_{a \in U} [\overline{a}/x]\neg\varphi   \tag{2}  \\
&\equiv \exists x \neg (\varphi) \tag{3}
\end{align}$$

However, note that your example above is not a happy one, since it's not an instance of 

$\neg \forall x (\varphi) \Leftrightarrow \exists x \neg (\varphi)$

Anyway, in the case where $\varphi$ is a molecular formula, say
$$\varphi \equiv ∃z P(z) \wedge ∀y P(x,y) \wedge ∃z∃k P(z,k) \tag{1}$$
(a slightly modified version of your example) we have:

$\neg \forall x (∃z P(z) \wedge ∀y P(x,y) \wedge ∃z∃k P(z,k)) \Leftrightarrow \exists x \neg (∃z P(z) \wedge ∀y P(x,y) \wedge ∃z∃k P(z,k))$

Naturally, we can apply De Morgan's law in the RHD:

$\exists x \neg (∃z P(z) \wedge ∀y P(x,y) \wedge ∃z∃k P(z,k)) \Leftrightarrow \exists x (\color{blue}{\neg ∃z P(z) \vee \neg ∀y P(x,y) \vee \neg ∃z∃k P(z,k)})$

And we can apply its generalization for quantifiers again:

$\exists x (\neg ∃z P(z) \vee \neg ∀y P(x,y) \vee \neg ∃z∃k P(z,k) \Leftrightarrow \exists x (\color{blue}{\forall z \neg P(z)} \vee \color{blue}{\exists y \neg P(x,y)} \vee \color{blue}{\forall z \neg ∃k P(z,k)})$

And once more (in order to show you the step by step procedure):

$\exists x ({\forall z \neg P(z)} \vee {\exists y \neg P(x,y)} \vee {∃z \neg ∃k P(z,k)}) \Leftrightarrow \exists x ({\forall z \neg P(z)} \vee \exists y \neg P(x,y) \vee \forall z \color{blue}{\forall k \neg P(z,k)})$


The equivalence thus, stands this way:
$$\begin{align} \neg \forall x (∃z P(z) \wedge ∀y P(x,y) \wedge ∃z∃k P(z,k)) & \Leftrightarrow  \exists x \neg (∃z P(z) \wedge ∀y P(x,y) \wedge ∃z∃k P(z,k)) \tag{1} \\  
&\Leftrightarrow \exists x ({\neg ∃z P(z) \vee \neg ∀y P(x,y) \vee \neg ∃z∃k P(z,k)})   \tag{2}  \\
&\Leftrightarrow \exists x ({\forall z \neg P(z)} \vee {\exists y \neg P(x,y)} \vee {\forall z \neg ∃k P(z,k)}) \tag{3}\\
&\Leftrightarrow \exists x ({\forall z \neg P(z)} \vee \exists y \neg P(x,y) \vee \forall z {\forall k \neg P(z,k)}) \tag{4}\\ \\
\end{align}$$
