TITLE: Binary Relation composition is associative proof explanation and set memberships and set definitions request
QUESTION [5 upvotes]: What set or relation does y,x belong to?
What set or thing does w belong to?
What set or thing does z belong to?
I have a hard time keeping track what set w,z,y are members of, are part of whose domain and codomain. What are all the codomains and domains here?
How do we formally define using set builder notation R,S, and T?

REPLY [4 votes]: In general if $R\subseteq A\times B$ and $S\subseteq B\times C$ then: $$S\circ R:=\{\langle a,c\rangle\mid\exists b\in B[\langle a,b\rangle\in R\wedge\langle b,c\rangle\in S\}\subseteq A\times C$$
So starting with relations $R\subseteq A\times B$, $S\subseteq B\times C$ and $T\subseteq C\times D$ we have $S\circ R\subseteq A\times C$ and $T\circ S\subseteq B\times C$.
Continuing this we find that $T\circ(S\circ R)$ and $(T\circ S)\circ R$ are both subsets of $A\times D$ that satisfy: $$T\circ(S\circ R)=(T\circ S)\circ R$$

REPLY [2 votes]: There is an unnamed set $X$ here, and $R,S,T$ are all binary relations on this set, i.e. $R,S,T\subseteq X\times X$.
The notation $\ x\,R\,y\ $ for a relation $R$ with this notation means nothing else but $(x,y)\in R$.