Definition of a distinguisher In Introduction to Modern Cryptography by Katz and Lindell, p. 70, they define a pseudorandom generator by:


  Let $l(\cdot)$ be a polynomial and let $G$ be a deterministic
  poly-time alg. s.t. for any input $s \in \{0,1\}^n,$ algo $G$ outputs
  a string of length $l(n).$ We say $G$ is a pseudorandom generator if
  the following conditions hold:
  
  (Expansion) For every $n$ we have $l(n)&gt;n$
  
  (Pseudorandomness) For all probabilistic poly-time distinguishers $D,$
  there exists a negligible function $negl$ s.t. $$\left| P[D(r)=1] - P[D(G(s))=1] \le negl(n) \right|,$$ where $r$ is chosen unif. at random
  from $\{0,1\}^{l(n)}, $ the seed $s$ is chosen unif. at random from
  $\{0,1\}^n,$ and the probabilities are taken over the random coins
  used by $D$ and the choice of $r$ and $s.$


I would like to clarify how we should be thinking about the distinguisher, $D$. I understand that it is typically any polynomial-time algorithm, but how do we interpret its output? Do we assume that when $D$ "thinks" its input is truly random then it outputs a $1$, and otherwise outputs a $0$?
I think of it this way: think of a distinguisher as an adversarially-chosen statistical experiment that attempts to support or refute some hypothesis, that again is adversarially selected.  This means that the honest party doesn't get to assume what meaning the adversary assigns to $0$ or $1$; their PRG has to behave like a random distribution no matter what the adversary does (with the proviso that the adversary's experiment must complete within polynomial time).

For example, a distinguisher could be an algorithm that takes the output of the PRG, chooses a random position in the bit string, tests whether the bits starting from this location are equal to some ASCII representation of the Gettysburg Address, and outputs $0$ if they are, $1$ otherwise.  If that's the statistical test the adversary wants to use, they can do it.