prove that composition $g$ of $f$ is bijective then $f$ is injective and $g$ is surjective

Claim: If $$g \circ f: A \to C$$ is bijective then where $$f:A \to B$$ and $$g:B \to C$$ are functions then $$f$$ is injective and g is surjective. Also give an example where $$g \circ f$$ is bijective but $$f$$ is not surjective and $$g$$ is not injective.

Proof attempt:

Well if $$g \circ f$$ is bijective then $$g \circ f$$ is injective. Therefore $$f$$ is injective:

Suppose $$f(x)=f(y)$$

$$g(f(x))=g(f(y))$$ which means

$$(g \circ f)(x) = (g \circ f)(y)$$ since $$g \circ f$$ is injective we have $$x = y$$

Also if $$g \circ f$$ is bijective then $$g \circ f$$ is surjective and therefore $$g$$ is surjective

Suppose that $$g \circ f$$ is surjective take any $$y \in C$$

Since $$g \circ f$$ is surjective there exists an $$a \in A$$

such that $$(g \circ f)(a) =y$$ so

$$g (f(a)) = y$$ set

$$b=f(a) \in B$$ Then $$g(b)=g(f(a))=y$$

Therefore g is surjective.

firstly just to verify, my proofs answer the question right? Secondly is there a more direct and faster method?

Now for the second part:

$$A = \{1\}, B=\{2,3\}, C\{4,5\}$$

Define $$f: A \to B$$ as $$f\{1\} \to \{2\}$$ which is clearly not surjective because 3 is not mapped. Define $$G\{2,3\} \to \{4,4\}$$ Thus $$g$$ is not injective however my problem is that I don't think $$f \circ g$$ is bijective I just cannot figure out how to rectify a composition where one function is not surjective and the other is not injecitive and get a bijection

Your proof for $$f$$ being injective and $$g$$ being surjective are correct. For the counterexample, let $$A = C = \{0\}$$, $$B = \{0,1\}$$, and define $$f$$ such that $$f(0) = 0$$, and $$g(0) = g(1) = 0$$. Then clearly $$f$$ is not surjective and $$g$$ is not injective, but $$g \circ f : \{0\} \to \{0\}$$ with $$g \circ f(0) = 0$$ is clearly bijective.