Knowledge based theorem proving and learning