First reflection theorem for $\Pi_1^1$ on $\Pi_1^1$ properties Let $\Phi\subseteq\mathcal{P}(\mathcal{X})$ be a collection of subsets of $\mathcal{X}$. We say $\Phi$ is $\Pi_1^1$ on $\Pi_1^1$ if for $A\subseteq\mathbb{N}\times\mathcal{X}$, $A\in \Pi_1^1$, the set of sections $\{n:A_n\in\Phi\}$ is $\Pi_1^1$. Similarly define what it means for $\Phi$ to be $\Pi_1^1$ on $\Sigma_1^1$. So $\Phi$ can be thought of as a "property" of sets
The first reflection theorem states the following: If $\Phi$ is $\Pi_1^1$ on $\Pi_1^1$ and $A$ is a $\Pi_1^1$ set, then $$\Phi(A)\implies\exists B\in\Delta_1^1 (B\subseteq A \wedge \Phi(B)).$$ An equivalent formulation is that if $\Phi$ is $\Pi_1^1$ on $\Sigma_1^1$, and $A$ is $\Sigma_1^1$, then $$\Phi(A)\implies\exists B\in\Delta_1^1(B\supseteq A\wedge\Phi(B)).$$ This easily follows from the first formulation by taking $\Phi'(A)=\Phi(\neg A)$.
The proof of this theorem is given as follows:
Proof: Suppose not. Take $W\subseteq\mathbb{N}$, $W\in\Pi_1^1\setminus\Delta_1^1$. Let $U\subseteq\mathcal{N}$ be $\Pi_1^1$-complete, and let $\varphi:U\to\operatorname{Ordinals}$ be a $\Pi_1^1$-rank on $U$. Then, there are total recursive functions $f$ and $g$ such that $x\in A\iff f(x)\in U$ and $n\in W\iff g(n)\in U$ (this is just the definition of completeness). Now, here is the part that I am having trouble wrapping my head around. The proof goes on to say that all this means that 

$$n\notin W\iff\Phi(\{x:f(x)<_{\varphi}^*g(n)\}),$$

which means $W$ is $\Delta_1^1$, a contradiction.
The statement $n\in W\iff g(n)\in U$ gives us a $\Pi_1^1$ definition of $W$, so I understand that we are trying to get a $\Sigma_1^1$ definition of $W$ to arrive at a contradiction. What confuses me is how we arrive at the highlighted statement by assuming the contrary of the statement of the theorem, and why that means the complement of $W$ is $\Pi_1^1$. I would also appreciate it if someone could give an intuitive explanation of being $\Pi_1^1$ on $\Pi_1^1$. I've also been unable to find any reference on any of this -- the closest is Moschovakis' Descriptive Set Theory text, but even that doesn't seem to contain this result. Any help is greatly appreciated. 
EDIT: The document here gives a proof of the boldface result, but seems to be structured differently(?)
 A: Recall that $x<^\ast_\varphi y$ is defined as $x\in U\land (y\notin U\lor\varphi(x)<\varphi(y))$ (see for example Moschovakis' Descriptive Set Theory 4B).
Let me denote with $Q_n:=\{x : f(x)<^\ast_\varphi g(n)\}$. Notice that by the definition of $<^\ast_\varphi$ we have that $x\in Q_n$ implies $f(x)\in U$ which yields that $x\in A$ and therefore we have $Q_n\subseteq A$.
If $n\notin W$ we have that $g(n)\notin U$ and thus by the definition of  $<^\ast_\varphi$ we have that for any $x$ such that $f(x)\in U$ (i.e. $x\in A$) it is the case that $f(x)<^\ast_\varphi g(n)$. Thus it follows that $Q_n=A$ and hence, by the assumption, $\Phi(Q_n)$ is the case.
Now let $n\in W$. Notice that $Q_n$ is $\Delta_1^1$ (this is because $Q_n$ is a subset of $A$ with bounded rank, for a proof I found the Boundedness Theorem 4A.4 in Moschovakis' book). Hence by the assumption that there doesn't exist $\Delta_1^1$ set $B\subseteq A$ with $\Phi(B)$ it follows that it is not the  case that $\Phi(Q_n)$. 
This proves the highlighted statement.
Now to see that $\mathbb{N}\setminus W$ is $\Pi_1^1$ notice that since the $\{(n,x) : f(x)<^\ast_\varphi g(n)\}$ is $\Pi_1^1$ and $\Phi$ is $\Pi^1_1$ we have that $\mathbb{N}\setminus W=\{n : \{x : f(x)<^\ast_\varphi g(n)\}\in\Phi\}$ is $\Pi^1_1$.
Unfortunately I can't provide much insight and references for the results themselves, since it's been a long time since I last studied any descriptive set theory :(
