  We extend the usual internal logic of a (pre)topos to a more general
interpretation, called the stack semantics, which allows for "unbounded"
quantifiers ranging over the class of objects of the topos. Using well-founded
relations inside the stack semantics, we can then recover a membership-based
(or "material") set theory from an arbitrary topos, including even
set-theoretic axiom schemas such as collection and separation which involve
unbounded quantifiers. This construction reproduces the models of
Fourman-Hayashi and of algebraic set theory, when the latter apply. It turns
out that the axioms of collection and replacement are always valid in the stack
semantics of any topos, while the axiom of separation expressed in the stack
semantics gives a new topos-theoretic axiom schema with the full strength of
ZF. We call a topos satisfying this schema "autological."
