The macro-level lattice structure of relations in the vicinity of `DEE`, `DUM`
Quote from AntC on May 22, 2021, 11:11 amQuote from AntC on May 21, 2021, 11:37 pm [was: ANNOUNCE a relational algebra ...]
... can't be
DUMbecause it's not immediately adjacent toDEE.Ok, trying an entirely different tack.
I'll presume for the time being all attribute types have cardinality at least 2. That is,
Boolis amongst the smallest possible types. (I'll come back at the end to consider the consequences of a single-valued or zillary attribute type.)Single-attribute relations
Say we have two relation values, one with single attribute
A, one with single attributeB, both typeBool. Consider the fullest possible relation values with those headings, and the emptiest possible:
RA1=dfREL{A Bool} {TUP{A True}, TUP{A False}}. (two tuples)RB1=df likewise, for attributeB.RA0=dfREL{A Bool} {}. (no tuples)RB0=df likewise, for attributeB.Where do those sit in the lattice?
RA1, RB1are immediately adjacent belowDEE.RA0, RB0are immediately adjacent belowDUM. By 'immediately adjacent below' I mean lesser in the lattice ordering, but with no other relation value in between.
RA0, RB0are belowRA1, RB1but not immediately adjacent: in between are the relations with a single tuple for that heading. Is there anything else immediately adjacent belowRA1, RB1? Yes:RA1 NatJoin RB1-- that is, the Cartesian product, with heading{A Bool, B Bool}and all possible tuples (4 of) for that heading. (And likewise all the pairings of single-attribute headings -- that is all the degree-two relations, maximum possible tuples.)Finding
DUMBut hold!
DUMis immediately adjacent belowDEE, andRA0 = DUM NatJoin RA1, RB0 = DUM NatJoin RB1are immediately adjacent belowDUM. So to findDUMin the lattice:
DUMis immediately adjacent belowDEE;- and for all other relations immediately adjacent below
DEE(sayRA1, RB1), pairwiseNatJoining them yields a relation immediately adjacent below each;- whereas
DUM NatJoin RA1yields a relation immediately adjacent belowDUM;- but not immediately adjacent below
RA1.- (This is not news. It's an example of the smallest non-distributive lattice
N5Pic 11, which appear all over relational lattice structures. What's new is me realising it appears in a very specific location in the vicinity ofDEE, DUM. In that Pic:1corresponds toDEE;acorresponds toDUM;ccorresponds toRA1;bcorresponds toRA½-- headingA, body a single tuple;0corresponds toRA0 = DUM NatJoin RA1. In our example, there should be another relationdcorresponding to a differentRA?-- headingA, body the single other possible tuple with that heading -- with routec — RA? — 0bypassing the route throughb.)Code/equations
The bonus here is I've described this location using only
NatJoin(which gives the lattice ordering). To talk about it, some predicates/operators would be handy:
r1 >= r2 ≡ r1 NatJoin r2 = r2.greater-or-equal in the lattice ordering.between(r1, s, r2) ≡ r1 >= s & s >= r2.apart(r1, r2) ≡ ∃ s. (r1 >= s & r1 ≠ s & s >= r2 & s ≠ r2).below, but not immediately adjacentadj(r1, r2) ≡ (r1 >= r2 & r1 ≠ r2 & (∀ s (between(r1, s, r2) ≡ r1 = s | s = r2))).immediately adjacent belowDUMgiven by:adj(DEE, DUM)
& ( ∀ r1. (adj(DEE, r1) & r1 ≠ DUM) → ( adj(DUM, DUM NatJoin r1) & apart(r1, DUM NatJoin r1) ) ).- Prover9 tells me this fixes
DUMuniquely.- Also confirms this holds:
r1 NatJoin DUM ≠ r1 ≡ r1 InnerUnion DUM = DEE. Two equivalent ways to tell if a relation is empty.- Sadly, that axiom/predicates are in 'non-positive' form: There's not-equals, existential quant, nested universal quant, nested disjunction. We can shuffle the equations around, but we'd still get a non-positive somewhere.
Now I can define those problematic operators (
NotMatching, project, Remove) usingDUM, especially... NatJoin DUMforemptify( ). And some of the equations I expect to hold get proven; and none of them can Mace4 provide a counter-example. But most of them can't be proven -- even after several hours of running -- and that's because of the non-positive forms.Degenerate attribute types
Coming back to the presumption about attribute types.
- Types with no possible values (TTM
Omega?) are (surprisingly) not a difficulty.- Consider a Relation with attribute name
Eof that type, heading{E T0};- there's only on possible relation value
RE0 = REL{E T0} {}.RE0is immediately adjacent belowDUM, but not adjacent toDEE-- precisely becauseDUMintervenes.- So
RE0won't be considered for its location in the vicinity ofDEE.- OTOH attribute types with exactly one possibly value are dodgy.
- Consider Relations with attribute name
Dof that unitype.- There's two possible relation values
RD1 = REL{D T1} {D TheValue}; RD0 = REL{D T1} {}.RD1is immediately adjacent belowDEE;RD0 = DUM NatJoin RD1is immediately adjacent below bothDUMandRD1.- So by the definition above, the appearance of
RD1, RD0in the lattice would make it impossible to uniquely identifyDUM.- The definition requires
Rx1to be apart fromRx0 = DUM NatJoin Rx1for all attributesx. This in effect rules out attribute types of cardinality 1. In the words of that acute observer of schoolroom algebra Lauren Cooper, "Am I bovvered?".
Quote from AntC on May 21, 2021, 11:37 pm [was: ANNOUNCE a relational algebra ...]
... can't be
DUMbecause it's not immediately adjacent toDEE.
Ok, trying an entirely different tack.
I'll presume for the time being all attribute types have cardinality at least 2. That is, Bool is amongst the smallest possible types. (I'll come back at the end to consider the consequences of a single-valued or zillary attribute type.)
Single-attribute relations
Say we have two relation values, one with single attribute A, one with single attribute B, both type Bool. Consider the fullest possible relation values with those headings, and the emptiest possible:
RA1=dfREL{A Bool} {TUP{A True}, TUP{A False}}. (two tuples)RB1=df likewise, for attributeB.RA0=dfREL{A Bool} {}. (no tuples)RB0=df likewise, for attributeB.
Where do those sit in the lattice? RA1, RB1 are immediately adjacent below DEE. RA0, RB0 are immediately adjacent below DUM. By 'immediately adjacent below' I mean lesser in the lattice ordering, but with no other relation value in between.
RA0, RB0 are below RA1, RB1 but not immediately adjacent: in between are the relations with a single tuple for that heading. Is there anything else immediately adjacent below RA1, RB1? Yes: RA1 NatJoin RB1 -- that is, the Cartesian product, with heading {A Bool, B Bool} and all possible tuples (4 of) for that heading. (And likewise all the pairings of single-attribute headings -- that is all the degree-two relations, maximum possible tuples.)
Finding DUM
But hold! DUM is immediately adjacent below DEE, and RA0 = DUM NatJoin RA1, RB0 = DUM NatJoin RB1 are immediately adjacent below DUM. So to find DUM in the lattice:
DUMis immediately adjacent belowDEE;- and for all other relations immediately adjacent below
DEE(sayRA1, RB1), pairwiseNatJoining them yields a relation immediately adjacent below each; - whereas
DUM NatJoin RA1yields a relation immediately adjacent belowDUM; - but not immediately adjacent below
RA1. - (This is not news. It's an example of the smallest non-distributive lattice
N5Pic 11, which appear all over relational lattice structures. What's new is me realising it appears in a very specific location in the vicinity ofDEE, DUM. In that Pic:1corresponds toDEE;acorresponds toDUM;ccorresponds toRA1;bcorresponds toRA½-- headingA, body a single tuple;0corresponds toRA0 = DUM NatJoin RA1. In our example, there should be another relationdcorresponding to a differentRA?-- headingA, body the single other possible tuple with that heading -- with routec — RA? — 0bypassing the route throughb.)
Code/equations
The bonus here is I've described this location using only NatJoin (which gives the lattice ordering). To talk about it, some predicates/operators would be handy:
r1 >= r2 ≡ r1 NatJoin r2 = r2.greater-or-equal in the lattice ordering.between(r1, s, r2) ≡ r1 >= s & s >= r2.apart(r1, r2) ≡ ∃ s. (r1 >= s & r1 ≠ s & s >= r2 & s ≠ r2).below, but not immediately adjacentadj(r1, r2) ≡ (r1 >= r2 & r1 ≠ r2 & (∀ s (between(r1, s, r2) ≡ r1 = s | s = r2))).immediately adjacent belowDUMgiven by:adj(DEE, DUM)
& ( ∀ r1. (adj(DEE, r1) & r1 ≠ DUM) → ( adj(DUM, DUM NatJoin r1) & apart(r1, DUM NatJoin r1) ) ).- Prover9 tells me this fixes
DUMuniquely. - Also confirms this holds:
r1 NatJoin DUM ≠ r1 ≡ r1 InnerUnion DUM = DEE. Two equivalent ways to tell if a relation is empty. - Sadly, that axiom/predicates are in 'non-positive' form: There's not-equals, existential quant, nested universal quant, nested disjunction. We can shuffle the equations around, but we'd still get a non-positive somewhere.
Now I can define those problematic operators (NotMatching, project, Remove) using DUM, especially ... NatJoin DUM for emptify( ). And some of the equations I expect to hold get proven; and none of them can Mace4 provide a counter-example. But most of them can't be proven -- even after several hours of running -- and that's because of the non-positive forms.
Degenerate attribute types
Coming back to the presumption about attribute types.
- Types with no possible values (TTM
Omega?) are (surprisingly) not a difficulty. - Consider a Relation with attribute name
Eof that type, heading{E T0}; - there's only on possible relation value
RE0 = REL{E T0} {}. RE0is immediately adjacent belowDUM, but not adjacent toDEE-- precisely becauseDUMintervenes.- So
RE0won't be considered for its location in the vicinity ofDEE. - OTOH attribute types with exactly one possibly value are dodgy.
- Consider Relations with attribute name
Dof that unitype. - There's two possible relation values
RD1 = REL{D T1} {D TheValue}; RD0 = REL{D T1} {}. RD1is immediately adjacent belowDEE;RD0 = DUM NatJoin RD1is immediately adjacent below bothDUMandRD1.- So by the definition above, the appearance of
RD1, RD0in the lattice would make it impossible to uniquely identifyDUM. - The definition requires
Rx1to be apart fromRx0 = DUM NatJoin Rx1for all attributesx. This in effect rules out attribute types of cardinality 1. In the words of that acute observer of schoolroom algebra Lauren Cooper, "Am I bovvered?".