On the foundations of geometry and formal theories of arithmetic