A Theory of Non-Acyclic Generative Flow Networks