Sum of ramification indices times residue degrees equals degree of extension Let $A$ be a Dedekind Domain with quotient field $K$. Let $L$ be a finite separable extension of $K$ and let $B$ be the integral closure of $A$ in $L$. Let $\mathfrak{p}$ be a prime ideal of $A$ and suppose the ideal $\mathfrak{p}B$ factors into a product of prime ideals as
$$\mathfrak{p}B = \mathfrak{p}_i^{e_1}\cdots\mathfrak{p}_g^{e_g}.$$
If we let
$$f_i = [B/\mathfrak{p_i}B : A/\mathfrak{p}],$$
then there's a theorem which states that
$$\sum_{i=1}^ge_if_i = [L : K].$$
There's one step in the proof of this that I'm confused about, mainly the claim that
$$\dim_{A/\mathfrak{p}}\left(\frac{B}{\mathfrak{p}_i^{e_i}}\right) = \sum_{j=0}^{e_i - 1}\dim_{A/\mathfrak{p}}\left(\frac{\mathfrak{p}_i^j}{\mathfrak{p}_i^{j+1}}\right).$$
Apparently this something has to do with "filtering" the vector space, but I'm totally unfamiliar with this concept. Is there any other way to see why this is true? Thanks.
EDIT: I think you're supposed to observe that
$$\frac{B}{\mathfrak{p}_i^{e_i}} = \frac{\mathfrak{p}_i^{e_i - 1}}{\mathfrak{p}_i^{e_i}} + \cdots + \frac{\mathfrak{p}_i}{\mathfrak{p}_i^{e_i}} + \frac{B}{\mathfrak{p}_i^{e_i}}.$$
 A: Here are some comments which may help you understand the situation better. Consider one prime $\mathfrak{p}$, then $f$ is the index of the residue class modulo $\mathfrak{p}$. So consider $\mathbb{Q}(i)$ and the prime $3$. There are $3^2=9$ incongruent elements modulo $3$, namely $$0,1,2,i,1+i,2+i,2i,1+2i,2+2i.$$ So here $f=2$. How many elements are there modulo $9$ ? On $\mathbb{Z}$ there are $$0,1,2, 0+3,1+3,2+3,0+6,1+6,2+6.$$ That is they are of the form $a+b\cdot 3$ where $a,b\in \{0,1,2\}$ In $\mathbb{Z}(i)$ they are of the same form but now $a,b$ range over the list of complex residues mod $3$ given above.
Hope this helps, you might try the same exercise with the primes $2$ and $5$. To see ramification and splitting.
A: Hint:
Consider the sequence:
$$B\supset \mathfrak p_i\supset \mathfrak p_i^2\supset\dots\supset\mathfrak p_i^{e_i-1}\supset\mathfrak p_i^{e_i}$$
The exact sequence:
$$0\longrightarrow\mathfrak p_i/\mathfrak p_i^2\longrightarrow B/\mathfrak p_i^2\longrightarrow B/\mathfrak p_i\longrightarrow 0$$
shows that 
$$\dim_{A/\mathfrak p} B/\mathfrak p_i^2=\dim_{A/\mathfrak p} B/\mathfrak p_i+\dim_{A/\mathfrak p} \mathfrak p_i/\mathfrak p_i^2. $$
Then you can prove by an easy induction d that for all $k\ge 2$ that
$$\dim_{A/\mathfrak p} B/\mathfrak p_i^k=\sum_{j=0}^{k-1}\dim_{A/\mathfrak p} \bigl(\mathfrak p_i^j/\mathfrak p_i^{j+1}\bigr). $$
