Everywhere I see commutativity defined somewhat like this:
A binary operator $*$ is commutative in $S$, if for any $x, y \in S$, the following property holds: $x*y=y*x$.
That definition is, of course, intuitive, and the reason why commutativity is defined that way in most texts need not be explained. However, I'm wondering if the following definition is correct/equivalent:
Let $\mathcal{T}$ be the set of all subsets of $S$ of size $2$. The binary operator $*: \mathcal{T}\to S$ is commutative.
Edit: I just realized that this definition fails to capture the fact that commutativity works if the two operands are equal... which can't be represented as a function from a set of size 2. Is there a way to modify my definition to make it work?
Edit 2: One solution I'm thinking of is dropping the requirement that the operator be binary, and just define the commutative operator as $*:\mathcal{R}\to S$, where $\mathcal{R}$ is the set of all subsets of $S$. And then specializing the definition to a binary operator if it's acting on subsets of size $\leq 2$.
BONUS QUESTION: Can you define associativity in a similar way? That is, as a specific type of function?
It's a bit peculiar to use the term "binary operator" for an operation whose domain is not the product of some set with itself.
Here's one way to arrange things: First, note that for any $S$ there's a natural map $$\pi : S \times S \to \mathcal (S \times S) / \sim,$$ where $\sim$ is the equivalence relation on $S \times S$ defined by declaring $(s, t) \sim (t, s)$ for all $s, t \in S$. Then, a binary operation $\ast : S \times S \to S$ is commutative iff it descends via $\pi$ to a map $$\tilde\ast : \mathcal (S \times S) / \sim \to S ,$$ that is, if there is a (necessarily unique) map $\tilde\ast: \mathcal (S \times S) / \sim \to S$ such that $$\ast = \tilde\ast \circ \pi .$$
Remark We can identify $(S \times S) / \sim$ with the set of all multisets of elements of $S$ with exactly $2$ elements.