In logic, a variable is a symbol used to refer to something else. This article deals with variables used in logics that refer to some object or subject in a sentence. Propositional variables, on the other hand, represent entire sentences.
Variables are, by convention, represented by lowercase Roman letters, and usually begin with x.
In most logics, variables are only used when they are under some kind of quantifying constraint, namely either a universal quantification ∀ or an existential quantification ∃. Formulae in which all variables are quantified over are called sentences or closed formulae. Otherwise, the formulae are called open, and are said to contain free variables.
For instance, we may say for every x, x is red, which means “everything is red”. Formally, we express this as:
∀x(x is red)
…or, if we use a predicate symbol Rx, to mean “x is red”, then we write:
In this instance, the variable x refers to anything, and in fact, everything. We may also say
∃xRx, which means “something is red”.
Variables of this type are contrasted with constants, which are essentially variables for whom a meaning is set and (in most cases) does not change. For example, instead of referring to a variable x, which may mean anything, I may use the constant j to refer to a specific thing or person, such as Jim.