The Rules-and-Facts Model for Simultaneous Generalization and Memorization in Neural Networks