I'm reading through my axiomatic set theory lecture notes and came across the following result:
Suppose $\kappa$ is an uncountable regular cardinal. Let $g : \kappa → \kappa$ be any function. Prove that for any $α < \kappa$, there exists $β < \kappa$, with $α ≤ β$, such that $β$ is closed under $g$ (i.e. for all $γ < β$, $g(γ) < β$).
The proof given is the following:
We define recursively for $n ∈ ω$, $α_0 = α$ and $α_{n+1} = \textrm{sup} g[α_n]$. Since $\kappa$ is a cardinal, if $α_n \in \kappa$ then $\textrm{sup} g[α_n] \in \kappa$, so all $α_n \in \kappa$ (by induction). Since $\kappa$ is regular uncountable this implies $β = \textrm{sup } α_n ∈ \kappa$. This $β$ works since if $δ \in β$ then $δ ∈ α_n$ for some $n ∈ ω$ and hence $g(δ) \in g[α_n] = α_{n+1} ⊆ β$.
I can understand how each step follows except where we conclude that since $\kappa$ is regular uncountable this implies $β = \textrm{sup } α_n \in \kappa$ - I don't see how this follows. The previous fact that if $α_n \in \kappa$ then $\textrm{sup} g[α_n] \in \kappa$ clearly follows from regularity since if $α_n ∈ \kappa$ then $g|_{α_n}$ must be bounded in $\kappa$, but just because every $α_n$ is in $\kappa$ it doesn't follow that the supremum must be - presumably the supremum could be $\kappa$ itself.
Presumably uncountability comes into it somehow, but I can't work out how it does. If anyone could point me in the right direction I'd really appreciate it!
If $\sup_n\alpha_n$ were equal to $\kappa$, $\kappa$ would have countable cofinality: it would be the limit of the sequence $\langle\alpha_n:n\in\omega\rangle$. But $\kappa$ is regular and uncountable, so $\operatorname{cf}\kappa=\kappa>\omega$.