CMPS 260
Some Laws of Logic and Sets

Propositional Logic

Among the operators used in propositional logic are negation (¬), conjunction (∧), disjunction (∨), implication (⟹), and equivalence )(=). They are defined via the following "truth tables":

p¬p
truefalse
falsetrue
p q p∧q p∨q p⟹q p=q
truetrue truetruetruetrue
truefalse falsetruefalsefalse
falsetrue falsetruetruefalse
falsefalse falsefalsetruetrue

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.

Some Laws of Propositional Logic:

Double Negation: ¬¬p p
Identity of ∧: p ∧ truep
Zero of ∧: p ∧ falsefalse
Contradiction: p ∧ ¬pfalse
Idempotence of ∧: p ∧ pp
Symmetry of ∧: p∧qq∧p
Associativity of ∧: (p∧q)∧rp∧(q∧r)
Identity of ∨: p ∨ falsep
Zero of ∨: p ∨ truetrue
Excluded Middle: p ∨ ¬ptrue
Idempotence of ∨: p ∨ pp
Symmetry of ∨: p∨qq∨p
Associativity of ∨: (p∨q)∨rp∨(q∨r)
∧ Distributes over ∨: p∧(q∨r)(p∧q) ∨ (p∧r)
∨ Distributes over ∧: p∨(q∧r)(p∨q) ∧ (p∨r)
Absorption (L1): p∧(p∨q)p
Absorption (L2): p∨(p∧q)p
DeMorgan (L1): ¬(p ∧ q) ¬p ∨ ¬q
DeMorgan (L2): ¬(p ∨ q) ¬p ∧ ¬q
Equality: p = q (p∧q) ∨ (¬p∧¬q)
Equality 2: p = q (p ⟹ q) ∧ (q ⟹ p)
Implication: p ⟹ q ¬p ∨ q
Contrapositive: p ⟹ q ¬q ⟹ ¬p

Operator Precedence:

Highest¬
 =
 ∧, ∨
Lowest
A standard precedence hierarchy for logical operators is shown to the right. Based on that, the expression p = q ∧ p ⇒ ¬r ∨ q should be interpreted as ((p = q) ∧ p) ⇒ ((¬r) ∨ q)


Predicate Logic:

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

(∀k : isPrime(k) ∧ k≠2  ⟹  isOdd(k))

Meanwhile, using the existential quantifier ∃, the statement "There is a prime number in the range [100,110]" can be written

(∃k : isPrime(k) ∧ 100≤k≤110)

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,

Likes(x,y) = true if x likes y, false otherwise

The statement "Every person likes someone" would be formalized as

(∀x : (∃y : Likes(x,y)))

Meanwhile, the statement "There is someone who likes everyone" would be formalized as

(∃x : (∀y : Likes(x,y)))

These two examples illustrate that ∀ and ∃ are not "commutative".


Sets:

Intuitively, a set is a collection of items drawn from some universe of items. Among the common universal sets are ℝ (the set of real numbers), ℤ (the set of integers), ℕ (the set of natural numbers), and {0,1}* (the set of all bit strings). (Often U is used to refer to the universal set, when it is being spoken of generically.)

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:

SetDescription
{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:

SetDescription
{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

{x ∈ U : P(x)}

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:

SetDescription
{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

{(x, ⌊|x|⌋) : x ∈ ℝ}

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.

PropertyDefining 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

{(k,m) ∈ ℕ×ℕ  :  (k−m) % 3 = 0}

This relation has three equivalence classes: {0,3,6,9,...}, {1,4,7,10,...}, and {2,5,8,11,...}.


Functions are Special Cases of Relations

Suppose that R is a binary relation whose universe is X×Y (which is just another way of saying that R ⊆ X×Y). We say that R is a function if (∀x,y,z : xRy ∧ xRz ⟹ y=z). In other words, if each element of X is related to at most one element of Y, we have a function.

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).


Set Operator Axioms:

Familiar binary set operators include union (∪), intersection (∩), and difference (— (or \)). The empty set is written ∅ and the universal set is U. The complement of a set S, written either as S' or as S, means the same thing as U − S.

All these operators can be defined in terms of the set membership predicate and the logical operators:

Union: x ∈ S ∪ T x ∈ S ∨ x ∈ T
Intersection: x ∈ S ∩ T x ∈ S ∧ x ∈ T
Difference: x ∈ S − T x ∈ S ∧ x ∈ T
Complement: x ∈ S x ∉ S
Non-member: x ∉ S ¬(x ∈ S)
Equality: S = T (∀x : x ∈ S = x ∈ T)
Subset: S ⊆ T (∀x : x ∈ S ⟹ x ∈ T)

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.

Double Negation: ¬¬pp   Double Complement: S = S
Identity of ∧: p ∧ truep   Identity of ∩: S ∩ U=S
Zero of ∧: p ∧ falsefalse   Zero of ∩: S ∩ ∅=
Contradiction: p ∧ ¬pfalse   Mutual Exclusion: S ∩ S =
Idempotence of ∧: p ∧ pp   Idempotence of ∩: S ∩ S=S
Symmetry of ∧: p∧qq∧p   Symmetry of ∩: S ∩ T=T ∩ S
Associativity of ∧: (p∧q)∧rp∧(q∧r)   Associativity of ∩: (R ∩ S) ∩ T=R ∩ (S ∩ T)
Identity of ∨: p ∨ falsep   Identity of ∪: S ∪ ∅=S
Zero of ∨: p ∨ truetrue   Zero of ∪: S ∪ U=U
Excluded Middle: p ∨ ¬ptrue   Excluded Middle(?): S ∪ S =U
Idempotence of ∨: p ∨ pp   Idempotence of ∪: S ∪ S=S
Symmetry of ∨: p∨qq∨p   Symmetry of ∪: S ∪ T=T ∪ S
Associativity of ∨: (p∨q)∨rp∨(q∨r)   Associativity of ∪: (R ∪ S) ∪ T=R ∪ (S ∪ T)
∧ Distributes over ∨: p∧(q∨r)(p∧q) ∨ (p∧r)   ∩ Distributes over ∪: R∩(S∪T)=(R∩S) ∪ (R∩T)
∨ Distributes over ∧: p∨(q∧r)(p∨q) ∧ (p∨r)   ∪ Distributes over ∩: R∪(S∩T)=(R∪S) ∩ (R∪T)
Absorption (L1): p∧(p∨q)p   Absorption (S1): S∩(S∪T)=S
Absorption (L2): p∨(p∧q)p   Absorption (S2): S∪(S∩T)=S
DeMorgan (L1): ¬(p ∧ q) ¬p ∨ ¬q   DeMorgan (S1): S∩T = ST
DeMorgan (L2): ¬(p ∨ q) ¬p ∧ ¬q   DeMorgan (S2): S∪T = ST
Equality: p = q (p∧q) ∨ (¬p∧¬q)   Name? S = T (∀x : x ∈ S∩T  ∨  x ∈ ST)
Equality 2: p = q (p ⟹ q) ∧ (q ⟹ p)   Name? S = T S ⊆ T  ∧  T ⊆ S
Implication: p ⟹ q ¬p ∨ q   Name? S ⊆ T S ∪ T = U
Contrapositive: p ⟹ q ¬q ⟹ ¬p   Name? S ⊆ T TS



Sample proofs

Below we show two sample proofs, one in the realm of propositional logic and the other pertaining to sets. In each case, the approach is to transform one expression into another via a sequence of steps, in each of which one subexpression is replaced by another to which it is equal. This approach should be familiar to you from high school, where you would have applied it in simplifying algebraic expressions. The point is that each expression resulting from taking a step is equivalent to the one that came before it, which means (because equivalence is transitive) that the expression obtained in the last step is equivalent to the initial expression.

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.

Proof of Shunting:
(p∧q) ⇒ r  ≡  p ⇒ (q ⇒ r)
   (p∧q) ⇒ r 

=     < Implication >

   ¬(p∧q) ∨ r 

=     < DeMorgan (L1) >

   (¬p ∨ ¬q) ∨ r 

=     < Associativity of ∨ >

   ¬p ∨ (¬q ∨ r)

=     < Implication >

   ¬p ∨ (q ⇒ r)

=     < Implication >

   p ⇒ (q ⇒ r)
Proof of DeMorgan (S1): S∩T = ST
     x ∈ S ∩ T 

=       < Complement >

     x ∉ S ∩ T

=       < Non-member >

     ¬(x ∈ S ∩ T)

=       < Intersection >

     ¬(x ∈ S ∧ x ∈ T)

=       < DeMorgan (L1) >

     ¬(x ∈ S) ∨ ¬(x ∈ T)

=       < Non-member >

     x ∉ S  ∨  x ∉ T

=       < Complement >

     x ∈ S ∨ x ∈ T 

=       < Union >

     x ∈ ST