I was told that identity functions have the definition when followed.
If f ∘ e = f, e = idx. If e ∘ f = f, e = idy.
The textbook had a question below the definition asking, for any functions f and g, does either of g ∘ f = idx, f ∘ g = idy implies the other.
My answer was,
f ∘ g = idy
f ∘ g ∘ f = idy ∘ f = f
f ∘ (g ∘ f) = f
(g ∘ f) = idx (from the definition of f ∘ e = f, e = idx)
and similarly
g ∘ f = idx
f ∘ g ∘ f = f ∘ idx = f
(f ∘ g) ∘ f = f
(f ∘ g) = idy (from the definition of e ∘ f = f, e = idy)
But the answer was, no they do not imply the other and it didn't give me the proof, but showed a counter example.
Okay, I understand the counter example, but where in my proof has gone wrong? I didn't assume anything, just followed definition in the proof.
Edit: The text book says, (translated)
Let's figure out whether identity and inverse elements exist for composites. The identity element is a function e that satisfies, f ∘ e = e ∘ f = f for all f: X->Y. However, the function that satisfies f ∘ e = f is e: X->X, and the function that satisfies e ∘ f = f is e: Y->Y and hence they are different. Therefore, identity element of composites does not exist nor the inverse element. Despite this, we define the function e that satisfies f ∘ e = f as the identity function of X and write as id_X, and the function e that satisfies e ∘ f = f as the identity function of Y and write as id_Y. For each set, there exists one identity function.
Edit2: updated some lines for readability
The problem is that you have no justification for jumping from$$f\circ(g\circ f)=f\implies g\circ f=\operatorname{id}_X,\tag1$$to $g\circ f=\operatorname{id}_X$. In fact, if $f$ was injective then, yes, you could deduce that $(1)$ hods, but all that you can deduce from $f\circ g=\operatorname{id}_Y$ is that $f$ is surjective, not that it is injective.