We argue that the main reason of crisis in quantum theory is that nature, which is fundamentally discrete and even finite, is described by continuous mathematics. Moreover, no ultimate physical theory can be based on continuous mathematics because, as follows from Gödel's incompleteness theorems, any mathematics involving the set of all natural numbers has its own foundational problems which cannot be resolved. In the first part of the work we discuss inconsistencies in standard quantum theory and reformulate the theory such that it can be naturally generalized to a formulation based on finite mathematics. It is shown that: a) as a consequence of inconsistent definition of standard position operator, predictions of the theory contradict the data on observations of stars; b) the cosmological acceleration and gravity can be treated simply as kinematical manifestations of de Sitter symmetry on quantum level (i.e. for describing those phenomena the notions of dark energy, space-time background and gravitational interaction are not needed). In the second part we consider a quantum theory based on finite mathematics with a large characteristic p. In this approach the de Sitter gravitational constant depends on p and disappears in the formal limit p → ∞, i.e. gravity is a consequence of finiteness of nature. The application to particle theory gives that: a) no neutral elementary particles can exist; b) the electric charge and the baryon and lepton quantum numbers can be only approximately conserved (i.e. the notion of a particle and its antiparticle is only approximate). We also consider a possibility that only Dirac singletons can be true elementary particles.