magikker / TreeHouse-Private

TreeHouse development.
GNU General Public License v3.0
0 stars 0 forks source link

Define a relationship algebra #44

Open magikker opened 11 years ago

magikker commented 11 years ago

Can we add substract multiply or divide relationships? What would the result of [AB|CD] + [DE|FG] be?

How about [ABCD|EFGH] - [AD|FG]

How about set operations? Union, Intersection, difference, symmetric difference?

We can put relationships in the user's hands, but how do we interact with them? We can (and should) define it.

This is the type of question that'll take a bit of brain storming to get it all figured out. What makes sense? What's useful?

I'm very very interested in this question.

Ok, first round of thoughts. Equality (==) and inequality (!=) operators ought to be defined. [AB|CD] == [AB|CD] should be true.... But depending on how we define things order may or may not matter.... so if [AB|CD] + [EF|GH] is different from [AB|CD] + [GH|EF] and it might have to be, then [AB|CD] == [CD|AB] should probably return false.... and we'd want a third equality operation that was orientation independent...

So maybe oriented equality ==, unoriented equality ==, oriented inequality !=, unoriented inequality !=

And some sort of oriented union. [AB|CD] + [EF|GH] = [ABEF|CDGH] We could define all the standard set operations to work on relationships if we treat set side as more or less independent. This works for when orientation matters, so when someone types them into the command line... is there a version that would work for when orientation doesn't matter? Should the result of [AB|CD] + [EF|GH] = { [ABEF|CDGH], [ABGH|CDEF] }...? Should that be a different symbol? is that a useful operation at all?

Next we'd probably want to define compatibility operations. As in, "could these two relationships be in the same tree?" This is different than, but related to the question, "is one relationship a subset of the other?" Both of these operations should be defined.