Before presenting the actual question, I'd like to emphasize that this question is for an assignment, so I do not want a full solution. This is something I need to solve on my own, but I am looking for some guidance in the correct direction. The question is as follows:
Suppose $\mathcal{L}$ is a finite language, and $\mathcal{M}$ is a finite $\mathcal{L}$-structure. Find an $\mathcal{L}$-sentence $\phi$ such that given any $\mathcal{L}$-structure $\mathcal{N}$ if $\mathcal{N} \models \phi$ then $\mathcal{M} \cong \mathcal{N}$.
First, since $\mathcal{M}$ is finite, we know $|M|=n$ for some $n$, so the following $\mathcal{L}$-sentence describes the size of $M$: $$ \exists x_1,\dots,x_n(\bigwedge\limits_{i=1}^n (\bigwedge\limits_{j=1}^n x_i \neq x_j) \land \forall y(\bigvee\limits_{i=1}^n y=x_i)) $$ (I'm aware this sentence is not rigorously written, but my professor has no problems with writing it this way as "we are humans, not computers").
My confusion arises when trying to write out a first-order $\mathcal{L}$-sentence that also preserves the operations of $\mathcal{M}$. I have a feeling there might be some way to do it by somehow writing out how $x_1,\dots,x_n$ are interacting with each other in each relation and function (which is why I imagine $\mathcal{L}$ must be finite), but I'm at a complete loss on how one might do this.
Again, I'm going to reiterate that I am not looking for solutions, only hints. I will post my solution once I solve it.
Thanks for any help.
Edit
It is suggested that I write a sentence out for a more concrete example, say the group $\mathbb{Z}/2\mathbb{Z}$. We might write: $$ \exists x_1, \exists x_2 (x_1+x_1=x_1 \land x_1+x_2=x_2 \land x_2+x_1=x_2 \land x_2+x_2=x_1) $$ This sentence, along with the one above for when $n=2$, completely describes the group $\mathbb{Z}/2\mathbb{Z}$. My confusion is more how one might explicitly write a sentence similar to the one above without actually knowing how the functions and relations of the structure are actually interacting with the elements. Could I, without loss of generality, make arbitrary choices for the way in which the functions and relations are interacting with the group?
Edit 2 Let us consider the following $\mathcal{L_\textrm{grp}}$-structures $$ \mathcal{M}=(\mathbb{Z}/2\mathbb{Z},+,-,0) \\ \mathcal{N}=(\mathbb{Z}/2\mathbb{Z},+,-,1) $$ Now, the suggested sentence by commenters and posters would be as follows: $$ \phi :=\exists x_1,x_2(x_1 \neq x_2 \land \forall y (y=x_1 \lor y=x_2) \land x_1+x_1=x_1 \land x_1+x_2=x_2 \land x_2+x_1=x_2 \land x_2+x_2=x_1) $$ What I'm curious about is that $\mathcal{M} \models \phi$ and $\mathcal{N} \models \phi$, but $\mathcal{M} \not\cong \mathcal{N}$ since you must map $0$ to $1$ in any isomorphism, and this could not possibly preserve the structure of the group. Note that in $L_{grp}$ the actual structures don't need to actually be groups since there is no theory associated with it.
Is there a way around this?
You seem to just be having a hard time making it precise and general.
If the structure $\mathcal A$ has domain $A = \{a_1,a_2,\ldots, a_n\}$ and we have some function symbol $f$ with arity $n,$ and $\sigma$ is a permutation of $\{1,2,\ldots, n\}$, define $X_f(\sigma)$ to be the unique $m\in\{1,2,\ldots,n\}$ such that $f^{\mathcal A}(a_{\sigma(1)}, \ldots, a_{\sigma(n)}) = a_m.$ Then you can take care of the function symbols by appending to your conjunction the conjunction of $$ \bigcup_{f\in \mathcal F}\left\{f(x_{\sigma(1)},\ldots, x_{\sigma(\mathrm{arity}(f))}) = x_{X_f(\sigma)}: \sigma\in S_{\mathrm{arity}(f)}\right\}$$ where $\mathcal F$ is the set of function symbols in $\mathcal A$'s language. The relations can be handled similarly. I'll leave that up to you.