In mathematics, a theory is a set of statements closed under logical implication. In mathematical logic, "theory" is the term for a set of well-formed formulae consisting of certain axioms and all theorems provable from said axioms. Gödel's incompleteness theorem states that no consistent theory, with a finite number of axioms (in a language at least as strong as arithmetic), can include all true statements.
In science, a theory is a model of reality, used for rationalizing, explaining, predicting, and mastering physical phenomena. There is a difference between the technical term and its common usage. A theory has to be something which is in some way testable; for example, one can theorize that an apple will fall when dropped, and then drop an apple, to see what happens. Many scientists, but not all, argue that religious beliefs are not testable, and thus not theories, because they are matters of faith.
There are two types of theories; a supposition which is not backed by observation is known as a conjecture, and if backed by observation it is a hypothesis. A theory is different from a theorem. The former is a model of physical events and cannot be proved from basic axioms. The latter is a statement of mathematical fact which logically follows from a set of axioms. A theory is also different from a physical law in that the former is a model of reality whereas the latter is a statement of what has been observed.
The word theoretical is derived from theory, and is used to describe that which has not yet been observed. For example, until recently, black holes were theoretical.
Theories can become accepted if they are able to make correct predictions and avoid incorrect ones. Theories which are simplier, and more mathematically elegant, tend to be accepted over theories which are complex. Theories are more likely to be accepted if they connect a wide range of phenonomena. The process of accepting theories is part of the scientific method.
In common usage a theory is often viewed as little more than a guess or a hypothesis. But in science, a theory is much more than that. A theory is an established paradigm that explains all of the data we have and offers valid predictions that can be tested. In science, a theory can never be proven true, because we can never assume we know all there is to know. Instead, theories remain standing until they are disproven, at which point they are thrown out altogether or modified slightly.
Some examples of current scientific theories are gravity, quantum mechanics, and evolution. Some other theories that have been disproved are those such as Lamarckism and the geocentric universe theory. Sufficient evidence has risen to declare these theories false.
Often the statement "Well, it's just a theory," is used to dismiss controversial theories such as evolution, but in science, theories are held to be true as far as science can asertain. Scientists aren't just guessing that gravity or evolution are true. They are the best theories we have for explaining the millions of data all around us.