On martingales and recursive optimal state estimation