\(age > 19\) is a predicate because it is a function from elements of the set to \(\{True, False\}\). The result of applying this function to (Maya, 19, CS) is False, while applying this function to (Liu, 20, Physics) returns True.
Predicates can be composed using Boolean operators. For a predicate \(X\), let \(e(X)\) denote its extension. Here are examples of extensions.
\( e((age > 19) \wedge (major = CS)) \; = \; e(age > 19) \cap e(major = CS) \)
So, \( e((age > 19) \wedge (major = CS)) \; = \; \{(Eve, 21, CS)\} \)
\( e((age > 20) \vee (major = physics)) = \{(Liu, 20, Physics), (Eve, 21, CS)\} \)
\( e(\neg (major = physics)) = \{(Maya, 19, CS), (Eve, 21, CS)\} \)
True, can be viewed as a predicate whose extension is the entire universal set \(V\). Similarly, False can be viewed as a predicate whose extension is the empty set.
Example
\((major = CS) \; \Rightarrow \; (age < 20) \) is a predicate which when applied to Maya is True; when applied to Liu is also True because the antecedent \(major = CS\) doesn't hold for Liu; and when applied to Eve is False because the antecedent is True whereas the consequent, \(age < 20\), is False.
We use Edsger W. Dijkstra's notation of square brackets, \([P]\), to refer to the boolean: \(P\) is universally True which means that the the extension of \(P\) is the universal set.
Example
\([(major = CS) \; \Rightarrow \; (age < 22)] \)
is a boolean - note the square brackets. It's value is the boolean constant, True, exactly when the formula holds universally. In our example, the predicate \((major = CS) \; \Rightarrow \; (age < 22)\) holds for all elements - Maya, Liu, and Eve. So, the boolean, \([(major = CS) \; \Rightarrow \; (age < 22)] \) is True.Example
\(\neg [(major = CS) \; \Rightarrow \; (age < 20)] \)
because \((major = CS) \; \Rightarrow \; (age < 20)\) applied to Eve is False, and so the predicate is not universally True.\( (P \equiv Q) \quad \equiv \quad (P \wedge Q) \vee (\neg P \wedge \neg Q) \)
We usually use equivalence in formula that are universally True, denoted by \([P \equiv Q]\).
Example
Let \(odd\) be a function on integers that returns True exactly when the integer is an odd number.\( odd(age) \; \equiv \; (major = CS) \)
is a predicate which when applied to Maya and Eve return True because both sides of the equivalence are True; and when applied to Liu returns True because both sides of the equivalence are False. Since the extension of this predicate is the universal set, we write:\([odd(age) \; \equiv \; (major = CS)]\)
In this course, a
predicate
is a function from states of a program to
the Boolean constants \(\{True, False\}\).
For example, for a program with variables
x, y
, the predicate x > y
is true in
the state (x, y) = (1, 0)
and is false in the state
(x, y) = (1, 1)
.
For a predicate \(P\) and a state \(s\), the value of the predicate at state \(s\) is written \(P(s)\), which is a Boolean. We say that "\(P\) holds in state \(s\)" exactly when \(P(s)\) is True.
Boolean operators such as disjunction (or) are "lifted" to be operators on predicates: the predicate \(P \vee Q\) holds in a state \(s\) exactly when \(P(s) \vee Q(s)\) holds. Likewise, the predicate \(P \wedge Q\) holds in a state \(s\) exactly when \(P(s) \wedge Q(s)\) holds.
Disjunction, conjunction, and negation of predicates correspond to the union intersection, and complement, respectively, of the corresponding sets of states. Let \(e(P)\) be the extension of \(P\). Then
K. Mani Chandy, Emeritus Simon Ramo Professor, California Institute of Technology