This paper proposes an approach allowing topology learning and recognition in indoor environments by using a probabilistic approach called Bayesian Programming. The main goal of this approach is to cope with the uncertainty, imprecision and incompleteness of handled information. The Bayesian Program for topology recognition and door detection is presented. The method has been successfully tested in indoor environments with the BIBA robot, a fully autonomous robot. The experiments address both the topology learning and topology recognition capabilities of the approach.