I'm trying to write a paper for one of my classes and I'm having trouble proving the following:

A function f (A to B) is bijective if and only if there exists a function g (B to A) such that f composed with g equals 1B and g composed with f equals 1A.

Also, I want to show that if a function g (B to A) exists such that f composed with g equals 1B then f (A to B) is bijective.

I'm really stalled out. Any help would be great.