Among the operators used in propositional logic are negation (¬), conjunction (∧), disjunction (∨), implication (⟹), and equivalence )(=). They are defined via the following "truth tables":
|
|
As you can infer from the tables, negation is a unary operator whereas the other four are binary operators. Below we use ≡ as a meta-operator by which to assert that two boolean expressions are equivalent.
|
Highest | ¬ |
---|---|
= | |
∧, ∨ | |
Lowest | ⇒ |
Predicate logic extends propositional logic by introducing predicates (which generalize propositional variables (e.g., p,q,r as seen above)) and quantification. Doing so provides more expressive and deductive power.
A predicate is a function that yields a boolean value (i.e., true or false). For example, one can define isPrime() to be the predicate that, applied to a natural number, yields true iff that number is prime. Thus, for example, isPrime(19) is true but isPrime(25) is false.
Universal (respectively, existential) quantification is used to express the idea that every (resp., at least one) element in a specified set (see below) satisfies a specified condition.
For example, using the universal quantifier ∀, the statement "Every prime number, except 2, is odd" can be written as
Meanwhile, using the existential quantifier ∃, the statement "There is a prime number in the range [100,110]" can be written
To express complex statements formally, it is often necessary to nest one quantification inside another. For example, suppose that Likes is a predicate that indicates whether or not one person "likes" another. That is,
The statement "Every person likes someone" would be formalized as
Meanwhile, the statement "There is someone who likes everyone" would be formalized as
These two examples illustrate that ∀ and ∃ are not "commutative".
The two most common ways of describing a set are by enumeration and by comprehension. In the former, we simply list (i.e., enumerate) all the members of the set (and enclose that list between a pair of curly braces). Examples:
Set | Description |
---|---|
{2, 3, 5, 7} | the prime numbers less than 10 |
{red, green, blue} | the (additive) primary colors |
{Ellis, Blass, Briles, Moose, Kison} | the starting pitchers for the 1972 Pittsburgh Pirates |
Of course, describing a set by enumeration is practical only when the set has relatively few members, and it is impossible when the set is infinite. (And most interesting sets are infinite.) Because people are able to recognize patterns, it is often convenient to describe a set using a pseudo-enumeration in which only a few of its members are explicitly provided, together with "..." (or some similar notation) to indicate that the reader is expected fill in the missing details either by inferring an unstated pattern or by making use of prior knowledge. Examples:
Set | Description |
---|---|
{2, 3, 5, 7, 11, 13, 17, ...} | the prime numbers |
{0, 1, 4, 9, 16, ...} | the perfect squares |
{(0,0), (1,1), (2,4), (3,9), (4,16), ....} | the ordered pairs of the form (k,k2), where k∈ℕ |
The last example above serves to illustrate that the members of a set can be composite entities (such as ordered pairs), as opposed to atomic ones (such as numbers).
Note that a set differs from a list in that there is no notion of a set's elements being arranged in any particular order. For example, the expressions {red, green, blue, yellow} and {blue, red, yellow, green} describe the same set. For that matter, so does the expression {blue, red, blue, yellow, green, yellow, blue}, because there is no notion of an element occurring more than once in a set (and thus including it multiple times in an enumeration is simply a case of being redundant). In other words, if S is a set, then for each item x in S's universal set, x either is, or is not, a member of S. The set membership operator is ∈, so that the expression x ∈ S is true if x is a member of S and false otherwise. (Note that the bag, or multiset, concept generalizes sets in allowing an element to occur multiple times.)
In the second way to describe a set S, via comprehension, we specify S's universe along with a predicate that characterizes which items in that universe are members of S. A syntactic template is
which describes the set whose members are all the items in U (the universal set) that satisfy the predicate (i.e., boolean function) P. Examples:
Set | Description |
---|---|
{k∈ℕ : isPrime(k)} | the prime numbers |
{k∈ℕ : k<10 ∧ isPrime(k)} | the prime numbers less than 10 |
{n∈ℕ : n = k2 for some k∈ℕ} | the perfect squares |
{(k,k2)∈ℕ×ℕ : true} | the ordered pairs of the form (k,k2), where k∈ℕ |
Of course, the reader is to understand that isPrime() is a function mapping integers to boolean values, with isPrime(k) yielding true iff k is a prime number.
When the members of a set are ordered pairs, we usually refer to it as a binary relation. (If the members are ordered triples, it would be a ternary relation. In general, if the members are ordered k-tuples, we call the set a k-ary relation.) If the "arity" of a relation is not specified, the default is binary.
If a relation R is a set of ordered pairs (x,y), where x∈X and y∈Y, what is R's universal set? That would be X×Y, the so-called cartesian product of X and Y. That is, X×Y = {(x,y) : x∈X ∧ y∈Y}. The relation identified above, which matches each natural number with its square, has ℕ×ℕ as its universal set. The relation
which matches each real number with the floor of its absolute value (so that, for example, (5.35, 5) and (−3.2, 3) are members) has ℝ×ℕ as its universal set.
As a shorthand for the expression (x,y) ∈ R, it is common to write xRy. We shall do so in what follows.
The concepts of domain and range of a binary relation are often useful. For R ⊆ X×Y, we have
domain(R) = { x∈X : xRy for some y∈Y } ⊆ X
range(R) = { y∈Y : xRy for some x∈X } ⊆ Y
When a binary relation R is over a finite set X, a common way to depict R is to use a directed graph whose vertices correspond to the elements of X and such that the edge (x,y) appears iff (x,y)∈R.
The inverse of a binary relation R, denoted R-1, is the relation obtained by flipping each of its ordered pairs. That is, xRy iff yR-1x. In terms of the directed graph representation, the graph for R-1 is obtained from that for R by reversing the direction of each edge.
If R is a relation whose universal set is X×X, we say that R is a relation on X ("binary" being understood). In studying such a relation, it is often useful to determine which of several interesting properties it possesses. Those properties are described next.
Property | Defining Condition |
---|---|
Reflexive | (∀x ∈ X : xRx) |
Irreflexive | (∀x ∈ X : ¬(xRx)) |
Symmetric | (∀x,y ∈ X : xRy = yRx) |
Antisymmetric | (∀x,y ∈ X : xRy ∧ yRx ⟹ x=y) |
Asymmetric | (∀x,y ∈ X : xRy ⟹ ¬(yRx)) |
Transitive | (∀x,y,z ∈ X : xRy ∧ yRz ⟹ xRz) |
An equivalence relation is one that is reflexive, symmetric, and transitive. Such a relation partitions the elements of X into disjoint equivalence classes. Each such class is a subset of X such that every two of its members are related to each other but none of its members is related to any member of a different equivalence class.
A canonical example of an equivalence relation is
This relation has three equivalence classes: {0,3,6,9,...}, {1,4,7,10,...}, and {2,5,8,11,...}.
If, in addition to being a function, the inverse R-1 of R is also a function, we say that R is a one-to-one function (also called an injection). If both R and R-1 are one-to-one, we say that R (and R-1, for that matter) is a one-to-one correspondence (also called a bijection).
All these operators can be defined in terms of the set membership predicate and the logical operators:
|
Theorems: What follows is a repeat of the laws of propositional logic shown above, each one matched with its counterpart in the realm of sets. Recall that ∅ denotes the empty set and U the universal set.
|
By the Set Equality Axiom, to show that two sets are equal it suffices to show that, for arbitrary x, x is a member of one set iff it is a member of the other. That is what we do in the proof of DeMorgan (S1) below.
|
|