The article "Intuitionistic algebra and representations of rings" is fantastic; it develops the language, logic etc. for the topos $Sh(X)$, where $X$ is a fixed topological space, from scratch and thereby illuminating most of the known (and more) notions of sheaf theory in the sense that they become more natural. Thanks again Peter Arndt for this reference.
On page 37, the rank of a module $M$ is introduced as a upper Dedekind cut in the sheaf $\mathbb{N}$, or equivalently as a upper semi-continuous function $r : X \to \mathbb{N} \cup \{\infty\}$. Now it is claimed that it is given explicitely by mapping $x$ to the minimal number of generators needed for the stalks $M_x$. However, I don't see why this should be upper semi-continuous. I can show that only in the case that $M$ is locally of finite type. In fact, when I track back the constructions I get, that $r(x)$ is the infimum of numbers of sections which generate $M|_U$, where $U$ varies over the open neighborhoods of $x$.
Is this the correct definition of the rank?
Basically the same question applies to the definition of the independence $i(x)$, which is claimed to be the maximal number of linearly independent elements in $M_x$. Again, I don't see why this should be lower semi-continuous.