Types and Programming Languages Exercises

Preface

2 Mathematical Preliminaries

2.2 Ordered Sets

2.2.6

Exercise [★★ ↛]: Suppose we are given a relation R on a set S. Define the relation R′ as follows:

R′ = R ∪ {(s, s) | sS}.

That is, R′ contains all the pairs in R plus all pairs of the form (s, s). Show that R′ is the reflexive closure of R.

We need to show that:

2.2.7

Exercise [★★, ↛]: Here is a more constructive definition of the transitive closure of a relation R. First, we define the following sequence of sets of pairs:

R0 = R Ri+1 = Ri { (s,u) for some t (s,t) Ri  and  (t,u) Ri }

That is, we construct each Ri + 1 by adding to Ri all the pairs that can be obtained by “one step of transitivity” from pairs already in Ri. Finally, define the relation R+ as the union of all the Ri:

R+ = i Ri

Show that this R+ is really the transitive closure of R—i.e., that it satisfies the conditions given in Definition 2.2.5.

We need to show that:

2.2.8

Exercise [★★, ↛]: Suppose R is a binary relation on a set S and P is a predicate on S that is preserved by R. Show that P is also preserved by R*.

We need to show that: For any sS and tS: (s, t) ∈ R* and sP implies tP.

Since P is preserved by R, we have: For any sS and tS: (s, t) ∈ R and sP implies tP.

First, we prove that for all i, P is preserved by Ri that is defined in exercise 2.2.7. This can be done by induction:

Since R* is the union of all Ri, P is also preserved by R*.


List of common unicode characters:

U+2032 PRIME : minutes, feet                       ′
U+219B RIGHTWARDS ARROW WITH STROKE:               ↛
U+2208 ELEMENT OF                                  ∈
U+2209 NOT AN ELEMENT OF                           ∉
U+2223 DIVIDES : such that, APL stile:             ∣
U+222A UNION : cup:                                ∪
U+2286 SUBSET OF OR EQUAL TO:                      ⊆
U+22C3 N-ARY UNION : z notation generalised union: ⋃
U+2605 BLACK STAR:                                 ★