  This work considers the theory underlying a discrete-time quantum filter
recently used in a quantum feedback experiment. It proves that this filter
taking into account decoherence and measurement errors is optimal and stable.
We present the general framework underlying this filter and show that it
corresponds to a recursive expression of the least-square optimal estimation of
the density operator in the presence of measurement imperfections. By
measurement imperfections, we mean in a very general sense unread measurement
performed by the environment (decoherence) and active measurement performed by
non-ideal detectors. However, we assume to know precisely all the Kraus
operators and also the detection error rates. Such recursive expressions
combine well known methods from quantum filtering theory and classical
probability theory (Bayes' law). We then demonstrate that such a recursive
filter is always stable with respect to its initial condition: the fidelity
between the optimal filter state (when the initial filter state coincides with
the real quantum state) and the filter state (when the initial filter state is
arbitrary) is a sub-martingale.
