A Simple Generative Model of Logical Reasoning and Statistical Learning