Chapter 9

Equality Comparisons etc.

The defect of equality is that we only desire it with our superiors.

—Henry Becque:Querelles Littéraires (1890)

All animals are equal, but some animals are more equal than others.

—George Orwell:Animal Farm (1945)

This chapter considers the question of how the fundamental operation of equality comparison needs to be revised to take account of inheritance. It also looks at the implications of inheritance for the dyadic relational operators union, intersection, difference, and join, all of which are crucially dependent on that notion of equality (tuple equality, to be precise)—though there’s quite a bit more to discuss in connection with those operators than just the issue of equality as such.

IM PRESCRIPTION 12: EQUALITY WITH INHERITANCE

Consider the equality comparison

Y = X

(where Y and X are expressions). DT(Y) and DT(X) shall overlap. The comparison shall return TRUE if v(Y) is equal to v(X) (and hence if MST(Y) is equal to MST(X) also), and FALSE otherwise.

image

Without inheritance, the type rule for the equality comparison

Y = X

is very simple: It just says the types of Y and X must be the same (in effect, it can be thought of as saying their declared types must be the same, since their declared types are the only types they’ll have if there’s no inheritance). IM Prescription 12 extends that rule—actually it weakens it, in a way—by requiring only ...

Get Type Inheritance and Relational Theory now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.