浅色盘子中摆放着三只桃子
盘中的三只桃子 · Henri Fantin-Latour / National Gallery of Art

The same relation can be represented by a set of ordered pairs, a zero-one matrix, or a directed graph. The set lists its members precisely, the matrix supports computation, and the graph reveals loops, directions, and connections. Changing representation does not change the relation, provided that element order and edge direction are recorded consistently.

1. Zero-One Matrices

Rows Are Sources; Columns Are Targets

Let A={a1,…,am}A=\{a_1,\ldots,a_m\} and B={b1,…,bn}B=\{b_1,\ldots,b_n\}, with fixed orderings. A relation R⊆A×BR\subseteq A\times B is represented by the m×nm\times n zero-one matrix

MR=[rij],rij={1,(ai,bj)∈R,0,(ai,bj)∉R.M_R=[r_{ij}],\qquad r_{ij}=\begin{cases} 1,&(a_i,b_j)\in R,\\ 0,&(a_i,b_j)\notin R. \end{cases}

Row ii corresponds to the first component aia_i, and column jj to the second component bjb_j. Changing an ordering changes the matrix’s appearance. Without specified orderings, the matrix cannot uniquely identify its relation. When A=BA=B, use the same ordering for rows and columns to apply the diagonal and transpose criteria.

Example: From a condition to a matrix. Let A={1,2,3}A=\{1,2,3\} and B={1,2}B=\{1,2\}, both listed in increasing order, and define aRbaRb if and only if a>ba>b. Find RR and MRM_R.

Show solution and steps

The first row represents 1, which is greater than neither candidate target. The second row represents 2, which is related only to 1. The third represents 3, which is related to both 1 and 2. Thus

R={(2,1),(3,1),(3,2)},MR=[001011].R=\{(2,1),(3,1),(3,2)\},\qquad M_R=\begin{bmatrix}0&0\\1&0\\1&1\end{bmatrix}.

The three source elements give three rows, and the two target elements give two columns. Since the relation is between different sets, the square-matrix reflexivity test does not directly apply.

Example: Recovering ordered pairs from a matrix. Let A={a1,a2,a3}A=\{a_1,a_2,a_3\} and B={b1,b2,b3,b4,b5}B=\{b_1,b_2,b_3,b_4,b_5\}, ordered by their subscripts. Suppose

MR=[010001011010101].M_R=\begin{bmatrix} 0&1&0&0&0\\ 1&0&1&1&0\\ 1&0&1&0&1 \end{bmatrix}.

Find RR and explain how to check for omitted pairs.

Show solution and steps

Read the positions of the 1s row by row: column 2 in row 1; columns 1, 3, and 4 in row 2; and columns 1, 3, and 5 in row 3. Hence

R={(a1,b2),(a2,b1),(a2,b3),(a2,b4),(a3,b1),(a3,b3),(a3,b5)}.R=\{(a_1,b_2),(a_2,b_1),(a_2,b_3),(a_2,b_4), (a_3,b_1),(a_3,b_3),(a_3,b_5)\}.

The seven 1s give seven ordered pairs, each with its source from the row and its target from the column.

Membership Predicates and Characteristic Functions

For an n-ary relation R⊆A1×⋯×AnR\subseteq A_1\times\cdots\times A_n, its characteristic function records membership:

χR(t)={1,t∈R,0,t∉R.\chi_R(t)=\begin{cases}1,&t\in R,\\0,&t\notin R.\end{cases}

The input is a complete tuple in the specified Cartesian product. A predicate such as x<yx<y defines this membership rule without listing infinitely many pairs.

For finite domains, a table can list all tuples with characteristic value 1. A zero-one matrix arranges these values by row and column for a binary relation.

Supplement: Membership algorithms. An algorithm representing a relation must terminate and decide membership correctly for every input in the stated domain. Specifying a mathematical predicate alone does not guarantee such a procedure.

2. Digraphs and Property Tests

Elements as Vertices; Pairs as Directed Edges

For a relation on AA, each element is a vertex and each (a,b)∈R(a,b)\in R is a directed edge from aa to bb. A pair (a,a)(a,a) is represented by a loop. An element occurring in no pair must still appear as an isolated vertex; omitting it changes the underlying set and may change the reflexivity test.

A digraph and zero-one matrix for the same relation, containing three loops and the edges 1 to 2 and 2 to 3

Figure 1. The edge 1→2 gives a 1 in row 1, column 2. The three loops give diagonal 1s. There is no edge 1→3, so row 1, column 3 contains 0.

Three Views of Each Property

Assume that AA has nn elements, R⊆A2R\subseteq A^2, and both matrix orderings are the same. Let InI_n denote the identity matrix, with 1s on the diagonal and 0s elsewhere. The symbol ≤\le compares matrices entry by entry.

PropertySet or composition criterionMatrix criterionDigraph criterion
ReflexiveIA⊆RI_A\subseteq REvery diagonal entry is 1Every vertex has a loop
IrreflexiveR∩IA=∅R\cap I_A=\varnothingEvery diagonal entry is 0No vertex has a loop
SymmetricR=R−1R=R^{-1}MR=MRTM_R=M_R^{\mathsf T}Every edge between distinct vertices has its reverse
AntisymmetricR∩R−1⊆IAR\cap R^{-1}\subseteq I_AFor i≠ji\ne j, rijr_{ij} and rjir_{ji} cannot both be 1No distinct vertices are connected in both directions
AsymmetricR∩R−1=∅R\cap R^{-1}=\varnothingThe antisymmetry criterion, plus diagonal 0sNeither opposite edges nor loops occur
TransitiveR2⊆RR^2\subseteq RMR⊙MR≤MRM_R\odot M_R\le M_REvery two-step connection has a direct shortcut

The symbol ⊙\odot denotes the Boolean product defined below. Antisymmetry places no restriction on the diagonal. Opposite off-diagonal positions may both be 0; they simply cannot both be 1. Antisymmetry does not require every edge to point in the same direction and does not rule out cycles of length greater than two.

Example: Classifying a relation in three representations. Figure 1 represents the relation on A={1,2,3}A=\{1,2,3\} given by

R={(1,1),(2,2),(3,3),(1,2),(2,3)},MR=[110011001].R=\{(1,1),(2,2),(3,3),(1,2),(2,3)\},\qquad M_R=\begin{bmatrix}1&1&0\\0&1&1\\0&0&1\end{bmatrix}.

Determine whether it is reflexive, irreflexive, symmetric, antisymmetric, asymmetric, and transitive.

Show solution and steps

It is reflexive and antisymmetric. It is not irreflexive, symmetric, asymmetric, or transitive.

  • Every diagonal entry is 1, so it is reflexive. Its loops disprove both irreflexivity and asymmetry.
  • The reverse of (1,2)(1,2) is missing, disproving symmetry. No distinct vertices are related in both directions, establishing antisymmetry.
  • Both (1,2)(1,2) and (2,3)(2,3) are present, but (1,3)(1,3) is absent, disproving transitivity. Equivalently, the Boolean square has 1 in position (1,3)(1,3) while the original matrix has 0, violating entrywise containment.

Example: Diagonal entries do not settle antisymmetry. On A={1,2,3,4}A=\{1,2,3,4\} with the natural ordering, let

MR=[1100111001100011],MS=[1100011010100011].M_R=\begin{bmatrix}1&1&0&0\\1&1&1&0\\0&1&1&0\\0&0&1&1\end{bmatrix}, \qquad M_S=\begin{bmatrix}1&1&0&0\\0&1&1&0\\1&0&1&0\\0&0&1&1\end{bmatrix}.

Determine whether each relation is reflexive, symmetric, and antisymmetric. Give a specific witness whenever a property fails.

Show solution and steps

Both are reflexive because every diagonal entry is 1. Neither is symmetric: both have (4,3)(4,3) but lack (3,4)(3,4).

RR is not antisymmetric because (1,2)(1,2) and (2,1)(2,1) both occur for distinct elements. In SS, no off-diagonal pair and its reverse both occur, so SS is antisymmetric. Its cycle 1→2→3→11\to2\to3\to1 does not violate antisymmetry, which forbids two-way pairs rather than every directed cycle.

3. Matrix Forms of Relation Operations

Entrywise Boolean Operations and Transpose

For relations using the same element orderings:

Relation operationMatrix operation
Inverse R−1R^{-1}Transpose MRTM_R^{\mathsf T}
Union R∪SR\cup SEntrywise OR, MR∨MSM_R\lor M_S
Intersection R∩SR\cap SEntrywise AND, MR∧MSM_R\land M_S
Difference R−SR-SEntrywise rij∧¬sijr_{ij}\land\neg s_{ij}
Symmetric difference R⊕SR\oplus SEntrywise exclusive OR
Complement R‾\overline RInterchange 0 and 1 in every position

Ordinary matrix addition does not directly compute union: two 1s would add to 2, while a relation matrix records only presence or absence.

Example: Union and intersection of matrices. Two relations on A={1,2,3}A=\{1,2,3\} have matrices

MR=[101100010],MS=[101011100].M_R=\begin{bmatrix}1&0&1\\1&0&0\\0&1&0\end{bmatrix},\qquad M_S=\begin{bmatrix}1&0&1\\0&1&1\\1&0&0\end{bmatrix}.

Find MR∪SM_{R\cup S} and MR∩SM_{R\cap S}.

Show solution and steps

For union, write 1 wherever either input is 1. For intersection, write 1 only where both inputs are 1:

MR∪S=[101111110],MR∩S=[101000000].M_{R\cup S}=\begin{bmatrix}1&0&1\\1&1&1\\1&1&0\end{bmatrix},\qquad M_{R\cap S}=\begin{bmatrix}1&0&1\\0&0&0\\0&0&0\end{bmatrix}.

For example, position (2,1)(2,1) has inputs 1 and 0, giving union 1 and intersection 0. Position (1,3)(1,3) has two 1s, so both results are 1.

Boolean Products and Composition

For an m×nm\times n matrix MRM_R and an n×pn\times p matrix MSM_S, define the Boolean product by

(MR⊙MS)ij=⋁k=1n(rik∧skj).(M_R\odot M_S)_{ij}=\bigvee_{k=1}^{n}(r_{ik}\land s_{kj}).

Use the same row–column pairing as ordinary multiplication, but replace multiplication with AND and addition with OR. The result is 1 if there is at least one intermediate index kk for which both entries are 1. The number of such intermediate connections does not affect the final Boolean value.

For relations R:A→BR:A\to B and S:B→CS:B\to C, this gives

MS∘R=MR⊙MS.\boxed{M_{S\circ R}=M_R\odot M_S}.

The relation is written S∘RS\circ R, but its matrix is computed in the order MR,MSM_R,M_S. This follows from the convention “rows are sources; columns are targets.” The columns of MRM_R and rows of MSM_S both correspond to BB, and their dimensions must match.

Example: Computing a Boolean product. Given

MR=[101110000],MS=[010001101],M_R=\begin{bmatrix}1&0&1\\1&1&0\\0&0&0\end{bmatrix},\qquad M_S=\begin{bmatrix}0&1&0\\0&0&1\\1&0&1\end{bmatrix},

find MS∘RM_{S\circ R} and explain the computations for its first and second rows.

Show solution and steps

The entry in row 1, column 1 is

(1∧0)∨(0∧0)∨(1∧1)=1.(1\land0)\lor(0\land0)\lor(1\land1)=1.

The other two entries in the first row are also 1. Alternatively, row 1 of MRM_R says that intermediate vertices 1 and 3 can be reached. Take the entrywise OR of rows 1 and 3 of MSM_S:

(0,1,0)∨(1,0,1)=(1,1,1).(0,1,0)\lor(1,0,1)=(1,1,1).

Row 2 of MRM_R reaches intermediate vertices 1 and 2, so OR the corresponding rows of MSM_S to get (0,1,0)∨(0,0,1)=(0,1,1)(0,1,0)\lor(0,0,1)=(0,1,1). Row 3 of MRM_R contains no 1s, so its output row is all zeros. Thus

MS∘R=[111011000].M_{S\circ R}=\begin{bmatrix}1&1&1\\0&1&1\\0&0&0\end{bmatrix}.

Boolean Powers and Walk Length

Write MR[n]M_R^{[n]} for the nnth Boolean power of MRM_R. Then

MRn=MR[n].M_{R^n}=M_R^{[n]}.

Its (i,j)(i,j) entry is 1 exactly when a directed walk of nn edges exists from aia_i to aja_j. Ordinary arithmetic matrix powers count the number of these walks; Boolean powers record only whether at least one exists.

Example: A loop in a Boolean square. List A={1,2,3}A=\{1,2,3\} in increasing order, and suppose

MR=[010011100].M_R=\begin{bmatrix}0&1&0\\0&1&1\\1&0&0\end{bmatrix}.

Find MR2M_{R^2} and explain why (2,2)(2,2) belongs to R2R^2.

Show solution and steps

Row 1 reaches vertex 2, so copy row 2 of the original matrix. Row 2 reaches vertices 2 and 3, so OR rows 2 and 3. Row 3 reaches vertex 1, so copy row 1. The result is

MR2=[011111010].M_{R^2}=\begin{bmatrix}0&1&1\\1&1&1\\0&1&0\end{bmatrix}.

The loop 2→22\to2 can be followed twice, giving the two-step walk 2→2→22\to2\to2. Hence (2,2)∈R2(2,2)\in R^2. Walks may repeat both vertices and edges.

4. Review and Self-Check

Keep three correspondences in mind: first component ↔ matrix row ↔ edge source; second component ↔ matrix column ↔ edge target; membership in the relation ↔ matrix entry 1 ↔ presence of an edge.

  1. If MRM_R has kk entries equal to 1, how many 1s does MR−1M_{R^{-1}} have? For a relation on nn elements, how many 1s does MR‾M_{\overline R} have?
  2. Does deleting an isolated vertex leave a digraph representing the same relation on the same set?
  3. Which edge must be added to the relation in Figure 1 to make it transitive? Give the new matrix.
Show self-check answers
  1. Transpose preserves the number of 1s, giving kk. The complement flips all n2n^2 positions, giving n2−kn^2-k.
  2. No. Even if the edge set is unchanged, the vertex set has changed, which may affect reflexivity. A representation must include every element of the specified underlying set.
  3. Add (1,3)(1,3). The matrix becomes [111011001]\begin{bmatrix}1&1&1\\0&1&1\\0&0&1\end{bmatrix}. Every two-step connection now has its direct edge.

Glossary and Sources

TermMain idea
Zero-one matrixEvery entry is either 0 or 1
TransposeExchange rows and columns
Boolean productUse AND for multiplication and OR for addition
Boolean powerRepeated Boolean multiplication
Directed graph / digraphVertices together with directed edges
LoopAn edge from a vertex to itself
  • Course slides.
  • Rosen, 8th edition, Section 9.3: printed pages 621–626, PDF pages 644–649. The Boolean square example is on printed page 624; digraph definitions and property tests are on pages 625–626.
  • Figure 1 and its classification example are constructed from the definitions; the full edge set and matrix are given in the text. Matrix criteria for difference, complement, asymmetry, and transitivity are supplementary deductions from the definitions.

Updated:

RelationsMatricesDigraphs